📜 ⬆️ ⬇️

Hardware video decoding on AMD Radeon in Ubuntu (mplayer)

Introduction


When I had a card from Nvidia, there were no issues with video playback: Download the latest snapshot from mplayer, install proprietary drivers, compile with vdpau support, add the appropriate codecs and output device, and everything works (it's worth noting that distros vdpau support is already in mplayer).
Not long ago, I had an AMD Radeon, when choosing a video card, mental obstacles existed for using Radeon, including those related to hardware decoding settings. But they were successfully broken by the financial side of the issue, and so I had an AMD Radeon HD with UVD3.
This article appeared as a search result on the topic: how to make the video card decode video + save as a note for the future. So let's get started.
Note: The comments indicated that this is an outdated method, the new method is described by reference , and the finished script is here .


Little about terms


Unified Video Decoder (rus. Unified Video Decoder; formerly called Universal Video Decoder - rus. Universal Video Decoder; abbreviated - UVD) is a hardware component (block) of graphics processors manufactured by American company AMD, designed for hardware decoding of video bit streams compressed with video codecs H.264, VC-1 and MPEG-2. [1]
X-Video Bitstream Acceleration (XvBA), the equivalent of DXVA for the X Window System, supports MPEG-2, H.264 and VC-1. [2]

Xvba


Under linux, different technologies are used for video decoding, for example, NVIDIA-vdpau, AMD - XvBA. This article describes how to install XvBA. It can be delivered from source, or from binaries. Everything you need is on the website: http://www.splitted-desktop.com/~gbeauchesne/ . Below, I will first give an example of installing from binary packages, and then from source codes. I note that I did all the actions under Ubuntu 11.04 (natty), 64 bits.
')
Installation from binary packages

Note 1: Since I use the 64-bit version of the OS, so further actions will be exactly for 64-bit. For a 32-bit OS, there will be corresponding versions of these packages. (For example: libva1_0.32.0-1 + sds2_i386.deb instead of libva1_0.32.0-1 + sds2_amd64.deb)
Note 2: The site contains assembled mplayer for 32 bit OS (the latest version is currently mplayer-vaapi-20110127.i686.tar.bz2 ). Therefore, if you are not going to build mplayer, then you can take advantage of this, but you will need to install (possibly) some packages.

1. Download packages

wget www.splitted-desktop.com/~gbeauchesne/xvba-video/xvba-video_0.8.0-1_amd64.deb www.splitted-desktop.com/~gbeauchesne/libva/pkgs/amd64/libva1_0.32.0-1+sds2_amd64.deb www.splitted-desktop.com/~gbeauchesne/mplayer-vaapi/mplayer-vaapi-latest-FULL.tar.bz2 www.splitted-desktop.com/~gbeauchesne/libva/pkgs/amd64/libva-dev_0.32.0-1+sds2_amd64.deb
Note: If you do not build mplayer, then you do not need the dev packages, just like the mplayer-vaapi-latest-FULL.tar.bz2 file.

2. Install

sudo apt-get install libdrm-dev #
sudo dpkg -i libva1_0.32.0-1+sds2_amd64.deb xvba-video_0.8.0-1_amd64.deb libva-dev_0.32.0-1+sds2_amd64.deb

You can check the operation of xvba by running the vainfo command:
$ vainfo
libva: libva version 0.32.0-sds2
Xlib: extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib/va/drivers/fglrx_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA API version: 0.32
vainfo: Driver version: Splitted-Desktop Systems XvBA backend for VA-API - 0.8.0
vainfo: Supported profile and entrypoints
VAProfileH264High : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD

Now put MPlayer.
Note: If you use already compiled, it is enough to unzip it and copy it to the folder where bash can find it, so that you can call the mplayer command and not specify the entire path (for example, in / usr / local / bin, ie cp mplayer / usr / local / bin), it will also need libraries, their presence can be viewed with the ldd $ command (which mplayer) and installed if necessary.
sudo apt-get build-dep mplayer # ,
sudo apt-get install yasm # - c build-dep
tar xf mplayer-vaapi-latest-FULL.tar.bz2 #
cd mplayer-vaapi-20110127 # . -
sh checkout-patch-build.sh #
cd mplayer-vaapi #
sudo make install #

Now you have a working mplayer with VAAPI support!

Assembly from source codes

wget www.splitted-desktop.com/~gbeauchesne/xvba-video/xvba-video-0.8.0.tar.gz www.splitted-desktop.com/~gbeauchesne/libva/libva_0.32.0-1+sds2.tar.gz www.splitted-desktop.com/~gbeauchesne/mplayer-vaapi/mplayer-vaapi-latest-FULL.tar.bz2 #
sudo apt-get build-dep mplayer # ,
sudo apt-get install autoconf libtool libxfixes-dev yasm #
tar xf libva_0.32.0-1+sds2.tar.gz # libva
cd libva-0.32.0/
for p in debian/patches/*.patch; do patch -p1 < $p; done #
autoreconf -vif #
./configure #
make #
sudo make install #
cd .. #

wget developer.amd.com/downloads/xvba-sdk-0.74-404001.tar.gz # xvba-video
tar xf xvba-sdk-0.74-404001.tar.gz include/amdxvba.h #
sudo cp include/amdxvba.h /usr/local/include #
sudo ln -s /usr/lib/fglrx/libXvBAW.so.1 /usr/local/lib/libXvBAW.so #

tar xf xvba-video-0.8.0.tar.gz #
cd xvba-video-0.8.0/
./configure
make
sudo make install #
cd ..

tar xf mplayer-vaapi-latest-FULL.tar.bz2 # MPlayer
cd mplayer-vaapi-20110127/
sed -i 's\/usr/include/va/va.h\/usr/local/include/va/va.h\g' checkout-patch-build.sh # libva /usr/local/include, /usr/include
sh checkout-patch-build.sh #
cd mplayer-vaapi
sudo make install #


In addition

You need to add the line LIBVA_DRIVER_NAME="fglrx" in / etc / enviroment, or you can add it to ~ / .bashrc: export LIBVA_DRIVER_NAME = fglrx (I didn't run mplayer without this variable)
In order not to enter parameters in the command line each time, you can put them in ~ / .mplayer / config:
va=vaapi
vo=vaapi

To use GL: vo = vaapi: gl

Conclusion


In this article, perhaps, there are not enough tests, I will give the following figures for reflection: For the same video with the CPU, the load percentage reached 80% memory consumption up to 28.2 MB, while with the GPU, the CPU load was 6%, rarely 8% (stably outside the scene), memory consumption 68-69mb. Loading GPU ... hmm ... yes it did not boot!
For the future, I hope that in future Ubuntu releases, XvBA support will be out of the box.

Bibliography


  1. ru.wikipedia.org/wiki/Unified_Video_Decoder - UVD
  2. ru.wikipedia.org/wiki/DirectX_Video_Acceleration - DXVA
  3. help.ubuntu.ru/wiki/apparatus_podderzhka_hd_video#computer_decoding_video_equities_video_card_amd_va-api - Instructions in the wiki section of the site ubuntu.ru

Source: https://habr.com/ru/post/126090/


All Articles