plugin.video.twitch icon indicating copy to clipboard operation
plugin.video.twitch copied to clipboard

Add a "Supported codecs" setting (HEVC / Enhanced Broadcasting)

Open einanderson opened this issue 5 months ago • 1 comments

Summary

Adds a "Supported codecs" setting so users can opt in to Twitch Enhanced Broadcasting (HEVC), which is required to receive 1440p+ variants.

Addresses #699 (Playback broken for 2k streams) and #700 (No audio on 2k stream): those 2K streams use HEVC, which Twitch only serves when the client requests supported_codecs.

What it does

  • New setting General → "Supported codecs": Twitch default / H.265 (HEVC).
  • The selected value is passed to usher (live / video / live_request / video_request) via the new supported_codecs parameter.
  • Default = "Twitch default" → no supported_codecs sent → behaviour unchanged (no regression).
  • Opt-in by design: HEVC requires hardware decode; users without it keep the default. h264 stays in the requested list as a fallback, so non-HEVC channels/devices still get a playable variant.
  • Graceful fallback: the value is only passed when the installed script.module.python.twitch accepts the parameter (feature-detected), so the plugin still works with an older library.

Pairs with

The library-side change anxdpanic/script.module.python.twitch#141, which adds the supported_codecs parameter. With an older library the setting simply has no effect.

Testing

  • Default setting: usher calls are byte-for-byte unchanged (regression-safe).
  • Codec mapping + graceful fallback verified; the supported_codecs=h265,h264 mechanism is in production use on Raspberry Pi 4 / Kodi 21 (HEVC 1440p plays).
  • Uses only standard APIs (stdlib inspect); platform-independent.

Notes

  • AV1 is intentionally left out for now (Enhanced Broadcasting AV1 is not generally served); the library parameter is codec-agnostic, so it can be added trivially later.

einanderson avatar Jun 05 '26 15:06 einanderson

Ready for review (no longer draft) — no rush. This builds directly on your existing quality/usher handling; it only adds a small optional "Supported codecs" setting that requests H.265 (HEVC) / Enhanced Broadcasting, so 2K streams play (with audio) through inputstream.adaptive. Default stays "Twitch standard", so nothing changes unless enabled — an addition on top of your code, not a rewrite. Addresses #699 / #700.

How to test: check out this branch + the lib PR anxdpanic/script.module.python.twitch#141 → Settings → Supported codecs = H.265 (HEVC), Video Quality = Adaptive (needs inputstream.adaptive) → a 2K channel plays 2K HEVC with audio; back to "Twitch standard" = unchanged stock behaviour. Uses inspect feature-detection so it degrades gracefully on an older lib. Tested on LibreELEC / RPi 4 / Kodi 21.

einanderson avatar Jun 10 '26 21:06 einanderson

Superseded by the consolidated release PR #707 (same change, plus the token-store hardening from the fork betas) — keeping this open for reference until that lands.

einanderson avatar Jul 11 '26 04:07 einanderson