Sunday, December 16, 2007

Encoding movies in Ubuntu - How?

Alright, so now I want to convert RM and WMV into AVI. Here's what I did that worked (of course after quite a few experiments)

1. Enable multiverse repository

All the package installations work from repositories. There are a few kinds of repositories depending on the level of security and authority. If you want to follow the GUI approach, open System->Administration->Synaptic Package Manager. Go to Settings->Repositories. I think the 'main' and'universe' repositories are enabled by default, but for mencoder we need the multiverse repository. So, enable it and ensure you're connected to the Internet and click on Reload to sync the packages with the repositories.

2. Install mencoder

This can be done easily from the terminal using apt-get, since we've enabled the multiverse repository. So get to the bash and,

$paddu>sudo apt-get install mencoder

This should be done w/o any problems.

3. Add the Medibuntu repository (Multimedia, Entertainment and Distractions in Ubuntu) to the list of APT repositories.

Again, the Medibuntu repository is not included with the default Ubuntu distribution due to copyright, patent, licenses and other issues. We're adding this repository to get two main packages - w32codecs and libdvdcss2 - which are needed my mencoder to perform to conversion.

The repository can be added by the following steps
(a) Get the list using HTTP GET and add it to /etc/apt/sources.list.d/

$paddu> sudo wget -O /etc/apt/sources.list.d/medibuntu.list

(b) Then, add the GPG key

$paddu> wget -q -O- | sudo apt-key add - && sudo apt-get update

Now, the codecs would have been installed at /usr/lib/win32 or /usr/lib/codecs

4. Run mencoder with parameters

This is the easy part, but may take a few minutes depending on the size of the file and the input and output audio and video types.

I'm just going to give an example of RM to AVI here -

$paddu> mencoder source.rm -ovc lavc -ffourcc DX50 -oac pcm -o target.avi

ovc - output video codec
oac - output audio codec
ffourcc DX50 - This option is used because although the video is produced in MPEG4 AVI, the default header is FMP4 which is not widely recognized. My IOmega player did not recognize the format (said - Codec not supported) when I first tried the conversion without that option. A header with DX50 claims that the video is DivX 5 (hence MPEG4) compatible and should therefore play on any media player that can play MPEG4 video.

That's it and you're good to go!

Steps 1-3 are just required the first time to set things up. Then on onwards just running step-4 would be sufficient. Even that can me minimized by adding the parameters to the mencoder config file at ~/.mplayer/mencoder.conf

More tutorials on the mencoder options and various other format conversions can be found at Gentoo Wiki



Anonymous CresceNet said...

Gostei muito desse post e seu blog é muito interessante, vou passar por aqui sempre =) Depois dá uma passada lá no meu site, que é sobre o CresceNet, espero que goste. O endereço dele é . Um abraço.

2:34 AM  

Post a Comment

<< Home