Hardware video acceleration: Difference between revisions
m (→Intel: mention part decoding first) |
(→VDPAU drivers: VP9 support is coming) |
||
(One intermediate revision by the same user not shown) | |||
Line 272: | Line 272: | ||
| {{G|Broadwell and newer}} | | {{G|Broadwell and newer}} | ||
| {{No}} | | {{No}} | ||
| rowspan=3 {{ | | rowspan=3 {{B|Coming Soon<sup>5</sup>}} | ||
|- | |- | ||
! VP9 8bit | ! VP9 8bit | ||
Line 323: | Line 323: | ||
* <sup>3</sup> Hybrid VP8 encoder and VP9 decoder supported by {{AUR|intel-hybrid-codec-driver}}. [https://github.com/intel/intel-hybrid-driver/issues/21 VP9 decoding on Haswell crashes]. | * <sup>3</sup> Hybrid VP8 encoder and VP9 decoder supported by {{AUR|intel-hybrid-codec-driver}}. [https://github.com/intel/intel-hybrid-driver/issues/21 VP9 decoding on Haswell crashes]. | ||
* <sup>4</sup> MPEG-4 is disabled by default due to VAAPI limitations. Set the [[environment variable]] {{ic|1=VAAPI_MPEG4_ENABLED=true}} to try to use it anyway. | * <sup>4</sup> MPEG-4 is disabled by default due to VAAPI limitations. Set the [[environment variable]] {{ic|1=VAAPI_MPEG4_ENABLED=true}} to try to use it anyway. | ||
* <sup>5</sup> [https://gitlab.freedesktop.org/vdpau/libvdpau/merge_requests/7] | |||
=== VDPAU drivers === | === VDPAU drivers === | ||
{{Note| | {{Note|VP9 support is coming [https://gitlab.freedesktop.org/vdpau/libvdpau/merge_requests/7].}} | ||
{| class="wikitable" style="text-align:center;" | {| class="wikitable" style="text-align:center;" |
Revision as of 11:35, 16 August 2019
Hardware video acceleration makes it possible for the video card to decode/encode video, thus offloading the CPU and saving power.
There are several ways to achieve this on Linux:
- Video Acceleration API (VA-API) is a specification and open source library to provide both hardware accelerated video encoding and decoding, developed by Intel.
- Video Decode and Presentation API for Unix (VDPAU) is an open source library and API to offload portions of the video decoding process and video post-processing to the GPU video-hardware, developed by NVIDIA. VDPAU has not been updated since September 2015.
- NVDECODE/NVENCODE - proprietary APIs for hardware video acceleration used by NVIDIA Fermi, Kepler, Maxwell and Pascal generation GPUs.
For pre-2007 video cards see XvMC. For comprehensive overview of driver and application support see #Comparison tables.
Installation
Intel
Intel graphics open-source drivers support VA-API:
- HD Graphics series starting from CannonLake (or optionally from Broadwell) and newer are supported by intel-media-driver.
- GMA 4500 series and newer GPUs up to Coffee Lake are supported by libva-intel-driver.
- GMA 4500 H.264 decoding is supported by libva-intel-driver-g45-h264AUR, see Intel#Hardware accelerated H.264 decoding on GMA 4500.
- Broadwell to Skylake VP9 decoding and Haswell to Skylake hybrid VP8 encoding is supported by intel-hybrid-codec-driverAUR. VP9 decoding on Haswell crashes.
NVIDIA
Nouveau open-source driver supports both VA-API and VDPAU:
- GeForce 8 series and newer GPUs up until GeForce GTX 750 are supported by libva-mesa-driver and mesa-vdpau.
- Requires nouveau-fwAUR firmware package, presently extracted from the NVIDIA binary driver.
NVIDIA proprietary driver supports via nvidia-utils:
- VDPAU on GeForce 8 series and newer GPUs;
- NVDECODE on Fermi and newer GPUs [1];
- NVENCODE on Kepler and newer GPUs.
ATI/AMD
ATI and AMDGPU open-source drivers support both VA-API and VDPAU:
- VA-API on Radeon HD 2000 and newer GPUs is supported by libva-mesa-driver.
- VDPAU on Radeon R300 and newer GPUs is supported by mesa-vdpau.
AMDGPU PRO proprietary driver is built on top of AMDGPU driver and supports both VA-API and VDPAU.
Translation layers
To get VA-API support when device driver provides none:
- libva-vdpau-driver – VDPAU backend for VA-API.
- libva-vdpau-driver-chromiumAUR – VDPAU backend for VA-API, patched to work with Chromium.
- XvBA backend for VA-API is provided by proprietary AMD Catalyst driver.
To get VDPAU support when device driver provides none:
- libvdpau-va-gl – VA-API backend for VDPAU, only H.264 support.
Verification
Your system may work perfectly out-of-the-box without needing any configuration. Therefore it is a good idea to start with this section to see that it is the case.
Verifying VA-API
Verify the settings for VA-API by running vainfo
, which is provided by libva-utils:
$ vainfo
libva info: VA-API version 0.39.4 libva info: va_getDriverName() returns 0 libva info: Trying to open /usr/lib/dri/i965_drv_video.so libva info: Found init function __vaDriverInit_0_39 libva info: va_openDriver() returns 0 vainfo: VA-API version: 0.39 (libva 1.7.3) vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 1.7.3 vainfo: Supported profile and entrypoints VAProfileMPEG2Simple : VAEntrypointVLD VAProfileMPEG2Simple : VAEntrypointEncSlice VAProfileMPEG2Main : VAEntrypointVLD VAProfileMPEG2Main : VAEntrypointEncSlice VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP VAProfileH264Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointEncSlice VAProfileH264Main : VAEntrypointEncSliceLP VAProfileH264High : VAEntrypointVLD VAProfileH264High : VAEntrypointEncSlice VAProfileH264High : VAEntrypointEncSliceLP VAProfileH264MultiviewHigh : VAEntrypointVLD VAProfileH264MultiviewHigh : VAEntrypointEncSlice VAProfileH264StereoHigh : VAEntrypointVLD VAProfileH264StereoHigh : VAEntrypointEncSlice VAProfileVC1Simple : VAEntrypointVLD VAProfileVC1Main : VAEntrypointVLD VAProfileVC1Advanced : VAEntrypointVLD VAProfileNone : VAEntrypointVideoProc VAProfileJPEGBaseline : VAEntrypointVLD VAProfileJPEGBaseline : VAEntrypointEncPicture VAProfileVP8Version0_3 : VAEntrypointVLD VAProfileVP8Version0_3 : VAEntrypointEncSlice VAProfileHEVCMain : VAEntrypointVLD VAProfileHEVCMain : VAEntrypointEncSlice
VAEntrypointVLD
means that your card is capable to decode this format, VAEntrypointEncSlice
means that you can encode to this format.
In this example the i965
driver is used, as you can see in this line:
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
If the following error is displayed when running vainfo
:
libva info: va_openDriver() returns -1 vaInitialize failed with error code -1 (unknown libva error),exit
You need to configure the correct driver, see #Configuring VA-API.
Verifying VDPAU
Install vdpauinfo to verify if the VDPAU driver is loaded correctly and retrieve a full report of the configuration:
$ vdpauinfo
display: :0 screen: 0 API version: 1 Information string: G3DVL VDPAU Driver Shared Library version 1.0 Video surface: name width height types
420 16384 16384 NV12 YV12 422 16384 16384 UYVY YUYV 444 16384 16384 Y8U8V8A8 V8U8Y8A8 Decoder capabilities: name level macbs width height
MPEG1 --- not supported --- MPEG2_SIMPLE 3 9216 2048 1152 MPEG2_MAIN 3 9216 2048 1152 H264_BASELINE 41 9216 2048 1152 H264_MAIN 41 9216 2048 1152 H264_HIGH 41 9216 2048 1152 VC1_SIMPLE 1 9216 2048 1152 VC1_MAIN 2 9216 2048 1152 VC1_ADVANCED 4 9216 2048 1152 ..
Configuration
Although the video driver should automatically enable hardware video acceleration support for both VA-API and VDPAU, it may be needed to configure VA-API/VDPAU manually. Only continue to this section if you went through #Verification.
The default driver names, used if there is no other configuration present, are guess by the system. However, they are often hacked together and may not work. You can see the guessed values by running:
$ grep -iE 'vdpau | dri driver' ~/.local/share/xorg/Xorg.0.log
(II) RADEON(0): [DRI2] DRI driver: radeonsi (II) RADEON(0): [DRI2] VDPAU driver: radeonsi
In this case radeonsi
is the default for both VA-API and VDPAU.
journalctl -b | grep -iE 'vdpau | dri driver'
instead.This does not represent the configuration however. The values above will not change even if you override them.
Configuring VA-API
You can override the driver for VA-API by using the LIBVA_DRIVER_NAME
environment variable:
- Intel graphics:
- For libva-intel-driver use
i965
. - For intel-media-driver use
iHD
.
- For libva-intel-driver use
- NVIDIA:
- ATI/AMD:
- For AMDGPU driver use
radeonsi
. - For AMD Catalyst use
fglrx
.
- For AMDGPU driver use
- You can find the installed drivers in
/usr/lib/dri/
. They are used as/usr/lib/dri/${LIBVA_DRIVER_NAME}_drv_video.so
. - Some drivers are installed several times under different names for compatibility reasons. You can see which by running
sha1sum /usr/lib/dri/*
. LIBVA_DRIVERS_PATH
can be used to overrule the VA-API drivers location.- Since version 12.0.1 libva-mesa-driver provides
radeonsi
instead ofgallium
.
Configuring VDPAU
You can override the driver for VDPAU by using the VDPAU_DRIVER
environment variable.
The correct driver name depends on your setup:
- For Intel Graphics or AMD Catalyst you need to set it to
va_gl
. - For the open source AMD/ATI driver set it to the proper driver version depending on your GPU, see #Verification.
- For the open source Nouveau driver set it to
nouveau
. - For NVIDIA's proprietary version set it to
nvidia
.
- You can find the installed drivers in
/usr/lib/vdpau/
. They are used as/usr/lib/vdpau/libvdpau_${VDPAU_DRIVER}.so
. - Some drivers are installed several times under different names for compatibility reasons. You can see which by running
sha1sum /usr/lib/vdpau/*
. - For hybrid setups (both NVIDIA and AMD), it may be necessary to set
DRI_PRIME=1
. For more information see PRIME.
Troubleshooting
Failed to open VDPAU backend
You need to set VDPAU_DRIVER
variable to point to correct driver. See #Configuring VDPAU.
VAAPI init failed
An error along the lines of libva: /usr/lib/dri/i965_drv_video.so init failed
is encountered. This can happen because of improper detection of Wayland. One solution is to unset $DISPLAY
so that mpv, mplayer, VLC, etc. do not assume it is X11. Another mpv-specific solution is to add the parameter --opengl-backend=wayland
.
Comparison tables
VA-API drivers
Codec | libva-intel-driver [2] | intel-media-driver [3] | libva-mesa-driver [4] [5] | AMD Catalyst (XvBA adapter) |
libva-vdpau-driver (VDPAU adapter) |
---|---|---|---|---|---|
Decoding | |||||
MPEG-2 | GMA 4500 and newer | Broadwell and newer | Radeon HD 6000 and newer GeForce 8 and newer1 |
Radeon HD 4000 and newer | See #VDPAU drivers |
MPEG-44 | No | No | Radeon HD 6000 and newer | Radeon HD 6000 and newer | |
VC-1 | Sandy Bridge and newer | Broadwell and newer | Radeon HD 2000 and newer GeForce 9300 and newer1 |
Radeon HD 4000 and newer | |
H.264/MPEG-4 AVC | GMA 45002, Ironlake and newer | Radeon HD 2000 and newer GeForce 8 and newer1 |
Radeon HD 4000 and newer | ||
H.265/HEVC 8bit | Cherryview/Braswell and newer | Skylake and newer | Radeon R9 Fury and newer | No | |
H.265/HEVC 10bit | Broxton and newer | Broxton/Apollo Lake and newer | Radeon 400 and newer | ||
VP8 | Broadwell and newer | Broadwell and newer | No | Coming Soon5 | |
VP9 8bit | Broxton and newer Hybrid: Broadwell to Skylake3 |
Broxton/Apollo Lake and newer | Raven Ridge and newer | ||
VP9 10bit | Kaby Lake and newer | Kaby Lake and newer | |||
Encoding | |||||
MPEG-2 | Ivy Bridge and newer | Broadwell and newer except Broxton/Apollo Lake |
No | No | No |
H.264/MPEG-4 AVC | Sandy Bridge and newer | Broadwell and newer | Radeon HD 7000 and newer | ||
H.265/HEVC 8bit | Skylake and newer | Skylake and newer | Radeon 400 and newer | ||
H.265/HEVC 10bit | Kaby Lake and newer | Kaby Lake and newer | Raven Ridge and newer | ||
VP8 | Cherryview/Braswell and newer Hybrid: Haswell to Skylake3 |
No | |||
VP9 8bit | Kaby Lake and newer | Icelake and newer | |||
VP9 10bit | No |
- 1 Up until GeForce GTX 750.
- 2 Supported by libva-intel-driver-g45-h264AUR instead.
- 3 Hybrid VP8 encoder and VP9 decoder supported by intel-hybrid-codec-driverAUR. VP9 decoding on Haswell crashes.
- 4 MPEG-4 is disabled by default due to VAAPI limitations. Set the environment variable
VAAPI_MPEG4_ENABLED=true
to try to use it anyway. - 5 [6]
VDPAU drivers
Codec | mesa-vdpau [8] [9] | nvidia-utils [10] | libvdpau-va-gl (VA-API adapter) | |
---|---|---|---|---|
Decoding | ||||
MPEG-2 | Radeon R300 and newer GeForce 8 and newer1 |
GeForce 8 and newer | No | |
MPEG-4 | Radeon HD 6000 and newer GeForce 200 and newer1 |
GeForce 200 and newer | ||
VC-1 | Radeon HD 2000 and newer GeForce 9300 and newer1 |
GeForce 8 and newer2 | ||
H.264/MPEG-4 AVC | Radeon HD 2000 and newer GeForce 8 and newer1 |
GeForce 8 and newer | See #VA-API drivers | |
H.265/HEVC 8bit | Radeon R9 Fury and newer | GeForce 900 and newer3 | No | |
H.265/HEVC 10bit | Radeon 400 and newer | No4 |
- 1 Up until GeForce GTX 750.
- 2 Except GeForce 8800 Ultra, 8800 GTX, 8800 GTS (320/640 MB).
- 3 Except GeForce GTX 970 and GTX 980.
- 4 NVIDIA implementation is limited to 8-bit streams [11] [12].
NVIDIA driver only
Codec | nvidia-utils [13] | |
---|---|---|
NVDECODE | NVENCODE | |
MPEG-2 | Fermi and newer1 | No |
VC-1 | ||
H.264/MPEG-4 AVC | Kepler and newer2 | |
H.265/HEVC 8bit | Maxwell (GM206) and newer | Maxwell (2nd Gen) and newer |
H.265/HEVC 10bit | Pascal and newer | |
VP8 | Maxwell (2nd Gen) and newer | No |
VP9 8bit | Maxwell (GM206) and newer | |
VP9 10bit | Pascal and newer |
- 1 Except GM108 (not supported)
- 2 Except GM108 and GP108 (not supported)
Application support
Application | Decoding | Encoding | Documentation | |||
---|---|---|---|---|---|---|
VA-API | VDPAU | NVDECODE | VA-API | NVENCODE | ||
FFmpeg | Yes | Yes | Yes | Yes | Yes | FFmpeg#Hardware video acceleration |
GStreamer | Yes1 | Yes | Yes2 | Yes1 | Yes2 | GStreamer#Hardware video acceleration |
Kodi | Yes | Yes | Yes | – | – | Kodi#Hardware video acceleration |
mpv | Yes | Yes | Yes | – | – | mpv#Hardware video acceleration |
VLC media player | Yes | Yes | No | – | – | VLC media player#Hardware video acceleration |
MPlayer | Yes3 | Yes | No | – | – | MPlayer#Hardware video acceleration |
Flash | No4 | Yes4 | No | – | – | Browser plugins#Adobe Flash Player |
Chromium | Yes3 | No | No | – | – | Chromium#Hardware video acceleration |
Firefox | No | No | No | – | – | Bug report |
- 1 GStreamer uses a whitelist of VA-API drivers. To use other drivers like intel-media-driver, set environment variable
GST_VAAPI_ALL_DRIVERS=1
. - 2 NVDECODE/NVENCODE is disabled in the Arch package.
- 3 Not supported officially by developers, alternative packages available.
- 4 VDPAU is supported only by NPAPI plugin. PPAPI plugin to NPAPI browser experimental adapter is available that provides partial VA-API and VDPAU acceleration.