[FFmpeg-user] Remux MPEG-TS file fails: Mid-stream changes?

Carl Eugen Hoyos cehoyos at ag.or.at
Sun Dec 13 23:49:31 CET 2015

On Saturday 12 December 2015 12:08:46 pm Peter B. wrote:
> >> btw, choosing to transcode the audio *and* using Matroska did the trick:
> >> I've now tried converting the audio to pcm_s16le and using Matroska as
> >> output container, and now the audio works for the whole video :D
> >
> > I don't think that this is a good idea.
> >
> > mpegts is a container (maybe the only one) that by definition allows
> > data corruption. So in your source file you have data corruption. (I
> > mean generally, not necessarily in the file that you tested but the
> > error message you quote above can be an indication for such an error.)
> > While I haven't read the matroska specification, I am quite sure that it
> > does not allow corruption. So if you do -vcodec copy for ts input and
> > mkv output there is a realistic chance of producing invalid output.
> Hm...
> According to what you said, it seems that there are multiple things
> wrong with these MPEG-TS files?

No, sorry for being unclear:
I am trying to explain that *generally* transport streams are allowed 
to contain receiving errors and I suspect remuxing such files to mkv 
leads to invalid output files.

> I was mainly looking for a way to normalize the format/behavior of the
> audio track, because it couldn't be opened properly in NLEs or most
> players it was opened with.

I still don't think this is true (just disable libfaad in all these 
players, they most likely use libavcodec as well) but why don't you 
simply use the following if really needed?
$ ffmpeg -i input.ts -vcodec copy -acodec ac3 -ab 640k out1.ts
$ ffmpeg -i input.ts -vcodec copy -acodec mp2 -ab 320k out2,ts

Carl Eugen

More information about the ffmpeg-user mailing list