Linux graphics hardware acceleration

Hardware video acceleration (Русский)

Аппаратное ускорение видео (англ.) позволяет выполнять операции кодирования и декодирования видео на стороне видеокарты, разгружая CPU и экономя энергию.

Существуют несколько реализаций этой технологии на Linux:

  • Video Acceleration API (VA-API) — разработанная Intel спецификация и свободная библиотека, предоставляющая аппаратное ускорение кодирования и декодирования видео.
  • Video Decode and Presentation API for Unix (VDPAU) — разработанная NVIDIA свободная библиотека и API для переноса части процесса декодирования видео и его постобработки на сторону GPU.
  • NVDECODE/NVENCODE — проприетарные API аппаратного ускорения, используемые в таких поколениях GPU от NVIDIA, как Fermi, Kepler, Maxwell и Pascal.

Для получения информации о видеокартах, выпущенных до 2007 года, см. XvMC. Также всесторонний обзор поддержки данных технологий со стороны драйверов и приложений доступен в разделе #Сравнительные таблицы.

Contents

Установка

Intel

Свободные драйверы Intel graphics поддерживают VA-API:

    Серия HD Graphics, начиная с Broadwell(

2015) и новее, поддерживается intel-media-driver .

  • GMA 4500 series и более новые GPU до Coffee Lake поддерживаются libva-intel-driver .
  • Декодирование H.264 на GMA 4500 поддерживается libva-intel-driver-g45-h264AUR , см. Intel graphics (Русский)#Декодирование H.264 на GMA 4500.
  • Гибридное декодирование VP9 на процессорах от Broadwell до Skylake, а также гибридное декодирование VP8 на процессорах от Haswell до Skylake, поддерживается intel-hybrid-codec-driverAUR .
  • Skylake и более новые поколения также требуют linux-firmware .
  • NVIDIA

    Свободный драйвер Nouveau поддерживает как VA-API, так и VDPAU:

    • GeForce 8 series и новее (до GeForce GTX 750) поддерживаются libva-mesa-driver и mesa-vdpau .
    • Необходимnouveau-fwAUR — пакет с микропрограммой, которая на сегодняшний день извлекается из бинарного драйвера NVIDIA.

    Проприетарный драйвер NVIDIA поддерживает следующие технологии с помощью пакета nvidia-utils :

    • VDPAU на серии GeForce 8 и новее;
    • NVDECODE на Fermi и новее [1];
    • NVENCODE на Kepler и новее.

    ATI/AMD

    Свободные драйверы ATI и AMDGPU поддерживают как VA-API, так и VDPAU:

    • VA-API на Radeon HD 2000 и новее поддерживается libva-mesa-driver .
    • VDPAU на Radeon R300 и новее поддерживается mesa-vdpau .

    Проприетарный драйвер AMDGPU PRO основывается на драйвере AMDGPU и поддерживает как VA-API, так и VDPAU.

    Слои преобразований

    Активация поддержки VA-API при её отсутствии в драйвере:

    Активация поддержки VDPAU при её отсутствии в драйвере:

    Проверка

    Аппаратное ускорение, скорее всего, хорошо заработает по умолчанию. Проверить это можно описанными ниже способами.

    Проверка VA-API

    Проверьте настройки VA-API, выполнив vainfo (предоставляется пакетом libva-utils ):

    VAEntrypointVLD означает, что видеокарта способна декодировать данный формат, а VAEntrypointEncSlice означает, что данный формат можно кодировать.

    В данном примере используется драйвер i965 :

    Если при выполнении vainfo отображается следующая ошибка:

    Необходимо задать корректный драйвер, см. #Настройка VA-API.

    Проверка VDPAU

    Установите пакет vdpauinfo , чтобы получить полный отчёт о конфигурации драйвера VDPAU и убедиться, что он загружен корректно:

    Настройка

    Несмотря на то, что видеодрайвер должен автоматически активировать поддержку аппаратного ускорения видео с помощью VA-API и VDPAU, в некоторых случаях может потребоваться настроить VA-API/VDPAU вручную. Перед тем как продолжать чтение данного раздела, просмотрите раздел #Проверка.

    Названия драйверов по умолчанию угадываются системой, если остутствуют какие-либо другие настройки. Однако они часто не совпадают и не работают. Предполагаемые значения можно просмотреть, выполнив следующую команду:

    В данном случае по умолчанию используется radeonsi для VA-API и VDPAU.

    Настройка VA-API

    Драйвер VA-API можно переопределить с помощью переменной окружения LIBVA_DRIVER_NAME :

    • Intel graphics:
      • Укажите i965 , если используется libva-intel-driver .
      • Укажите iHD , если используется intel-media-driver .
    • NVIDIA:
      • Укажите nouveau , если используется Nouveau.
      • Укажите vdpau , если используется NVIDIA.
    • ATI/AMD:
      • Укажите radeonsi , если используется AMDGPU.
      • Укажите fglrx , если используется AMD Catalyst.
    Читайте также:  Как убрать прилипание окон windows 10

    Настройка VDPAU

    Драйвер VDPAU можно переопределить с помощью переменной окружения VDPAU_DRIVER .

    Корректное название драйвера зависит от конфигурации:

    • Если используется Intel Graphics или AMD Catalyst, необходимо задать va_gl .
    • Если используется свободный драйвер AMD/ATI, задайте соответствующую версию драйвера, в зависимости от видеокарты. См. #Проверка.
    • Если используется свободный драйвер Nouveau, задайте nouveau .
    • Если используется проприетарный драйвер NVIDIA, задайте nvidia .

    Настройка приложений

    Решение проблем

    Ошибка «Failed to open VDPAU backend»

    Необходимо задать переменную VDPAU_DRIVER , указывающую на корректный драйвер. См. #Настройка VDPAU.

    Источник

    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.
    • NVDECODE/NVENCODE — NVIDIA’s proprietary APIs for hardware video acceleration, used by NVIDIA GPUs from Fermi onwards.

    For pre-2007 video cards see XvMC. For comprehensive overview of driver and application support see #Comparison tables.

    Contents

    Installation

    Intel

    Intel graphics open-source drivers support VA-API:

    • HD Graphics series starting from Broadwell(2014) and newer are supported by intel-media-driver .
    • GMA 4500 (2008) and newer GPUs, including HD Graphics up to Coffee Lake (2017) 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.
    • Haswell refresh to Skylake VP9 decoding and Broadwell to Skylake hybrid VP8 encoding is supported by intel-hybrid-codec-driverAUR .
    • Skylake or later also need linux-firmware .

    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 .
    • Requiresnouveau-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

    • libva-vdpau-driver — A VDPAU-based backend for VA-API.

    https://cgit.freedesktop.org/vaapi/vdpau-driver || libva-vdpau-driver , libva-vdpau-driver-chromiumAUR , libva-vdpau-driver-vp9-gitAUR

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

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

    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 :

    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:

    If the following error is displayed when running vainfo :

    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:

    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:

    In this case radeonsi is the default for both VA-API and VDPAU.

    Читайте также:  Windows file checker sfc

    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:

    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 you need to set it to va_gl .
    • For the open source AMD 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 .

    Configuring applications

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

    Video decoding corruption or distortion with AMDGPU driver

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

    Источник

    • HardwareVideoAcceleration

    With modern graphics cards, it’s often possible to offload the jobs of video encoding and decoding to them from the CPU in order to reduce power usage and make more resources available to the rest of the system. Compared to CPUs, GPUs are much more efficient at the job. However, both hardware as well as software support are required for this offloading, and the latter in particular (at least in the Linux world) has undergone much evolution in recent years. Online documentation is therefore sparse and incomplete, inconsistent, and often outdated. Furthermore, support for hardware video acceleration under Linux world is unfortunately split across different APIs with different levels of support.

    Benefits

    Historically, the benefits of hardware acceleration under Linux have been uncertain, but it seems likely that support today has improved drastically. In at least some relatively typical scenarios, the performance gains of using hardware decoding can be huge, with reductions in CPU usage of around 90%.

    APIs and Hardware / Software Support

    The three main APIs that are in use are VA-API, VDPAU, and NVENC/NVDEC.

    VA-API — Supported on Intel, AMD, and NVIDIA (only via the open-source Nouveau drivers). Widely supported by software, including Kodi, VLC, MPV, Chromium, and Firefox. Main limitation is lacking any support in the proprietary NVIDIA drivers.

  • VDPAU — Supported fully on AMD and NVIDIA (both proprietary and Nouveau). Supported by most desktop applications like Kodi, VLC, and MPV, but has no support at all in Chromium or Firefox. Main limitations are poor and incomplete Intel support and not working with browsers for web video acceleration.
  • NVENC/NVDEC — A proprietary API supported exclusively by NVIDIA. Only supported in a few major applications (FFmpeg and OBS Studio for encoding, FFmpeg and MPV for decoding). Main limitation is limited software and hardware support across the board because of its proprietary nature.
  • Installation

    VA-API

    VA-API sees broad software support and is even used by default in applications like MPV when it’s available.

    For Nouveau and the various AMD drivers, support can be added simply by installing the mesa-va-drivers package.

    For Intel, it’s split generationally, and into free and non-free drivers. The non-free drivers are necessary to encode media while the free drivers can only decode.

    For Gen 8+ Intel hardware, the free driver can be installed with the intel-media-va-driver package. You can find the non-free driver in the intel-media-va-driver-non-free package after adding a non-free component to your apt sources.

    For older Intel hardware, the free driver can be installed with the i965-va-driver package. The non-free driver can be installed with the i965-va-driver-shaders package after adding a non-free component to your apt sources. This driver supports up to Gen 9 GPUs. If both drivers are installed, the newer driver from intel-media-va-driver is preferred over i965-va-driver (since Debian 11/Bullseye).

    Читайте также:  Свой браузер для windows phone

    Driver selection can be overridden by setting the environment variable LIBVA_DRIVER_NAME to a specific driver, e.g., LIBVA_DRIVER_NAME=i965 (to use the driver from i965-va-driver on Bullseye) or LIBVA_DRIVER_NAME=iHD (to use the driver from intel-media-va-driver on Debian 10/Buster). See EnvironmentVariables for more details on how to set this environment variable system-wide or per user.

    VDPAU

    VDPAU faces considerably more limitations compared to VA-API, but nonetheless, it’s the only option for some users. Particularly, anyone using the NVIDIA proprietary drivers. It’s not supported in any major browser except for GNOME Web but is useful for local playback. MPV is recommended for this.

    To enable VDPAU support for the AMD drivers (radeon and amdgpu), along with the open-source Nouveau driver for NVIDIA cards, install the vdpau-driver-all package.

    This will also enable VDPAU support over the OpenGL/VA-API backend for Intel GPUs. However, this has severe stability issues and may not work at all on some Intel devices. If possible, you are heavily recommended to use VA-API instead with Intel.

    To enable VDPAU support for the proprietary NVIDIA drivers, you must choose the relevant package for your driver version. If you installed the latest drivers via the nvidia-driver package, then you can simply install the nvidia-vdpau-driver package.

    NVENC/NVDEC

    NVDEC is supported by the libnvcuvid1 package.

    NVENC is supported by the libnvidia-encode1 package.

    For the legacy drivers, instead choose either the libnvidia-legacy-340xx-encode1 or libnvidia-legacy-390xx-encode1 package.

    These are only non-free runtime libraries however. Applications in Debian’s main archive, including FFmpeg and OBS Studio, are not compiled with support for NVENC or NVDEC and so the usefulness is limited to third-party binaries not supplied by Debian.

    Checking support

    You can find a full report of whether or not VA-API or VDPAU are functional, and what codecs they support, by installing the vainfo and vdpauinfo packages and running their commands. vainfo and vdpauinfo

    Application Support

    Application support for hardware acceleration varies, and each application requires individual configuration. Following are details for various applications.

    mpv has good hardware acceleration support, although it is not enabled by default. To enable it, use the –hwdec command line switch. It can also be made the default by adding a line like “ hwdec” to the mpv configuration file (e.g., $HOME/.config/mpv/mpv.conf). [ hwdec can also take various values, although ideally supplying the switch with no value should be sufficient. See the mpv manpage for more details (which recommends not to set the switch).]

    If hardware acceleration is being used, mpv’s output will contain lines like the following:

    Hardware acceleration in VLC is controlled in the GUI via “Tools → Preferences → Input / Codecs → Hardware-accelerated decoding”, or via the CLI option –avcodec-hw value [‘value’ is mandatory].

    If hardware acceleration is being used, VLC’s output will contain lines like the following:

    Browser support

    Web video is one of the most important use-cases for hardware video acceleration, as without it, sites like YouTube will cause heavy CPU usage (and therefore power consumption), a particular concern on mobile devices such as laptops and tablets.

    As of Debian 11/Bullseye, VA-API support is enabled by default in Chromium, and is available in Firefox.GNOME Web has VA-API support through the gstreamer1.0-vaapi package if installed.

    VDPAU isn’t supported at all in Chromium or Firefox. The only browser that supports it is GNOME Web, available in the epiphany-browser package. GNOME Web leverages GStreamer for this support, also requiring the gstreamer1.0-plugins-bad package for VDPAU support to work properly.

    Источник

    Оцените статью