Intel G45 with VA API on Ubuntu 11.10

Seems like this feature doesn’t bother a lot of people. At least I didn’t find too much information let alone instructions on how to get Video Acceleration API (VA API) to work on my machines with Intel GMA X4500MHD. Since this is still work in progress Intel has not merged g45-h264 branch into their drivers and it seems unclear, when those will be available from Ubuntu repositories. I have already been using Nvidia’s Video Decode and Presentation API for Unix (VDPAU) for a couple of years on capable hardware and have since then been longing for a solution on Intel G45. VDPAU is very easy to install and to get running with e. g. mplayer or XBMC. VAAPI is not. But it’s not as troublesome as I thought. All of the following instructions are likely to break your system or leave it in unusable state. Either you know exactly what you’re doing and hence can reverse it or you are simply brave. Like me. Here’s how I finally did it.

Step 1: Add the Xorg-Edgers PPA to your system as you will need the bleeding edge

sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install libva1 i965-va-driver vainfo build-essential

Step 2: Get everything you need from GIT

download libva source into subfolder libva)

git clone git://anongit.freedesktop.org/vaapi/libva libva

download intel-driver source into subfolder intel-driver)

git clone git://anongit.freedesktop.org/vaapi/intel-driver intel-driver

download mplayer source into subfolder mplayer)

git clone git://gitorious.org/vaapi/mplayer.git mplayer

Step 3: You need to checkout the branches with applied vaapi-patches from inside each subdirectory

cd libva
git pull origin g45-h264
cd ..

cd intel-driver
git pull origin g45-h264
cd ..

cd mplayer
git pull origin hwaccel-vaapi
cd ..

Step 4: Compiling time! First you need to install necessary dependencies

sudo apt-get build-dep libva mplayer

then compile livba and install it

cd libva
./autogen.sh
./configure
make
sudo make install
cd ..

same with the intel-driver

cd intel-driver
./autogen.sh
./configure
make
sudo make install
cd ..

At this point – if everything went well – you should have support for VAAPI! Verfiy with vainfo. Result should be something like this:

libva: VA-API version 0.32.0
libva: va_getDriverName() returns 0
libva: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA-API version: 0.32 (libva 1.0.16.pre1)
vainfo: Driver version: Intel i965 driver - 1.0.16.pre1
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileH264Baseline : VAEntrypointVLD
VAProfileH264Main : VAEntrypointVLD
VAProfileH264High : VAEntrypointVLD

New are the H264 profiles which enable us to do some serious video decoding on HD content.

Step 5: Compiling mplayer and ffmpeg (hit ENTER when asked!)

cd mplayer
./configure
make
make install
cd ..

If that worked you can run your first GPU accelerated test

mplayer -vc vaapi file.mkv

Note: Best you put vc=vaapi,xv, into your ~/.mplayer/config file. Also don’t use multithreaded decoding with lavdopts=threads=2. It won’t work!

30 Comments

  1. rence

    Does this mean hardware support for H.264 decoding? More specifically, does this make 720p and 1080p mkv-s smooth?

  2. Exactly! Although it’s still work in progress and hence not included in the main driver tree it already does a quite good job. XBMC does somewhat better than mplayer in my opinion in case it doesn’t stutter at higher bitrate streams.

  3. rentze

    Sounds great! I just have a little problem when pulling vaapi. Namely, there is a conflict when merging the h264 branch (git pull origin g45-h264). Could you explain how you managed to resolve it? Or it just didn’t happen back then?

  4. rentze

    Sounds great! I just have a little problem when pulling libva. Namely, there is a conflict when merging the h264 branch (git pull origin g45-h264). Could you explain how you managed to resolve it? Or it just didn’t happen back then?

  5. As far as I recall I did a git commit -a and CTRL-X from nano. After that the response from the pull is

    From git://anongit.freedesktop.org/vaapi/libva
    * branch g45-h264 -> FETCH_HEAD
    Already up-to-date.

    and it worked.

  6. rentze

    That’s good to know. I have a small issue with libva, however — g45-h264 won’t merge. There are conflict messages when I run “git pull origin g45-h264″. Did you encounter the same problem and how did you solve it? Thanks in advance!

  7. rentze

    You can ignore (delete) the previous message, I just didn’t know that the previous one had made its way (two times).

    As for your suggestion, I did exactly the same thing, I just wasn’t sure if I did the right thing. Apparently I did, but it still doesn’t work. “vainfo” gives what it should give, it’s mplayer that is complaining now. Twisted. I’ll try your tutorial for XBMC, that will maybe work.

  8. rentze

    Got it to work with VLC. 720p is nice and smooth, 1080p is obviously a work in progress: stutters all the time. Unfortunately, AVCHD from my handycam is totally unplayable. I guess I’m condamned to Windows for this… There are no recent activities regarding g45-h264 as far as I can see (5 months since the last patch).

  9. Thank you everyone! Worked. I installed the intel_gpu_tools package in ubuntu to monitor my gpu usage & its finally at 100%. Mplayer’s video is still a little choppy.

    I used: mplayer -vo vaapi video.mkv to run it though mplayer -vc didn’t work.

  10. John

    I have Ubuntu 12.04 x64 with Intel 4500MHD video, when I give the command vainfo get this info:

    libva: VA-API version 0.32.0
    libva: va_getDriverName() returns 0
    libva: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
    libva: va_openDriver() returns 0
    vainfo: VA-API version: 0.32 (libva 1.1.0.pre1)
    vainfo: Driver version: Intel i965 driver – 1.0.15
    vainfo: Supported profile and entrypoints
    VAProfileMPEG2Simple : VAEntrypointVLD
    VAProfileMPEG2Main : VAEntrypointVLD

    how can I solve for h264?

  11. Bob

    Thanks!

    I did use that under debian, and for an i5 2500k – so I didn’t ‘git pull origin g45-h264′ as it’s not needed, but I have to use the option -vo vaapi, and let mplayer decide the codec and not -vc vaapi – that wouldn’t work.

    BTW, as that might help somebody:

    I did install the build dependencies that way:

    apt-get build-dep libva mplayer

    when it was finished, I did remove those that way:

    aptitude markauto $(apt-cache showsrc mplayer | grep Build-Depends | perl -p -e ‘s/(?:[\[(].+?[\])]|Build-Depends:|,|\|)//g’)

    Cheers!

  12. taklap

    Dude please i have really tried this a billion of times with almost any ubuntu based distro and i never had this working….my laptop got an x4500mhd as you have but……please tell me what im doing wrong even if i follow every step you wrote….now im just installed xubuntu 11.10 to see if the problem is with 12.04 but….same things

    libva: VA-API version 0.33.0
    libva: va_getDriverName() returns 0
    libva: Trying to open /usr/local/lib/dri/i965_drv_video.so
    libva: Found init function __vaDriverInit_0_33
    libva: va_openDriver() returns 0
    vainfo: VA-API version: 0.33 (libva 1.1.0.pre1)
    vainfo: Driver version: Intel i965 driver – 1.1.0.pre1
    vainfo: Supported profile and entrypoints
    VAProfileMPEG2Simple : VAEntrypointVLD
    VAProfileMPEG2Main : VAEntrypointVLD

    please i dont want to go back in windows for this silly reason but my little kid wants to see H264 cartoons that i have on my server…..thx in advanced for any help.

  13. Trav

    I have the same problem as John. I do not see the h264 part in vainfo. How to fix this?

  14. An2

    Check where you installed the libraries, I had a problem of not picking up the /usr/local one.

  15. works

    This works for Ubuntu 12.04.

    No need to use the xorg-edgers ppa.

    It’s making some difference, but:

    Got an 4500mhd here. 40mbps video-test-file stutters a bit. must be either the limit of the decoding-capabilities or the intel-driver is not really good…

  16. yannis t

    I get libva for g45-h264. When I `make` I get:

    Making all in test
    make[2]: Entering directory `/home/yannis/intel/libva/test’
    Making all in basic
    make[3]: Entering directory `/home/yannis/intel/libva/test/basic’
    CC test_01.o
    CCLD test_01
    /usr/bin/ld: test_01.o: undefined reference to symbol ‘vaMaxNumProfiles’
    /usr/bin/ld: note: ‘vaMaxNumProfiles’ is defined in DSO /home/yannis/intel/libva/va/.libs/libva.so.1 so try adding it to the linker command line
    /home/yannis/intel/libva/va/.libs/libva.so.1: could not read symbols: Invalid operation
    collect2: error: ld returned 1 exit status
    make[3]: *** [test_01] Error 1
    make[3]: Leaving directory `/home/yannis/intel/libva/test/basic’
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/home/yannis/intel/libva/test’
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/yannis/intel/libva’
    make: *** [all] Error 2

  17. yannis t

    DO NOT use libva branch g45-h264.

    So in step 3 do not do the following for 12.04/12.10

    cd libva
    git pull origin g45-h264
    cd ..

  18. yannis t

    you only need to add

    export LD_LIBRARY_PATH=/usr/local/lib/

    to ~/.profile in order to use the new libraries!

    mplayer2, ffmpeg (libav-tools) and kplayer work with vaapi out of the box.

    VLC does not currently support vaapi.

  19. El Patron

    Yannis, do you have any idea on what to to allow this export line to be loaded by default on an ubuntu system? tried several things link putting it on .profile or .bashrc…

    more specifically I want it to load on a XBMCBuntu system, to enable VAAPI.

    thanks!

  20. El Patron

    or maybe we could link the files in there to wherever place libva is trying to link… I am thinking of a more automated solution.

  21. martin

    didn’t work for me…

    no problems during the process, but “vainfo” still returns only two mpeg2 profiles…

    btw, I am on ubuntu 12.04

Leave a Reply

Your email address will not be published. Required fields are marked *