Repository navigation
fix(crash-protection): play the reconnect screen on HEVC tracks - #73
Merged
Merged
Conversation
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.
Owner
Author
|
Actually I don't want to bump to 0.1.16. reverting that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 = HEVCandreconnect 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
-D warnings, 856/856 tests. Linux (Docker, Rust 1.98.1, ffmpeg 5.1): fmt, clippy, 853/853 twice.-fps_modeinstead 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.