fix(engine): add bt709 color space + range conversion to encoding#223
Merged
jrusso1020 merged 1 commit intomainfrom Apr 7, 2026
Merged
fix(engine): add bt709 color space + range conversion to encoding#223jrusso1020 merged 1 commit intomainfrom
jrusso1020 merged 1 commit intomainfrom
Conversation
…encoding Chrome captures frames in full-range sRGB, which maps to BT.709. Without explicit color metadata, players guess the wrong color space and range, causing color shifts and crushed dark values across devices. Changes: - Embed bt709 color info in H.264/H.265 VUI via x264-params/x265-params (colorprim, transfer, colormatrix) and FFmpeg metadata flags - Add scale filter (in_range=pc:out_range=tv) to convert full-range Chrome screenshots to limited/TV range expected by H.264 decoders - Chain range conversion with VAAPI's existing hwupload filter - Add -video_track_timescale 90000 for consistent A/V timing - Skip color metadata and range conversion for VP9/ProRes - 8 new regression tests for color space, range filter, VAAPI chain, GPU skip, VP9 skip, and timescale Verified via ffprobe: color_space=bt709, color_transfer=bt709, color_primaries=bt709, color_range=tv, time_base=1/90000. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
miguel-heygen
approved these changes
Apr 7, 2026
Collaborator
Author
Merge activity
|
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.
Description
Adds proper BT.709 color space metadata and full→limited range conversion to H.264/H.265 encoding. Chrome captures frames in full-range sRGB (BT.709 primaries), but without explicit color tagging, players guess the wrong color space and range — causing color shifts across iOS/Android/desktop and crushed dark values that compound the gradient banding issue fixed in #222.
What changed:
color_spacebt470bg(guessed)bt709(explicit)color_primariesunknownbt709color_transferunknownbt709color_rangepc(full, wrong for H.264)tv(limited, correct)time_base1/15360(varies by platform)1/90000(fixed)Approach:
colorprim=bt709:transfer=bt709:colormatrix=bt709) — ensures the bitstream itself carries color info-colorspace:v bt709, etc.) — belt-and-suspendersscale=in_range=pc:out_range=tvfilter converts Chrome's full-range output to TV/limited rangeformat=nv12,hwupload-video_track_timescale 90000for consistent cross-platform A/V timing (same as Remotion)Testing