Monday, October 14, 2013

How to combine mp4/mov movie clips fast

Cut and paste are key basic operations for editing.  So it's always been maddening to me how getting both these operations fast & simply has been way too hard.  On Mac OS X, CUT is incredibly easy and fast (the Edit:Trim in Quicktime Player), but PASTE (concatenate) required using a "hidden" function only found in the old Quicktime Player 7 (drag and drop a clip into an existing clip, then Close without saving, then tell it to save combined file).  But Apple broke that functionality, it no longer works (at least on Snow Leopard).  After scouring the internet for lots of possibilities (e.g. using VLC, the swiss army knife of media tools), I found the easiest, fastest way is to download ffmpeg (e.g. from http://ffmpegmac.net/) and run the following commands:
ffmpeg -i input1.mov -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mov -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
Note that this requires NO transcoding (conversion), takes just a few seconds, and the resulting filesize will simply be the sum of your input filesizes.  In my case, 57 MB total for my 18 minute lecture video.
By contrast, when I concatenated the same two mov files in iMovie, using exactly the same settings as the input mov files, it took nearly an hour running my CPU so hard it was overheating, and the resulting file was 350 MB.  Idiotic iMovie insists on re-encoding the video, which probably degrades the image quality, just to add insult to injury.

I got this method from the ffmpeg docs:
https://trac.ffmpeg.org/wiki/How%20to%20concatenate%20(join,%20merge)%20media%20files

1 comment:

  1. Thanks for review, it was excellent and very informative.
    thank you :)

    ReplyDelete