feat(engine): add HDR two-pass compositing — DOM layer + native HLG video#288
Open
vanceingalls wants to merge 1 commit intofix/hdr-output-pipelinefrom
Open
feat(engine): add HDR two-pass compositing — DOM layer + native HLG video#288vanceingalls wants to merge 1 commit intofix/hdr-output-pipelinefrom
vanceingalls wants to merge 1 commit intofix/hdr-output-pipelinefrom
Conversation
This was referenced Apr 16, 2026
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Apr 16, 2026
16ff590 to
823ba6b
Compare
Per-frame in-memory alpha compositing: Chrome screenshots DOM with transparent background (PNG alpha), FFmpeg extracts native HLG/PQ frames as 16-bit PNG. DOM pixels (sRGB RGBA8) composited over HDR (rgb48le) via 256-entry sRGB-to-HLG/PQ LUT. Pure Node.js PNG decoder, single-pass FFmpeg extraction, native HDR detection before SDR conversion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
912fced to
f39b02a
Compare
1a45995 to
ffc3b12
Compare
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
Compositions with HDR video AND DOM overlays (text, graphics, SDR video) couldn't render both correctly — either HDR data was lost (Chrome captures sRGB only) or DOM overlays were missing (FFmpeg pass-through skips Chrome). This PR adds in-memory alpha compositing that combines both.
What it does
Per-frame two-pass capture:
Key components:
decodePng()/decodePngToRgb48le()— Pure Node.js PNG decoders (no native dependencies). Support all 5 PNG filter types.blitRgba8OverRgb48le()— Alpha composite with per-pixel sRGB→HDR LUT conversion. Fast paths for alpha=0 (skip) and alpha=255 (overwrite).initTransparentBackground()+captureAlphaPng()— Split CDP transparent background setup (once) from per-frame screenshot capture (eliminates 2 CDP round-trips per frame).-ssfast seek).Key design decisions
-f rawvideoloses color metadata, causing moiré artifacts. PNG is self-describing.extractAllVideoFramesconverts SDR→HDR. Pre-extraction probe identifies original HDR sources so only truly-HDR videos get native extraction.Files changed
packages/engine/src/utils/alphaBlit.tspackages/engine/src/services/screenshotService.tscaptureAlphaPng()packages/engine/src/services/videoFrameInjector.tshideVideoElements()/showVideoElements()packages/engine/src/services/streamingEncoder.tspackages/producer/src/services/renderOrchestrator.tsHow to test
Render a composition with an HDR video background and text overlays. Both should be visible — HDR video at full quality, text crisp with correct colors (not orange-shifted).
Stack position
3 of 6 — Stacked on #265 (HDR output pipeline). This is the foundation for all layered compositing that follows.
🤖 Generated with Claude Code