Skip to content

fix: encode HyperFrames renders with BT.709 and tag the output - #342

Merged
rponeawa merged 1 commit into
hypit-ai:mainfrom
zhangfeite:fix/hyperframes-bt709-color
Sep 23, 2026
Merged

rponeawa merged 1 commit into
hypit-ai:mainfrom
zhangfeite:fix/hyperframes-bt709-color

Conversation

@zhangfeite

Copy link
Copy Markdown
Contributor

The HyperFrames local provider encodes Chromium's sRGB PNG frames to yuv420p without choosing a conversion matrix or writing color metadata. FFmpeg then converts with BT.601, while players and platform transcoders decode untagged HD video as BT.709, so every render shifts color.

Reproduction (0.2.12, FFmpeg 8.1.2, macOS arm64)

  • examples/semantic-composition/chat.svrun renders with color_space, color_primaries, color_transfer and color_range all unknown.
  • SMPTE HD bars (1280×720) through the current encode arguments: 48.98 dB PSNR against the source when decoded as BT.601, 28.67 dB when decoded as BT.709.
  • With this change: 48.60 dB decoded as BT.709, and the stream is tagged tv / bt709 / bt709 / bt709.

Change

The final encode now runs scale=out_color_matrix=bt709:out_range=tv,format=yuv420p,setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709:range=tv and drops the separate -pix_fmt yuv420p (the format filter covers it). setparams is needed because the output-level -color_primaries / -color_trc flags alone are not written into the H.264 stream on this path.

Checks

  • Rebuilt the chat example with the patched provider: tags are written, render time unchanged (~11 s end to end for the 8 s example).
  • Emulated the pixel assertions in test/range.test.ts (four solid colors through the patched encode, decoded with the test's default -pix_fmt rgb24): maximum channel error 1, within the test's tolerance of 12. FFmpeg honors the new tags when decoding.
  • I have not run the full pnpm check / pnpm test suite locally; the change is limited to the argv of one runProcess call.

🤖 Generated with Claude Code

The local provider converted sRGB PNG frames to yuv420p without choosing a
matrix or writing color metadata, so FFmpeg used BT.601 while players decode
untagged HD video as BT.709. Convert with BT.709 and tag the stream.

Co-Authored-By: Claude Opus 5 <[email protected]>
@rponeawa
rponeawa merged commit 465bef7 into hypit-ai:main Sep 23, 2026
rponeawa pushed a commit that referenced this pull request Oct 8, 2026
render-still-video converted authored sRGB pictures to yuv420p with
FFmpeg's default BT.601 matrix and wrote no color metadata. Players and
Chromium decode untagged HD video as BT.709, so an HD still clip shifted
color, e.g. #20C040 came back as (20,169,62) in a Chrome <video>, which
is also how HyperFrames composites these clips.

Use the same encode tail as the HyperFrames local renderer (#342) for
the single-picture and the multi-picture paths, and add a test that
checks the stream tags and the decoded color of both paths.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
SanHsien pushed a commit to SanHsien/hypit that referenced this pull request Oct 24, 2026
…i#363)

render-still-video converted authored sRGB pictures to yuv420p with
FFmpeg's default BT.601 matrix and wrote no color metadata. Players and
Chromium decode untagged HD video as BT.709, so an HD still clip shifted
color, e.g. #20C040 came back as (20,169,62) in a Chrome <video>, which
is also how HyperFrames composites these clips.

Use the same encode tail as the HyperFrames local renderer (hypit-ai#342) for
the single-picture and the multi-picture paths, and add a test that
checks the stream tags and the decoded color of both paths.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
(cherry picked from commit 31c358d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants