How to: Join MPEG or AVI videos

Ξ January 11th, 2009 | → 0 Comments |
Tools |, , , , |

One of the initial purposes of this blog was to store small pieces of knowledge collected from the web and that I use in a day-to-day basis. I haven’t really used the blog to do that, but I have several posts drafted and ready to be published containing only small tips. So, this is the first of many (I hope).

It makes me mad, the fact that most movies I download from the internet come divided into CD size avi or mpeg files. Why not one big, unique, file with the complete movie? I don’t know, but my solution is to join (or concatenate) the parts back together.

This is how I do it (in linux, of course)

Step 1 : To join the several parts of the same movie I just:

cat part1.avi part2.avi > joined.avi


The example is also applicable to MPEG video. The idea is create a big file just by joining the consecutive movie parts, so the order in the command is important.

After the previous step, you should be able to play MPEG videos although their index information might be screwed up. In general, you’ll see you ‘movies time’ be reset to 0 at the end of the first part. In the case of AVI video, you won’t be able to play the movie.

Step 2: Use mencoder* to ‘fix’ the joined video, by simply doing:

For AVI video:

mencoder -forceidx -oac copy -ovc copy joined.avi -o full.avi


For MPEG video:

mencoder -forceidx -oac copy -ovc copy -of mpeg joined.mpg -o full.mpg


This second step usually takes no more than one or two minutes.

And that’s it. You can download joinavi.sh and joinmpg.sh, and use it at your own risk. Use these scripts by just executing: joinX.sh part1.X part2.X, and you’ll get a full.X video in your current directory.

Note: Don’t forget you need to “sudo aptitude install mencoder” to able to use mencoder.

 

On the nightstand...


    The Art of Agile Development


    Beautiful Architecture


    Modern C++ Design


    Large Scale C++ Software Design

Personal

Friends


Interesting


Shared Readings