Repository navigation
fix: encode still-video clips with BT.709 and tag the output - #363
Merged
Merged
Conversation
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]>
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)
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.
Follow-up to #342, for the same issue in the local media Provider's
render-still-videopath.Problem
executeRenderStillVideo(packages/media-execution/src/execute.ts) encodes authored PNG/JPEG pictures with-pix_fmt yuv420p(the multi-picture path also usesformat=yuv420p). It doesn't choose a conversion matrix or write any color metadata. So FFmpeg converts with BT.601 and leaves the stream asunknown / unknown / unknown / unknown.How an untagged stream is decoded depends on the player. I encoded a solid
#20C040(32, 192, 64) picture with the current argv and decoded the first frame in Chrome through a<video>→ canvas. HyperFrames composites clips the same way (<video>indocument.ts).Chrome assumes BT.601 for untagged SD video but BT.709 for HD, so any HD still clip shifts color. The same happens in other players and platform transcoders. With FFmpeg decoding the SMPTE HD bars as BT.709, the current output scores 28.7 dB PSNR against the source; this PR's output scores 41.9 dB.
Change
Both still paths now end with the encode tail from #342:
In the multi-picture path it replaces the per-segment
format=yuv420pbeforeconcat. The frame-count, timing, and letterbox logic is unchanged.Tests
packages/provider-media-local/test/provider.test.ts. It renders a 1280×720 solid picture through the single-picture and the two-segment paths. It then checks that the stream is taggedtv,bt709,bt709,bt709and that the decoded color is within 3 of the source when decoded as BT.709. Onmainit fails withactual: 'unknown,unknown,unknown,unknown'.node --import tsx --test packages/provider-media-local/test/*.test.ts packages/media-execution/test/*.test.ts: 28/28 pass. This includes the existing still, spread and 24 fps spread cases.pnpm checkis clean.🤖 Generated with Claude Code