Join avi Or Other Movie Files Together


In this modern digital world we generate a lot of digital media, one of the most prevalent is movies. After a while I have a lot of indiviual movie files that could be better used as one long movie. This post aims to show you how to combine these movie files into one long movie. This isnt going to use an app like iMovie where you have to create a movie or apply any video editing. This post is going to show you how to stick lots of movies together in a simple and easy to use way. There is going to be two methods shown, one using Terminal and one with Quicktime, where you can pick the best option for yourself.

Using Terminal

The first method I am going to show you is to use a couple of Terminal commands. This is slightly more complicated however in the long run it will process your movie files quicker. This options takes the individual movie files, sticks them together and then sorts out the header section of the movie file so it will play correctly. The method using Quicktime will involve it re-encoding the files and can take a long time.

To begin with this method change directory to where you movie files are located. First open up Terminal located in Applications Utilites. Do this using the change directory command. You can either type the path out by hand or drop the folder into the Terminal window and press enter.

cd /path/to/seperate/video/files

We now need to stick the files together into one file. This process will take the second file, put the bytes on the end of the first file and repeat until it has gone through all of the files in the list. I like to think of it as putting a book together. You take your second book, spread glue on the cover and stick to the back of the first book. To do this in Terminal, we put out glue pot down, and use the cat, from the wordconcatenate cocommand.

cat video1.avi video2.avi videon.avi output.avi

The cat command will take videos 1 and 2 and stick them together, it will place them in the order in the list so dont get them mixed up. You can add as many as you want to the list, it doesnt have to be two items long however I would keep in mind that really long list of video files to stick together may cause some problems, so if you have hundreds of files it may be best to do this in bulk. When this has finished you will noticed to things. First the file size of output.avi is the same as the sum of video1 and video2. Second, when you play the avi file it will only play the length to the length of the first video. This is beacause the header section of the first avi only knows its original length. Going back to our book analogy the contents page of the first book, only knows the contents of the first book and not the second. What we now need to do is rebuild the header file so it knows about the second video (or second book contents). This will make sure when it plays it plays all of the video and not just the first part.

To do this we are going to use a program called mencoder. Its from a site called mplayerhq, however we only need the binary for Terminal. To do this head over to stefpause and download the mencoder bianry located at the bottom of the page. When you have downloaded the binary move it using the following command.

sudo mv /path/to/mencoder /usr/local/bin

Terminal will ask for your admin password. This is done so you only have to write mencoder in Terminal and not the path to the mencoder file. More information on install this app can be found here.

Now that we have mencoder installed we can use it rebuild the header of our avi file. To do this write or copy and paste the following into Terminal. The command assumes you are in the same location as the file output.avi created earlier.

mencoder -forceidx -oac copy -ovc copy output.avi -o output_final.avi;

In a nutshell this commands rebuilds the header file. One unqiue point about this commands is that it only copies the frames and audio across, it doesnt re-encode them. This saves a lot of time in building the final file. Most of the time you dont need to re-encode anything. If you want more of an understanding of mencoder you can read the basic help.

When the command has finished, which shouldnt take to long you should now have a working avi file which is the correct lenght and contains all of the previous videos.

To summarise the commands are:

cat video1.avi video2.avi videon.avi output.avi
mencoder -forceidx -oac copy -ovc copy output.avi -o output_final.avi;
rm output.avi

The last line removes the incorrect output file from the cat command. There you have it a video made from the sum of the smaller parts. Once you understand what is happening this command is very fast and very useful.

If you want to learn more about cat and other unix commands I recommend Mac OS X Toolbox, if you want to learn more about mencoder amazon has thrown this book up, although I am dubious to it content.

Using Quicktime

If you are not very confident in using Terminal and want more more application based method, Quicktime Player 7, located in Applications Utilites in Mac OS X 10.6, has an option to do this sort of thing. The only downside is that you dont have much control on the final video specs. I have found that it does a bit of re-encoding as well as converting the file from avi to mov. However if all you want to do is stick some movies together this method it very simple.

To begin with open up Quicktime located in the Utilites folder. Then open up your first movie. Move the scrubber to the far right as shown in the image below.

Then drag and drop your second movie onto Quicktime, move the scrubber the far right and repeat.

When you have finished compling your movie go to File Save As and select self-contained movie. The app will compile your movie and spit it out.

If you want to learn more about Quicktime something like QuickTime for Filmmakers is very well rated.


In total these are two of many methods where you can combine movie files together. I prefer the Terminal method since it is quicker, however the Quicktime method may be more useful and easier to remember if you dont use Terminal that frequently.

If you have any questions or comments about this trick please leave them below.

If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

%d bloggers like this: