jellyfin / jellyfin

The Free Software Media System
https://jellyfin.org
GNU General Public License v2.0
30.58k stars 2.83k forks source link

[Issue]: EncodingHelper: avoid hardcoding `i915` as driver name in `GetQsvDeviceArgs` #11485

Closed Harry-Chen closed 2 weeks ago

Harry-Chen commented 2 weeks ago

Please describe your bug

In GetQsvDeviceArgs in EncodingHelper.cs, the parameters of invoking GetVaapiDeviceArgs are hardcoded:

https://github.com/jellyfin/jellyfin/blob/169698619dfe2989d0562b9723d0a01cfa02b9ba/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs#L892

This leads to the following ffmpeg cmdline when using QSV: ffmpeg -init_hw_device vaapi=va:,kernel_driver=i915,driver=iHD -init_hw_device qsv=qs@va.

However, with the new Intel drm driver xe, auto-detection no longer works:

[AVHWDeviceContext @ 0x57d6a1110a40] Cannot open DRM render node for device 0.
[AVHWDeviceContext @ 0x57d6a1110a40] Ignoring device 1 with non-matching kernel driver (xe).
[AVHWDeviceContext @ 0x57d6a1110a40] Cannot open DRM render node for device 2.
[AVHWDeviceContext @ 0x57d6a1110a40] Cannot open DRM render node for device 3.
[AVHWDeviceContext @ 0x57d6a1110a40] Cannot open DRM render node for device 4.
[AVHWDeviceContext @ 0x57d6a1110a40] Cannot open DRM render node for device 5.
[AVHWDeviceContext @ 0x57d6a1110a40] Cannot open DRM render node for device 6.
[AVHWDeviceContext @ 0x57d6a1110a40] Cannot open DRM render node for device 7.
[AVHWDeviceContext @ 0x57d6a1110a40] No VA display found for any default device.
Device creation failed: -22.
Failed to set value 'vaapi=va:,kernel_driver=i915,driver=iHD' for option 'init_hw_device': Invalid argument
Error parsing global options: Invalid argument

I suggest allowing the user to specify the render device when QSV is enabled (just as with VAAPI), or simply remove the kernel_driver=i915 which can work with both i915 and xe.

Reproduction Steps

Run any transcode with an Intel GPU supported by xe DRM driver and enable QSV transcode.

Jellyfin Version

10.8.13

if other:

No response

Environment

- OS: Debian 12
- Linux Kernel: 6.8.9
- FFmpeg Version: 6.0.1-Jellyfin
- Playback Method: Transcode
- Hardware Acceleration: QSV
- GPU Model: Intel DG1

Jellyfin logs

N/A. FFmpeg fails to run.

FFmpeg logs

See issue description.

Please attach any browser or client logs here

No response

Please attach any screenshots here

No response

Code of Conduct

jellyfin-bot commented 2 weeks ago

Hi, it seems like your issue report has the following item(s) that need to be addressed:

This is an automated message, currently under testing. Please file an issue here if you encounter any problems.

gnattu commented 2 weeks ago

i915 is required because the experimental xe driver does not implement all features used by Jellyfin: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/234

You may also facing other user space runtime lib compatibility issues from intel oneVPL library which jellyfin uses for certain video processing filters if you are not using i915

Harry-Chen commented 2 weeks ago

i915 is required because the experimental xe driver does not implement all features used by Jellyfin: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/234

Yes, currently i915 works well on most scenarios and devices. But xe works better on some hardware (like my DG1 on latest kernel). It will eventually become mature and come into production. Thus I believe an timely fix is good for potential users.

As another point, no matter what driver they are using, users should also be able to specify the device with QSV enabled, in case they have multiple GPUs to choose from.

You may also facing other user space runtime lib compatibility issues from intel oneVPL library which jellyfin uses for certain video processing filters if you are not using i915

Still, I'm not saying about abandoning i915, but allowing xe to be an option.

felix920506 commented 2 weeks ago

As suggested above Xe isn't feature complete enough for Jellyfin and supporting it would put more burden on the Jellyfin team.

As another point, no matter what driver they are using, users should also be able to specify the device with QSV enabled, in case they have multiple GPUs to choose from.

You cannot chose which QSV device you want to use with ffmpeg, that's just how it is and there is nothing we can do about it.

Harry-Chen commented 2 weeks ago

You cannot chose which QSV device you want to use with ffmpeg, that's just how it is and there is nothing we can do about it.

I don't think so. Per my observation, when using qsv=@va, the QSV device is the previously selected VAAPI device.

For this specific case, all of the following options can work with xe, but the command that Jellyfin currently generates (-init_hw_device vaapi=va:,kernel_driver=i915,driver=iHD -init_hw_device qsv=qs@va) doesn't.

Again, I am not seeking any additional support for xe at the moment. But device selection for QSV is not "how it is and there is nothing we can do about it”.

nyanmisaka commented 2 weeks ago

We will reconsider this after several Linux kernel version iterations, and after both media-driver and VPL runtime declared non-experimental support for Xe KMD in the release docs.

For the time being, Xe KMD is still guarded by the xe.force_probe kernel parameter, and the QSV hwcontext in FFmpeg is still hardcoded to be supported only by i915 KMD. So I wouldn't jump in until Intel devs decide to officially use them.