Decoding HD video in VLC

In past posts, I talked a bit about video decoding in VLC, particularly using the GPU (your graphics card’s processor) to decode frames instead of letting the software do all the work. My previous posts mostly revolved around the fact that this did not yet work in the release candidates of VLC 1.1.0 (which will hopefully be released soon).

There is good news however! Last weekend, the bug in VLC was fixed which made the player crash as soon as the VAAPI functions were called. My updated packages (32-bit and 64-bit) for vlc-1.1.0-rc3 are available now, with the patch included, and indeed I have no more crashes. Get those new RC3 packages and enjoy!

So, what is this GPU supported hardware decoding of video and why is it beneficial?

High Definition video has become a de facto standard on the internet, and lots of home video recorders save in HD format too. Playback of a HD video on your computer will stretch the limits of what your CPU can do… resulting in stuttering playback (dropped video frames) or display artefacts because the CPU can not keep up.

This is where the Video Acceleration API (VAAPI) originally drafted by Intel, and adopted by other hardware vendors (Nvidia and Ati of course) comes into play. VAAPI is a software interface which provides access to hardware accelerated video processing, using your computer’s  GPU which is very much suited for computationally intensive operations. For instance, owners of a Nvidia graphics card will notice that VAAPI-supported HD playback will drop the CPU usage from 100 to 30 or less percent.

My VLC package supports VAAPI hardware acceleration, if you add the following package(s):

  • libva: your computer will at least need this one. This is the library which exposes the VA API and adds the driver which VLC will use if your graphics card is an Intel one.
  • vdpau-video: this is only needed if your graphics card is an Nvidia. Vdpau is Nvidia’s own acceleration API and this package adds a VDPAU backend to libva.
  • xvba-video: this is only needed if you own an Ati-powered graphics card. This package adds a XvBA backend to libva. Unfortunately (for you) I do not own an Ati card, so I can not compile this software into a Slackware package. Get the sources here and compile them yourself, after you installed my libva package.

I should mention one caveat:

It depends on your hardware, how good the support for GPU-accelerated video processing is. An Intel card can only accelerate MPEG-2 video, whereas Nvidia and Ati cards will also support acceleration for MPEG-4/H.264/VC-1 video formats. Note that hardware-acceleration is not limited to HD video. VAAPI will for instance be beneficial to Atom-powered netbooks too, their Intel graphics will allow fluent full-screen playback of DVDs in VLC with low CPU usage, thereby saving your battery.

You can easily determine what your card’s capabilities are. After installing libva, run the “vainfo” command and examine the output. This is what my T410 laptop reports:

$ vainfo
libva: libva version 0.31.0-sds6
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib64/va/drivers/i965_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA API version: 0.31
vainfo: Driver version: i965 Driver 0.1
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple            : VAEntrypointVLD
VAProfileMPEG2Main              : VAEntrypointVLD

Have fun! Eric

18 thoughts on “Decoding HD video in VLC

  1. Thanks Eric!
    This sure made a difference in dvd playback for me. I no longer hear the fans screaming during playback, and cpu usage is next to nothing.


  2. Thanks Eric ! VLC RC3 WORKS WELL with libva and vdpau-video on my Nvidia equipped laptop.

    Here is the output of vainfo on my laptop

    libva: libva version 0.31.0-sds6
    Xlib: extension “XFree86-DRI” missing on display “:0.0”.
    libva: va_getDriverName() returns 0
    libva: Trying to open /usr/lib64/va/drivers/nvidia_drv_video.so
    libva: va_openDriver() returns 0
    vainfo: VA API version: 0.31
    vainfo: Driver version: Splitted-Desktop Systems VDPAU backend for VA API – 0.6.9
    vainfo: Supported profile and entrypoints
    VAProfileMPEG2Simple : VAEntrypointVLD
    VAProfileMPEG2Main : VAEntrypointVLD
    VAProfileH264Main : VAEntrypointVLD
    VAProfileH264High : VAEntrypointVLD
    VAProfileVC1Simple : VAEntrypointVLD
    VAProfileVC1Main : VAEntrypointVLD
    VAProfileVC1Advanced : VAEntrypointVLD


  3. Goededag, Eric.

    Thanks again for keeping your good work.

    A question to ATI geeks. I have integrated r600 based ATI GPU in my laptop. I tried the above procedure, but here is what i get:
    vladimir@darkstar:~$ vainfo
    libva: libva version 0.31.0-sds6
    libva: va_getDriverName() returns 0
    libva: Trying to open /usr/lib64/va/drivers/r600_drv_video.so
    libva: va_openDriver() returns -1
    vaInitialize failed with error code -1 (unknown libva error),exit

    The question is – as I understood the above xvba-video is for fglrx drivers. But I use opensource drivers. Could anyone direct me to similar opensource solution?

    thank you.


  4. @dolphin77:
    The XvBA backend driver unfortunately only works with the binary driver (fglrx). The same is true for the nvidia (vdpau) backend – that one also works exclusively with the binary driver.

    Eric


  5. Ok. thank you for explanations. I thought if vainfo looks for /usr/lib64/va/drivers/r600_drv_video.so, it should exist somewhere. But googling for the filename doesn’t help either.


  6. alien, on a side note, there is no need to compile xvba-video. You just have to download the ‘.tar.gz’ file, decompress it and then copy the contents of “decompressedfolder”/usr/lib/va/drivers to /usr/lib(your arch sufix here)/va/drivers/.

    So, since I am running slackware64 I did:

    cp -r xvba-video-0.6.11.x86_64# ls usr/lib64/va/drivers/* /usr/lib64/va/drivers

    Thanks for this excelente post, alien.


  7. Excuse me for stupid question but how to determine if vlc really uses GPU-acceleration? What video output module must be set in vlc? I have 8600GT, NVIDIA-Linux-x86-195.36.24 driver, vlc-1.1.0-rc4, libva and vdpau-video libs installed and I see no difference in CPU usage.


  8. I have the same issue as valgors. I have a 9600 GT card, Nvidia 256.29 driver and alienbob’s libva, vdpau-video, vlc 1.1.0 rc4, ffmpeg-0.6 packages. I checked with cat /proc//maps and libva is not loaded neither by vlc nor by ffplay. With smplayer the CPU usage is 6-7% while with vlc it’s 40-60%.


  9. I found the key of the problem 🙂
    You just need to check one option:
    Menu – Tools – Preferences – Input & Codecs Settings – Codecs – Use GPU acceleration (experimental)


  10. Well done valgors 🙂
    I had forgotten that I had been editing the .vlcrc file, manually enabling hardware acceleration before it was available as an option in the GUI..

    Eric




  11. Thanks for this post Eric!

    There is also another dependency (at least, on Slackware 13.1): FFMpeg with VAPI enabled; otherwise, VLC does not allow to enable GPU acceleration.


  12. @Ralph:
    An additional ffmpeg dependency would be very strange – because I built VLC with an internal ffmpeg library that has vaapi enabled.

    I will check when I get back home.

    Eric


  13. @Eric:

    I had an old version 0.5 of FFMpeg. Compiling VLC 1.1.0 with that library I get the message: “LIBVA found but /usr/include/libavcodec/vaapi.h does not exist”; after the compilation I get a version of VLC with the “GPU acceleration” checkbox unchecked and grayed out.
    Now I have installed FFMpeg 0.6 compiled with –enable-vdpau and VLC 1.1.0 recompiled with that library makes available the GPU acceleration.


  14. @Ralph – you did not tell the first time that you recompiled VLC in the presence of an already installed FFMPEG…
    My package for VLC does not have that FFMPEG issue. I always build on a clean system. It is perfectly safe to use the pre-compiled package.

    Eric


  15. Pingback: Flash and Slackware - How to get every ounce of performance

  16. Pingback: Vaapi Problem

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.