VAAPI

From LinuxReviews
Jump to navigationJump to search
libva
Original author(s)Intel
Initial releaseSeptember 13, 2007; 14 years ago (2007-09-13)
Stable release
2.8.0 / June 18, 2020; 18 months ago (2020-06-18)
Repositorygithub.com/intel/libva
Written inC
Operating systemLinux, Android, BSD
TypeAPI
LicenseMIT License
Website01.org /linuxmedia/vaapi

The Video Acceleration API (VA-API) is the standard way of doing hardware accelerated video encoding and decoding on GNU/Linux and to some degree Android and BSD. ffmpeg and everything using it such as mpv, as well as other media players like VLC, support hardware video decoding using VAAPI. OBS Studio supports hardware video encoding using this API.

The VAAPI library is developed and maintained by Intel. The API works with AMD, Intel and Nvidia graphics cards.

GPU Support[edit]

In general, it is safe to assume that any old Intel or AMD graphics card supports H264/MPEG-AVC video decoding and encoding. This standard has had support for a very long time.

Intel Braswell/Cherry Trail a newer can do HEVC and so can AMD "Volcanic Islands" family graphics cards and newer. It is generally safe to assume that any Intel iGPU and any AMD GPU can do HEVC hardware video decoding unless it is ancient.

Intel has had VP9 hardware video decoding support since Broadwell. Broadwell chips before Apollo Lake need to use the "hybrid" VAAPI driver for VP9 decoding. AMD couldn't into VP9 hardware video decoding until their RAVEN/NAVI series. It is safe to assume a Intel iGPU chip can decode VP9 video in hardware. It is also safe to assume that a AMD graphics card can't unless it is brand new.

See AMD graphics: Hardware Video Decoding / Encoding and Intel graphics: Hardware Video Decoding / Encoding for detailed tables.

VAAPI can be used with all drivers:

  • The Mesa graphics drivers (for AMD and Intel cards)
  • The proprietary binary blob AMDGPU-PRO driver
  • The proprietary binary blob Nvidia graphics driver
  • The special Intel Quick Sync driver

There is also a pretty pointless libva-vapau-driver that allows VAAPI to use VDPAU as a back-end. This is in practice pointless since everything with VDPAU support can use VAAPI directly.

Tools[edit]

Support for hardward video encoding and decoding using VAAPI is provided by a combination of the libva library, Mesa graphics and kernel support.

The vainfo utility from the libva-utils package can be used show information about what capabilities are supported on a given system. It will output something like this:

libva info: VA-API version 1.8.0
libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_8
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.8 (libva 2.8.0)
vainfo: Driver version: Mesa Gallium driver 20.2.0-rc4 for Radeon RX 570 Series (POLARIS10, DRM 3.39.0, 5.9.0-rc2-9-Yeoreum, LLVM 11.0.0)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc

Application Support[edit]

The mpv media player defaults to --hwdec=no[1]. mpv can be configured to use VAAPI when it encountered files that can be hardware decoded by creating a configuration file $HOME/.config/mpv/mpv.conf with a minimum of:

File: $HOME/.config/mpv/mpv.conf
vo=gpu
gpu-context=x11egl
hwdec=vaapi

or

File: $HOME/.config/mpv/mpv.conf
vo=vaapi
hwdec=vaapi

The VLC video player can use VAAPI to do hardware video decoding. The VAAPI configuration option is hidden deep within VLCs settings. First, go to Tools ▸ Preferences then select Show settings ▸ All. Next, navigate to Input/Codecs ▸ Video codecs ▸ ffmpeg. There is a Hardware decoding option on that page where you can choose VA-API video decoder.

Kodi has had VAAPI support for a long time. It is not enabled by default.

The Jellyfin multimedia server supports hardware video encoding using VAAPI. This is quite useful if you run a Jellyfin server on a LAN and you want to transcode high resolution videos down to lower resolutions like 1080p or 720p on the fly or you want video files in a format mobile phones can not play transcoded to a format they can play. The setting for {Hardware acceleration is found Settings ▸ Playback ▸ Transcoding in the Jellyfin web interface.

Applications based on the GStreamer framework can in theory use VAAPI hardware decoding. There are no configuration options at all in the toy media player "apps" like GNOME Videos and Parole that are based on the GStreamer and it is also not possible to get any actual useful information about how they stutter and badly and brokenly play videos so it is unclear if they actually use VAAPI or not. "Apps" based on the GStreamer framework, and GNOME libraries in general, are never worth using anyway so it doesn't really matter if they do or don't actually support VAAPI.

ffmpeg can leverage VAAPI for hardware video encoding and decoding. You can encode HEVC video using hardware like this:

File: ffmpeg-encode-x265-HW
#!/bin/bash
inputf="$*"
inputnoext="${inputf%.*}"
outputf="${inputnoext}.x265.mp4"

ffmpeg -i "$*" \
  -vaapi_device /dev/dri/renderD128 \
  -c:v hevc_vaapi \
  -b:v 6M \
  -vf 'format=nv12,hwupload' \
  -b:a 192k \
  "${outputf}"

The important options are -vaapi_device /dev/dri/renderD128, -c:v hevc_vaapi and -vf 'format=nv12,hwupload'

Chromium can use VAAPI for hardware video decoding[2]. This configuration is officially unsupported; it must be manually enabled using the command line:

$ chromium --use-gl=desktop --enable-features=VaapiVideoDecoder

Mozilla Firefox got "experimental" disabled-by-default VAAPI support in version 80. Actually enabling it requires a bit of configuration, see Mozilla Firefox#Enabling Hardware Accelerated Video Decoding Mozilla Firefox: Enabling Hardware Accelerated Video Decoding.

Comparison to VDPAU[edit]

The VDPAU API, originally created by Nvidia, used to be a common way of doing hardware video decoding on AMD graphics cards on Linux. Nvidia stopped maintaining VDPAU long ago and it has some limitations like no support for 10-bit video. The VAAPI interface from Intel works great with both Intel and AMD graphics cards.

Footnotes[edit]


Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.