Hardware video acceleration - ArchWiki

Jump to content

# Hardware video acceleration

From ArchWiki

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.
- Advanced Media Framework SDK (AMF) is an open source framework which allows "Optimal" access to AMD GPUs for multimedia processing, developed by AMD.
- NVDEC/NVENC - NVIDIA's proprietary APIs for hardware video acceleration, used by NVIDIA GPUs from Fermi onwards.
- Vulkan Video is an extension of the Vulkan graphics API designed to support hardware-accelerated video encoding and decoding.

For comprehensive overview of driver and application support see #Comparison tables.

## Installation

### Intel

#### VA-API

The Intel graphics open-source driver supports VA-API:

- HD Graphics series starting from Broadwell (2014) and newer (e.g. Intel Arc) are supported by intel-media-driver.
- GMA 4500 (2008) up to Coffee Lake (2017) are supported by libva-intel-driver.
- Haswell Refresh to Skylake VP9 decoding and Broadwell to Skylake hybrid VP8 encoding is supported by intel-hybrid-codec-driver-gitAUR.

Note Skylake or later also need linux-firmware-intel.

Also see VAAPI supported hardware and features.

#### Vulkan Video

ANV open-source vulkan driver provides Vulkan Video support via vulkan-intel.

Note Enabling Vulkan Video requires additional configuration, see #Configuring Vulkan Video

#### Intel Video Processing Library (Intel VPL)

For Intel VPL, install the base library libvpl, and at least one of the following runtime implementations:

- vpl-gpu-rt: provides support for Tiger Lake and newer GPUs
- intel-media-sdk (Discontinued): provides support for older Intel GPUs

### NVIDIA

The Nouveau open-source driver supports VA-API:

- GeForce 8 series and newer GPUs up until GeForce GTX 750 are supported by mesa.
- Requires nouveau-fwAUR firmware package, presently extracted from the NVIDIA binary driver.

The NVIDIA proprietary driver supports (via nvidia-utils):

- VDPAU on GeForce 8 series and newer GPUs;
- NVDEC on Fermi and newer GPUs [1];
- NVENC on Kepler and newer GPUs;
- Vulkan Video on Pascal and newer GPUs [2].

### AMD/ATI

AMD and ATI open-source drivers support VA-API, Vulkan Video, and AMF:

- VA-API on Radeon HD 2000 and newer GPUs via mesa.

- Vulkan Video Encode and Decode via the RADV open-source vulkan driver vulkan-radeon.

- AMF (Legacy Driver) on Fiji up to RDNA 2 supported by the proprietary amf-amdgpu-proAUR driver.

- AMF (Latest Driver) on RDNA 3 and newer GPUs supported via amf-amdgpuAUR, which uses an "All Open" stack with vulkan-radeon.

Note

- HEVC encoding may not be available on GPUs older than Navi.

### Translation layers

- libvdpau-va-gl — VDPAU driver with OpenGL/VAAPI backend. H.264 only.

  https://github.com/i-rinat/libvdpau-va-gl || libvdpau-va-gl

- nvidia-vaapi-driver — A CUDA NVDEC based backend for VA-API.

  https://github.com/elFarto/nvidia-vaapi-driver/ || libva-nvidia-driver

Note While the libva-nvidia-driver implementation does enable hardware video decoding, current limits for NVIDIA power management mean that with default settings it actually consumes more power than CPU video decoding. A workaround is possible using NVIDIA driver version 580.105.08 or newer, exporting the environment variable `CUDA_DISABLE_PERF_BOOST=1`.

## 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.

Tip

- mpv with its command-line support is great for testing hardware acceleration. Look at the log of `mpv --hwdec=auto video_filename` and see hwdec for more details.
- Use nvtop to check "DEC" (decoder) usage on the top lines while playing a video, for AMD, Intel and NVIDIA.
- For Intel GPU, use intel-gpu-tools and run `intel_gpu_top` as root to monitor the GPU activity during video playback for example. The video bar being above 0% indicates GPU video decoder/encoder usage. (If new Xe driver is in use `intel_gpu_top` will throw error, so to check run `gputop`, vcs field (Video Command Streamer) above 0% indicates GPU video decoder/encoder usage.)
- For AMD GPU, use amdgpu_top to monitor GPU activity.
- For any GPU, you can compare CPU usage with a tool like htop. Especially for higher resolution videos (4k+), CPU usage when VA-API is enabled and working should be dramatically lower on laptops and other relatively low-power devices.

### 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:

    vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 1.7.3

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: OpenGL/VAAPI backend for VDPAU

    Video surface:

    name   width height types
    -------------------------------------------
    420     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16
    422     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16
    444     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16
    420_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16
    422_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16
    444_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16

    Decoder capabilities:

    name                        level macbs width height
    ----------------------------------------------------
    MPEG1                          --- not supported ---
    MPEG2_SIMPLE                   --- not supported ---
    MPEG2_MAIN                     --- not supported ---
    H264_BASELINE                  51 16384  2048  2048
    H264_MAIN                      51 16384  2048  2048
    H264_HIGH                      51 16384  2048  2048
    VC1_SIMPLE                     --- not supported ---
    VC1_MAIN                       --- not supported ---
    VC1_ADVANCED                   --- not supported ---
    ...

### Verifying Vulkan Video

Install vulkan-tools and use vulkaninfo to verify if the video processing extensions are available:

    $ vulkaninfo | grep VK_KHR_video_

    	VK_KHR_video_decode_av1                       : extension revision 1
    	VK_KHR_video_decode_h264                      : extension revision 9
    	VK_KHR_video_decode_h265                      : extension revision 8
    	VK_KHR_video_decode_queue                     : extension revision 8
    	VK_KHR_video_encode_h264                      : extension revision 14
    	VK_KHR_video_encode_h265                      : extension revision 14
    	VK_KHR_video_encode_queue                     : extension revision 12
    	VK_KHR_video_maintenance1                     : extension revision 1
    	VK_KHR_video_queue                            : extension revision 8

## Configuration

The factual accuracy of this article or section is disputed.

Reason: Very Xorg-centric: what is the way to tell which value is "guessed" on Wayland? Is it even necessary to have this step if readers are expected to have followed the previous section? (Discuss in Talk:Hardware video acceleration)

This article or section is out of date.

Reason: mesa 25.3.0 removed VDPAU support from the open source drivers, including from the `radeonsi` driver used in this example. (Discuss in Talk:Hardware video acceleration)

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 guessed by the system. However, they are often hacked together and may not work. The guessed value will be printed in the Xorg log file, which is `~/.local/share/xorg/Xorg.0.log` if rootless, or `/var/log/Xorg.0.log` if Xorg is running as root. To search the log file for the values of interest:

    $ grep -iE 'vdpau | dri driver' xorg_log_file

    (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.

Note If you use GDM, run `journalctl -b --grep='vdpau | dri driver'` as root 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`.
- NVIDIA:
  - For Nouveau use `nouveau`.
  - For NVIDIA NVDEC use `nvidia`.
- AMD:
  - For AMDGPU driver use `radeonsi`.

Note

- 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/* | sort`.
- `LIBVA_DRIVERS_PATH` can be used to overrule the VA-API drivers location.
- Since version 12.0.1 Mesa provides `radeonsi` instead of `gallium`.

### 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 the open source AMD, Intel and Nouveau drivers you need to set it to `va_gl`.
- For NVIDIA's proprietary version set it to `nvidia`.

Note

- 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 the `DRI_PRIME` environment variable. For more information see PRIME.

### Configuring Vulkan Video

- Intel graphics: Vulkan Video support in vulkan-intel can be enabled with the `ANV_DEBUG=video-decode,video-encode` environment variable. [3]
- AMD: Vulkan Video support in vulkan-radeon is enabled by default for VCN 2+ since Mesa 25. To force-enable experimental support on older cards, set the `RADV_EXPERIMENTAL` environment variable to `video_decode,video_encode`.

Warning

Note that some older GPU models do not have Vulkan Video support in Mesa. Force-enabling experimental Vulkan Video support on such GPUs may result in crashes with some applications (for example, mpv).

### Configuring applications

Multimedia frameworks:

- FFmpeg#Hardware video acceleration
- GStreamer#Hardware video acceleration

Video players:

- Kodi#Hardware video acceleration
- MPlayer#Hardware video acceleration
- mpv#Hardware video acceleration
- VLC media player#Hardware video acceleration

Web browsers:

- Chromium#Hardware video acceleration
- Firefox#Hardware video acceleration
- GNOME/Web#Video

Multimedia recording/streaming:

- Open Broadcaster Software#Hardware video acceleration

## Troubleshooting

### Failed to open VDPAU backend

You need to set `VDPAU_DRIVER` variable to point to correct driver. See #Configuring VDPAU.

Starting from mesa 25.3.0 the VDPAU support was removed from the open source drivers (`d3d12`, `nouveau`, `r600`, `radeonsi` and `virtio_gpu`). If you were using any of these drivers before, you will need to replace them with one of the #Translation layers or configure your applications to use VA-API directly.

### 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 `--gpu-context=wayland`.

This error can also occur if you installed the wrong VA-API driver for your hardware.

### Video decoding corruption or distortion with AMDGPU driver

When experiencing video decoding corruption or distortion with AMDGPU driver, set `allow_rgb10_configs=false` as an environment variable. [4]

### vainfo fails when using iHD

If you encounter the following error:

    $ vainfo

    Trying display: wayland
    Trying display: x11
    error: can't connect to X server!
    Trying display: drm
    libva error: dlopen of /usr/lib64/dri/iHD_drv_video.so failed: /usr/lib64/dri/iHD_drv_video.so: undefined symbol: _ZN6GmmLib16GmmClientContext9GmmGetAILEv
    vainfo: VA-API version: 1.22 (libva 2.22.0)
    vainfo: Driver version: Intel i965 driver for Intel(R) Coffee Lake - 2.4.1
    vainfo: Supported profile and entrypoints
    [...]

Try installing the intel-media-driver-legacyAUR instead of the non-legacy one, which works with intel-compute-runtime-legacyAUR. [5]

### vainfo fails when using a secondary GPU

If you get an error message like:

    DRM_IOCTL_VERSION, unsupported drm device by media driver

especially when setting the driver via `LIBVA_DRIVER_NAME`, you will likely need to use `--display drm`.

This also allows you to check the info of GPUs without a display attached.

## Comparison tables

### VA-API drivers

Codec | libva-intel-driver [6] | intel-media-driver [7] | mesa [8] [9] | libva-nvidia-driver (NVDEC adapter)
--- | --- | --- | --- | ---
Decoding
MPEG-2 | GMA 4500 to Ice Lake | Broadwell and newer | Radeon HD 6000 - Radeon RX 6000 GeForce 8 to GTX 750 | See #NVIDIA driver only
VC-1 | Sandy Bridge to Ice Lake | Broadwell and newer | Radeon HD 2000 - Radeon RX 6000 GeForce 9300 to GTX 750
H.264/MPEG-4 AVC | Ironlake to Ice Lake | Radeon HD 2000 and newer GeForce 8 to GTX 750
H.265/HEVC 8bit | Cherryview/Braswell to Ice Lake | Skylake and newer | Radeon R9 Fury and newer
H.265/HEVC 10bit | Broxton to Ice Lake | Broxton/Apollo Lake and newer | Radeon 400 and newer
VP8 | Broadwell to Ice Lake | Broadwell and newer | No
VP9 8bit | Broxton to Ice Lake Hybrid: Haswell refresh to Skylake1 | Broxton/Apollo Lake and newer | Raven Ridge + Radeon RX 5000 and newer
VP9 10bit & 12bit | Kaby Lake to Ice Lake | Kaby Lake and newer
AV1 8bit & 10bit | No | Tiger Lake and newer | Radeon RX 6600 and higher/newer
Encoding
MPEG-2 | Ivy Bridge to Ice Lake | Broadwell and newer except Broxton/Apollo Lake | No | No2
H.264/MPEG-4 AVC | Sandy Bridge to Ice Lake | Broadwell and newer | Radeon HD 7000 and newer
H.265/HEVC 8bit | Skylake to Ice Lake | Skylake and newer | Radeon 400 and newer
H.265/HEVC 10bit | Kaby Lake to Ice Lake | Kaby Lake and newer | Raven Ridge + Radeon RX 5000 and newer
VP8 | Cherryview/Braswell to Ice Lake Hybrid: Haswell to Skylake1 | No
VP9 8bit | Kaby Lake to Ice Lake | Ice Lake and newer
VP9 10bit & 12bit | No
AV1 8bit & 10bit | Alchemist and newer | Radeon RX 7900 and higher/newer

1. Hybrid VP8 encoder and VP9 decoder supported by intel-hybrid-codec-driver-gitAUR.
2. NVIDIA CUDA adapter codec support is in active development and susceptible to change [10].

### VDPAU drivers

Codec | Color depth | nvidia-utils | libvdpau-va-gl (VA-API adapter)
--- | --- | --- | ---
Decoding
MPEG-2 | 8bit | GeForce 8 and newer | No
H.263/MPEG-4 Visual | 8bit | GeForce 200 and newer
VC-1 | 8bit | GeForce 8 and newer1
H.264/MPEG-4 AVC | 8bit | GeForce 8 and newer | See #VA-API drivers
H.265/HEVC | 8bit | GeForce 900 and newer2 | No
10bit | No3
VP9 | 8bit | GeForce 900 and newer2
10bit/12bit | No3
AV1 | 8bit | RTX 30 series and newer4
10bit | No3

1. Except GeForce 8800 Ultra, 8800 GTX, 8800 GTS (320/640 MB).
2. Except GeForce GTX 970 and GTX 980.
3. NVIDIA implementation is limited to 8bit streams [11] [12].
4. Starting with driver version 510.[13]

### NVIDIA driver only

Codec | nvidia-utils [14]
--- | ---
NVDEC | NVENC
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 & 12bit | Pascal and newer
AV1 8bit & 10bit | Ampere and newer3 | Ada Lovelace and newer

1. Except GM108 (not supported)
2. Except GM108 and GP108 (not supported)
3. Except A100 (not supported)

### Application support

Application | Decoding | Encoding | Documentation
--- | --- | --- | ---
VA-API | VDPAU | NVDEC | Vulkan | VA-API | NVENC | Vulkan
FFmpeg | Yes | Yes | Yes | Yes | Yes | Yes | Yes | FFmpeg#Hardware video acceleration
GStreamer | Yes | No | Yes | Yes | Yes | Yes | Yes | GStreamer#Hardware video acceleration
Kodi | Yes | Yes | No | No | – | – | – | Kodi#Hardware video acceleration
mpv | Yes | Yes | Yes | Yes | – | – | – | mpv#Hardware video acceleration
VLC media player | Yes | Yes | No | No | – | – | – | VLC media player#Hardware video acceleration
MPlayer | No | Yes | No | No | – | – | – | MPlayer#Hardware video acceleration
Chromium | Yes | No | No | No | Yes | No | No | Chromium#Hardware video acceleration
Firefox | Yes | No | No | Partial | No | No | No | Firefox#Hardware video acceleration
GNOME/Web | GStreamer | ? | ? | ? | GNOME/Web#Video

Categories:

- Graphics
- X server

Hidden categories:

- Pages or sections flagged with Template:Accuracy
- Pages or sections flagged with Template:Out of date

Hardware video acceleration
Add topic