Thursday, June 14, 2012

How to join or merge multiple .avi or .mpg files

I have recently started watching the fab serialized movie Bloodspell, which is created entirely in Neverwinter Nights.
Bloodspell is released in a series of 6-7 MB files. So far they’re up to part 7. This certainly makes it easier to download on to my laptop and enjoy 10 minutes of Bloodspell at a time. However, I want to burn this to a DVD and watch all seven at once on my home DVD player. Before I did this I just wanted to string together the 7 .avi files into one larger file. (I can’t stand a mess!) Sounds like a simple request? Guess what, in my distro, Ubuntu, it is!

This will most likely work on just about any linux distro that includes the ability to install mplayer/mencoder.
First, let’s get the right programs.
sudo apt-get install mencoder mplayer
Now that the hard part is out of the way, we’re going to make use of the wonderful cat command. I’d renamed each Bloodspell video as b1.avi – b7.avi. Now to string them all end to end.
cat b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi > bloodspell.avi
Now we’re 2/3 of the way there! Stringing together .avi files can cause a breakdown in the sync between video and sound. So, we’ll use mencoder to sort things out.
mencoder -forceidx -oac copy -ovc copy bloodspell.avi.avi -o bloodspell_final.avi
That’s it! You’ve got one contiguous .avi file now containing all seven bloodspell releases to date. This will of course work with other .avi files. It will also work with .mpg or .mpeg files as well.
Later we’ll discuss getting this .avi file on to a DVD so you can watch it anywhere.
geek out.