Thursday, May 23, 2013

VA API backend for VDPAU

Video acceleration on Linux

There are multiple hardware video acceleration API's available in Linux world. VDPAU by NVIDIA is the most popular (at least by the number of projects using it). VDPAU is available on all modern NVIDIA graphics with proprietary blob driver. Intel has developed its own VA API. Currently, VDPAU is available on NVIDIA and some AMD graphics, while VA API on Intel.

The great thing about those two is that they are not hardware bound and can support multiple drivers. For a long time, there have been a VDPAU backend for VA API. But only recently, the same have been implemented in opposite direction.

VA API in applications

VA API is available in number of video applications (VLC, XBMC, MythTV, GStreamer-vaapi, mplayer-vaapi, ...), but its concrete usage in some of them is far from ideal.
Enabling hw acceleration in VLC leads to even more CPU usage than with mplayer with software video decoding.
mplayer-vaapi is not officially part of mplayer and also have its pitfalls. It cannot scale ssa/ass subtitles with video, subtitles are "embedded" in video, leaving them in the same resolution as video (this means ugly subtitles for SD videos). It isn't also available for mplayer2, which contains some improvements over mplayer.

Video acceleration in Flash

Situation in Adobe's Flash is very simple. Only VDPAU is, and ever be supported. There is only one solution, actually use VDPAU even on Intel cards.


This quite new project finally provides VA API backend for VDPAU. I have discovered it only recently, but so far everything works just fine.
You may find it in your distribution's repository (eg. Arch users). If you don't, follow this simple howto.

Building from source

The code is available on github (i-rinat/libvdpau-va-gl), so let's clone the repo first:
git clone git://
Now install build dependencies (command is for Debian based distributions):
sudo apt-get install libvdpau-dev libva-dev libglib2.0-dev libswscale-dev libgl1-mesa-dev libglu1-mesa-dev
And start compiling:
mkdir build && cd build
sudo make install
You can of course skip make install and create a package instead.

Post-build configuration

You now have the library installed, let's use it! You need to specify which VDPAU backend should be used, it is done with VDPAU_DRIVER variable.
Put this into your .profile (or .zprofile if you are using zsh :)
export VDPAU_DRIVER=va_gl
There are also some tweaks for this backend, but you can find it in the README file at git (and they are not needed for Intel cards).

Configure applications

I myself am using mplayer as my preferred media player.
mplayer -vo vdpau -vc ffh264vdpau,ffmpeg12vdpau,ffvc1vdpau, ...
# That comma at the end of -vc list is important. It tells mplayer to fallback 
# to other video codecs if those cannot play the video

# Those are all codecs that VA API supports, however your card may 
# not support them all. Tune the list according to output of `vainfo`
And also a little tweak to force Flash to accelerate video decoding:
echo "echo EnableLinuxHWVideoDecode=1 > /etc/adobe/mms.cfg" | sudo sh
# Little trick to run the whole command as root ;)
You should now see "accelerated video rendering, accelerated video decoding" after right click -> show video info on a video at YouTube.

Accelerated YouTube Flash video on Sandy Bridge HD 3000

Saturday, February 16, 2013

Useful Git commands

In this post, I want to show some very useful Git commands for everyday use.

Show diff of single commit

git diff ^<commit>

git diff ^HEAD # Show diff of last commit

Generate git patch from single commit

git format-patch -1 <commit>

git format-patch -1 HEAD # Generate patch from last commit

Show history of a file

git log -p -- path/to/file

Commit as a different author

git commit --author <e-mail>

Edit last commit (not yet pushed)

git commit --amend

Remove last commit (not yet pushed)

Very useful for cases when someone pushed and you commited and didn't pull.
git reset --soft HEAD~1 # HEAD~2 for 2 commits, etc

Stash only some files

To stash files not staged for commit, as seen in picture:
git stash --keep-index

Delete untracked files

git clean -f