Kristian Lyngstøl's Blog

VDPAU - 1080p with CPU cycles to spare

Posted on 2009-03-28

I just went from Ubuntu 8.04 to 9.04 (through 8.10). For two reasons:

  1. EXT4
  2. VDPAU

In Ubuntu 9.04, the 180-series of drivers from nVidia is included. Doesn't matter much? Well, it does have VDPAU. That means GPU-assisted decoding of h264. I'm currently playing a 1080p video on my Core 2 Duo 2.4GHz on battery power and it's smooth. Very smooth.

kristian@kjeks:~$ while sleep 1; do cat /proc/cpuinfo | grep MHz; done
cpu MHz         : 2000.000
cpu MHz         : 800.000
cpu MHz         : 2400.000
cpu MHz         : 800.000
cpu MHz         : 1600.000
cpu MHz         : 800.000
cpu MHz         : 1600.000
cpu MHz         : 800.000
cpu MHz         : 2000.000
cpu MHz         : 800.000
cpu MHz         : 2000.000
cpu MHz         : 800.000

That's my cpu clocking down to conserve battery and because the decoding isn't taking place on the CPU any more. Mind you, the CPU usage is still pretty high, but the difference between 70-90% of CPU usage and 100% is the difference with decoding just in time and decoding just a bit too late.

One side note is that VDPAU doesn't work while running Compiz. Yet.

To get this madness to work, nVidia has made a nice little script and patch to compile mplayer with the required support. Available from ftp://download.nvidia.com/XFree86/vdpau/ (ftp://download.nvidia.com/XFree86/vdpau/), it's surprisingly clean. These things have a nasty habit of doing Bad Stuff, but this really is as clean as it gets. It's essentially just a few svn checkouts followed by patch -p0, ./configure and make. Not even make install. Oh yeah, if you're doing this you obviously need patch, subversion and the ability to build mplayer.

After that, all you do is grab your favorite h264 1080p video and play it with mplayer -vo vdpau.