Joining H264 *without* re-encoding
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
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.
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):
- Open the two H264 videos in Quicktime 7. Let's suppose they are named video1.mp4 and video2.mp4.
- Working on video1.mp4, Select All, then Copy.
- 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.
- 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".
- 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.
- 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.
- 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.