本文最后更新于:2012-09-04 23:38:51原文:http://www.yaosansi.com/post/h264-video-mp4-to-ts
Mp4 To TS 
1 ffmpeg -i "test.mp4" -i "test.aac" -f mpegts  -vcodec copy -acodec copy -vbsf h264_mp4toannexb -y test.ts 
 
如果不使用-vbsf h264_mp4toannexb ,将出现如下提示:
1 [mpegts @ 0x61c040] h264 bitstream malformated, no startcode found, use -vbsf h264_mp4toannexb av_interleaved_write_frame(): Operation not permitted 
 
1 vlc  -vvv --extraintf=logger  test.mp4 :sout=#std{access=file,mux=ts,dst=test.ts} 
 
合并MP4 1 ffmpeg -i 1.mp4 -sameq 1.mpg ffmpeg -i 2.mp4 -sameq 2.mpg cat 1.mpg 2.mpg | ffmpeg -f mpeg -i - -sameq -vcodec mpeg4 output.mp4 
 
或
1 ffmpeg -i concat:"video1.mp4|video2.mp4" 
 
###当然也可以使用 mp4box 分割或合并MP4
1 2 3 MP4Box -split time_sec foo.mp4 #按照时长切割MP4文件 MP4Box -split-size size foo.mp4 #按照文件大小切割MP4文件,单位是KB MP4Box -split-chunk S:E foo.mp4 #切出视频中指定时间的一段 
 
1 2 3 4 #这样就合并了,要求编码参数一致 MP4Box -cat foo1.mp4 -cat foo2.mp4 -new foo.mp4  MP4Box -force-cat foo1.mp4 -force-cat foo2.mp4 -new foo.mp4 #强制合并,有可能合出来看不了 MP4Box -add video1.264 -cat video2.264 -cat video3.264 -add audio1.aac -cat audio2.aac -cat audio3.aac -new muxed.mp4 -fps 24 
 
1 MP4Box -cprt sinav foo.mp4 
 
TS To  Mp4 1 2 3 ffmpeg -i input.ts -c:v copy -c:a libfaac out.mp4 ffmpeg -i input.ts -c:v libx264 -crf 24 -c:a libfaac out.mp4 Set CRF to anything between 19 and 25, or even more. The more, the worse the quality, but the smaller the file size. 
 
部分引用:http://blog.yikuyiku.com/?p=1854