I have two halves of a single show in two .MP4 files, encoded in H264. I would like to join them without re-encoding.

Is this possible?

I managed to create a joined video as a Quicktime file (.mov) using Quicktime Pro, but then Quicktime Pro will not convert it back to .MP4 without re-encoding. This may be because looking inside the .mov file, the two H264 videos are in there still separated as individual "objects".

I am also struggling with MPEG StreamClip without reaching a real solution. But I may have missed something.

Note that I do not have the same issue with MPEG2 files. I can export them to a .MPEG container or a .TS file for example, and then I can join them without re-encoding using MPEG Streamclip.

Any suggestion welcome, preferably using Mac software.

  • 1
    Of course the videos need to have the same aspects to be joined without re-encoding (same size, bitrate, etc.). You should be able to do it in VirtualDubMOD: open the MP4, then Append Segment.
    – Synetech
    Commented Mar 10, 2011 at 6:06

5 Answers 5

ffmpeg -i f1.mp4 -c copy -bsf h264_mp4toannexb f1.ts

ffmpeg -i f2.mp4 -c copy -bsf h264_mp4toannexb f2.ts

ffmpeg -i 'concat:f1.ts|f2.ts' -c copy -bsf aac_adtstoasc f3.mp4

How to concatenate flv file into one

  • What if it is m4v (non-h264 mp4), what bsf should be used?
    – Edison
    Commented Jun 12, 2013 at 23:12
  • 2
    I left off -bsf aac_adtstoasc for the concat command
    – Csaba Toth
    Commented Nov 8, 2016 at 8:44
  • I needed to left off all -bsf arguments, then it worked for me.
    – KittMedia
    Commented Nov 9, 2017 at 18:36
  • Doing this on MacOS 10.13.3, I omitted all the -bsf xxx stuff with good results. However the 2nd time I tried it, the second half of the combined movie was corrupted. It turns out that, for unknown reasons, Handbrake had encoded the two halves with different widths (640 vs. 636). I had used the same preset in both cases. Anyway, I went back and used Handbrake again on the 1st half, which now matched the 2nd half. The re-combined movie was okay. Tip: exiftool will display everything about an mp4/m4v file.
    – Jamie Cox
    Commented Mar 10, 2018 at 20:40
  • See also stackoverflow.com/questions/28922352/… on batch joining all files in a directory.
    – Vadzim
    Commented Aug 20, 2020 at 0:06

MP4Box will do this for you:

MP4Box -cat File01.m4v -cat File02.m4v File-joined.m4v

MP4Box is cross-platform and works on OSX, however I tried this on Ubuntu Linux with H264 videos created by Handbrake for the iPhone 4S.

This works quite fast as the files are not re-encoded.

  • 1
    Works great. Use sudo apt-get install gpac to install it. You can use this command line if you have many files to join: MP4Box $(for file in single*m4v; do echo -cat $file; done) joined.m4v
    – guettli
    Commented Nov 5, 2015 at 14:54

The Quicktime MP4 Codec choice has a "pass through" mode.

Here is a full detailed recipe to join two MP4 H264 videos, using Quicktime. Note that Quicktime X is not advanced enough yet, so use Quicktime 7 (an optional install with Snow Leopard):

  1. Open the two H264 videos in Quicktime 7. Let's suppose they are named video1.mp4 and video2.mp4.
  2. Working on video1.mp4, Select All, then Copy.
  3. Switch to video2.mp4, make sure the "cursor" is at the beginning of the video, then Paste. This inserts the content of video1.mp4 at the front of video2.mp4.
  4. This step is probably optional. "Save As" the modified video2.mp4. You will be able to save in .mov format only. I saved as a self-contained movie, but I suppose a reference movie would work too. I used the filename "video.mov".
  5. Select "Export" in the file menu to export video.mov to the joined H264 file. The "Export" to select is "Movie to MPEG-4". The preset is not important, I chose "LAN/Intranet". The preset is not important because we override it in the next step.
  6. Click on "Options" to reach the settings dialog. In the Video pane, "Video Format" is selected to be "H.264". Click on the menu, select "Pass Through". As expected, all the other options will get disabled.
  7. Click OK, then Save, and watch your joined file be saved at the speed of your hard disk.

You could alternatively use SimpleMovieX, a shareware video editor which exactly advertises this as a feature.

  • 1
    Saving in mov I assume will need some form of re-encoding unfortunately.
    – Csaba Toth
    Commented Nov 8, 2016 at 8:13

Use mkvtoolnix . Then open "mkvtoolnix-gui.exe" (in windows 8.1 64bits it is located at : C:\Program Files\MKVToolNix\mkvtoolnix-gui.exe). Add the first file. Then select this first file and right click "append files" and select the file(s) that you want to merge. Maybe change the destination folder and filename. Then finally click on "start multiplexing".


I think this should be possible, although the two parts might need to be the "same" certain ways (resolution, etc) in order for the join to work. This sounds like it will probably be the case with your situation.

You could try this tool: http://www.smlabs.net/tsmuxer_en.html ... I have not used it but it specifically lists joining files as part of its feature set and H.264 is one of the supported encodings.

  • Thanks for the link. I could not try it as the site says this program does not support Snow Leopard. Moreover, I just found a working solution using Quicktime only (see my answer). Also, though I don't know in this case, some tools advertise joining video file but do so with full re-encoding, which is at best misleading.
    – jdmuys
    Commented Apr 23, 2010 at 6:12
  • My apologies; I misread that bit on the site. Glad you found a simpler approach -- it did seem strange that it would be necessary to get a special tool for this. Commented Apr 23, 2010 at 7:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .