fix(engine): normalize mixed HDR/SDR video inputs#258
Open
vanceingalls wants to merge 1 commit intomainfrom
Open
fix(engine): normalize mixed HDR/SDR video inputs#258vanceingalls wants to merge 1 commit intomainfrom
vanceingalls wants to merge 1 commit intomainfrom
Conversation
…ut colors When a composition contains both HDR (bt2020) and SDR (bt709) video elements, the SDR content appears washed out because Chrome clamps HDR frames to sRGB during rendering. This adds automatic color space detection and normalization during the video frame extraction phase — if any video is HDR, all SDR videos are converted to HLG/BT.2020 (npl=600) via zscale before frame extraction. - Add colorSpace (transfer, primaries, matrix) to VideoMetadata via ffprobe - Add isHdrColorSpace() to detect bt2020/PQ/HLG content - Add convertSdrToHdr() using zscale with 600 nit nominal peak luminance - Restructure extractAllVideoFrames into 3 phases: resolve, normalize, extract - 6 new unit tests for HDR detection across all color space variants Same approach as HeyGen Rio's pipeline (heygen_rio.py#L568-585). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bc461a1 to
4923ab0
Compare
Collaborator
Author
This was referenced Apr 16, 2026
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.

Summary
When a HyperFrames composition contains both HDR and SDR video files, the SDR content looks washed out because Chrome's compositor clamps HDR pixel values to sRGB range. This PR normalizes all video inputs to the same color space before rendering.
What it does
ffprobenow extractscolorTransfer,colorPrimaries, andcolorSpacefrom video metadata. A newisHdrColorSpace()helper identifies bt2020/PQ/HLG sources.colorspacefilter during frame extraction. This ensures all video frames share the same color space before compositing.Files changed
packages/engine/src/utils/ffprobe.tsVideoColorSpaceto metadata,isHdrColorSpace()detectionpackages/engine/src/services/videoFrameExtractor.tsconvertSdrToHdr()via colorspace filterpackages/engine/src/services/videoFrameExtractor.test.tsisHdrColorSpacere-exportHow to test
Render a composition that mixes an iPhone HDR clip (HLG) with a standard SDR clip. The SDR clip should look normal — not washed out or orange-shifted.
Stack position
1 of 6 — This is the base of the HDR stack. All subsequent PRs build on this normalization.
🤖 Generated with Claude Code