A game view recording looked darker and its colours off in VLC, and
each round of recording a recording made it worse. Chrome's encoder,
fed RGB frames, wrote full-range H.264 and left the colour out of the
stream. Only our Matroska head said "full range", and VLC reads only
the stream. Chrome itself plays the converted MP4, which was right.
- The GPU now turns the game view into I420, limited range BT.709,
before it is read back (PictureReader). The encoder gets the planes
with that colour, as it does for a recording of the whole editor.
- Where the planes lie in the read-back picture is a plain function,
i420Layout in recording.ts.
- Only 1.5 instead of 4 bytes a pixel come back from the GPU.
- avcColour.ts writes the colour into the SPS of the encoder's avcC as
well, so a player that reads only the stream knows it. An SPS with a
VUI only gets its colour block replaced. One without gets a VUI that
holds the colour. An SPS it cannot read stays as the encoder made it.
- A first try sent the frames through a 2D canvas. That gave limited
range too, but only 18 to 20 of 33 frames at 1080p30.
Found on the way:
- With the colour in the stream alone, VLC 3.0.8 still showed the
full-range picture too dark. It ignores the range.
- The one old full-range original on the server got the same SPS fix
without loss: the clusters are byte-equal, the decoded frames are
equal (framemd5), backup in /root/config-backup-20261013/videos/.
- Older game view recordings stay full range. Fixing that in VLC would
mean encoding them again.
Tests:
- tsc, eslint, Prettier clean.
- Gate on melektaus-atx: CHECK EXIT 0, 308 files, 4772 tests.
- avc-colour.test.ts new (9), expectations read back with ffmpeg
trace_headers. Counter-check: the old bug in the no-VUI path turns
it red.
- e2e 67: ALL PASSED, 12 checks. 67d-ii reads tv/bt709 from the file
and from the bare H.264 stream, red with the old code.
- 1080p30 34 frames, 640x360@60 68 frames, none dropped (was 33/47).
- Checked by the user: a new recording looks right in VLC 3.0.8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>