jellyfin-roku icon indicating copy to clipboard operation
jellyfin-roku copied to clipboard

HEVC Content Being Transcoded on app version 1.5 because of VideoProfile

Open lakerssuperman opened this issue 2 years ago • 5 comments

BUG Since upgrading to app version 1.5, all HEVC files are being transcoded to h264. This also seems to be triggering an audio transcode as well, but the root issue is the video Jellyfin 1-5 Jellyfin Dev . The screenshots show the same file, in this case my Bluray rip of The Batman. It is encoded in HEVC/EAC3. WIth 1.5 it transcodes. On the dev channel version I have installed from a week or so ago, the file direct plays without issue.

Expected Behavior HEVC content should Direct Play as it did on previous versions of the Jellyfin Roku app.

JELLYFIN LOG ENTRY: 2022-07-31 01:09:15.715 +00:00] [INF] [53] Jellyfin.Api.Helpers.MediaInfoHelper: Profile: "VideoCodecProfile", DirectPlay=false. Reason="Unknown Profile".VideoProfile Condition: EqualsAny. ConditionValue: "main". IsRequired: False. Path: "nfs:/REDACTED/The ``Batman.mkv"

FULL TRANSCODING LOG

`/videos/74d3ffb1-4242-4129-b5ee-14eeb21e3a02/hls1/main/1491.ts

{"Protocol":0,"Id":"74d3ffb142424129b5ee14eeb21e3a02","Path":"/media/Linux_HD_4TB2/Video/1 - Movies/Batman Movies/The Batman (2022)/The Batman.mkv","EncoderPath":null,"EncoderProtocol":null,"Type":0,"Container":"mkv,webm","Size":10047764480,"Name":"The Batman","IsRemote":false,"ETag":"b136d8847ffdbfb49b0d6e0943e611b7","RunTimeTicks":105715662848,"ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"OpenToken":null,"RequiresClosing":false,"LiveStreamId":null,"BufferMs":null,"RequiresLooping":false,"SupportsProbing":true,"VideoType":0,"IsoType":null,"Video3DFormat":null,"MediaStreams":[{"Codec":"hevc","CodecTag":null,"Language":null,"ColorRange":null,"ColorSpace":"bt709","ColorTransfer":"bt709","ColorPrimaries":"bt709","Comment":null,"TimeBase":"1/1000","CodecTimeBase":"1001/24000","Title":null,"VideoRange":"SDR","localizedUndefined":null,"localizedDefault":null,"localizedForced":null,"DisplayTitle":"1080p HEVC SDR","NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":null,"BitRate":7603614,"BitDepth":null,"RefFrames":1,"PacketLength":null,"Channels":null,"SampleRate":null,"IsDefault":true,"IsForced":false,"Height":804,"Width":1920,"AverageFrameRate":23.976025,"RealFrameRate":23.976025,"Profile":"Main 10","Type":1,"AspectRatio":"2.40:1","Index":0,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":"yuv420p10le","Level":120,"IsAnamorphic":null},{"Codec":"eac3","CodecTag":null,"Language":"eng","ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"Comment":null,"TimeBase":"1/1000","CodecTimeBase":"1/48000","Title":"Dolby Digital\u002B 5.1","VideoRange":null,"localizedUndefined":null,"localizedDefault":null,"localizedForced":null,"DisplayTitle":"Dolby Digital\u002B 5.1 - Eng - 6 ch - Default","NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":null,"BitRate":640000,"BitDepth":null,"RefFrames":null,"PacketLength":null,"Channels":6,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Height":null,"Width":null,"AverageFrameRate":null,"RealFrameRate":null,"Profile":null,"Type":0,"AspectRatio":null,"Index":1,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":null,"Level":0,"IsAnamorphic":null},{"Codec":"ac3","CodecTag":null,"Language":"eng","ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"Comment":null,"TimeBase":"1/1000","CodecTimeBase":"1/48000","Title":"Dolby Digital 5.1","VideoRange":null,"localizedUndefined":null,"localizedDefault":null,"localizedForced":null,"DisplayTitle":"Dolby Digital 5.1 - Eng","NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":"5.1","BitRate":640000,"BitDepth":null,"RefFrames":null,"PacketLength":null,"Channels":6,"SampleRate":48000,"IsDefault":false,"IsForced":false,"Height":null,"Width":null,"AverageFrameRate":null,"RealFrameRate":null,"Profile":null,"Type":0,"AspectRatio":null,"Index":2,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":null,"Level":0,"IsAnamorphic":null},{"Codec":"srt","CodecTag":null,"Language":"eng","ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"Comment":null,"TimeBase":null,"CodecTimeBase":null,"Title":null,"VideoRange":null,"localizedUndefined":"Undefined","localizedDefault":"Default","localizedForced":"Forced","DisplayTitle":"Eng","NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":null,"BitRate":null,"BitDepth":null,"RefFrames":null,"PacketLength":null,"Channels":null,"SampleRate":null,"IsDefault":false,"IsForced":false,"Height":null,"Width":null,"AverageFrameRate":null,"RealFrameRate":null,"Profile":null,"Type":2,"AspectRatio":null,"Index":3,"Score":null,"IsExternal":true,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":true,"SupportsExternalStream":true,"Path":"/media/Linux_HD_4TB2/Video/1 - Movies/Batman Movies/The Batman (2022)/The Batman.en.srt","PixelFormat":null,"Level":null,"IsAnamorphic":null}],"MediaAttachments":[],"Formats":[],"Bitrate":8883614,"Timestamp":null,"RequiredHttpHeaders":{},"TranscodingUrl":null,"TranscodingSubProtocol":null,"TranscodingContainer":null,"AnalyzeDurationMs":null,"DefaultAudioStreamIndex":null,"DefaultSubtitleStreamIndex":null}

/usr/lib/jellyfin-ffmpeg/ffmpeg -ss 01:14:33.000 -hwaccel vaapi -noaccurate_seek -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:"/media/Linux_HD_4TB2/Video/1 - Movies/Batman Movies/The Batman (2022)/The Batman.mkv" -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -b:v 12672690 -maxrate 12672690 -bufsize 25345380 -profile:v:0 high -level 41  -force_key_frames:0 "expr:gte(t,4473+n_forced*3)" -vf "format=nv12|vaapi,hwupload,scale_vaapi=format=nv12" -start_at_zero -vsync -1 -codec:a:0 aac -ac 6 -ab 640000 -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 1491 -hls_segment_filename "/config/transcodes/f57441f799e51fd3ef73299d1bff61c4%d.ts" -hls_playlist_type vod -hls_list_size 0 -y "/config/transcodes/f57441f799e51fd3ef73299d1bff61c4.m3u8"


ffmpeg version 4.3.2-Jellyfin Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-shared --disable-libxcb --disable-sdl2 --disable-xlib --enable-gpl --enable-version3 --enable-static --enable-libfontconfig --enable-fontconfig --enable-gmp --enable-gnutls --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libdav1d --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --arch=amd64 --enable-opencl --enable-vaapi --enable-amf --enable-libmfx --enable-vdpau --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvenc --enable-nvdec --enable-ffnvcodec
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, matroska,webm, from 'file:/REDACTED/The Batman.mkv':
  Metadata:
    title           : The Batman
    creation_time   : 2022-07-07T16:15:35.000000Z
    ENCODER         : Lavf58.76.100
  Duration: 02:56:11.57, start: 0.000000, bitrate: 7603 kb/s
    Chapter #0:0: start 0.000000, end 721.221000
    Metadata:
      title           : Chapter 1
    Chapter #0:1: start 721.221000, end 1401.734000
    Metadata:
      title           : Chapter 2
    Chapter #0:2: start 1401.734000, end 1914.079000
    Metadata:
      title           : Chapter 3
    Chapter #0:3: start 1914.079000, end 2504.502000
    Metadata:
      title           : Chapter 4
    Chapter #0:4: start 2504.502000, end 3096.677000
    Metadata:
      title           : Chapter 5
    Chapter #0:5: start 3096.677000, end 3612.901000
    Metadata:
      title           : Chapter 6
    Chapter #0:6: start 3612.901000, end 4232.395000
    Metadata:
      title           : Chapter 7
    Chapter #0:7: start 4232.395000, end 4715.127000
    Metadata:
      title           : Chapter 8
    Chapter #0:8: start 4715.127000, end 5354.558000
    Metadata:
      title           : Chapter 9
    Chapter #0:9: start 5354.558000, end 6153.064000
    Metadata:
      title           : Chapter 10
    Chapter #0:10: start 6153.064000, end 6736.897000
    Metadata:
      title           : Chapter 11
    Chapter #0:11: start 6736.897000, end 7101.011000
    Metadata:
      title           : Chapter 12
    Chapter #0:12: start 7101.011000, end 7779.689000
    Metadata:
      title           : Chapter 13
    Chapter #0:13: start 7779.689000, end 8474.383000
    Metadata:
      title           : Chapter 14
    Chapter #0:14: start 8474.383000, end 8851.343000
    Metadata:
      title           : Chapter 15
    Chapter #0:15: start 8851.343000, end 9516.090000
    Metadata:
      title           : Chapter 16
    Chapter #0:16: start 9516.090000, end 10018.759000
    Metadata:
      title           : Chapter 17
    Chapter #0:17: start 10018.759000, end 10571.520000
    Metadata:
      title           : Chapter 18
    Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt709), 1920x804 [SAR 1:1 DAR 160:67], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Metadata:
      DURATION        : 02:56:11.566000000
    Stream #0:1(eng): Audio: eac3, 48000 Hz, 5.1, fltp (default)
    Metadata:
      title           : Dolby Digital+ 5.1
      DURATION        : 02:56:11.552000000
    Stream #0:2(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
    Metadata:
      title           : Dolby Digital 5.1
      DURATION        : 02:56:11.552000000
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (eac3 (native) -> aac (native))

lakerssuperman avatar Jul 31 '22 01:07 lakerssuperman

I should mention that his happens on all three of my Roku Ultras in my house and the same behavior occurs at my father in laws house on his Jellyfin system I setup for him.

lakerssuperman avatar Jul 31 '22 01:07 lakerssuperman

Do you happen to know know what Profile Level the hevc videos are using? Roku only "support" versions 4.1, 5.0 and 5.1, although it's likely they can play other versions without too many issues.

For h264 we allow attempting to play unsupported profile versions and falling back to transcoding if the playback fails - but we haven't implemented that for hevc yet. Would be interested to know what profile version your media is using - as I've not found anything higher than 5.1 in my (limited) search

neilsb avatar Aug 01 '22 15:08 neilsb

Do you happen to know know what Profile Level the hevc videos are using? Roku only "support" versions 4.1, 5.0 and 5.1, although it's likely they can play other versions without too many issues.

For h264 we allow attempting to play unsupported profile versions and falling back to transcoding if the playback fails - but we haven't implemented that for hevc yet. Would be interested to know what profile version your media is using - as I've not found anything higher than 5.1 in my (limited) search

Neil,

Just to follow up on this post and our discussion in the Matrix chat, most of my HEVC media is L4.0 as that is the default for Handbrake. I have one video that is L5.0 which is an officially supported profile which failed to direct play and was transcoded. I then just re-ripped a Bluray to HEVC Main 10 L4.1 and that failed as well.

From what you told me, they should pass the profile checking logic as they are less than 5.1 and it doesn't check for specific profiles. The only other thing of note about the L4.1 and L5.0 videos is that they are listed as high tier, not main. I didn't select this in Handbrake. It seems to be part of encoding about L4.0. I'm not sure if tiers have any impact on the profile checking.

Even without adding in an option to attempt direct playing unsupported profiles like was implemented for h264 video, should not at least the videos with profile levels L4.1 and L5.0 direct play?

Thanks, Matt

lakerssuperman avatar Aug 04 '22 23:08 lakerssuperman

I experience the similar issue with client 1.5 (Roku 4K TV). Video is HEVC main 10, L4.1.

TranscodeReason=VideoProfileNotSupported

zaharcelac avatar Aug 29 '22 15:08 zaharcelac

I also am experiencing a similar issue with client 1.5 on Roku Ultra LT. Have tested with multiple videos / encodings / video profiles. Any video which is HEVC main 10 - regardless of video profile level - fails to direct play and instead is transcoded with the

TranscodeReason=VideoProfileNotSupported reason.

Any video with is HEVC main plays directly without issues.

copperheadclgp avatar Sep 17 '22 01:09 copperheadclgp

You can modify line 137 in source/utils/deviceCapabilities.brs with:

            {
                "Type": "Video",
                "Codec": "hevc",
                "Conditions": [
                    {
                        "Condition": "EqualsAny",
                        "Property": "VideoProfile",
                        "Value": "main 10",
                        "IsRequired": false
                    },
                    {
                        "Condition": "LessThanEqual",
                        "Property": "VideoLevel",
                        "Value": StrI(30 * 5.1),
                        "IsRequired": false
                    }
                ]
            }

This appears to have solved the issue with trascoding / remuxing for me.

Removing the line also works, as hevc 5.1 should still be picked up as valid for direct playback. The change introduced by the 1.5 release that added the hevc codec conditions seems to override the direct play flag (which should still say True in the logs) and cause the transcode or repackaging.

MikeProsper avatar Nov 17 '22 03:11 MikeProsper

So I managed to also get it working by changing the existing portion in source/utils/deviceCapabilities.brs to:

            {
                "Type": "Video",
                "Codec": "hevc",
                "Conditions": [
                    {
                        "Condition": "EqualsAny",
                        "Property": "VideoProfile",
                        "Value": "main|main 10",
                        "IsRequired": false
                    },
                    {
                        "Condition": "LessThanEqual",
                        "Property": "VideoLevel",
                        "Value": StrI(120 * 5.1),
                        "IsRequired": false
                    }
                ]
            }

This allowed my HEVC and HEVC 10 files to direct play in one of the PR that I downloaded.

Sheepykin avatar Nov 23 '22 17:11 Sheepykin