Difference between revisions of "Accelerated Video Playback"

From NixOS Wiki
Jump to: navigation, search
(Fix link)
m (Changed vaapiIntel to its new package name intel-vaapi-driver. Currently vaapiIntel is aliases to intel-vaapi-driver so in the given example (before my edit) a collision would occur if vaapiIntel was attempted installed along with intel-vaapi-driver.)
Line 3: Line 3:
 
This is done by adding relevant <code>libva</code>-related packages to the <code>hardware.opengl.extraPackages</code> option.
 
This is done by adding relevant <code>libva</code>-related packages to the <code>hardware.opengl.extraPackages</code> option.
  
Additionally, the <code>vaapiIntel</code> package can be overriden to enable [https://github.com/01org/intel-hybrid-driver Intel's Hybrid Driver].
+
Additionally, the <code>intel-vaapi-driver</code> (previously <code>vaapiIntel</code>) package can be overridden to enable [https://github.com/01org/intel-hybrid-driver Intel's Hybrid Driver].
  
 
Intel users also can enable <code>intel-media-driver</code>. It can be used at runtime with <code>LIBVA_DRIVER_NAME=iHD mpv ...</code> for example, if you use Mic92's mpv settings below.
 
Intel users also can enable <code>intel-media-driver</code>. It can be used at runtime with <code>LIBVA_DRIVER_NAME=iHD mpv ...</code> for example, if you use Mic92's mpv settings below.
Line 12: Line 12:
 
   ...
 
   ...
 
   nixpkgs.config.packageOverrides = pkgs: {
 
   nixpkgs.config.packageOverrides = pkgs: {
     vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
+
     intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; };
 
   };
 
   };
 
   hardware.opengl = {
 
   hardware.opengl = {
Line 18: Line 18:
 
     extraPackages = with pkgs; [
 
     extraPackages = with pkgs; [
 
       intel-media-driver # LIBVA_DRIVER_NAME=iHD
 
       intel-media-driver # LIBVA_DRIVER_NAME=iHD
       vaapiIntel        # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
+
       intel-vaapi-driver # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
 
       vaapiVdpau
 
       vaapiVdpau
 
       libvdpau-va-gl
 
       libvdpau-va-gl
 
     ];
 
     ];
 
   };
 
   };
 +
  environment.sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; }; # Force intel-media-driver
 
   ...
 
   ...
 
}
 
}
Line 29: Line 30:
 
32 bit example:
 
32 bit example:
 
<syntaxhighlight lang="nix">
 
<syntaxhighlight lang="nix">
hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ vaapiIntel ];
+
hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ intel-vaapi-driver ];
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 22:57, 22 February 2024

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 intel-vaapi-driver (previously vaapiIntel) package can be overridden 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: {
    intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; };
  };
  hardware.opengl = {
    enable = true;
    extraPackages = with pkgs; [
      intel-media-driver # LIBVA_DRIVER_NAME=iHD
      intel-vaapi-driver # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
      vaapiVdpau
      libvdpau-va-gl
    ];
  };
  environment.sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; }; # Force intel-media-driver
  ...
}

32 bit example:

hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ intel-vaapi-driver ];

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

See Chromium.

Firefox

See Firefox#Hardware_video_acceleration (ArchWiki).

MPV

You can place the following configuration in ~/.config/mpv/mpv.conf for mpv to use hardware acceleration for VP9 on Intel Broadwell (and probably later):

hwdec=auto-safe
vo=gpu
profile=gpu-hq

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

gpu-context=wayland

This is based on the Arch Linux mpv article.

Other

See the Arch Linux wiki.