Jellyfin Forum
Hardware transcoding in Jellyfin on AMD cpu - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+--- Thread: Hardware transcoding in Jellyfin on AMD cpu (/t-hardware-transcoding-in-jellyfin-on-amd-cpu)



Hardware transcoding in Jellyfin on AMD cpu - lamzu - 2024-02-23

Hi! 
I have AMD 5600G cpu and would like to use hardware transcoding. 
I can watch any movie only when selected in Hardware acceleration: None, but when I select Video Acceleration API (VAAPI) and VA-API Device: dev/dri/renderD128 I will get error for some movies “This client isn't compatible with the media, and the server isn't sending a compatible media format.”

Jellyfin in docker container from repo: lscr.io/linuxserver/jellyfin:latest also have tried to add  DOCKER_MODS=linuxserver/mods:jellyfin-amd - no luck.

Example of docker run:

Quote:docker run
  -d
  --name='jellyfin'
  --net='br0'
  --ip='192.168.98.44'
  -e TZ="Europe/Kiev"
  -e HOST_CONTAINERNAME="jellyfin"
  -e 'TCP_PORT_8096'='8096'
  -e 'TCP_PORT_8920'='8920'
  -e 'UDP_PORT_7359'='7359'
  -e 'UDP_PORT_1900'='1900'
  -e 'DOCKER_MODS'='linuxserver/mods:jellyfin-amd'
  -e 'PUID'='99'
  -e 'PGID'='100'
  -e 'UMASK'='022'
  -l net.unraid.docker.managed=dockerman
  -l net.unraid.docker.webui='http://[IP]:[PORT:8096]'
  -l net.unraid.docker.icon='https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/jellyfin-logo.png'
  -v '/mnt/user/media/TV_Show/':'/data/tvshows':'rw'
  -v '/mnt/user/media/Movie/':'/data/movies':'rw'
  -v '/mnt/user/docker/jellyfin':'/config':'rw'
  --device='/dev/dri/renderD128'
  --restart always 'lscr.io/linuxserver/jellyfin:latest'

Also I can see next exception logs:

From one I can see
Quote:/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device opencl=ocl:.0,device_vendor="Advanced Micro Devices" -filter_hw_device ocl -autorotate 0 -i file:"/data/tvshows/True.Detective.S04.2160p.HDR.DV.NewComers/True.Detective.S04E02.2160p.HDR.DV.NewComers.mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:2 -map -0:s -codec:v:0 h264_vaapi -rc_mode VBR -b:v 37979453 -maxrate 37979453 -bufsize 75958906 -force_key_frames:0 "expr:gte(t,0+n_forced*3)" -flags:v -global_header -vf "setparams=color_primaries=bt2020:color_trc=smpte2084:colorspace=bt2020nc,scale=trunc(min(max(iw\,ih*a)\,min(3840\,1920*a))/2)*2:trunc(min(max(iw/a\,ih)\,min(3840/a\,1920))/2)*2,format=yuv420p10le,hwupload=derive_device=opencl,tonemap_opencl=format=nv12:p=bt709:t=bt709:m=bt709:tonemap=bt2390:peak=100:desat=0,hwdownload,format=nv12,hwupload_vaapi" -codec:a:0 libfdk_aac -ac 2 -ab 384000 -af "volume=2" -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 0 -hls_segment_filename "/config/data/transcodes/5b9203bdc4d13c71d16943c5a77c2213%d.ts" -hls_playlist_type vod -hls_list_size 0 -y "/config/data/transcodes/5b9203bdc4d13c71d16943c5a77c2213.m3u8"


ffmpeg version 5.1.4-Jellyfin Copyright © 2000-2023 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-libs=-lfftw3f --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-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-opencl --enable-vaapi --enable-amf --enable-libmfx --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      57. 28.100 / 57. 28.100
  libavcodec    59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter    8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample  4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
amdgpu: os_same_file_description couldn't determine if two DRM fds reference the same file description.
If they do, bad things may happen!
[AVHWDeviceContext @ 0x55fc192be2c0] No matching devices found.
Device creation failed: -19.
Failed to set value 'opencl=ocl:.0,device_vendor=Advanced Micro Devices' for option 'init_hw_device': No such device
Error parsing global options: No such device
So, probably  DOCKER_MODS is not necessarily.

And from another log file I can see next:
Quote:[2024-02-23 22:34:38.781 +02:00] [INF] [62] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="Anonymous Profile", Path="/data/tvshows/True.Detective.S04.2160p.HDR.DV.NewComers/True.Detective.S04E02.2160p.HDR.DV.NewComers.mkv", AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=Transcode, TranscodeReason=VideoCodecNotSupported, AudioCodecNotSupported ) "media:/videos/8807993c-781c-20ab-b388-84963928dd93/master.m3u8?MediaSourceId=8807993c781c20abb38884963928dd93&VideoCodec=h264&AudioCodec=aac,mp3&AudioStreamIndex=2&VideoBitrate=139616000&AudioBitrate=384000&MaxFramerate=23.976025&api_key=<token>&TranscodingMaxAudioChannels=2&RequireAvc=false&Tag=759314ece71650f67a6beb119914cc31&SegmentContainer=ts&MinSegments=1&BreakOnNonKeyFrames=True&hevc-level=153&hevc-videobitdepth=10&hevc-profile=main10&TranscodeReasons=VideoCodecNotSupported,%20AudioCodecNotSupported"
[2024-02-23 22:34:39.257 +02:00] [INF] [59] Jellyfin.Api.Controllers.DynamicHlsController: Current HLS implementation doesn't support non-keyframe breaks but one is requested, ignoring that request
[2024-02-23 22:34:39.259 +02:00] [INF] [59] Jellyfin.Api.Helpers.TranscodingJobHelper: "/usr/lib/jellyfin-ffmpeg/ffmpeg" "-analyzeduration 200M -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device opencl=ocl:.0,device_vendor=\"Advanced Micro Devices\" -filter_hw_device ocl -autorotate 0 -i file:\"/data/tvshows/True.Detective.S04.2160p.HDR.DV.NewComers/True.Detective.S04E02.2160p.HDR.DV.NewComers.mkv\" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:2 -map -0:s -codec:v:0 h264_vaapi -rc_mode VBR -b:v 37979453 -maxrate 37979453 -bufsize 75958906 -force_key_frames:0 \"expr:gte(t,0+n_forced*3)\" -flags:v -global_header -vf \"setparams=color_primaries=bt2020:color_trc=smpte2084:colorspace=bt2020nc,scale=trunc(min(max(iw\,ih*a)\,min(3840\,1920*a))/2)*2:trunc(min(max(iw/a\,ih)\,min(3840/a\,1920))/2)*2,format=yuv420p10le,hwupload=derive_device=opencl,tonemap_opencl=format=nv12:p=bt709:t=bt709:m=bt709:tonemap=bt2390:peak=100:desat=0,hwdownload,format=nv12,hwupload_vaapi\" -codec:a:0 libfdk_aac -ac 2 -ab 384000 -af \"volume=2\" -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 0 -hls_segment_filename \"/config/data/transcodes/5b9203bdc4d13c71d16943c5a77c2213%d.ts\" -hls_playlist_type vod -hls_list_size 0 -y \"/config/data/transcodes/5b9203bdc4d13c71d16943c5a77c2213.m3u8\""
[2024-02-23 22:34:41.916 +02:00] [ERR] [56] Jellyfin.Api.Helpers.TranscodingJobHelper: FFmpeg exited with code 1
[2024-02-23 22:34:42.012 +02:00] [ERR] [71] Jellyfin.Server.Middleware.ExceptionMiddleware: Error processing request. URL "GET" "/videos/8807993c-781c-20ab-b388-84963928dd93/hls1/main/0.ts".
MediaBrowser.Common.FfmpegException: FFmpeg exited with code 1
  at Jellyfin.Api.Helpers.TranscodingJobHelper.StartFfMpeg(StreamState state, String outputPath, String commandLineArguments, HttpRequest request, TranscodingJobType transcodingJobType, CancellationTokenSource cancellationTokenSource, String workingDirectory)
  at Jellyfin.Api.Controllers.DynamicHlsController.GetDynamicSegment(StreamingRequestDto streamingRequest, Int32 segmentId)
  at Jellyfin.Api.Controllers.DynamicHlsController.GetHlsVideoSegment(Guid itemId, String playlistId, Int32 segmentId, String container, Int64 runtimeTicks, Int64 actualSegmentLengthTicks, Nullable1 static, String params, String tag, String deviceProfileId, String playSessionId, String segmentContainer, Nullable1 segmentLength, Nullable1 minSegments, String mediaSourceId, String deviceId, String audioCodec, Nullable1 enableAutoStreamCopy, Nullable1 allowVideoStreamCopy, Nullable1 allowAudioStreamCopy, Nullable1 breakOnNonKeyFrames, Nullable1 audioSampleRate, Nullable1 maxAudioBitDepth, Nullable1 audioBitRate, Nullable1 audioChannels, Nullable1 maxAudioChannels, String profile, String level, Nullable1 framerate, Nullable1 maxFramerate, Nullable1 copyTimestamps, Nullable1 startTimeTicks, Nullable1 width, Nullable1 height, Nullable1 maxWidth, Nullable1 maxHeight, Nullable1 videoBitRate, Nullable1 subtitleStreamIndex, Nullable1 subtitleMethod, Nullable1 maxRefFrames, Nullable1 maxVideoBitDepth, Nullable1 requireAvc, Nullable1 deInterlace, Nullable1 requireNonAnamorphic, Nullable1 transcodingMaxAudioChannels, Nullable1 cpuCoreLimit, String liveStreamId, Nullable1 enableMpegtsM2TsMode, String videoCodec, String subtitleCodec, String transcodeReasons, Nullable1 audioStreamIndex, Nullable1 videoStreamIndex, Nullable1 context, Dictionary2 streamOptions)
  at lambda_method1144(Closure , Object )
  at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask
1 actionResultValueTask)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
  at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
  at Jellyfin.Server.Middleware.ServerStartupMessageMiddleware.Invoke(HttpContext httpContext, IServerApplicationHost serverApplicationHost, ILocalizationManager localizationManager)
  at Jellyfin.Server.Middleware.WebSocketHandlerMiddleware.Invoke(HttpContext httpContext, IWebSocketManager webSocketManager)
  at Jellyfin.Server.Middleware.IpBasedAccessValidationMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager)
  at Jellyfin.Server.Middleware.LanFilteringMiddleware.Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager)
  at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
  at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
  at Jellyfin.Server.Middleware.QueryStringDecodingMiddleware.Invoke(HttpContext httpContext)
  at Swashbuckle.AspNetCore.ReDoc.ReDocMiddleware.Invoke(HttpContext httpContext)
  at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
  at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
  at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
  at Jellyfin.Server.Middleware.RobotsRedirectionMiddleware.Invoke(HttpContext httpContext)
  at Jellyfin.Server.Middleware.LegacyEmbyRouteRewriteMiddleware.Invoke(HttpContext httpContext)
  at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
  at Jellyfin.Server.Middleware.ResponseTimeMiddleware.Invoke(HttpContext context, IServerConfigurationManager serverConfigurationManager)
  at Jellyfin.Server.Middleware.ExceptionMiddleware.Invoke(HttpContext context)

Could anyone help me how to solve it?


RE: Hardware transcoding in Jellyfin on AMD cpu - TheDreadPirate - 2024-02-23

Follow out guide here.

https://jellyfin.org/docs/general/administration/hardware-acceleration/amd/#configure-with-linux-virtualization

Particularly, the parts about passing the render and video groups into the container.


RE: Hardware transcoding in Jellyfin on AMD cpu - lamzu - 2024-02-23

(2024-02-23, 09:30 PM)TheDreadPirate Wrote: Follow out guide here.

https://jellyfin.org/docs/general/administration/hardware-acceleration/amd/#configure-with-linux-virtualization

Particularly, the parts about passing the render and video groups into the container.

Already and was able to fix it only by using latest unstable version: linuxserver/jellyfin:nightly-version-20231115.15-unstable.
It seems working now. Thanks.

Copy