Difference between revisions of "Hardware video acceleration"

From ArchWiki
Jump to navigation Jump to search
(Installation: add expansion flag)
(Swapped configuration with verification, simplified and corrected the latter, general fixes.)
Line 107: Line 107:
 
* <sup>4</sup> Except GeForce GTX 970 and GTX 980.
 
* <sup>4</sup> Except GeForce GTX 970 and GTX 980.
  
The features supported by your GPU may vary. To see what your GPU supports see [[#Verifying]].
+
The features supported by your GPU may vary. To see what your GPU supports see [[#Verification]].
  
 
Regarding the {{aur|libvdpau-amdgpu-pro}} package, see also:
 
Regarding the {{aur|libvdpau-amdgpu-pro}} package, see also:
Line 128: Line 128:
 
|-
 
|-
 
! [[mpv]]
 
! [[mpv]]
| ✓ (see [[Mpv#Hardware Decoding]])
+
| ✓ (see [[mpv#Hardware Decoding]])
| ✓ (see [[Mpv#Hardware Decoding]])
+
| ✓ (see [[mpv#Hardware Decoding]])
 
|-
 
|-
 
! [[MPlayer]]
 
! [[MPlayer]]
Line 155: Line 155:
 
* For Intel Graphics use VA-API.
 
* For Intel Graphics use VA-API.
 
* For NVIDIA cards use VDPAU.
 
* For NVIDIA cards use VDPAU.
* For AMD cards you have a choice: either VA-API with {{Pkg|mesa}} or VDPAU.
+
* For AMD cards you can use both (with {{Pkg|mesa}}).
  
 
There are also two specific types of drivers for VA-API and VDPAU:
 
There are also two specific types of drivers for VA-API and VDPAU:
Line 194: Line 194:
 
** GeForce 8/9 and GeForce 100-300 series are supported by {{pkg|nvidia-340xx-utils}}.
 
** GeForce 8/9 and GeForce 100-300 series are supported by {{pkg|nvidia-340xx-utils}}.
  
== Configuration ==
+
== Verification ==
 
 
=== Configuring VA-API ===
 
 
 
The [http://www.freedesktop.org/wiki/Software/vaapi/#driversback-endsthatimplementva-api driver] for  VA-API is autodetected. To determine which one is used see [[#Verifying]]. You can override it by setting the {{ic|LIBVA_DRIVER_NAME}} [[environment variable]]:
 
 
 
* For Intel Graphics use {{ic|i965}}.
 
* For NVIDIA use {{ic|vdpau}}.
 
* For AMD use either {{ic|gallium}} (for {{Pkg|libva-mesa-driver}}) or {{ic|vdpau}} (for {{Pkg|libva-vdpau-driver}}).
 
 
 
{{note|You can find the installed drivers in {{ic|/usr/lib/dri/}}.}}
 
 
 
=== Configuring VDPAU ===
 
 
 
{{Expansion|When does {{ic|VDPAU_DRIVER}} ''need'' to be set? So far I only know about Intel and Catalyst (because of {{pkg|libvdpau-va-gl}}), it should work correctly with other cards.}}
 
 
 
The driver for use with VDPAU is auto-detected, but you may need to override it by using the {{ic|VDPAU_DRIVER}} [[environment variable]].
 
  
The correct driver name depends on your setup:
+
{{Tip| [[mpv#Hardware Decoding|mpv]] is great for testing hardware acceleration in practice.}}
 
 
* For Intel Graphics or AMD Catalyst you [[#Failed_to_open_VDPAU_backend|need]] to set it to {{ic|va_gl}}.
 
* For the open source AMD/ATI driver set it to the proper driver version depending on your GPU (see below).
 
* For NVIDIA's proprietary version set it to {{ic|nvidia}}.
 
 
 
The driver name can determined by running:
 
{{hc|$ grep -i vdpau ~/.local/share/xorg/Xorg.0.log|
 
(II) RADEON(0): [DRI2] VDPAU driver: r300
 
}}
 
In this case you want to set {{ic|1=VDPAU_DRIVER=r300}}.
 
 
 
{{note|You can find the installed drivers in {{ic|/usr/lib/vdpau/}}.}}
 
 
 
For hybrid setups (both NVIDIA and AMD), it may be necessary to [[environment variable|set]] {{ic|1=DRI_PRIME=1}}. For more information see [[PRIME]].
 
 
 
== Verifying ==
 
  
 
=== Verifying VA-API ===
 
=== Verifying VA-API ===
Line 270: Line 238:
 
Information string: NVIDIA VDPAU Driver Shared Library  364.19  Tue Apr 19 14:14:26 PDT 2016
 
Information string: NVIDIA VDPAU Driver Shared Library  364.19  Tue Apr 19 14:14:26 PDT 2016
 
}}
 
}}
 +
 +
== Configuration ==
 +
 +
The drivers for both VA-API and VDPAU are detected automatically. Only proceed if [[#Verification]] fails for you.
 +
 +
=== Configuring VA-API ===
 +
 +
You can override the driver used by VA-API with the {{ic|LIBVA_DRIVER_NAME}} [[environment variable]] so that {{ic|/usr/lib/dri/'''${LIBVA_DRIVER_NAME}'''_drv_video.so}} matches the driver you want to use. See [[Pacman#Querying_package_databases]] to find out what package provides what drivers.
 +
 +
=== Configuring VDPAU ===
 +
 +
You can override the driver used by VDPAU with the {{ic|VDPAU_DRIVER}} [[environment variable]] so that {{ic|/usr/lib/vdpau/libvdpau_'''${VDPAU_DRIVER}'''.so}} matches the driver you want to use. See [[Pacman#Querying_package_databases]] to find out what package provides what drivers.
 +
 +
{{Tip|For Intel Graphics or AMD Catalyst you [[#Failed_to_open_VDPAU_backend|need]] to set it to {{ic|va_gl}}.}}
 +
 +
The name of the driver VDPAU autodetects can be obtained by running this command (note that this doesn't change even if overrided with the above method):
 +
{{hc|$ grep -i vdpau ~/.local/share/xorg/Xorg.0.log|
 +
(II) RADEON(0): [DRI2] VDPAU driver: r300
 +
}}
 +
 +
For hybrid setups (both NVIDIA and AMD), it may be necessary to [[environment variable|set]] {{ic|1=DRI_PRIME=1}}. For more information see [[PRIME]].
  
 
== Troubleshooting ==
 
== Troubleshooting ==

Revision as of 16:29, 7 June 2016

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: I only have an Intel card so I wasn't able to test this out on AMD/NVIDIA. Please correct me in those places. (Discuss in Talk:Hardware video acceleration#)

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.
  • X-Video Motion Compensation (XvMC) is an extension for the X.Org Server, allowing video programs to offload portions of the video decoding process to the GPU video-hardware.

Support

Formats

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: I haven't found a usable list for libva-mesa-driver or libvdpau-amdgpu-proAUR. (Discuss in Talk:Hardware video acceleration#)
Note: To choose the correct driver see #Installation.
VA-API
libva-intel-driver libva-mesa-driver libva-xvba-driverAUR libva-vdpau-driver
MPEG2 decoding GMA 4500 and newer
?
Radeon HD 4000 and newer
See VDPAU.
MPEG4 decoding
?
Radeon HD 6000 and newer
H.264 decoding GMA 45001, Ironlake Graphics and newer
?
Radeon HD 4000 and newer
VC1 decoding Sandy Bridge Graphics and newer
?
Radeon HD 4000 and newer
MPEG2 encoding Ivy Bridge Graphics and newer
?
H.264 encoding Sandy Bridge Graphics and newer
?
VDPAU
mesa-vdpau libvdpau-va-gl libvdpau-amdgpu-proAUR nvidia-utils
MPEG2 decoding Radeon 9500 and newer, GeForce 8 and newer
2
?
GeForce 8 and newer
MPEG4 decoding Radeon HD 6000 and newer, GeForce 200 and newer
2
?
GeForce 200 and newer
H.264 decoding Radeon HD 4000 and newer, GeForce 8 and newer
See VA-API.
?
GeForce 8 and newer
VC1 decoding Radeon HD 4000 and newer, GeForce 83 and newer
2
?
GeForce 83 and newer
HEVC (H.265) decoding
2
?
GeForce 9004 and newer
  • 1 Supported by libva-intel-driver-g45-h264AUR instead.
  • 2 As of version 0.3, the VA GL driver doesn't support any other hardware decoder than H.264.
  • 3 Except GeForce 8800 Ultra, 8800 GTX, 8800 GTS (320/640 MB).
  • 4 Except GeForce GTX 970 and GTX 980.

The features supported by your GPU may vary. To see what your GPU supports see #Verification.

Regarding the libvdpau-amdgpu-proAUR package, see also: AMD Radeon™ Software AMD GPU-PRO Beta Driver – Linux® for Vulkan™ Release Notes. Loosely, this VDPAU driver is for the Radeon R9 family.

Software

VA-API VDPAU
GStreamer ✓ (with gstreamer-vaapi, see GStreamer#Hardware acceleration) ✓ (with gst-plugins-bad, see GStreamer#Hardware acceleration)
VLC media player ✓ (see VLC media player#Hardware acceleration support) ✓ (see VLC media player#Hardware acceleration support)
mpv ✓ (see mpv#Hardware Decoding) ✓ (see mpv#Hardware Decoding)
MPlayer ✓ (with mplayer-vaapiAUR, see MPlayer#Enabling VA-API) ✓ (see MPlayer#Enabling VDPAU)
Flash ✓ (with libvdpau-va-gl, see Flash#Configuration) ✓ (see Flash#Configuration)
Kodi
Firefox [1] [2] [3]

Installation

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: The AMDGPU driver is not mentioned. (Discuss in Talk:Hardware video acceleration#)

The choice varies depending on your video card vendor:

  • For Intel Graphics use VA-API.
  • For NVIDIA cards use VDPAU.
  • For AMD cards you can use both (with mesa).

There are also two specific types of drivers for VA-API and VDPAU:

For pre-2007 cards see XvMC.

Tip: It is recommended to install and configure both VA-API and VDPAU to achieve support in different scenarios, e.g. Flash doesn't support VA-API but can use the VDPAU VA-API backend.
Warning: Do not use libva-vdpau-driver and libvdpau-va-gl together as it will create an (infinite) loop between VA-API and VDPAU, which will result in something either really bad or really fun. But if you try it anyway please share your experiences.

Installing VA-API

Open source drivers:

Proprietary drivers:

Installing VDPAU

Open source drivers:

Proprietary drivers:

Verification

Tip: mpv is great for testing hardware acceleration in practice.

Verifying VA-API

Verify the settings for VA-API by running vainfo, which is provided by libva:

$ vainfo
libva info: VA-API version 0.39.0
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.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Sandybridge Mobile - 1.7.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

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

Verifying VDPAU

You can verify that the VDPAU driver is loaded correctly using vdpauinfo:

$ vdpauinfo | grep "Information string:"
Information string: NVIDIA VDPAU Driver Shared Library  364.19  Tue Apr 19 14:14:26 PDT 2016

Configuration

The drivers for both VA-API and VDPAU are detected automatically. Only proceed if #Verification fails for you.

Configuring VA-API

You can override the driver used by VA-API with the LIBVA_DRIVER_NAME environment variable so that /usr/lib/dri/${LIBVA_DRIVER_NAME}_drv_video.so matches the driver you want to use. See Pacman#Querying_package_databases to find out what package provides what drivers.

Configuring VDPAU

You can override the driver used by VDPAU with the VDPAU_DRIVER environment variable so that /usr/lib/vdpau/libvdpau_${VDPAU_DRIVER}.so matches the driver you want to use. See Pacman#Querying_package_databases to find out what package provides what drivers.

Tip: For Intel Graphics or AMD Catalyst you need to set it to va_gl.

The name of the driver VDPAU autodetects can be obtained by running this command (note that this doesn't change even if overrided with the above method):

$ grep -i vdpau ~/.local/share/xorg/Xorg.0.log
(II) RADEON(0): [DRI2] VDPAU driver: r300

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

This happens when you use libvdpau-va-gl without overriding VDPAU_DRIVER. VDPAU doesn't know what driver to use in this case for some reason and guesses wrongly. See #Configuring VDPAU.

You may however to configure your media player to use VA-API instead, getting far better results, see #Software.

VA-API vaInitialize failed

If vainfo gives you this error:

libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

You may need to set the LIBVA_DRIVER_NAME environment variable to vdpau or gallium, see #Configuring VA-API.