Ubuntu Terminal: How to Join the Parts of a Split AVI Video File CodeUnit 09 MAY 2011

Sometimes you will encounter files that have been split into segments in order to make them more manageable for either download or fixed size media transfer purposes. For example, a common method for doing this on Windows is to make use of the excellent dinosaur (in other words, it appears to have been available on PCs since the dawn of the computing age) application, HJ Split, which neatly chops any files fed to it into nice little manageable chunks of bits.

But now the question arises: say you encounter a AVI video file that you have downloaded all the segments for, but now want to put everything together via your Ubuntu desktop in order to view the full video. How will we do it?

Well a remarkably simple way is to open up a standard terminal window and then concatenate all the pieces together with the bog-standard cat command:

cat video1.avi.001 video1.wmv.002 video1.avi.003 > video1.avi

This should result in a fully watchable, complete AVI video file.

However, this process can sometimes cause the video and audio to fall slightly out of synch. One way of dealing with this is to use the clever little mplayer/memcoder application bundle.

First, install with:

sudo apt-get install mencoder mplayer

Now, force a audio/video resynch with:

mencoder -forceidx -oac copy -ovc copy video1.avi  video1-fixed.avi

This should work on a couple of other formats as well, such as MPG or MPEG video files for example.


Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.