Compile mplayer with VDPAU support on Ubuntu

In this article I’ll show you how you can compile mplayer with VDPAU support on Ubuntu Intrepid but first I’ll try to explain why you would want to recompile mplayer with VDPAU support.

NOTICE: This article has been superseded by my newer article

Before we start compiling, you might want to know a bit more about it and if it’s something you want to do.

What is VDPAU?
WikiPedia defines it as follows:

VDPAU (Video Decode and Presentation API for Unix) is an API designed by NVIDIA for its GeForce 8 series and later GPU hardware, targeted at the X Window System on Unix operating-systems (including Linux, FreeBSD, and Solaris). The VDPAU API allows video programs to offload portions of the video decoding process and video post-processing to the GPU video-hardware. Currently, the portions designed to be offloaded by VDPAU onto the GPU are motion compensation (mo comp) and inverse discrete cosine transform (iDCT), and VLD (Variable-Length Decoding) for MPEG-1, MPEG-2, MPEG-4 AVC (H.264), VC-1, and WMV3/WMV9 encoded videos.

Great! What does it mean?
What it means that instead of using your processor is utilizes your graphics processor for certain decoding processes. This allows you to run other things when you are watching a video, the most known application that benefits from this is mythTV, you can use a less powerful processor to watch videos.

Why do I want it?
Well like I said, if you have a less powerful processor and you want to watch a DVD, movie on your computer this implementation makes it possible.

It says it is designed by nVidia, can I use it with other graphic cards?
Short answer, No. The API is designed specifically for nVidia graphic card, and then only for the GeForce 8 and higher.

Let’s start

First of all you’ll need to use the official nVidia graphics driver, not the one that comes with Ubuntu itself.
To download the latest driver go to this site. At the time I’m writing this, the latest version is 180.29. You’ll need to download the pkg1 version.

Install nVidia driver
To compile mplayer with VDPAU support we need to run the nVidia driver.
Install this driver follow the following steps.

  • Log off from your computer. Not restart but Logoff
  • Press Ctrl-Alt-1. Your on the console right now
  • Login like you normally would
  • Type:
    sudo su -

    And when asked for your password give your password

  • If you are running Gnome type:
    /etc/init.d/gdm stop

    If you are running KDE type:

    /etc/init.d/kdm stop
  • In order to install the driver we’ll need to install some software:
    apt-get install build-essential linux-headers-`uname -r`
  • Go to the directory where you downloaded the driver
  • Type: sh NVIDIA-Linux-x86-180.29-pkg1.run
  • Accept the license, no need to search the FTP site and let the installer modify the X configuration
  • Personally I always reboot after this
    reboot

Compiling mplayer
I download the software in /d1/software/mplayer
nVidia provides us with an easy script that will patch mplayer for VDPAU support. You can find the script here. Check the dates and download the newest version, again at the time I’m writing this, the latest version is mplayer-vdpau-3482714.tar.bz2. You will also need all the development files for mplayer, we can get those by using aptitude.
In order to compile mplayer you’ll also need two extra files, nVidia does provide them but for your convenience I tarred them up. You can find the download link in the sidebar of this blog under Local Downloads.

Prepare for configuration and compilation
Open a terminal.

cd /d1/software/mplayer
tar xf vdpau.tar.gz
mv vdpau /usr/include/
tar xf mplayer-vdpau-3482714.tar.bz2
sudo aptitude build-dep mplayer
cd mplayer-vdpau-3482714

I modify the script (checkout-patch-build.sh) nVidia uses so when we run it, it only gets the source code. The configuring and building I do by hand that way mplayer will use the same settings as the Ubuntu or Medibuntu versions.
Comment out the last two lines so the script looks like this:

#!/usr/bin/env sh

set -e
set -x

co_dir=mplayer-vdpau
mplayer_rev=28348
ffmpeg_rev=16726
dvdnav_rev=1166

svn co --ignore-externals -r ${mplayer_rev} svn://svn.mplayerhq.hu/mplayer/trunk ${co_dir}
cd ${co_dir}
svn co -r ${ffmpeg_rev} svn://svn.mplayerhq.hu/ffmpeg/trunk/libpostproc
svn co -r ${ffmpeg_rev} svn://svn.mplayerhq.hu/ffmpeg/trunk/libavformat
svn co -r ${ffmpeg_rev} svn://svn.mplayerhq.hu/ffmpeg/trunk/libavcodec
svn co -r ${ffmpeg_rev} svn://svn.mplayerhq.hu/ffmpeg/trunk/libavutil
svn co -r ${dvdnav_rev} svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdread/src libdvdread4
svn co -r ${dvdnav_rev} svn://svn.mplayerhq.hu/dvdnav/trunk/libdvdnav/src libdvdnav

patch -p0 < ../mplayer-vdpau-mplayer.patch

#./configure --disable-x264-lavc --disable-x264 --enable-vdpau
#make

Run the script to get the source code

./checkout-patch-build.sh

Now that we have the source code, we need to do a little bit more. In order to utilize VDPAU we need to add some extra parameters when starting mplayer. As most of us will use the menu, or the file browser to start mplayer we'll modify the menu entry.

cd mplayer-vdpau
sed 's/%F/-vo vdpau -vc ffh264vdpau,ffmpeg12vdpau,ffvc1vdpau,ffwmv3vdpau, %F/' etc/mplayer.desktop > /tmp/mplayer.desktop
mv /tmp/mplayer.desktop etc/mplayer.desktop

Configuring, Compiling and Installing
I use the --target in my configure script to force mplayer to use this that specific target. For some reason the configure script doesn't recognize I have a core2 processor. You can leave it out and mplayer will figure out what kind of processor you have.

./configure --enable-gui --disable-x264-lavc --disable-x264 --enable-vdpau --target=i686-linux --prefix=/usr --confdir=/etc/mplayer --mandir=/usr/share/man

As mentioned earlier, mplayer doesn't recognize the core2 I have, so in order for the compilation to use core2 I modify the output created by the configuration script.
Skip this if you don't have a core2 processor!

sed 's/i686/core2/g' config.mak > /tmp/config.mak
mv /tmp/config.mak config.mak

Now for the compilation and installation

make
sudo make install

That's all, you should have mplayer with VDPAU capabilities.

How do you know if you are using the VDPAU capabilities?
Download a clip from here

  • Open mplayer from the menu
  • Open a terminal and type: top
  • Open the movie in mplayer and play it
  • Check top in the terminal, you should see gmplayer in the command column. This is the GUI version of mplayer. Check the %CPU column. Try to remember the approximate percentage.
  • Close mplayer
  • Open another terminal
  • Type: gmplayer
  • Open the movie in mplayer and play it
  • Check top in the terminal, you should see gmplayer in the command column. This is the GUI version of mplayer. Check the %CPU column.
  • If the percentages of CPU is lower while playing the movie started from the menu you are running VDPAU. Congrats.
    If the percentages are about the same something went wrong during the configuration/compilation steps I described
This article is filed under the category Desktop and has the following tags associated with it: , , , , , , .
Showing 19 comments
Skip to the end and leave a comment.
  1. Soren Yeadon

    This is great!

  2. Eike

    Great, it worked, thanks for this howto!

    CPU is at 2 or 3% playing a 720P movie, before this it was at ~90% (Coreduo 2,1GHz@2,7GHz, GPU 9800GTX+)

  3. Valent Turkovic

    Any tips how to make this work on LinuxMCE who is based on Ubuntu 7.10 (Gutsy) ?
    I compiled it without problem but compiled mplayer still has no support for vdpau, any ideas?!?

    • Peter

      I just saw this thread you started: http://forum.linuxmce.org/index.php?topic=7643.0
      It gave me a little bit more info :)

      If I go with the steps you took described in there you forgot to install the include files.

      In order to compile mplayer you’ll also need two extra files, nVidia does provide them but for your convenience I tarred them up. You can find the download link in the sidebar of this blog under Local Downloads.>/qoute>

      How to install them is described in Prepare for configuration and compilation.

  4. Valent Turkovic

    I tried adding those missing files, and I’m still missing it :(
    The details are on linuxmce forum…
    Thank you for answering!

  5. connstance

    Great thanx! ^ ^

  6. Squishy

    All i get is

    Error: Cannot find header either inttypes.h or bitypes.h. There is no chance for compilation to succeed.

    Check “configure.log” if you do not understand why it failed.
    wp@wp-laptop:~/Documents/mplayer/mplayer-vdpau$ sed ‘s/i686/core2/g’ config.mak > /tmp/config.mak
    sed: can’t read config.mak: No such file or directory
    wp@wp-laptop:~/Documents/mplayer/mplayer-vdpau$

    • Peter

      What is the output of these commands, remember to do sudo su – first.
      apt-get install build-essential linux-headers-`uname -r`
      sudo aptitude build-dep mplayer

  7. Squishy

    the problem was that i didn’t remove the target.. i think it wasnt clear that it had to be removed when having a core2duo

  8. Squishy

    So i got it working..but whenever i load subtitles it crashes..any ideas..vdpau doesnt work with subtitles yet?
    It says: Error 3 at libvo/vo_vdpau.c:1113

  9. denver

    Got error:

    Error 25 at libvo/vo_vdpau.c:258

    when playing one of the trailers.

  10. lester

    I am trying apt-get build-dep mplayer and am getting add url to sources.list.

    I am attempting on linuxmce, an MD. Checked the /etc/apt/sources.list and there are only minimal entries.

    What entries should be included to be able to accomplish the above?

    • Peter

      I personally don’t know much about Linux MCE but if you have an option to add the sources repository that’s what you have to do.

  11. Alex

    I get a similar error as denver:

    Error 23 at libvo/vo_vdpau.c:786

    …when I try to use one of the VDPAU codecs like for example ffh264vdpau

    any idea?

    looks like the crash happens in config() after the VideoMixer is created. Following macro is printing the error:

    /* MACRO for error check */
    #define CHECK_ST \
    if (vdp_st != VDP_STATUS_OK) { \
    printf(“Error %d at %s:%d\n”, vdp_st, __FILE__, __LINE__); \
    exit(1); \
    }

    vdp_st is NOT_OK after this call:
    vdp_st = vdp_video_mixer_create(
    vdp_device,
    0,
    0,
    ARSIZE(parameters),
    parameters,
    parameter_values,
    &videoMixer

    I am using Ubuntu 9.04 with 180.44 driver on 8600GS and I’ve picked up the latest Nvidia patch for VDPAU which is “mplayer-vdpau-3532130″

    • Peter

      If you are running Gnome and Compiz, try disabling Compiz.
      Goto : System -> Preferences -> Appearance -> Visual Effects and select None.
      You might have to restart your computer to get rid of Compiz.

  12. muhammad negm

    Thanks that’s a perfect how to :)

  13. IR

    Great, although I didn’t quite catch the stuff under “How do you know if you are using the VDPAU capabilities?”. I just played a 1080p clip without specifying -vc ffh264vdpau -vo vdpau and compared against playing with those options and there is a huge difference ofcourse.

    BTW any idea when NVIDIA will come up with mpeg4 part2 VP based decoder? Also seems like only one decoding instance with VDPAU currently – but there are two video processors in most of their GPUs. When are they coming up with support for moe than one?

  14. Danno

    Thanks for the great howto. Built mplayer on an Atom 330 board with a PCI GeForce8400GS, plays all my 1080p x264 AC3-5.1 content really well. I had read time and time again how an Atom330 didn’t have the muscle to play hidef stuff, but after compiling mplayer for VDPAU, I average only about 10% on the CPU, occasionally spiking to 23% – the video card does the heavy lifting.
    I had originally tried the multi-threaded ffmpeg libraries, and they seemed to work fine through the board’s integrated VGA port on the PCI-E bus, ran about 240% (of a possible 400%) for 2.35AR 1080p content. I need a DVI port for the TV, though, and there was simply too much data to push through the 133Mbps PCI bus. My x264 tracks are rarely more than 8-10Mbps (profile H4.0 2pass x264, AC3-5.1; the main system isn’t even breaking a sweat during playback, even with the sound being downmixed to 2.0, streamed across a gigabit LAN.
    Couldn’t get the gui to compile, not sure why, not overly concerned. Also, did not need those two vdpau files; mplayer compiled without them.
    Anyway, thanks for taking the time to put the info up, appreciate it.
    System : Jetway NC92 motherboard, based on an Intel 945GC/82801(ICH7), single 2G DDR2, eVGA GeForce8400GS PCI video card, nVidia 185.18.14 drivers, 32bit-SMP Slackware 13.0.

  15.  

Leave a comment

For questions and/or support consider using the forums.

download