PDA

View Full Version : HOWTO: Recompiling MPlayer / MEncoder on (K)Ubuntu Breezy


amarra
February 25th, 2006, 12:45 PM
HOWTO: Recompiling MPlayer / MEncoder on (K)Ubuntu Breezy

I've tried installing all the different versions of MPlayer / MEncoder in my Breezy but I feel disappointed by the fact that these versions aren't compiled to use latest processor extensions (despite their name...). So I've googled around and managed to rebuild the MPlayer / MEncoder packages as described below. Furthermore, I've added the H.254 support by installing the open source x.264 codec library from VLC.


1) Install development tools:

sudo apt-get install build-essentials
sudo apt-get install devscripts
sudo apt-get install subversion
sudo apt-get install nasm

Note that the subversion and nasm packages are needed to download and build x.264 sources from VLC repository. If you don't mind about it, you can skip subversion and nasm installation.


2) Install x.264 codec (optional)

Download latest SVN version from VLC repository:

svn co svn://svn.videolan.org/x264/trunk x264

Build and install the codec with the following commands:

cd x264
./configure
make
sudo make install
cd ..



3) Download MPlayer sources with all needed dependencies

MPlayer is in the multiverse section of Ubuntu repository, so please enable this section in the sources.list or directly in Synaptic. Then:

sudo apt-get source mplayer
sudo apt-get build-dep mplayer


4) Hacking debian/rules

This is a quick-and-dirty tip to enable missing processor extensions in the MPlayer/MEncoder build.

cd mplayer-1.0-pre7cvs20050716/debian/
vi rules

Find and remove all the '--disable-xxx' options where xxx is in (mmx|mmx2|sse|sse2|3dnow|3dnow2). Don't mind about what your processor actually support. By removing all the '--disable-xxx' directives you force the MPlayer build to be tailored to your CPU.


5) Building packages and install

Now you can rebuild .deb packages of MPlayer and MEncoder by:

cd ..
sudo debuild -us -uc


At the end of the build you will find all the .deb packages produced in the parent directory.

cd ..
sudo dpkg -i install mplayer-586*
sudo dpkg -i install mencoder-586*

Despite their name, as said before, mplayer and mencoder binaries now support all extensions of your CPU, as you can easily check by launching mplayer or mencoder without any parameter. On my Athlon 64 mencoder said:

MEncoder dev-CVS--4.0.2 (C) 2000-2005 MPlayer Team
CPU: Advanced Micro Devices (Family: 8, Stepping: 0)
Detected cache-line size is 64 bytes
CPUflags: Type: 8 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

while on an Athlon XP:

MEncoder dev-CVS--4.0.2 (C) 2000-2005 MPlayer Team
CPU: Advanced Micro Devices Athlon MP/XP Thoroughbred (Family: 6, Stepping: 1)
Detected cache-line size is 64 bytes
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE

If you installed the x.264 codec before the mplayer building, you can check the codec presence in MEncoder by the following command:

mencoder -ovc help

It should display, among others, the following line:

x264 - H.264 encoding

That's all, folks.... ;)

I hope this can help anyone that is 'optimization-fanatic' as I am.

Bye.

jazzi
March 5th, 2006, 10:29 PM
THAT'S very helpful.Thanks

Ahriman
March 14th, 2006, 05:49 AM
Another satisfied customer!

Cheers, dude, works great \\:D/

TrendyDark
March 14th, 2006, 06:11 AM
Is there an performance increase with this little mod?

DumbNoob
March 18th, 2006, 06:19 PM
I was skeptical that this might break mencoder working in acidrip because until the recent update it didn't work for me. It's going great though. On my computer it gave me, at the minimum, 50% faster speeds with Xvid so far on the second pass. The first pass I got an even better improvement. I'm a third of the way through the second pass. I'll edit the post if it doesn't work out but I've already tested a one pass encode so I doubt there's a problem. Anyhow THANKS!

As you can see by my username, I don't know a lot unless it's spelled out for me. I got stuck in the how to at deleting all the --disable-xxx with vi rules because I didn't know how to save it. I figured out key combinations to get me backto the prompt but it didn't save it and it got old trying over and over to find the right key combo and google was no help so I just used sudo gedit which turned out to be easier too becuase I could use the search function for --disable and then just make sure it wasn't something other than the entrys I wanted.

Also, I think the H.254 thing was already installed because it's what comes up default in the gui when I use gtranscode. Maybe not.. I'm not sure. I got an error on part of the installation of it in this guide though. I also got a bit of error messages when it came to making the deb packages but it is still working and my one pass has a little better detail, such as facial expression, than it did in the two pass before I did all the above so it's still worked out.

Once again, thanks.

Also, it took a really, really long time for the final part to do it's work. I thought perhaps I had edited that file wrong and that it was caught in a loop and almost closed the window. Maybe it would be a good idea to add that it takes a long time to build and is also building more than just one architecture because seeing the same things fly by a few times also had me scratchin my head during that part of the process.

efreddi
April 2nd, 2006, 12:02 PM
Hi All,

I wanted to have Mencoder capable to use the x264 (in my opinion the best free codec at the moment), so I tried to apply the posted procedure. Here my experience:

x264: the procedure of Amarra worked without any hickup, everything ok :)

mplayer/mencoder: here things didn't go that easy... :(

sudo apt-get source mplayer
ok, no problems

sudo apt-get build-dep mplayer
here I receve the message that some dependency can't be satisfied. I tried to go on.

cd mplayer-1.0-pre7cvs20050716/debian/
vi rules
made ;)

cd ..
sudo debuild -us -uc
first problem, some error message during building, I have been suggested to run debuild with -d option. The second trial gave me another error: missin GTK Devel... with Synapthic I installed the libgtk1.2-dev. I try againg

sudo debuild -us -uc -d
but after several minutes I get another error :mad:
At this point I got nervous. Looking in the forum I found this post on the same topic:

http://www.ubuntuforums.org/showthread.php?t=85190&highlight=compiling+mplayer

so I decided to give it a trial.

./configure
make
and again error. I didn't have the permission to open some file. My nervous were like trings of violine... I tried to force the situation in not correct way:

sudo make
after several minutes I get an error: some file is missing. I opened the guilty source file and I found that the missing files were connected to some tremor, so I made

./congig --help
and I found the option to disable this tremor.
Again

sudo make
finally everything ok :)
and then

sudo make install

and everything went fine.
Anyway, I didn't want to spend to much time to understand what was wrong, it was too late in the night. My goal was to get mencoder and x264 working together and I accomplished it.

My 2 cents, bye


Elia