crobibero / jellyfin-plugin-tmdb-trailers

GNU General Public License v3.0
128 stars 17 forks source link

Trailer transcodes do not use hardware acceleration settings #77

Closed danmons closed 1 year ago

danmons commented 1 year ago

jellyfin-server version: 10.8.10 jellyfin-ffmpeg version: 5.1.3 Plugin version: 12.0.0.0

In addition to #21 where streams appear to be transcoded no matter what their codec or bitrate, when transcoded the hardware acceleration transcode options set in Jellyfin are ignored.

Here's an example snippet from a /var/log/jellyfin/FFmpeg.Transcode* log file from regular on-disk content being transcoded to H.264 via VA-API. This particular video is H.265 HDR so there's output about tonemapping, but this is the same for something like H.264 SDR where the bitrate is too high for the client. The important note is the encoder chosen is h264_vaapi which enables hardware encoding:

/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -init_hw_device vaapi=va:,driver=iHD -filter_hw_device va -hwaccel vaapi -hwaccel_output_format vaapi -autorotate 0 -i file:"/path/to/filename.mp4" -autoscale 0 -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -low_power 1 -rc_mode VBR -b:v 9616000 -maxrate 9616000 -bufsize 19232000 -force_key_frames:0 "expr:gte(t,0+n_forced*3)" -vf "setparams=color_primaries=bt2020:color_trc=smpte2084:colorspace=bt2020nc,scale_vaapi=w=1920:h=910:extra_hw_frames=24,hwmap=derive_device=opencl,tonemap_opencl=format=nv12:p=bt709:t=bt709:m=bt709:tonemap=bt2390:peak=100:desat=0,hwmap=derive_device=vaapi:reverse=1,format=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 "/var/lib/jellyfin/transcodes/c50845f3e822b3a85a6973629dc440fa%d.ts" -hls_playlist_type vod -hls_list_size 0 -y "/var/lib/jellyfin/transcodes/c50845f3e822b3a85a6973629dc440fa.m3u8"

Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_vaapi))

Output #0, hls, to '/var/lib/jellyfin/transcodes/c50845f3e822b3a85a6973629dc440fa.m3u8':
  Metadata:
    encoder         : Lavf59.27.100
  Stream #0:0: Video: h264 (High), vaapi(tv, bt709, progressive), 1920x910 [SAR 1:1 DAR 192:91], q=2-31, 9616 kb/s, 23.98 fps, 90k tbn (default)
    Metadata:
      encoder         : Lavc59.37.100 h264_vaapi

And by comparison, a snippet from a log of a trailer transcode, where the chosen encoder is libx264 which doesn't offer hardware acceleration:

/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -init_hw_device vaapi=va:,driver=iHD -filter_hw_device va -autorotate 0 -i "https://url/of/stream" -map_metadata -1 -map_chapters -1 -threads 0 -sn   -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_base_url "hls/e2ef7c2ccf2463d3849220a9838d7ae2/" -hls_segment_filename "/var/lib/jellyfin/transcodes/e2ef7c2ccf2463d3849220a9838d7ae2%d.ts" -hls_playlist_type event -hls_list_size 0 -y "/var/lib/jellyfin/transcodes/e2ef7c2ccf2463d3849220a9838d7ae2.m3u8"

Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))

Output #0, hls, to '/var/lib/jellyfin/transcodes/e2ef7c2ccf2463d3849220a9838d7ae2.m3u8':
  Metadata:
    encoder         : Lavf59.27.100
  Stream #0:0: Video: h264, yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 24 fps, 90k tbn (default)
    Metadata:
      encoder         : Lavc59.37.100 libx264
crobibero commented 1 year ago

This plug-in doesn’t control transcoding. It may need to provide more information to the server about the streams but I won’t be looking into it.

Closing as not a plug-in bug.