How can I concatenate or merge 2 or more MP4 files, in a final output MP4 file also?

I have tried in the DOS window to use the COPY command (I have read it somewhere) but it doesn't function well.


MP4Box can do this, though you might want to use a GUI for it like YAMB or My MP4Box GUI. (N.B.: It's not my program personally, that's just the name.) MP4Box binaries for Windows are available from this site.


MP4Box -tmp $HOME -add vid.01.m4v \
    -cat vid.02.m4v -cat vid.03.m4v vid-out.mp4

I'd reccomend usind ffmpeg, which is available for Mac OS X, Linux and Windows.

Here's a good examaple on how to concatenate two movies: http://www.ffmpeg.org/faq.html#SEC27

In the last step, you just need to make sure you make an MP4 container, for the resulting file.

  • As I understand the ffmpeg FAQ answer given, this cannot be done with MP4 (presumably H.264) video, because it's not one of the "privileged formats". – ttarchala Oct 1 '10 at 9:35
  • @ttarchala: I'd try if it can be done. I've converted into MP4 with FFmpeg before, but never concatenated two movies. Also: I'd like to point out, that FFmpeg has a very fast developement. What didn't work with one version, might work in just the next one. – polemon Oct 1 '10 at 19:57
  • 1
    Not all builds of FFMPEG have MP4 support. For one thing it's a patented technology and arguably it's illegal to distribute MP4 encoders in the USA without paying a fee. However, many builds can do this. – CarlF Sep 23 '11 at 19:25
  • @CarlF: As for Linux and Mac OS X, this is not an issue, really. The code can be distributed freely, so basically, whoever builds their own FFmpeg, all is good. As for patenting, I'd like to share a comment: I won't find the site off hand right now, but the first patent to expire for AAC (which is partially defined in MPEG-4), is in 2022. And that's just the first one, there's many more that need to expire till it's completely legal... – polemon Sep 25 '11 at 0:45

You can try doing this with ffmpeg:

mkfifo temp0 temp1
ffmpeg -i input0.mp4 -c copy -bsf h264_mp4toannexb -f mpegts -y temp0 2> /dev/null & \
ffmpeg -i input1.mp4 -c copy -bsf h264_mp4toannexb -f mpegts -y temp1 2> /dev/null & \
ffmpeg -f mpegts -i "concat:temp0|temp1" -c copy -absf aac_adtstoasc output.mp4

This doesn't re-encode anything, it places them in a new transport stream container, which makes them more easy to concatenate, and then concatenates them back into an MP4. If output.mp4 already exists, the command will fail. The version above uses named pipes, it you're on a system that doesn't support those you'd have to use intermediate files:

ffmpeg -i input0.mp4 -c copy -bsf h264_mp4toannexb temp0.ts
ffmpeg -i input1.mp4 -c copy -bsf h264_mp4toannexb temp1.ts
ffmpeg -i "concat:temp0.ts|temp1.ts" -c copy -absf aac_adtstoasc output.mp4
  • what if it's not h264 but mpeg4? – Edison Jun 12 '13 at 23:37

Update: Just checked avidemux as I had it installed, after reading that other answer. It’s what you are looking for (didn’t think it can do MP4 because of its name…).

I think VirtualDubMod is mp4-capable, I didn’t use it though so I dunno for sure.

You may want to check out MeGUI. It’s a rather complex and feature-rich app and tools.

The tool for embedding in a container (mp4 in your case) is called muxer, that one can probably not concatenate them though.

You can use it in combination with VirtualDub. Virtualdub to concatenate the video streams, and the muxer to make it an mp4 again (without having to reencode).


I'm doing it with mencoder, after having converted them to avi with ffmpeg

here's a simple script, assuming you have 15 files, named 01.mp4 ... 15.mp4

for j in `seq -w 1 15`;
    echo converting file $j.avi
    ffmpeg -i $j.mp4 $j.avi        

    echo adding file $j.avi to list
    z="$z $j.avi"

echo doing append
mencoder -oac copy -ovc copy $z -o all.avi



Here is the command:

ffmpeg -i concat:"video1.ts|video2.ts"
  • Does that pipe character need to be escaped? Or am I completely misreading that command? – killermist Jun 24 '12 at 17:00
  • it needed to be escaped. oops. – rogerdpack Jun 26 '12 at 23:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.