[FFmpeg-user] How to concatenate multiple mp4 files without re-encoding to an intermediate format

Tom Evans tevans.uk at googlemail.com
Fri Aug 31 13:56:42 CEST 2012

On Fri, Aug 31, 2012 at 11:33 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> Rares Pop <raresp <at> axz.ro> writes:
>> ffmpeg -i concat:'file1.mp4|file2.mp4' -vcodec copy -acodec copy  -y asset.mp4
>> Result: asset.mp4 file is the same as file1.mp4.It behaves
>> like it ignores file2.mp4
> So it seems that this is unsupported.
> You can try to concatenate the raw h264 and the raw aac streams
> and mux the resulting streams but this may lead to A/V desync
> (that you can try to eliminate by cutting the streams or inserting
> silence but this will have to be done manually).
> Please do not top-post here, Carl Eugen

Would re-muxing to TS as an intermediate help with this? Seems to work ok..

ffmpeg -i source1.mp4 -c copy -bsf h264_mp4toannexb -t 30 out1.ts
ffmpeg -i source2.mp4 -c copy -bsf h264_mp4toannexb -t 30 out2.ts
ffmpeg -i "concat:out1.ts|out2.ts" -c copy out.mp4
ffprobe out.mp4 2>&1| grep Duration
  Duration: 00:01:00.08, start: 0.000000, bitrate: 2086 kb/s



More information about the ffmpeg-user mailing list