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


Encoding movies in Ubuntu - Why?

So much to my heart's content, since it's been quite some time that I've been out of school and don't need that crappy OS on my system (you know what I'm talking about) I upgraded myself from a dual boot of Windows XP and Fedora Core 3, to a single boot Ubuntu. After a lot of self-debating and reading from forums on whether to migrate to Core 8 or Ubuntu, I went with the Gutsy Gibbon 7.x flavor of Ubuntu. The installation was like eating a piece of cheesecake. Almost a single click installation. Even if Microsoft were to reverse its name, they can't beat this. And remember, although I installed it, one can run the OS directly from the CD. Isin't that cool?

I'll write about some of the cool things of Ubuntu later, now I want to talk about how to encode movies in Ubuntu, since I just went through the process. I had bought an Iomega 500 gig Screenplay which is a hard-drive with multimedia playback capability. I bought that so that I can use it as a hard-drive and at the same time connect it via RCA or S-video to my TV and play directly.Reviews on that product to follow later.

Now this player has some limitations, it plays only AVI, MPEG-4 (with Divx 3.x, 4.x, 5.x encoding), and of course, MP3, JPEG and all that. AVIs just played perfect. Now, I wanted to play some .RM and .WMV movies, that my Iomega player wouldn't normally play. That's where MPlayer and MEncoder came to my rescue. MPlayer is the world's best and most-equipped multimedia player, hands down! Just imagine, if I were to switch to Windows, just to substitute the capabilities of MPlayer, I would need at least 10 different players or softwares. All supported here by just one Mplayer with the appropriate codecs. That's the power of open-source. That's the power of Linux. MEncoder is the encoding engine that comes with the MPlayer and separate.

What do you need to do to convert these RM and WMV files into AVI or MPEG, that my player understands? Read on, the how's on the follow up post...

Labels: ,