Ubuntu: Playing 1080i HD content with Nvidia hardware acceleration decoding


Playing HD content on Linux has not always been that easy to achieve. Firstly, you ideally need a supported graphics card and from my research it seems preferable to go with Nvidia over AMD/ATI for Linux supported drivers at the time of writing. Secondly, you will need to configure your system to make the best use of the hardware based decoder on the current generation of graphics cards. Here's how I configured Ubuntu 11.10, an Nvidia G210 / N210 and VLC to playback 720p and 1080i HD content on a lowly Intel Atom based system...

After some research I went with the cheap and cheerful Nvidia G/N2XX series, specifically the latest card in the series the 210 to perform HD playback on my system using the GPU based hardware decoder. Note you may benefit from using a slightly more powerful video card but I was particularly keen on the 2XX series fanless design. The card is not suitable for gaming but eventually after the following tweaking played HD content to a reasonable standard.

There's a good link here to VDPAU supported video cards http://www.mythtv.org/wiki/VDPAU.

1. Install the prerequisite software
sudo apt-get install -y vainfo, vdpau-va-driver, vlc

vdpau-va-driver
VDPAU (Video Decode and Presentation API for Unix) is an open source library (libvdpau) and API originally designed by Nvidia for its GeForce 8 series and later GPU hardware targeted at the X Window System on Unix-based 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. VDPAU can be described as the X Window System equivalent of the Microsoft's DxVA (DirectX Video Acceleration) API for Windows. Currently, the portions capable of being offloaded by VDPAU onto the GPU include deblocking for MPEG-1, MPEG-2, MPEG-4 ASP (MPEG-4 Part 2), H.264/MPEG-4 AVC and VC-1, WMV3/WMV9 encoded videos.

vainfo
vainfo is a program that returns information on the Video Acceleration (VA) API for Linux.

vlc
VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVD, Audio CD, VCD, and various streaming protocols. I am an avid user of VLC there are other solutions out there which maybe easier to configure but I am a keen supported of this cross platform application.

2. Generate the nvidia xorg configuration file
sudo nvidia-xconfig

Output:

Using X configuration file: "/etc/X11/xorg.conf".
Backed up file '/etc/X11/xorg.conf' as '/etc/X11/xorg.conf.backup'
New X configuration file written to '/etc/X11/xorg.conf'

3. Configure the Nvidia x server settings
For ease, I use the graphic user interface for editing the configuration file:
sudo nvidia-settings

Disable sync to vblank, which for me when left enabled caused tearing of the video:

X Screen 0 > X Server XVideo Settings > Sync to VBlank Uncheck

Set the graphics card to use maximum performance rather than adaptive performance, which for me in adaptive mode lead to jerky video
GPU 0 - (GeForce 210) > PowerMizer > Preferred Mode = Prefer Maximum Performance

Save the configuration before quitting!!

4. Check that vdpau is installed
This step also checks that the driver is not only installed but is also in use, you may need to restart before the vdpau driver is picked up based on my brief experience:
sudo vainfo

Output:

libva: libva version 0.31.1
Xlib: extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

Not sure what the last 3 lines are referring to, but at the moment they aren't causing me grief, the crucial line is the first.

5. Configure VLC
These are the tweaks I made to VLC for smoother 1080i playback:

Tools > Preferences > Video >
- Accelerated video output (overlay) Uncheck
- Deinterlacing Off

Tools > Preferences > Inputs & Codecs >
- Use GPU acceleration (experimental) Check
- Skip H.264 in-loop deblocking filter All

Now for some final tweaks, on the bottom right of the preferences screen click:
Show settings - All
Tools > Preferences > Video > Skip frames Check
Tools > Preferences > Inputs & Codes > Video codecs > FFmpeg > Hardware decoding check

The following tweak is because I play my HD content from a samba NAS and want to increase caching:
Tools > Preferences > Inputs & Codes > Access modules > SMB > Caching value in MS = 2000 (this option is no longer present in VLC 2.0.1)

Updated March 2012 for VLC 2.0.1



7 comments:

Note: only a member of this blog may post a comment.