Monday, 14 September 2009

Well, this blog's been dead for a while as I've been a busy man. But now I'm back and hopefully will update a lot more often.

A lot has happened in the OSS universe since I've been away – the new version of Ubuntu (9.04 Intrepid Ibex) has been released for starters – but to start things off again I'm going to give you a very simple, but very useful, little tip.

Ever needed to join two or more video files together but not sure how to navigate your way round one of those huge, scary video editing suites? Well, there's a very easy way to achieve the same task on the command line. That's not to say there's anything wrong with any of the various graphical video editing suites available for Linux – they're very powerful tools – its just that sometimes something like that can be overkill for a simple task such as this.

So without further ado...

First of all we need to install a couple of command line programs: Mencoder and Mplayer.

Open up a Terminal (of course) by going to Applications > Accessories > Terminal and type (or copy and paste) the following code:

sudo apt-get install mencoder mplayer

After that we need to cd (change directory) to where your video files are stored. For this example we'll assume you have your files stored in the location: /home/user/video where 'user' is your username.

cd /home/user/video

Now we need to join all the parts together and – most importantly – re-sync the audio with the video. We'll assume your files are called part1.avi, part2.avi, part3.avi etc. Obviously, you'll need to alter the below code to the actual filenames... but you get the picture.

mencoder -forceidx -oac copy -ovc copy part1.avi part2.avi part3.avi -o full.avi

This will create a new file called full.avi in the same directory.

Alternatively, you can use a wildcard (?) to shorten the command (assuming all the parts share the same naming convention – e.g. part1.avi part2.avi part3.avi etc).

mencoder -forceidx -oac copy -ovc copy part?.avi -o full.avi

And that's it! You should now have a complete video file that is equal to the sum of it's parts :)