Hardware video decoding in jellyfin

Discussion of applications not mentioned above.
User avatar
outkastm
Posts: 1185
Joined: 29 Dec 2020, 23:52

Re: Hardware video decoding in jellyfin

Post by outkastm »

Not possible yet for the new jasper lake (F4-423), some investigations are on going. Can be that the kernel need some parameters to be adapted as the Low-Power encoding cannot be enabled
User avatar
sanctimon
Posts: 98
Joined: 14 Nov 2021, 06:57

Re: Hardware video decoding in jellyfin

Post by sanctimon »

Is hardware acceleration possible in TOS 5.1 for F5-221? If so, which group manages the render?
User avatar
TMroy
TerraMaster Team
Posts: 2578
Joined: 10 Mar 2020, 14:04
China

Re: Hardware video decoding in jellyfin

Post by TMroy »

Since Intel has launched a new version of the media driver, Intel will no longer officially maintain the old version of the driver, but will instead maintain the new version. TOS 5.1 adopts the latest media driver officially recommended by Intel. For details, please refer to: https://github.com/intel/media-driver

The new version of the driver is based on the user-mode VA-API. The usage of the new version of the driver is somewhat different from that of the old version. If you need to use hardware acceleration in TOS 5.1, please refer to Intel's official documentation.
To contact our team, please send email to following addresses, remember to replace (at) with @:
Support team: support(at)terra-master.com (for technical support only)
Service team: service(at)terra-master.com (for purchasing, return, replacement, RMA service)
User avatar
crisisacting
Posts: 257
Joined: 20 Jan 2022, 16:42

Re: Hardware video decoding in jellyfin

Post by crisisacting »

{L_BUTTON_AT}TMroy

Which build is enabled by default on TOS 5.1 for the Intel Media Driver: Full Feature or Free Kernel?

If the latter, can Terra-Master not implement a toggle in the System Control Panel (under its own Video section) to switch between the two builds (with a reboot if required) to simplify this for most users?
User avatar
outkastm
Posts: 1185
Joined: 29 Dec 2020, 23:52

Re: Hardware video decoding in jellyfin

Post by outkastm »

TMroy wrote: 24 Mar 2023, 12:59 Since Intel has launched a new version of the media driver, Intel will no longer officially maintain the old version of the driver, but will instead maintain the new version. TOS 5.1 adopts the latest media driver officially recommended by Intel. For details, please refer to: https://github.com/intel/media-driver

The new version of the driver is based on the user-mode VA-API. The usage of the new version of the driver is somewhat different from that of the old version. If you need to use hardware acceleration in TOS 5.1, please refer to Intel's official documentation.
GUC is not enabled for the Jasperlake CPU in TOS 5.1.
Based on all the info found, this must be enabled and the firmware for GUC and HUC to be loaded.
Without this, the LP encoding mode cannot be activated which is mandatory for this CPU.
Withot this, even when using the latest intel media driver 26.6.6 the hardware transcoding is not working.

Code: Select all

LP Mode Hardware Support
NOTE
Gen X refers to Intel graphics architechure instead of the CPU generation. (i.e. Gen 9 graphics ≠ 9th Gen processors)

Gen 9.x SKL+ graphics - Support non-LP and LP (H.264 only) encoding.

Gen 11 ICL graphics - Support both two encoding modes.

Gen 11 JSL/EHL graphics - Only support LP encoding mode.

Gen 12 TGL/DG1+ graphics - Support both two encodng modes.

Gen 12.5 DG2/ARC A-Series - Only support LP encoding mode.

Gen 12.7 MTL and newer - To be announced.

Code: Select all

Intel Gen 11 Jasper Lake and Elkhart Lake platforms (e.g. N5095, N5105, N6005, J6412) have quirks when using video encoders on Linux. The Low-Power Encoding mode MUST be configured and enabled for correct VBR and CBR bitrate control that is required by Jellyfin.

Ticket: https://gitlab.freedesktop.org/drm/intel/-/issues/8080
The default kernel 5.15 that comes with Ubuntu 22.04 LTS has a regression on Intel Gen 11 graphics (ICL, JSL and EHL) that prevent you from using the Low-Power encoding mode. Linux 5.16+ is not affected.

Ticket: https://gitlab.freedesktop.org/drm/intel/-/issues/4067

Fixed by: drm/i915/gen11: Moving WAs to icl_gt_workarounds_init()

Code: Select all

[user@TNAS-xxxx ~]# dmesg | grep i915
[    0.000000] Command line: BOOT_IMAGE=/boot/bzImage type=raid hpet=disable i915.enable_guc=2
[    0.080333] Kernel command line: BOOT_IMAGE=/boot/bzImage type=raid hpet=disable i915.enable_guc=2
[    0.080365] Setting dangerous option i915.enable_guc - tainting kernel
[    0.701124] i915 0000:00:02.0: vgaarb: deactivate vga console
[    0.702369] i915 0000:00:02.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=io+mem
[    0.868993] i915 0000:00:02.0: Direct firmware load for i915/icl_dmc_ver1_09.bin failed with error -2
[    0.869004] i915 0000:00:02.0: [drm] Failed to load DMC firmware i915/icl_dmc_ver1_09.bin. Disabling runtime power management.
[    0.869007] i915 0000:00:02.0: [drm] DMC firmware homepage: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915
[    0.869017] i915 0000:00:02.0: Direct firmware load for i915/ehl_guc_62.0.0.bin failed with error -2
[    0.869020] i915 0000:00:02.0: [drm] GuC firmware i915/ehl_guc_62.0.0.bin: fetch failed with error -2
[    0.869023] i915 0000:00:02.0: [drm] GuC firmware(s) can be downloaded from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915
[    0.869628] i915 0000:00:02.0: [drm] GuC is uninitialized
[    0.871095] [drm] Initialized i915 1.6.0 20201103 for 0000:00:02.0 on minor 0
[    0.917735] i915 0000:00:02.0: [drm] Cannot find any crtc or sizes
[    0.958442] i915 0000:00:02.0: [drm] Cannot find any crtc or sizes
[    0.998941] i915 0000:00:02.0: [drm] Cannot find any crtc or sizes
User avatar
TMroy
TerraMaster Team
Posts: 2578
Joined: 10 Mar 2020, 14:04
China

Re: Hardware video decoding in jellyfin

Post by TMroy »

According to our engineers, it may be due to the 5.15 kernel limitation, and HUC failed to be enabled. Need to try again on the new kernel in the future.
To contact our team, please send email to following addresses, remember to replace (at) with @:
Support team: support(at)terra-master.com (for technical support only)
Service team: service(at)terra-master.com (for purchasing, return, replacement, RMA service)
User avatar
outkastm
Posts: 1185
Joined: 29 Dec 2020, 23:52

Re: Hardware video decoding in jellyfin

Post by outkastm »

{L_BUTTON_AT}TMroy

Any idea when the new kernel will be available? I'm stucked with this NAS without hardware transcoding for almost a year since I buy it on July 2022. It is advertised as hardware transcoding capable device.
User avatar
Supr4
Posts: 16
Joined: 26 Nov 2022, 01:17

Re: Hardware video decoding in jellyfin

Post by Supr4 »

{L_BUTTON_AT}outkastm
I'm on the same boat. Please Terramaster take into consideration, this is not really 4k transcoding capable.
User avatar
outkastm
Posts: 1185
Joined: 29 Dec 2020, 23:52

Re: Hardware video decoding in jellyfin

Post by outkastm »

Finally the 5.1.33 update fixed the hardware transcoding for the new series 223/423 with JasperLake

Firmware for GUC and HUC are now loaded into the kernel

Code: Select all

    0.000000] Command line: BOOT_IMAGE=/boot/bzImage type=raid hpet=disable i915.enable_guc=2
[    0.079488] Kernel command line: BOOT_IMAGE=/boot/bzImage type=raid hpet=disable i915.enable_guc=2
[  286.391988] i915 0000:00:02.0: vgaarb: deactivate vga console
[  286.394600] i915 0000:00:02.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=io+mem
[  286.395851] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/icl_dmc_ver1_09.bin (v1.9)
[  286.530613] i915 0000:00:02.0: [drm] GuC firmware i915/ehl_guc_62.0.0.bin version 62.0 submission:disabled
[  286.530627] i915 0000:00:02.0: [drm] GuC SLPC: disabled
[  286.530630] i915 0000:00:02.0: [drm] HuC firmware i915/ehl_huc_9.0.0.bin version 9.0 authenticated:yes
[  286.532447] [drm] Initialized i915 1.6.0 20201103 for 0000:00:02.0 on minor 0
[  286.574482] i915 0000:00:02.0: [drm] Cannot find any crtc or sizes
[  286.615439] i915 0000:00:02.0: [drm] Cannot find any crtc or sizes
[  286.654275] i915 0000:00:02.0: [drm] Cannot find any crtc or sizes
Running Jellyfin with hw transcoding, CPU load is less that 1%

Image
User avatar
Supr4
Posts: 16
Joined: 26 Nov 2022, 01:17

Re: Hardware video decoding in jellyfin

Post by Supr4 »

{L_BUTTON_AT}outkastm
Can you tell me how you made it to work? I've updated to 5.1.33, jellyfin no longer says its not supported, but it doesn't play either... If i call ffmpeg directly on cmd, it seems to work just fine. I have Intel QuickSync QSV enabled for hardware acceleration, Hardware encoding enabled and low power h264 and Hevc hardware ecoding enabled. Prefer OS native DXVA or VA-API hardware decoders enabled. I'm running it on a container an on the logs i see "Transcoding kill timer stopped for JobId 4f5368e8e8c54684ab213726de8bb2fa PlaySessionId 4ff234a2389244aa99d121e26176fffc. Killing transcoding":

Code: Select all

[12:15:33] [INF] [103] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for admin. EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True


[12:15:33] [INF] [103] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile=Anonymous Profile, Path=/movies/The Lord of the Rings The Return of the King (2003)/The.Lord.of.the.Rings.The.Return.of.the.King.2003.EXTENDED.PROPER.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.TrueHD.7.1.Atmos-FGT.mkv, AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=Transcode, TranscodeReason=VideoCodecNotSupported, AudioCodecNotSupported ) media:/videos/7e9713d2-c98b-79c2-37cd-2e87c50872b5/stream.mp4?MediaSourceId=7e9713d2c98b79c237cd2e87c50872b5&VideoCodec=h264,hevc,vp9,av1,hevc&AudioCodec=aac,mp3,opus,flac,vorbis&AudioStreamIndex=2&VideoBitrate=139616000&AudioBitrate=384000&MaxFramerate=23.976025&api_key=<token>&TranscodingMaxAudioChannels=2&RequireAvc=false&Tag=b41b2e75160ec295178e457a7fc2a505&hevc-level=153&hevc-videobitdepth=10&hevc-profile=main10&h264-profile=high,main,baseline,constrainedbaseline,high10&h264-rangetype=SDR&h264-level=52&h264-deinterlace=true&hevc-rangetype=SDR&hevc-deinterlace=true&vp9-rangetype=SDR,HDR10,HLG&av1-rangetype=SDR,HDR10,HLG&TranscodeReasons=VideoCodecNotSupported,%20AudioCodecNotSupported




3] [INF] [95] Jellyfin.Api.Helpers.TranscodingJobHelper: /usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -init_hw_device vaapi=va:,driver=iHD,kernel_driver=i915 -init_hw_device qsv=qs@va -filter_hw_device qs -hwaccel vaapi -hwaccel_output_format vaapi -autorotate 0 -i file:"/movies/The Lord of the Rings The Return of the King (2003)/The.Lord.of.the.Rings.The.Return.of.the.King.2003.EXTENDED.PROPER.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.TrueHD.7.1.Atmos-FGT.mkv" -autoscale 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_qsv -force_key_frames "expr:gte(t,n_forced*5)" -vf "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_vaapi=format=nv12,hwmap=derive_device=qsv,format=qsv" -low_power 1 -preset 7 -look_ahead 0 -b:v 139616000 -maxrate 139616000 -bufsize 279232000 -profile:v:0 high -level 51 -map_metadata -1 -map_chapters -1 -threads 0 -codec:a:0 libfdk_aac -ac 2 -ab 384000 -af "volume=2" -f mp4 -movflags frag_keyframe+empty_moov -y "/config/data/transcodes/4249117699b9dc48324a17184f7b914c.mp4"


[12:15:40] [WRN] [86] Jellyfin.Server.Middleware.ResponseTimeMiddleware: Slow HTTP Response from http://192.168.1.100:8096/jellyfin/videos/7e9713d2-c98b-79c2-37cd-2e87c50872b5/stream.mp4?DeviceId=TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzEwOC4wLjAuMCBTYWZhcmkvNTM3LjM2fDE2NzExNDI3NDY1NDI1&MediaSourceId=7e9713d2c98b79c237cd2e87c50872b5&VideoCodec=h264,hevc,vp9,av1,hevc&AudioCodec=aac,mp3,opus,flac,vorbis&AudioStreamIndex=2&VideoBitrate=139616000&AudioBitrate=384000&MaxFramerate=23.976025&PlaySessionId=68d6e63168b840c1b1f99d774d6814ce&api_key=cfe690addc0d4d329dc3e6bd0fc0060d&TranscodingMaxAudioChannels=2&RequireAvc=false&Tag=b41b2e75160ec295178e457a7fc2a505&hevc-level=153&hevc-videobitdepth=10&hevc-profile=main10&h264-profile=high,main,baseline,constrainedbaseline,high10&h264-rangetype=SDR&h264-level=52&h264-deinterlace=true&hevc-rangetype=SDR&hevc-deinterlace=true&vp9-rangetype=SDR,HDR10,HLG&av1-rangetype=SDR,HDR10,HLG&TranscodeReasons=VideoCodecNotSupported,%20AudioCodecNotSupported to 192.168.1.172 in 0:00:06.8790097 with Status Code 200


[12:15:56] [INF] [86] Jellyfin.Api.Helpers.TranscodingJobHelper: Transcoding kill timer stopped for JobId f2a32869d39a40eb9a40125ffd915a30 PlaySessionId 68d6e63168b840c1b1f99d774d6814ce. Killing transcoding


[12:15:56] [INF] [86] Jellyfin.Api.Helpers.TranscodingJobHelper: Stopping ffmpeg process with q command for /config/data/transcodes/4249117699b9dc48324a17184f7b914c.mp4


[12:15:56] [INF] [129] Jellyfin.Api.Helpers.TranscodingJobHelper: FFmpeg exited with code 0


[12:15:56] [INF] [86] Jellyfin.Api.Helpers.TranscodingJobHelper: Deleting partial stream file(s) /config/data/transcodes/4249117699b9dc48324a17184f7b914c.mp4
Any Idea? Apreciate your help.
Locked