I spent a couple of hours getting a proprietary software H.264 codec working in Linux and even published a writeup to help others. A day later I learned from one of the people I sourced in my article that nVidia started releasing Linux drivers last November for the hardware high definition decoders found on the 8xxx series of video cards as well as a customized version of mplayer to support the new drivers.

A mixture of emotions came across as I realized I wasted an entire day on a software decoder when a hardware solution was available for $30 to $40. The software solution was fairly disappointing, so I decided to try one of these new cards, an nVidia GeForce 8500 GT, to see if it provided a better solution. It took some work with my setup, but the results were worth it.

The new interface from nVidia for hardware video decoding on Linux is known as the Video Decode and Presentation API for UNIX or VDPAU. It’s been available officially since the release of the 180.22 nVidia Linux drivers in January of 2009, but has been available in beta drives since last November starting with 180.06. Drivers which support VDPAU will install special header files in /usr/include/vdpau/ which are required to compile media players with VDPAU support.

The installation process is fairly straightforward. The patches for mplayer can be found on the nVidia FTP site. The tarball contains not only the patch sets, but also a build script named checkout-patch-build.sh. As the name suggestes, the script checks out all the appropriate revisions of mplayer and its dependencies (libavcodec, libdvdread, etc) from a subversion repository, applies nVidia specific patches and compiles mplayer. The README.txt file in the package also suggests several free sample videos that can be used to test the new mplayer build.

To prevent conflicts with the copy of mplayer that may come with the Linux distribution and that is typically controlled by a package manager, I suggest manually installing the VDPAU version of mplayer by itself with its own name. The following are the commands I ran for both compiling and installation. Be sure to replace the tarball with the latest version available on the ftp site.

wget ftp://download.nvidia.com/XFree86/vdpau/mplayer-vdpau-3402051.tar.bz2
tar xvfj mplayer-vdpau-3402051.tar.bz2
cd mplayer-vdpau-3402051
./checkout-patch-build.sh
su 
cp ./mplayer /usr/local/bin/mplayer-vdpau

As stated earlier, the README.txt providers several sample files available to download to test out the decoder. I’d also suggest the following options when playing H.264 files:

mplayer-vdpau -vo vdpau -vc ffh264vdpau -framedrop -nocorrect-pts <filename>

Both the -framedrop and -nocorrect-pts will help provider for smoother playback and may be helpful on older CPUs. On machines that can handle the playback, they shouldn’t degrade the video quality.

You may get an error such as the following along with no video window being displayed:

Cannot find codec matching selected -vo and video format 0x31637661

This is most likely the result of having a ~/.mplayer/codecs.conf. Current versions of mplayer do not require a codecs.conf as one is compiled into the player itself. A stray configuration file will override the built-in defaults and remove the nVidia provided codecs. You may see this error if you had followed my previous tutorial on implementing software H.264 decoding.

Fixing this issue involves either deleting the file, renaming the file or combining the codecs.conf in your home directory with the patched one located in nVidia’s mplayer-vdpau build directory.

Another issue can arise if you have a multi-seat system; that is a system with multiple X servers each with their own monitor, keyboard and mouse configuration. In such an environment, it is essential that the X server you want to use the VDPAU card with comes up first. The video card does not need to be in the first PCI-E slot. Mine resides in the second:

# lspci | grep nVidia
01:00.0 VGA compatible controller: nVidia Corporation NV42 [GeForce 6800 XT] (rev a2)
02:00.0 VGA compatible controller: nVidia Corporation GeForce 8500 GT (rev a1)

However in the greeter configuration file, the server that holds the GeForce 8500 card I want to use for decoding must be listed first. In my case, I use gdm on Gentoo Linux which uses /etc/X11/gdm/custom.conf to define server startup:

[servers]
0=Plasma
1=Console

[server-Plasma]
name=Plasma server
command=/usr/X11R6/bin/X -layout Plasma -novtswitch -sharevts -isolateDevice PCI:2:0:0
flexiable=true

[server-Console]
name=Console server
command=/usr/X11R6/bin/X  -layout Console -novtswitch -sharevts -isolateDevice PCI:1:0:0
flexiable=true

When I got the VDPAU mplayer up and running, I was very impressed by the results. Some video still jumped and sputtered in placed, but nothing too distracting from the video considering the high bitrates and quality. There was also occasional screen tearing where one frame partially overlapped a previous one. I’ve read turning off the X composite extension may help alleviate this problem although I haven’t tried this yet.

I’m glad nVidia is realizing the importance of capitalizing on the Linux market. ATI is trying to catch up with their own RadeonHD drivers. Linux support will be essential as it’s an ideal platform for embedded systems such as nVidia’s Ion. It could open up an entire realm of possibilities for small, affordable, set-top box and media PC solutions.

Comments

hardware 2009-02-16

The new interface from nVidia for hardware video decoding on Linux is known as the Video Decode and Presentation API for UNIX or VDPAU

Comments are closed. Why?