jellyfin / jellyfin-web

Web Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.17k stars 1.15k forks source link

Support HEVC Level 8.5 #5586

Open rlauuzo opened 1 month ago

rlauuzo commented 1 month ago

Jellyfin is currently very strict about enforcing HEVC level compliance, which often leads to unnecessary transcoding. This is particularly problematic because many video files have non-standard level tags like "8.5" (used by x265 for unrestricted levels) or simply incorrect levels like "6.2".

Proposed Solution: When encountering non-standard or unusually high HEVC levels, Jellyfin should not immediately default to transcoding. Instead, it should attempt to determine compatibility based on other factors: Device Capabilities: Check the maximum HEVC level supported by the playback device (e.g., 5.1, 6.1). Video Parameters: Analyze the video's resolution, maxbitrate, and frame rate to assess if it's likely to be compatible with the device, even if the level tag is higher. User Option: Allow users to override Jellyfin's default behavior and force direct playback if they are confident their device can handle the video.

gnattu commented 1 month ago

Jellyfin already tests device capability up to HEVC level 6.1.

When encountering non-standard or unusually high HEVC levels, Jellyfin should not immediately default to transcoding. Instead, it should attempt to determine compatibility based on other factors

It should. Guessing is something we really want to avoid, and what we want to do is that to make sure this media plays, not guessing what the device can do it or not and break the playback totally when the guessing is wrong. We already bite ourselves a lot for the livetv function where the TV Tuners all have different kind of ideas and we are guessing a lot, and it breaks very often. If you are using non-standard level you cannot guarantee direct playback on every device, and we have to transcode it to make sure it will play.

User Option: Allow users to override Jellyfin's default behavior and force direct playback if they are confident their device can handle the video.

This is the only viable option if users want to guess and want to use any kind of non-standard videos.

rlauuzo commented 1 month ago

Thank you for taking the time to respond. I understand the desire to avoid guesswork and prioritize reliable playback. However, I still believe that relying on HEVC level tags for compatibility determination is overly restrictive and can lead to unnecessary transcoding in many cases.

HEVC levels, unlike H.264 levels, do not indicate the presence or absence of specific codec features. They primarily define limits on resolution, frame rate, and bitrate. Since Jellyfin already checks these parameters independently, the level tag itself becomes redundant.

Other media software often disregards HEVC levels entirely, which is why tools like x265 can use non-standard levels like 8.5 without major compatibility issues.

nyanmisaka commented 1 month ago

https://developer.apple.com/documentation/http-live-streaming/hls-authoring-specification-for-apple-devices Ignoring HEVC level will cause playback to fail on Apple devices. Especially older devices. So the only reliable way is to let the client/browser report the supported profiles/levels themselves.

gnattu commented 1 month ago

So the only reliable way is to let the client/browser report the supported profiles/levels themselves.

You misunderstood what the OP wants. The OP wants to play HEVC with the "unrestricted level" encoding profile (special level 8.5, or level = 255). The problem with this profile is that, per the spec, a decoder conforming to a given tier/level must be capable of decoding all bitstreams encoded for that tier/level and for all lower tiers/levels. Since level 8.5 is the highest possible level, supporting this level effectively means disregarding HEVC levels entirely. That's why I said that this can only be a user option if we ever want to support that level.

nyanmisaka commented 1 month ago

So the only reliable way is to let the client/browser report the supported profiles/levels themselves.

You misunderstood what the OP wants. The OP wants to play HEVC with the "unrestricted level" encoding profile (special level 8.5, or level = 255). The problem with this profile is that, per the spec, a decoder conforming to a given tier/level must be capable of decoding all bitstreams encoded for that tier/level and for all lower tiers/levels. Since level 8.5 is the highest possible level, supporting this level effectively means disregarding HEVC levels entirely. That's why I said that this can only be a user option if we ever want to support that level.

We can enable Level 8.5 by default if the client can bail out from the failure and downgrade to a lower level (DirectPlay/Remux -> Transcode). Otherwise it can only be an user option.