Skip to content

Commit c22d33f

Browse files
committed
fix(engine): SDR clips are not lifted to HDR when the render tone-maps to SDR
1 parent de0b89a commit c22d33f

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎packages/engine/src/services/videoFrameExtractor.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,6 +3283,22 @@ describe.skipIf(!HAS_FFMPEG)("extractAllVideoFrames on a VFR source", () => {
32833283
).toBe(false);
32843284
}, 60_000);
32853285

3286+
it("leaves SDR clips alone in a mixed timeline that tone-maps to SDR", async () => {
3287+
const SDR = await synthCfrClip("sdr-tonemap-peer.mp4", 1);
3288+
const HDR = await synthHdrTaggedClip("hdr-tonemap-peer.mp4", 1);
3289+
const outputDir = join(FIXTURE_DIR, "out-hdr-tonemap-mixed");
3290+
mkdirSync(outputDir, { recursive: true });
3291+
3292+
const result = await extractAllVideoFrames(
3293+
[cfrClipElement("sdr", SDR, 1), { ...cfrClipElement("hdr", HDR, 1), start: 1, end: 2 }],
3294+
FIXTURE_DIR,
3295+
{ fps: 30, outputDir, toneMapHdrToSdr: true },
3296+
);
3297+
3298+
expect(result.errors).toEqual([]);
3299+
expect(result.phaseBreakdown.hdrPreflightCount).toBe(0);
3300+
}, 60_000);
3301+
32863302
it("keeps a finite SDR past-EOF slot in a mixed HDR timeline", async () => {
32873303
const SDR_SHORT = await synthCfrClip("sdr-past-eof.mp4", 1);
32883304
const HDR_SHORT = await synthHdrTaggedClip("hdr-past-eof-peer.mp4", 1);

‎packages/engine/src/services/videoFrameExtractor.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ export async function extractAllVideoFrames(
21412141
// Phase 3 still calls `extractVideoFramesRange` on the same past-EOF
21422142
// mediaStart, surfacing a second raw FFmpeg error for the same clip.
21432143
const hdrSkippedIndices = new Set<number>();
2144-
if (hdrInfo.hasHdr && hdrInfo.dominantTransfer) {
2144+
if (!options.toneMapHdrToSdr && hdrInfo.hasHdr && hdrInfo.dominantTransfer) {
21452145
// dominantTransfer is "majority wins" — if a composition mixes PQ and HLG
21462146
// sources (rare but legal), the minority transfer's videos get converted
21472147
// with the wrong curve. We treat this as caller-error: a single composition

0 commit comments

Comments
 (0)