Accelerated Video Playback: Difference between revisions

From NixOS Wiki
imported>Primeos
Add the 32 bit example that I removed from https://nixos.wiki/wiki/Chromium
imported>Primeos
Add test/verification instructions
Line 35: Line 35:
Sometimes different opengl packages are required to achieve full performance. You can check different configuration repositories for similar hardware configuration:
Sometimes different opengl packages are required to achieve full performance. You can check different configuration repositories for similar hardware configuration:
* [https://github.com/NixOS/nixos-hardware The NixOS-Hardware Repository]
* [https://github.com/NixOS/nixos-hardware The NixOS-Hardware Repository]
== Testing your configuration ==
You can test your configuration by running: <code>nix-shell -p libva-utils --run vainfo</code>
See [https://wiki.archlinux.org/index.php/Hardware_video_acceleration#Verification Hardware video acceleration: Verification (Arch Wiki)] for more information.


== Applications ==
== Applications ==

Revision as of 12:41, 18 April 2020

This page is meant to help with techniques for getting accelerated video playback working in NixOS. This is generally done via libva and vaapi (and sometimes vdpau).

This is done by adding relevant libva-related packages to the hardware.opengl.extraPackages option.

Additionally, the vaapiIntel package can be overriden to enable Intel's Hybrid Driver.

Intel users also can enable intel-media-driver. It can be used at runtime with LIBVA_DRIVER_NAME=iHD mpv ... for example, if you use Mic92's mpv settings below.

Sample configuration:

{
  ...
  nixpkgs.config.packageOverrides = pkgs: {
    vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
  };
  hardware.opengl = {
    enable = true;
    extraPackages = with pkgs; [
      vaapiIntel
      vaapiVdpau
      libvdpau-va-gl
      intel-media-driver # only available starting nixos-19.03 or the current nixos-unstable
    ];
  };
  ...
}

32 bit example:

hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ vaapiIntel ];

Prepared Hardware configuration

Sometimes different opengl packages are required to achieve full performance. You can check different configuration repositories for similar hardware configuration:

Testing your configuration

You can test your configuration by running: nix-shell -p libva-utils --run vainfo

See Hardware video acceleration: Verification (Arch Wiki) for more information.

Applications

Chromium

Chromium builds from nixpkgs now support vaapi by default. It can be disabled via a flag in about:config. (see: https://github.com/NixOS/nixpkgs/pull/57837 and https://github.com/NixOS/nixpkgs/commit/60e2d2ce2bd8c36c6e6f5152bea2d78ebab58f8b)

MPV

@Mic92 needed the following configuration in ~/.mpv/config for mpv to use hardware acceleration for VP9 on Intel Broadwell:

hwdec=vaapi
vo=gpu
hwdec-codecs=all

With Wayland, you need to nudge mpv to do the right thing:

gpu-context=wayland

This is based on the archlinux MPV article.

Other

See the Arch Linux wiki.