Skip to content

fix(crash-protection): play the reconnect screen on HEVC tracks - #73

Merged
Soulhackzlol merged 2 commits into
mainfrom
fix/hevc-reconnect-screen
Oct 5, 2026
Merged

Soulhackzlol merged 2 commits into
mainfrom
fix/hevc-reconnect-screen

Conversation

@Soulhackzlol

@Soulhackzlol Soulhackzlol commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

What was wrong

2K Twitch channels stream their Enhanced Broadcasting tracks in HEVC. The crash-protection reconnect screen was H.264 only, so during a hold HEVC tracks re-sent their last keyframe once a second: viewers saw a frozen picture instead of the screen. Reported by fashion; his log shows video codec = HEVC and reconnect screen on air (last keyframe held, last keyframe held).

The fix

The screen is now encoded in HEVC for 8-bit 4:2:0 HEVC tracks, at each track's own resolution, under its own FourCC and track id. Nothing changes for the live stream (still passthrough) or with crash protection off.

  • src/slate/hevc.rs: lossless HEVC encoder for flat-colour screens, the counterpart of the H.264 one (skip / exact intra prediction / PCM). Its VPS, SPS and PPS ride in-band under id 1, so the stream's own (id 0) survive the hold.
  • src/slate/cabac.rs: the CABAC arithmetic encoder HEVC needs.
  • src/h264.rs: reads an HEVC track's size, bit depth and chroma format from its hvcC. 10-bit HEVC and AV1 still hold the last keyframe.
  • src/crash_hold.rs: picks the screen's codec per track; loop cache keyed by codec; the log names the codec.

Cost: about 0.6 s of one core per resolution, built once in the background while live. HEVC loops run at the same bitrate as the H.264 ones (275 to 951 kbps across themes, 1080p to 1440p).

Verification

  • ffmpeg decodes every theme pixel-exact in both codecs.
  • New splice test: a real x264/x265 stream is cut to one loop of the screen and back at a keyframe without parameter sets (as OBS's arrive over RTMP). No decode errors, the screen is exact, and the stream after it decodes exactly as it does alone. Mutation-checked: giving the screen parameter-set id 0 fails it.
  • Windows: fmt, clippy -D warnings, 856/856 tests. Linux (Docker, Rust 1.98.1, ffmpeg 5.1): fmt, clippy, 853/853 twice.
  • Test fixes: -fps_mode instead of -vsync (removed in ffmpeg 7+), unique temp files, ffmpeg runs take turns.

Not verifiable locally: Twitch's own HEVC pipeline accepting in-band parameter sets. The H.264 screen works the same way and does show on Twitch.

Release

No version bump: this ships as a refresh of v0.1.15. The 0.1.15 changelog now lists the HEVC screen and the OBS WebSocket password fix from #72.

2K Twitch channels stream Enhanced Broadcasting tracks in HEVC. The
reconnect screen was H.264 only, so during a hold those tracks re-sent
their last keyframe once a second and viewers saw a frozen picture
instead of the screen (reported by fashion).

The screen is now encoded in HEVC for 8-bit 4:2:0 HEVC tracks, at each
track's own resolution and under its own FourCC and track id:

- slate/hevc.rs: a lossless HEVC encoder for flat-colour screens, the
  counterpart of the H.264 one. 32x32 CTUs, split to 16x16 where needed;
  blocks are skipped, predicted exactly (DC, vertical, horizontal) or
  sent as PCM. Main profile, one slice, no reordering. Its VPS, SPS and
  PPS ride in-band under id 1, so the stream's own (id 0) survive the
  hold. Same bitrate as the H.264 loop.
- slate/cabac.rs: the CABAC arithmetic encoder HEVC needs.
- h264.rs: read an HEVC track's size, bit depth and chroma format from
  its hvcC. 10-bit HEVC and AV1 still hold the last keyframe.
- crash_hold.rs: pick the screen's codec per track; the loop cache is
  keyed by codec too; the log names it.

Tests: ffmpeg decodes every theme pixel-exact in both codecs, and a new
splice test cuts a real x264/x265 stream to the screen and back (at a
keyframe without parameter sets, as OBS's arrive): no decode errors,
and the stream after the screen decodes exactly as it does alone. The
decode tests now use -fps_mode (ffmpeg 7+ dropped -vsync), unique temp
files, and take turns running ffmpeg.

Version 0.1.16; the changelog also lists the OBS WebSocket password fix
from #72.
…gelog

The fix ships as a refresh of v0.1.15 rather than a new version.
@Soulhackzlol

Copy link
Copy Markdown
Owner Author

Actually I don't want to bump to 0.1.16. reverting that

@Soulhackzlol Soulhackzlol changed the title fix(crash-protection): play the reconnect screen on HEVC tracks (v0.1.16) fix(crash-protection): play the reconnect screen on HEVC tracks Oct 5, 2026
@Soulhackzlol
Soulhackzlol merged commit 394fd1e into main Oct 5, 2026
6 checks passed
@Soulhackzlol
Soulhackzlol deleted the fix/hevc-reconnect-screen branch October 5, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant