[home-manager on Non-NixOS] How can I install ffmpeg with NVIDIA GPU Hardware Acceleration support?

I am on Debian 11 and use home-manager.

I am trying to get ffmpeg with NVIDIA GPU Hardware Acceleration support on my system. I see two packages ffmpeg_5-full and arcanPackages.ffmpeg but both of them have this line:

Not packaged:
aacplus avisynth cdio-paranoia crystalhd libavc1394 libiec61883
libnut libquvi nvenc oss shine twolame
utvideo vo-aacenc vo-amrwbenc xvmc zvbi blackmagic-design-desktop-video

Can I do something so nvenc is indeed packaged?

You can package it :smiley: bad jokes aside. Even with it packaged you probably need nixGL, too.

1 Like

The comment is outdated. nvenc is in fact enabled in ffmpeg-full on Linux amd64:

I can’t say I’ve tried it with non-NixOS though.

Yep, ffmpeg-full has the required support and it’s working on a non-NixOS setup:

❯ ffmpeg -codecs | grep h264

DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_qsv libopenh264 **h264_cuvid** ) (encoders: libx264 libx264rgb libopenh264 h264_nvenc h264_qsv h264_v4l2m2m h264_vaapi nvenc **nvenc_h264** )

Can I ask you how you found this package? When I search in https://search.nixos.org/packages for “ffmpeg full” that package is not listed.

I plan to be pretty proficient with NixOS and am starting small with Nix Package manager because some day when I am comfortable I will full switch to it. :slight_smile:

Yes, nixGL is needed. The default installation doesn’t seem to install the proprietary drivers so I specifically went for nixgl.auto.nixGLNvidia.

ffmpeg-full is arcan.ffmpeg. It’s fortunate that the search page lists it that way, seems to be a result of arcan re-exporting it’s dependencies and being defined as arcanPackages = recurseIntoAttrs (callPackage ../desktops/arcan { });.

ffmpeg_5-full is the same derivation, just overriden to use v5 source code, rather than v4. So feel free to use that, it should work the same for your use-case.

1 Like

So how do i enable this in my configuration.nix?

nixgl.auto.enable = true;
nixgl.auto.nixGLNvidia = true;

i only have:

 services.xserver.videoDrivers = [ "nvidia" ];
  hardware.opengl.enable = true;
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
  hardware.nvidia.modesetting.enable = true;

But I’d like to see a lot more acceleration in all areas: chrome, FF, and overall performance.

Any suggestions?

PS:
i have this in my harware-acceleration.nix and commented out nvidia-x11 as none of it worked:

in configuration.nix:

{ config, pkgs, lib, ... }:

let scriptPath = "/etc/nixos/scripts/test.sh";
in {
  imports = [

    ./hardware/hardware-configuration.nix
    ./hardware/hardware-acceleration.nix
    ./pkgs/system-packages.nix
    ./network/system-networking.nix
    ./nix/system-nix-settings.nix
    ./printer/system-scanner-printer-settings.nix

  ];

in harware-acceleration.nix:

{ config, pkgs, ... }:

let nixpkgs = import <nixpkgs> { };
in {
  nixpkgs.config.packageOverrides = pkgs: {
    vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
    # nvidia_x11 = pkgs.nvidia_x11.override { enableGeforce1030 = true; };
  };
  hardware.opengl = {
    enable = true;
    extraPackages = with pkgs; [
      intel-media-driver  # LIBVA_DRIVER_NAME=iHD
      vaapiIntel          # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
      vaapiVdpau
      libvdpau-va-gl
      # nvidia_x11        # Nvidia X11 driver for GT1030
    ];
  };
}