Merging (joining) two videos with cat and QuickTime X

QuickTime 7 had this great feature of merging two videos together just by dragging a video file from the Finder to another QuickTime video. Unfortunately this is not possible in QuicTime X. But I still wanted to do it without installing additional software and came up with a solution that includes a small hack :).

Assume we have 2 video files named video1.dv and video2.dv in ~/Movies folder that we want to merge.

1.  Open the Terminal and navigate to Movies folder

$ cd Movies

2. Concatenate two files

$ cat video1.dv video2.dv > video3.dv

This step will take a while and the result is a strange (I don’t really want to say corrupted as it is just split in two MPEG containers) file, which will still play in most video players (I tried VLC and QuickTime X). This procedure works with transport stream formats (e.g. .dv, .ts, .mp3, .m2ts, etc.)

3. Open the new file in QuickTime X and re-save it 

File -> Save As and select one of the available formats or use

File -> Save for web and choose the desired quality

QuickTime X will re-save the file frame by frame with a proper (e.g. MOV or MP4) container.

It is off course possible to use other software (e.g. ffmpeg) and procedures.

PS: Comments on Mac OS X Hints are worth reading

Edit 22/4/2011:
I found out that it is possible to merge videos with cat and mencoder (mplayer) that rebuilds the index afterwards:

1. Install mencoder

$ sudo port install mplayer

2. merge videos together

2.1 AVI

$ cat movie1.avi movie2.avi > movie_new.avi
$ mencoder -forceidx -oac copy -ovc copy movie_new.avi -o movie.avi

2.1 MPG

$ mencoder -oac copy -ovc copy movie1 movie2 -o movie.mpg


Edit 11/9/2012:

This tip is more a proof of concept than a serious/professional way of joining videos. I still receive emails about this though. If you need something graphical with an UI, still light and opensource (and free as in free speech) try Avidemux. It can also concatenate or append (how they call it) files one after another. See the step 3.