caps: ask the real decoder, and stop the client from over-claiming HEVC

The capability probe only ever asked canPlayType about Main profile (8-bit)
codec strings, which is why the project notes said "8K HEVC: supported" right up
until a Main 10 file showed up and could not be decoded at all. It now also asks
about Main 10, and -- more importantly -- asks the decoder itself.

The override: Jellyfin Web derives its entire HEVC claim from canPlayType
(browserDeviceProfile.js):

    if (canPlayType('video/mp4; codecs="hvc1.2.4.L183"')) {
        maxHevcLevel = 183;              // level 6.1 = 8K
        hevcProfiles = 'main|main 10';
    }

canPlayType answers "does this system have an HEVC decoder", not "can it do
8192x4096 Main 10 at 60fps". A desktop that merely ships an HEVC decoder
therefore claims 8K Main 10, the server picks DirectPlay, and playback dies on a
black screen with no player UI at all. MediaCapabilities.decodingInfo asks the
actual decoder, so its verdict is fed back through canPlayType and Jellyfin's own
logic lands on the right profile -- the desktop drops to what it can really do
and the server transcodes, while a Quest that genuinely decodes 8K Main 10 keeps
DirectPlay. Meta's browser-video docs recommend exactly this API over UA sniffing.

Deliberately conservative: only supported === false downgrades.
supported:true/smooth:false is recorded but changes nothing -- too close to the
edge to act on, and the watchdog already covers "claimed to work, did not".
Kill switch if a device reports nonsense: localStorage['jfvr-cpt'] = 'off'.

Each level is probed at the resolution it exists for (L120 -> 1080p30,
L153 -> 4K60, L183/L186 -> 8K60), because a level string carries no dimensions.

Verified against a local harness in three modes, all passing:
  pc    -> 8K Main10 blocked, Jellyfin caps at level 153, the 8K Main 10 file
           exceeds the claim and the server transcodes
  quest -> nothing blocked, claim stays >= 183, DirectPlay preserved
  off   -> hook not installed, canPlayType untouched, old behaviour restored
Also re-ran the playback watchdog on the new bundle: still fires on media error.

Also widens the harness gitignore to _harness*.html for the new codec harness.
This commit is contained in:
2026-10-18 01:07:44 +08:00
parent bfcd102ed0
commit ab36d2f25c
3 changed files with 325 additions and 9 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ secrets*.md
# deploy.py --legacy actually uses), so only the legacy one is tracked.
/jfvr-mvp.js
# Temporary offline test page (fake <video> + libass canvas + XR stubs).
_harness.html
_harness*.html
# --- build / tooling noise --------------------------------------------
__pycache__/