Jump to content

Jellyfin: Difference between revisions

From NixOS Wiki
Normalcea (talk | contribs)
VAAPI and Intel QSV: Add legacy intel compute runtime package for <12gen intel cpus with relevant issue tracker page.
Add a section on setting up Jellyfin with VAAPI in a NixOS container
 
(12 intermediate revisions by 8 users not shown)
Line 1: Line 1:
Jellyfin is the volunteer-built media solution that puts you in control of your media. Stream to any device from your own server, with no strings attached.
[https://jellyfin.org/ Jellyfin] is an open source media server (Jellyfin Server) with several clients (Jellyfin Media Player and web client).


== Installation and configuration ==
== Installation and configuration ==
Line 54: Line 54:
</syntaxhighlight>
</syntaxhighlight>


If you have changed the user option after you have already installed Jellyfin, you have to change the ownership of the folder /var/lib/jellyfin to the user you set it to by doing this:
If you have changed the user option after you have already installed Jellyfin, you have to change the ownership of the folder `/var/lib/jellyfin` to the user you set it to by doing this:
<syntaxhighlight lang="nix">
 
   sudo chown -R /var/lib/jellyfin  
<syntaxhighlight lang="bash">
   sudo chown -R yourusername:yourusername /var/lib/jellyfin
</syntaxhighlight>
 
Additionally, you should also change the ownership of the cache directory to avoid transcoding issues:
 
<syntaxhighlight lang="bash">
  sudo chown -R yourusername:yourusername /var/cache/jellyfin
</syntaxhighlight>
 
Finally, restart Jellyfin for the changes to take effect:
 
<syntaxhighlight lang="bash">
  systemctl restart jellyfin
</syntaxhighlight>
</syntaxhighlight>


Line 90: Line 103:
In most cases you want to make most of your hardware. Modern boards often come with a hardware accelerator, all you need to do is enable it!
In most cases you want to make most of your hardware. Modern boards often come with a hardware accelerator, all you need to do is enable it!


Source: https://jellyfin.org/docs/general/administration/hardware-acceleration.html
Source: https://jellyfin.org/docs/general/post-install/transcoding/hardware-acceleration/


=== VAAPI and Intel QSV ===
=== VAAPI and Intel QSV ===
Line 96: Line 109:
VAAPI and QSV is often available on platforms with Intel GPUs but need their corresponding packages in <code>hardware.graphics.extraPackages</code>.
VAAPI and QSV is often available on platforms with Intel GPUs but need their corresponding packages in <code>hardware.graphics.extraPackages</code>.


<syntaxhighlight lang="nix">
You have to choose between <code>intel-vaapi-driver</code> (old driver for pre-Broadwell CPUs), <code>intel-compute-runtime</code> and <code>intel-media-driver</code> depending of your CPU.
{{Note|<code>intel-media-sdk</code> is deprecated and currently (as of 2025-09-05) does not build on unstable channel. Instead of QSV use VAAPI for hardware acceleration in the jellyfin settings.<br/>Source: https://discourse.nixos.org/t/intel-media-sdk-has-become-deprecated/66998}}<syntaxhighlight lang="nix">
{ pkgs, lib,config, ... }:
{ pkgs, lib,config, ... }:
{
{
   # 1. enable vaapi on OS-level
   # Only set this if you're using intel-vaapi-driver (see below):
   nixpkgs.config.packageOverrides = pkgs: {
   nixpkgs.config.packageOverrides = pkgs: {
     vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
     intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; };
   };
   };
  systemd.services.jellyfin.environment.LIBVA_DRIVER_NAME = "iHD"; # or i965, see below
  environment.sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; }; # ditto
 
   hardware.graphics = {
   hardware.graphics = {
     enable = true;
     enable = true;
     extraPackages = with pkgs; [
     extraPackages = with pkgs; [
      intel-ocl # generic OpenCL support, for all processors
      # For newer processors (Broadwell and higher, ca. 2014), use this paired with `LIBVA_DRIVER_NAME=iHD`:
       intel-media-driver
       intel-media-driver
       intel-vaapi-driver
 
       vaapiVdpau
      # ... while for older processors, use these paired with `LIBVA_DRIVER_NAME=i965`:
       intel-compute-runtime # OpenCL filter support (hardware tonemapping and subtitle burn-in)
       intel-vaapi-driver  
       # OpenCL support for intel CPUs before 12th gen
       libva-vdpau-driver # aka vaapiVdpau
       # see: https://github.com/NixOS/nixpkgs/issues/356535
 
      # In addition, for newer processors (13th gen and higher), add this as well:
       intel-compute-runtime
        
       # ... while for older processors, add this (https://github.com/NixOS/nixpkgs/issues/356535):
       intel-compute-runtime-legacy1  
       intel-compute-runtime-legacy1  
       vpl-gpu-rt # QSV on 11th gen or newer
 
       intel-media-sdk # QSV up to 11th gen
      # In addition once more, for newer processors (11th gen or newer), add this:
       vpl-gpu-rt
 
      # ... while for older processors, add this:
       intel-media-sdk # (note it's been deprecated since NixOS 25.11 and may not build anymore nowadays)
     ];
     ];
   };
   };


   # 2. do not forget to enable jellyfin
   # Of course, do not forget to enable Jellyfin:
   services.jellyfin.enable = true;
   services.jellyfin.enable = true;
}
}
</syntaxhighlight>
</syntaxhighlight>
==== Troubleshooting VAAPI and Intel QSV ====
You can check supported vaapi profile supported by your CPU / driver with : <code>nix-shell -p libva-utils --run vainfo</code>.
You can check the OpenCL properties and devices available on the system with : <code>nix-shell -p clinfo --run clinfo</code>. If clinfo shows <code>Number of platforms 0</code> on the first line, OpenCL is not enabled or available.
The command <code>intel_gpu_top</code>, provided by the <code>intel-gpu-tools</code> package is also useful to check the status of your intel GPU: <code>nix-shell -p intel-gpu-tools --run intel_gpu_top</code>.
At least on Intel N100 CPU, you will need the option <code>hardware.enableAllFirmware = true;</code> otherwise GuC formware will not load properly. Here is the type of error you will get without it : <syntaxhighlight lang="dmesg">
[    4.174843] i915 0000:00:10.0: [drm] *ERROR* GT0: GuC firmware i915/tgl_guc_70.bin: fetch failed -ENOENT
[    4.175621] i915 0000:00:10.0: [drm] GT0: GuC firmware(s) can be downloaded from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915
[    4.176286] i915 0000:00:10.0: [drm] GT0: GuC firmware i915/tgl_guc_70.bin version 0.0.0
[    4.176350] i915 0000:00:10.0: [drm] *ERROR* GT0: GuC initialization failed -ENOENT
[    4.176977] i915 0000:00:10.0: [drm] *ERROR* GT0: Enabling uc failed (-5)
[    4.177502] i915 0000:00:10.0: [drm] *ERROR* GT0: Failed to initialize GPU, declaring it wedged!
</syntaxhighlight>
==== VAAPI and Intel QSV on Arc GPU ====


If you want to use an Arc GPU for transcoding, you may need to override the ffmpeg version used by jellyfin to ensure that it is compiled with <code>vpl</code> and, potentially, <code>unfree</code>. An example to achieve this through [[Overlays|an overlay]]:<syntaxhighlight lang="nix">
If you want to use an Arc GPU for transcoding, you may need to override the ffmpeg version used by jellyfin to ensure that it is compiled with <code>vpl</code> and, potentially, <code>unfree</code>. An example to achieve this through [[Overlays|an overlay]]:<syntaxhighlight lang="nix">
Line 148: Line 196:
Note that if your system has an integrated GPU (one built into the CPU) and a discrete GPU, you may need to select the QSV device in the "Playback" settings. Otherwise the device may be picked at random and produce random results. You can use <code>intel_gpu_top -L</code> to identify the devices.
Note that if your system has an integrated GPU (one built into the CPU) and a discrete GPU, you may need to select the QSV device in the "Playback" settings. Otherwise the device may be picked at random and produce random results. You can use <code>intel_gpu_top -L</code> to identify the devices.


Related: [[Accelerated Video Playback]] and [[Intel Graphics]]
Related: [[Accelerated Video Playback]] and [[Intel Graphics]]
 
==== VAAPI with Jellyfin in a NixOS Container ====
 
Containers don't inherit graphic drivers from their root system, so if you run Jellyfin in a NixOS container, you have to copy the <code>hardware.graphics</code> block from the main configuration into your container's configuration.
 
You have to passthrough the graphics card device as well - usually it's located under <code>/dev/dri/card0</code> and/or <code>/dev/dri/renderD128</code>:
 
<syntaxHighlight lang="nix">
{
  allowedDevices = [
    {
      node = "/dev/dri/card0";
      modifier = "rw";
    }
    {
      node = "/dev/dri/renderD128";
      modifier = "rw";
    }
  ];
 
  bindMounts = {
    "/dev/dri/card0" = {
      hostPath = "/dev/dri/card0";
      isReadOnly = false;
    };
 
    "/dev/dri/renderD128" = {
      hostPath = "/dev/dri/renderD128";
      isReadOnly = false;
    };
  };
 
  config =
  # ... your container's configuration, including the hardware.graphics part!
}
</syntaxHighlight>
 
You can check if you got the configuration correct by adding <code>libva-utils</code> to the container's <code>environment.systemPackages</code>, logging into the container (<code>machinectl shell container-name</code>), and running <code>vainfo</code> - if you got everything right, you should see something akin to:
 
<syntaxHighlight>
Trying display: drm                                                                                                                                                                             
libva info: VA-API version 1.22.0                                                                                                                                                               
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so                                                                                                                           
libva info: Found init function __vaDriverInit_1_22                                                                                                                                             
libva info: va_openDriver() returns 0                                                                                                                                                           
vainfo: VA-API version: 1.22 (libva 2.22.0)                                                                                                                                                     
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 25.2.6 ()                                                                                                                   
vainfo: Supported profile and entrypoints                                                                                                                                                       
      VAProfileNone                  : VAEntrypointVideoProc                                                                                                                                   
      VAProfileNone                  : VAEntrypointStats     
      /* and many more, the list depends on your specific hardware */                                                                                                                                 
</syntaxHighlight>
 
With that, ffmpeg (and thus Jellyfin) should be able to use hardware transcoding.


[[Category:Server]]
[[Category:Server]]
[[Category:Applications]]
[[Category:Applications]]
[[Category:Web Applications]]

Latest revision as of 21:34, 17 September 2025

Jellyfin is an open source media server (Jellyfin Server) with several clients (Jellyfin Media Player and web client).

Installation and configuration

To get up and running with Jellyfin, add the packages pkgs.jellyfin pkgs.jellyfin-web & pkgs.jellyfin-ffmpeg to your `configuration.nix` file as shown below.

{
  services.jellyfin.enable = true;
  environment.systemPackages = [
    pkgs.jellyfin
    pkgs.jellyfin-web
    pkgs.jellyfin-ffmpeg
  ];
}

If you want more advanced configuration, use something like what's shown below and see the docs for more configuration options

{
  services.jellyfin = {
    enable = true;
    openFirewall = true;
  };
}

Once you have included the packages to be installed, and enabled and configured Jellyfin to your liking, then rebuild your system for changes to take effect.

$ sudo nixos-rebuild switch

After the rebuild is complete, Jellyfin should be running. Verify that it is with the following command.

$ sudo systemctl status jellyfin

If jellyfin is not running you should be able to start it by running jellyfin in your terminal.

$ jellyfin

After you've verified that Jellyfin is running you can start the configuration process.

  • The Jellyfin server should be running on port 8096.
  • Go to http://localhost:8096 if you are setting this up on your primary computer or want to test your build locally.
  • If you're logging into a remote server, replace localhost with the ip address of the server.

Allow Jellyfin to read external drives

You might encounter permission issues when you try to access external drives if you haven't configured anything else with the server yet. If you haven't explicitly set up a mounting configuration for your drives and instead let your desktop environment (e.g. GNOME or KDE) automatically mount it when you try accessing it via their file explorers, Jellyfin won't be able to access the drive. This is because the desktop environment mounts it to your user, while Jellyfin runs by default as the "jellyfin" user.

The easiest way to allow it to see these external drives is to change the service's user . Here is an example:

  services.jellyfin = {
    enable = true;
    openFirewall = true;
    user="yourusername";
  };

If you have changed the user option after you have already installed Jellyfin, you have to change the ownership of the folder `/var/lib/jellyfin` to the user you set it to by doing this:

  sudo chown -R yourusername:yourusername /var/lib/jellyfin

Additionally, you should also change the ownership of the cache directory to avoid transcoding issues:

  sudo chown -R yourusername:yourusername /var/cache/jellyfin

Finally, restart Jellyfin for the changes to take effect:

  systemctl restart jellyfin

The alternative is to explicitly mount the drives via Filesystems. This takes more effort to set up and requires every new drive to be explicitly declared, but allows more control in what Jellyfin is allowed to see.

Intro Skipper plugin

If you install the Intro Skipper plugin, it will not be able to display the skip button in the web interface. This is due to the plugin being unable to modify contents of files in the nix store. To get around this you can make the changes yourself with this:

  nixpkgs.overlays = with pkgs; [
    (
      final: prev:
        {
          jellyfin-web = prev.jellyfin-web.overrideAttrs (finalAttrs: previousAttrs: {
            installPhase = ''
              runHook preInstall

              # this is the important line
              sed -i "s#</head>#<script src=\"configurationpage?name=skip-intro-button.js\"></script></head>#" dist/index.html

              mkdir -p $out/share
              cp -a dist $out/share/jellyfin-web

              runHook postInstall
            '';
          });
        }
    )
  ];

Hardware transcoding

In most cases you want to make most of your hardware. Modern boards often come with a hardware accelerator, all you need to do is enable it!

Source: https://jellyfin.org/docs/general/post-install/transcoding/hardware-acceleration/

VAAPI and Intel QSV

VAAPI and QSV is often available on platforms with Intel GPUs but need their corresponding packages in hardware.graphics.extraPackages.

You have to choose between intel-vaapi-driver (old driver for pre-Broadwell CPUs), intel-compute-runtime and intel-media-driver depending of your CPU.

Note: intel-media-sdk is deprecated and currently (as of 2025-09-05) does not build on unstable channel. Instead of QSV use VAAPI for hardware acceleration in the jellyfin settings.
Source: https://discourse.nixos.org/t/intel-media-sdk-has-become-deprecated/66998
{ pkgs, lib,config, ... }:
{
  # Only set this if you're using intel-vaapi-driver (see below):
  nixpkgs.config.packageOverrides = pkgs: {  
    intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; };
  };

  systemd.services.jellyfin.environment.LIBVA_DRIVER_NAME = "iHD"; # or i965, see below
  environment.sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; }; # ditto
  
  hardware.graphics = {
    enable = true;

    extraPackages = with pkgs; [
      intel-ocl # generic OpenCL support, for all processors

      # For newer processors (Broadwell and higher, ca. 2014), use this paired with `LIBVA_DRIVER_NAME=iHD`:
      intel-media-driver

      # ... while for older processors, use these paired with `LIBVA_DRIVER_NAME=i965`:
      intel-vaapi-driver 
      libva-vdpau-driver # aka vaapiVdpau

      # In addition, for newer processors (13th gen and higher), add this as well:
      intel-compute-runtime
      
      #  ... while for older processors, add this (https://github.com/NixOS/nixpkgs/issues/356535):
      intel-compute-runtime-legacy1 

      # In addition once more, for newer processors (11th gen or newer), add this:
      vpl-gpu-rt

      # ... while for older processors, add this:
      intel-media-sdk # (note it's been deprecated since NixOS 25.11 and may not build anymore nowadays)
    ];
  };

  # Of course, do not forget to enable Jellyfin:
  services.jellyfin.enable = true;
}

Troubleshooting VAAPI and Intel QSV

You can check supported vaapi profile supported by your CPU / driver with : nix-shell -p libva-utils --run vainfo.

You can check the OpenCL properties and devices available on the system with : nix-shell -p clinfo --run clinfo. If clinfo shows Number of platforms 0 on the first line, OpenCL is not enabled or available.

The command intel_gpu_top, provided by the intel-gpu-tools package is also useful to check the status of your intel GPU: nix-shell -p intel-gpu-tools --run intel_gpu_top.

At least on Intel N100 CPU, you will need the option hardware.enableAllFirmware = true; otherwise GuC formware will not load properly. Here is the type of error you will get without it :

[    4.174843] i915 0000:00:10.0: [drm] *ERROR* GT0: GuC firmware i915/tgl_guc_70.bin: fetch failed -ENOENT
[    4.175621] i915 0000:00:10.0: [drm] GT0: GuC firmware(s) can be downloaded from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915
[    4.176286] i915 0000:00:10.0: [drm] GT0: GuC firmware i915/tgl_guc_70.bin version 0.0.0
[    4.176350] i915 0000:00:10.0: [drm] *ERROR* GT0: GuC initialization failed -ENOENT
[    4.176977] i915 0000:00:10.0: [drm] *ERROR* GT0: Enabling uc failed (-5)
[    4.177502] i915 0000:00:10.0: [drm] *ERROR* GT0: Failed to initialize GPU, declaring it wedged!

VAAPI and Intel QSV on Arc GPU

If you want to use an Arc GPU for transcoding, you may need to override the ffmpeg version used by jellyfin to ensure that it is compiled with vpl and, potentially, unfree. An example to achieve this through an overlay:

{ pkgs, ... }:
let
  jellyfin-ffmpeg-overlay = (
    _ prev: {
      jellyfin-ffmpeg = prev.jellyfin-ffmpeg.override {
        # Exact version of ffmpeg_* depends on what jellyfin-ffmpeg package is using.
        # In 24.11 it's ffmpeg_7-full.
        # See jellyfin-ffmpeg package source for details
        ffmpeg_7-full = prev.ffmpeg_7-full.override {
          withMfx = false; # This corresponds to the older media driver
          withVpl = true; # This is the new driver
          withUnfree = true;
        };
      };
    }
  );
in
{
  nixpkgs.overlays = [ jellyfin-ffmpeg-overlay ];
}

This will trigger a rebuild of Jellyfin package, but the end result is that if you select "Intel QuickSync (QSV)" you should see little to no CPU load when transcoding.

Note that if your system has an integrated GPU (one built into the CPU) and a discrete GPU, you may need to select the QSV device in the "Playback" settings. Otherwise the device may be picked at random and produce random results. You can use intel_gpu_top -L to identify the devices.

Related: Accelerated Video Playback and Intel Graphics

VAAPI with Jellyfin in a NixOS Container

Containers don't inherit graphic drivers from their root system, so if you run Jellyfin in a NixOS container, you have to copy the hardware.graphics block from the main configuration into your container's configuration.

You have to passthrough the graphics card device as well - usually it's located under /dev/dri/card0 and/or /dev/dri/renderD128:

{
  allowedDevices = [
    {
      node = "/dev/dri/card0";
      modifier = "rw";
    }
    {
      node = "/dev/dri/renderD128";
      modifier = "rw";
    }
  ];

  bindMounts = {
    "/dev/dri/card0" = {
      hostPath = "/dev/dri/card0";
      isReadOnly = false;
    };

    "/dev/dri/renderD128" = {
      hostPath = "/dev/dri/renderD128";
      isReadOnly = false;
    };
  };

  config =
  # ... your container's configuration, including the hardware.graphics part!
}

You can check if you got the configuration correct by adding libva-utils to the container's environment.systemPackages, logging into the container (machinectl shell container-name), and running vainfo - if you got everything right, you should see something akin to:

Trying display: drm                                                                                                                                                                               
libva info: VA-API version 1.22.0                                                                                                                                                                 
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so                                                                                                                            
libva info: Found init function __vaDriverInit_1_22                                                                                                                                               
libva info: va_openDriver() returns 0                                                                                                                                                             
vainfo: VA-API version: 1.22 (libva 2.22.0)                                                                                                                                                       
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 25.2.6 ()                                                                                                                    
vainfo: Supported profile and entrypoints                                                                                                                                                         
      VAProfileNone                   : VAEntrypointVideoProc                                                                                                                                     
      VAProfileNone                   : VAEntrypointStats       
      /* and many more, the list depends on your specific hardware */

With that, ffmpeg (and thus Jellyfin) should be able to use hardware transcoding.