Jellyfin Forum
How to Specify QSV Device for Transcoding in Jellyfin on TrueNAS Scale with k3s? - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: How to Specify QSV Device for Transcoding in Jellyfin on TrueNAS Scale with k3s? (/t-how-to-specify-qsv-device-for-transcoding-in-jellyfin-on-truenas-scale-with-k3s)



How to Specify QSV Device for Transcoding in Jellyfin on TrueNAS Scale with k3s? - Jade - 2024-07-19

Hello everyone,
I am running Jellyfin in a k3s environment on TrueNAS Scale and have set up two GPU devices within the container: an integrated GPU (iGPU) and an Arc A380 graphics card, both supporting QSV. These devices are recognized within the Jellyfin container as /dev/dri/renderD128 (iGPU) and /dev/dri/renderD129 (Arc A380). Currently, Jellyfin automatically selects the iGPU (renderD128) for video transcoding. I would like to configure Jellyfin to use the QSV on the Arc A380 (renderD129) instead.
Could anyone guide me on how to configure Jellyfin or the container settings to force the use of the renderD129 device for hardware-accelerated transcoding? Are there specific environment variables or settings in the configuration files that I need to adjust?
Additionally, here are the results of executing commands within the container to check the devices:

Code:
/usr/lib/jellyfin-ffmpeg/ffmpeg -v verbose -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device opencl@va

ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-opencl --enable-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-vaapi --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil 58. 2.100 / 58. 2.100
  libavcodec 60. 3.100 / 60. 3.100
  libavformat 60. 3.100 / 60. 3.100
  libavdevice 60. 1.100 / 60. 1.100
  libavfilter 9. 3.100 / 9. 3.100
  libswscale 7. 1.100 / 7. 1.100
  libswresample 4. 10.100 / 4. 10.100
  libpostproc 57. 1.100 / 57. 1.100
[AVHWDeviceContext @ 0x5564ed4e5480] libva: VA-API version 1.21.0
[AVHWDeviceContext @ 0x5564ed4e5480] libva: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so
[AVHWDeviceContext @ 0x5564ed4e5480] libva: Found init function __vaDriverInit_1_21
[AVHWDeviceContext @ 0x5564ed4e5480] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x5564ed4e5480] Initialised VAAPI connection: version 1.21
[AVHWDeviceContext @ 0x5564ed4e5480] VAAPI driver: Intel iHD driver for Intel(R) Gen Graphics - 24.2.3 (7c1c775).
[AVHWDeviceContext @ 0x5564ed4e5480] Driver not found in known nonstandard list, using standard behaviour.
[AVHWDeviceContext @ 0x5564ed517500] 1.0: Intel(R) OpenCL Graphics / Intel(R) UHD Graphics 730
[AVHWDeviceContext @ 0x5564ed517500] Intel QSV to OpenCL mapping function found (clCreateFromVA_APIMediaSurfaceINTEL).
[AVHWDeviceContext @ 0x5564ed517500] Intel QSV in OpenCL acquire function found (clEnqueueAcquireVA_APIMediaSurfacesINTEL).
[AVHWDeviceContext @ 0x5564ed517500] Intel QSV in OpenCL release function found (clEnqueueReleaseVA_APIMediaSurfacesINTEL).
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

Code:
I have no name!@jellyfin-868949cf78-ktmpn:/dev/dri$ /usr/lib/jellyfin-ffmpeg/ffmpeg -v verbose -init_hw_device vaapi=va:/dev/dri/renderD129 -init_hw_device opencl@va
ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-opencl --enable-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-vaapi --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      58.  2.100 / 58.  2.100
  libavcodec    60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter    9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample  4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
[AVHWDeviceContext @ 0x563508d7a480] libva: VA-API version 1.21.0
[AVHWDeviceContext @ 0x563508d7a480] libva: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/iHD_drv_video.so
[AVHWDeviceContext @ 0x563508d7a480] libva: Found init function __vaDriverInit_1_21
[AVHWDeviceContext @ 0x563508d7a480] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x563508d7a480] Initialised VAAPI connection: version 1.21
[AVHWDeviceContext @ 0x563508d7a480] VAAPI driver: Intel iHD driver for Intel(R) Gen Graphics - 24.2.3 (7c1c775).
[AVHWDeviceContext @ 0x563508d7a480] Driver not found in known nonstandard list, using standard behaviour.
[AVHWDeviceContext @ 0x563508dabbc0] 0.0: Intel(R) OpenCL Graphics / Intel(R) Arc(TM) A380 Graphics
[AVHWDeviceContext @ 0x563508dabbc0] Intel QSV to OpenCL mapping function found (clCreateFromVA_APIMediaSurfaceINTEL).
[AVHWDeviceContext @ 0x563508dabbc0] Intel QSV in OpenCL acquire function found (clEnqueueAcquireVA_APIMediaSurfacesINTEL).
[AVHWDeviceContext @ 0x563508dabbc0] Intel QSV in OpenCL release function found (clEnqueueReleaseVA_APIMediaSurfacesINTEL).
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Thank you for any help or guidance you can provide!


RE: How to Specify QSV Device for Transcoding in Jellyfin on TrueNAS Scale with k3s? - TheDreadPirate - 2024-07-19

How are you passing in the GPUs? Are you just passing in /dev/dri in its entirety? If so, add renderD129 to the end of the pass-through path and it will only pass that device in.


RE: How to Specify QSV Device for Transcoding in Jellyfin on TrueNAS Scale with k3s? - Jade - 2024-07-20

Thank you for your response! In TrueNAS, the Web UI currently only allows us to pass through the GPU core numbers, not the render device path.
Here's a video demonstrating the current GPU pass-through settings in the TrueNAS Web UI: https://files.catbox.moe/j0zt6g.mp4

It would be incredibly helpful if Jellyfin could add a feature in the transcoding settings to input additional FFmpeg parameters or specifically allow for the selection of the QSV device, similar to the VAAPI device input option on the transcode settings page of jellyfin webui. This would provide a perfect solution for users like me who need more precise control over which GPU is used for transcoding.

Just like this, copied from ffmpeg official document page: https://ffmpeg.org/ffmpeg.html
Code:
-init_hw_device qsv:hw,child_device=/dev/dri/renderD129



RE: How to Specify QSV Device for Transcoding in Jellyfin on TrueNAS Scale with k3s? - Efficient_Good_5784 - 2024-07-20

(2024-07-20, 12:47 AM)Jade Wrote:
(2024-07-19, 05:16 PM)TheDreadPirate Wrote: How are you passing in the GPUs?  Are you just passing in /dev/dri in its entirety?  If so, add renderD129 to the end of the pass-through path and it will only pass that device in.

Thank you for reply. But TrueNAS Web UI only allows to pass the GPU core numbers, not the render device path in the config page 😂
https://files.catbox.moe/j0zt6g.mp4
Due to how Linux works, Jellyfin cannot figure out which device is which GPU.

And as of right now, Truenas Scale's Kubernetes app implementation doesn't allow for specifying which GPU to use ONLY if you have multiple from the same brand (in your case, both the CPU and GPU are from Intel).
Your only choice right now is to either remove the GPU so you 100% know that the iGPU will be the one used, or switch the CPU to a different brand so you know the GPU will be used.

If you wait for the next major Truenas Scale update to drop later this year, the app section will be reworked to not use Kubernetes and instead use Docker and compose files. You should be able to specify which GPU device is used there.


RE: How to Specify QSV Device for Transcoding in Jellyfin on TrueNAS Scale with k3s? - TheDreadPirate - 2024-07-20

I did not know that about TrueNAS's kubernetes. If that is accurate, you would have to go into your BIOS and disable the iGPU.


RE: How to Specify QSV Device for Transcoding in Jellyfin on TrueNAS Scale with k3s? - Jade - 2024-07-20

(2024-07-20, 01:02 AM)TheDreadPirate Wrote: I did not know that about TrueNAS's kubernetes.  If that is accurate, you would have to go into your BIOS and disable the iGPU.

Thank you, disabled iGPU and transcoding works perfectly now!