Mencoding movies

A beautiful MPlayer logo I found... Yesterday I made a small five-minute movie with my camera to show Stéphanie around in our new appartment (which she hasn’t seen since she’s still in Switzerland). I thought the movie was small, but what is small in terms to minutes and seconds quickly becomes very large in terms to bits and bytes.

And as we all know: size does matter :-) (I’ve always wanted to include that in one of my posts…)

Seriously, size does matter, especially if you plan on sending the movie to someone. The five minutes of 640×480 MPEG movie weighted in with a whopping 114 MiB. With an upstream bandwidth of only 256 Kb/s (and here is really is Kb/s and not Kib/s since network equiptment don’t follow the binary units) it would take at least an hour to transfer the movie.

So what do you do? You bring our your mencoder and resize it. That was surpricingly easy to do:

mencoder a.mpg -ovc lavc -lavcopts vcodec=mpeg4 -vop scale=320:240 -oac copy -o b.mpg

That did the trick for me, converting a.mpg into b.mpg which was only 23 MiB. The new movie has about a quarter of the pixels in the old one, and the size reduction fits nicely with that. I guess I could have squizzed it some more by compressing it harder, but I have not investigated how to do that.


  1. Dan V. P. Christiansen:

    You should be aware that the resulting movie will be an AVI file and not an MPEG program stream, which is what usually is signified by the .mpg extension. Most Linux players do determine the format by simply trying the various demuxers until one succeeds. However, Mac and Windows players generally trust the file extension.

    Also, you should consider H.264 if you want good compression. It is one of the best, if not the best, video codecs out there. Also, you should be aware that there are many flags to mencoder which allow you to increase the quality of the encoded output. MPlayer/MEncoder is one of the least usable pieces of software I have seen…

  2. Martin Geisler:

    Thanks for the tip about H.264, I’ve never heard about it before but I’ll try it the next time.

    I’m surpriced that an MPEG4 encoded file isn’t an MPEG file? About the file extension then I don’t care since I don’t use Mac or Windows :-)

    But why is MPlayer not usable? It decodes just about everything and outputs it on just about anything…

  3. Janus:

    Only 256kb upstream? How are you ever going to squeeze 23 MiB into that space :p

    Sorry, had to make a rant since you so carefully wrote MiB instead of MB — you just missed kbps or kb/s instead of kb ;)

  4. Martin Geisler:

    Ahh… right, of course :-) I was just about to say that the “/s” is implicit, but then again so is the difference between “Kib” and “Kb”… :-D

Leave a comment