perf(engine): segment-scope convertSdrToHdr re-encode#432
Open
jrusso1020 wants to merge 1 commit intoperf/producer-phase-instrumentationfrom
Open
perf(engine): segment-scope convertSdrToHdr re-encode#432jrusso1020 wants to merge 1 commit intoperf/producer-phase-instrumentationfrom
jrusso1020 wants to merge 1 commit intoperf/producer-phase-instrumentationfrom
Conversation
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 23, 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.

What
Segment-scope the SDR→HDR preflight in
convertSdrToHdrso only the used composition window is re-encoded, not the full source. Direct mirror of the fix #360 already landed forconvertVfrToCfr.Why
PR 2 of the 5-PR stack from
hyperframes-notes/producer-render-architecture-review-2026-04-21.md. The doc flags the HDR preflight as one of the expensive items because it re-encodes the whole source regardless of how much of it the composition uses — a 4-second window of a 60-minute screen recording paid minutes of transcode on every render.The architecture review specifically calls this out as a direct parallel to the VFR fix:
How
Two changes in
videoFrameExtractor.ts:Signature —
convertSdrToHdrnow takesstartTimeanddurationand uses-ss $start -i $path -t $duration(identical ordering toconvertVfrToCfr, which also puts input seek before-ifor fast seek + accurate duration).Caller — Phase 2a now:
segDurationfrom the composition window (video.end - video.start), falling back todurationSeconds - mediaStartfor unbounded clips (same fallback pattern as Phase 3 and Phase 2b).entry.video.mediaStartafter a successful re-encode, because the segment-scoped output file starts att=0. This matches what the VFR fix does and ensures Phase 2b (VFR preflight) and Phase 3 (extraction) seek from 0, not from the original source mediaStart.The probe map changed shape — now returns
{ colorSpace, durationSeconds }per entry instead of justcolorSpace— so the HDR phase can compute the fallback duration without a second ffprobe.Interaction with the VFR preflight
HDR runs first (Phase 2a), then VFR (Phase 2b). If both apply to the same SDR source:
mediaStart.That's correct: the VFR pass sees exactly the segment that needs extracting, seeking from 0.
Test plan
New regression test in
videoFrameExtractor.test.tswith two synthesized fixtures:Compose a 2-second window out of the 10-second SDR source alongside the HDR clip (triggering mixed-timeline HDR preflight). Assertions:
phaseBreakdown.hdrPreflightCount === 1(the preflight actually ran)Full engine suite: 319 tests pass (was 318).
Typecheck clean in engine + producer.
Lint + format clean on changed files.
Stack
Built on #430 (phase-level instrumentation) so the improvement can be measured via the new
videoExtractBreakdown.hdrPreflightMsmetric.Follow-ups (remaining PRs in the stack)
(srcHash, windowStart, windowEnd, fps, hasAlpha)!hasAlphaand segment-length floor