Converting H.264 MPEG4 to TS with ffmpeg

When attempting to convert (re-mux) a MPEG4 container H.264 + AAC file to a MPEG2 transport stream I ran in to the following error message using ffmpeg:

[mpegts @ 0x(memory address)]h264 bitstream malformated
av_interleaved_write_frame(): Error while opening file

(The command I used was: ffmpeg -i input_file.m4v -vcodec copy -acodec copy output_file.ts)

To address this I searched google high and low, and finally found this post. The short story is that -vbsf h264_mp4toannexb is needed to convert an H.264 MPEG4 file to MPEG2 transport streams. To verify that your version of ffmpeg supports this filter check the output of ffmpeg -formats.

End result:
ffmpeg -i input_file.m4v -vcodec copy -acodec copy -vbsf h264_mp4toannexb output_file.ts

  1. thx a lot for sharing! :-)

  1. No trackbacks yet.