Skip to content

Write HTML. Render video. Built for agents.

fix: report HDR auto-promotion (#3985)

heygengenesis[bot]5d2478c6fae4
diff --git a/packages/cli/src/commands/check.test.ts b/packages/cli/src/commands/check.test.ts
index 73f548ef88..4fd3408370 100644
--- a/packages/cli/src/commands/check.test.ts
+++ b/packages/cli/src/commands/check.test.ts
@@ -268,6 +268,7 @@ function dependencies(
runtime?: CheckFinding[];
writeSnapshot?: CheckDependencies["writeSnapshot"];
captureFindingCrops?: CheckDependencies["captureFindingCrops"];
+ inspectHdrAutoPromotion?: NonNullable<CheckDependencies["inspectHdrAutoPromotion"]>;
} = {},
): { deps: CheckDependencies; runBrowserCheck: ReturnType<typeof vi.fn> } {
const runBrowserCheck = vi.fn(
@@ -292,6 +293,7 @@ function dependencies(
),
),
captureFindingCrops: options.captureFindingCrops ?? vi.fn(async () => []),
+ inspectHdrAutoPromotion: options.inspectHdrAutoPromotion ?? vi.fn(async () => null),
};
return { deps, runBrowserCheck };
}
@@ -423,6 +425,45 @@ it("preserves --json after bare --frame-check", async () => {
expect(log).toHaveBeenCalledWith(expect.stringContaining('"ok"'));
});
+it("includes local HDR auto-promotion attribution in --json output", async () => {
+ const { report } = await runScenario(
+ fakeDriver(),
+ {},
+ {
+ inspectHdrAutoPromotion: vi.fn(async () => ({
+ triggeringAsset: "assets/source-hdr.mp4",
+ output: { colorSpace: "BT.2020", codec: "HEVC Main10" } as const,
+ })),
+ },
+ );
+ const log = vi.spyOn(console, "log").mockImplementation(() => undefined);
+ const command = createCheckCommand({
+ resolveProject: () => PROJECT,
+ runPipeline: vi.fn(async () => report),
+ withMeta: (value) => value,
+ });
+
+ await runCommand(command, { rawArgs: ["--json"] });
+
+ expect(log).toHaveBeenCalledTimes(1);
+ expect(JSON.parse(String(log.mock.calls[0]?.[0])).hdr.autoPromotion).toEqual({
+ triggeringAsset: "assets/source-hdr.mp4",
+ output: { colorSpace: "BT.2020", codec: "HEVC Main10" },
+ });
+});
+
+it("distinguishes unavailable HDR inspection from no promotion", async () => {
+ const { report } = await runScenario(
+ fakeDriver(),
+ {},
+ {
+ inspectHdrAutoPromotion: vi.fn(async () => Promise.reject(new Error("ffprobe unavailable"))),
+ },
+ );
+
+ expect(report.hdr).toEqual({ autoPromotion: null, inspection: "unavailable" });
+});
+
it("threads --no-proxy into the browser check options", async () => {
const { report } = await runScenario(fakeDriver());
const runPipeline = vi.fn(async (_project: ProjectDir, _options: CheckOptions) => report);
@@ -922,6 +963,7 @@ function reportWithFindings(overrides: Partial<CheckReport> = {}): CheckReport {
},
motion: { ...emptySection(), enabled: false, samples: 0 },
contrast: { ...emptySection(), enabled: true, samples: [], checked: 0, passed: 0 },
+ hdr: { autoPromotion: null, inspection: "available" },
snapshots: { enabled: false, files: [], times: [], findingFiles: [] },
...overrides,
};
diff --git a/packages/cli/src/utils/checkPipeline.ts b/packages/cli/src/utils/checkPipeline.ts
index d80f7f9707..da5ca49f0f 100644
--- a/packages/cli/src/utils/checkPipeline.ts
+++ b/packages/cli/src/utils/checkPipeline.ts
@@ -23,6 +23,7 @@ import {
type MotionFrame,
} from "./motionAudit.js";
import { findMotionSpec, readMotionSpec, type MotionAssertion } from "./motionSpec.js";
+import { inspectHdrAutoPromotion } from "./hdrPromotion.js";
import { normalizeErrorMessage } from "./errorMessage.js";
import {
parseColorRGBA,
@@ -1145,8 +1146,24 @@ export async function runCheckPipeline(
});
const lint = buildLintSection(lintResult);
+ let hdrPromotion: CheckReport["hdr"]["autoPromotion"] = null;
+ let hdrInspection: CheckReport["hdr"]["inspection"] = "available";
+ try {
+ hdrPromotion = await (dependencies.inspectHdrAutoPromotion ?? inspectHdrAutoPromotion)(project);
+ } catch {
+ hdrInspection = "unavailable";
+ }
if (shouldBlockRender(true, false, lintResult.totalErrors, lintResult.totalWarnings)) {
- return buildReport(options, lint, emptyBrowserResult(), { kind: "none" }, [], []);
+ return buildReport(
+ options,
+ lint,
+ emptyBrowserResult(),
+ { kind: "none" },
+ [],
+ [],
+ hdrPromotion,
+ hdrInspection,
+ );
}
const motion = dependencies.resolveMotionSpec(project.dir);
@@ -1173,7 +1190,16 @@ export async function runCheckPipeline(
const snapshotFiles = options.snapshots
? await writeContrastSnapshots(dependencies, project.dir, browser)
: [];
- const report = buildReport(options, lint, browser, motion, specFindings, snapshotFiles);
+ const report = buildReport(
+ options,
+ lint,
+ browser,
+ motion,
+ specFindings,
+ snapshotFiles,
+ hdrPromotion,
+ hdrInspection,
+ );
return options.snapshots
? await withFindingCrops(dependencies, project, options, report)
: report;
@@ -1353,6 +1379,8 @@ function buildReport(
motion: MotionSpecResolution,
extraMotionFindings: CheckFinding[],
snapshotFiles: string[],
+ hdrPromotion: CheckReport["hdr"]["autoPromotion"] = null,
+ hdrInspection: CheckReport["hdr"]["inspection"] = "available",
): CheckReport {
const layout = shapeLayoutSection(browser.layoutIssues, browser, options);
const shapedMotion = shapeLayoutFindings(browser.motionIssues, options);
@@ -1391,6 +1419,7 @@ function buildReport(
checked: browser.contrastChecked,
passed: browser.contrastPassed,
},
+ hdr: { autoPromotion: hdrPromotion, inspection: hdrInspection },
snapshots: {
enabled: options.snapshots,
files: snapshotFiles,
@@ -1595,4 +1624,5 @@ const DEFAULT_DEPENDENCIES: CheckDependencies = {
runBrowserCheck,
writeSnapshot,
captureFindingCrops,
+ inspectHdrAutoPromotion,
};
diff --git a/packages/cli/src/utils/checkTypes.ts b/packages/cli/src/utils/checkTypes.ts
index 1a3199abeb..dd0fea2bae 100644
--- a/packages/cli/src/utils/checkTypes.ts
+++ b/packages/cli/src/utils/checkTypes.ts
@@ -4,6 +4,7 @@ import type { Canvas, MotionFrame } from "./motionAudit.js";
import type { MotionSpec } from "./motionSpec.js";
import type { ProjectDir } from "./project.js";
import type { BrowserGpuMode } from "../browser/gpuPolicy.js";
+import type { HdrAutoPromotion } from "@hyperframes/engine";
export interface CheckOptions {
samples: number;
@@ -282,6 +283,7 @@ export interface CheckReport {
checked: number;
passed: number;
};
+ hdr: { autoPromotion: HdrAutoPromotion | null; inspection: "available" | "unavailable" };
snapshots: { enabled: boolean; files: string[]; times: number[]; findingFiles: string[] };
}
@@ -304,6 +306,7 @@ export interface CheckDependencies {
options: CheckOptions,
requests: CheckFindingCropRequest[],
): Promise<string[]>;
+ inspectHdrAutoPromotion?(project: ProjectDir): Promise<CheckReport["hdr"]["autoPromotion"]>;
}
export function rectToBbox(rect: {
diff --git a/packages/cli/src/utils/hdrPromotion.test.ts b/packages/cli/src/utils/hdrPromotion.test.ts
new file mode 100644
index 0000000000..464955cf68
--- /dev/null
+++ b/packages/cli/src/utils/hdrPromotion.test.ts
@@ -0,0 +1,110 @@
+import { describe, expect, it, vi } from "vitest";
+import type { VideoColorSpace } from "@hyperframes/engine";
+import { resolveProjectRelativeSrc } from "@hyperframes/engine";
+import { inspectHdrAutoPromotion } from "./hdrPromotion.js";
+
+const PROJECT = { dir: "/project", name: "hdr-check", indexPath: "/project/index.html" };
+const HDR: VideoColorSpace = {
+ colorTransfer: "smpte2084",
+ colorPrimaries: "bt2020",
+ colorSpace: "bt2020nc",
+};
+const SDR: VideoColorSpace = {
+ colorTransfer: "bt709",
+ colorPrimaries: "bt709",
+ colorSpace: "bt709",
+};
+
+function metadata(colorSpace: VideoColorSpace, videoCodec = "hevc") {
+ return {
+ durationSeconds: 1,
+ videoStreamDurationSeconds: 1,
+ width: 1920,
+ height: 1080,
+ fps: 30,
+ videoCodec,
+ hasAudio: false,
+ isVFR: false,
+ hasAlpha: false,
+ colorSpace,
+ };
+}
+
+function bundledMedia(videos: string[], images: string[]) {
+ return {
+ bundleHtml: vi.fn(async () => "<html>bundled sub-composition</html>"),
+ collectMedia: vi.fn(() => ({
+ videos: videos.map((src) => ({ src })),
+ images: images.map((src) => ({ src })),
+ })),
+ };
+}
+
+describe("inspectHdrAutoPromotion", () => {
+ it("reports the local HDR asset that promotes automatic output", async () => {
+ const assetPath = resolveProjectRelativeSrc("assets/source-hdr.mp4", PROJECT.dir, PROJECT.dir);
+ const extractMetadata = vi.fn(async () => metadata(HDR));
+
+ await expect(
+ inspectHdrAutoPromotion(
+ PROJECT,
+ extractMetadata,
+ bundledMedia(["assets/source-hdr.mp4?token=secret#preview"], []),
+ ),
+ ).resolves.toEqual({
+ triggeringAsset: "assets/source-hdr.mp4",
+ output: { colorSpace: "BT.2020", codec: "HEVC Main10" },
+ });
+ expect(extractMetadata).toHaveBeenCalledOnce();
+ expect(extractMetadata).toHaveBeenCalledWith(assetPath);
+ });
+
+ it("reports an active remote HDR video from the bundled render media", async () => {
+ const remote = "https://media.example/remote-hdr.mp4?token=secret";
+ const extractMetadata = vi.fn(async () => metadata(HDR));
+
+ await expect(
+ inspectHdrAutoPromotion(PROJECT, extractMetadata, bundledMedia([remote], [])),
+ ).resolves.toEqual({
+ triggeringAsset: "https://media.example/remote-hdr.mp4",
+ output: { colorSpace: "BT.2020", codec: "HEVC Main10" },
+ });
+ expect(extractMetadata).toHaveBeenCalledWith(remote);
+ });
+
+ it("uses the first HDR video before an HDR image and still inspects images", async () => {
+ const firstVideo = "https://media.example/first-hdr-video.mp4?token=secret";
+ const image = "assets/fallback-hdr-image.png";
+ const extractMetadata = vi.fn(async (src: string) =>
+ metadata(src.replaceAll("\\", "/").endsWith("/assets/sdr.mp4") ? SDR : HDR),
+ );
+
+ await expect(
+ inspectHdrAutoPromotion(
+ PROJECT,
+ extractMetadata,
+ bundledMedia(["assets/sdr.mp4", firstVideo], [image]),
+ ),
+ ).resolves.toMatchObject({ triggeringAsset: "https://media.example/first-hdr-video.mp4" });
+ expect(extractMetadata).toHaveBeenCalledWith(
+ resolveProjectRelativeSrc("assets/sdr.mp4", PROJECT.dir, PROJECT.dir),
+ );
+ expect(extractMetadata).toHaveBeenCalledWith(firstVideo);
+ expect(extractMetadata).toHaveBeenCalledWith(
+ resolveProjectRelativeSrc("assets/fallback-hdr-image.png", PROJECT.dir, PROJECT.dir),
+ );
+ });
+
+ it("reports an HDR image when no HDR video is present", async () => {
+ const extractMetadata = vi.fn(async () =>
+ metadata(
+ { colorTransfer: "arib-std-b67", colorPrimaries: "bt2020", colorSpace: "bt2020nc" },
+ "png",
+ ),
+ );
+
+ await expect(
+ inspectHdrAutoPromotion(PROJECT, extractMetadata, bundledMedia([], ["assets/hdr.png"])),
+ ).resolves.toMatchObject({ triggeringAsset: "assets/hdr.png" });
+ });
+});
diff --git a/packages/cli/src/utils/hdrPromotion.ts b/packages/cli/src/utils/hdrPromotion.ts
new file mode 100644
index 0000000000..ed8a2566d4
--- /dev/null
+++ b/packages/cli/src/utils/hdrPromotion.ts
@@ -0,0 +1,61 @@
+import {
+ extractMediaMetadata,
+ findHdrAutoPromotion,
+ resolveProjectRelativeSrc,
+ type HdrAutoPromotion,
+} from "@hyperframes/engine";
+import type { ProjectDir } from "./project.js";
+import { loadProducer } from "./producer.js";
+
+type ExtractMetadata = typeof extractMediaMetadata;
+type MediaSource = { src: string };
+type RenderMedia = { videos: readonly MediaSource[]; images: readonly MediaSource[] };
+
+interface InspectHdrAutoPromotionDependencies {
+ bundleHtml(projectDir: string): Promise<string>;
+ collectMedia(html: string): RenderMedia | Promise<RenderMedia>;
+}
+
+async function bundleProjectHtml(projectDir: string): Promise<string> {
+ const { bundleToSingleHtml } = await import("@hyperframes/core/compiler");
+ return bundleToSingleHtml(projectDir);
+}
+
+async function collectBundledRenderMedia(html: string): Promise<RenderMedia> {
+ const producer = (await loadProducer()) as {
+ collectRenderMedia?: (source: string) => RenderMedia;
+ };
+ if (!producer.collectRenderMedia) throw new Error("Render media collector unavailable");
+ return producer.collectRenderMedia(html);
+}
+
+const DEFAULT_DEPENDENCIES: InspectHdrAutoPromotionDependencies = {
+ bundleHtml: bundleProjectHtml,
+ collectMedia: collectBundledRenderMedia,
+};
+
+export async function inspectHdrAutoPromotion(
+ project: ProjectDir,
+ extractMetadata: ExtractMetadata = extractMediaMetadata,
+ dependencies: InspectHdrAutoPromotionDependencies = DEFAULT_DEPENDENCIES,
+): Promise<HdrAutoPromotion | null> {
+ const assets: Array<{
+ asset: string;
+ colorSpace: Awaited<ReturnType<typeof extractMediaMetadata>>["colorSpace"];
+ }> = [];
+ const media = await dependencies.collectMedia(await dependencies.bundleHtml(project.dir));
+ for (const { src } of [...media.videos, ...media.images]) {
+ const path = /^https?:\/\//i.test(src)
+ ? src
+ : resolveProjectRelativeSrc(src, project.dir, project.dir);
+ try {
+ assets.push({
+ asset: src,
+ colorSpace: (await extractMetadata(path)).colorSpace,
+ });
+ } catch {
+ continue;
+ }
+ }
+ return findHdrAutoPromotion(assets);
+}
diff --git a/packages/engine/src/index.ts b/packages/engine/src/index.ts
index 0339841e8c..40da2ccdfc 100644
--- a/packages/engine/src/index.ts
+++ b/packages/engine/src/index.ts
@@ -400,9 +400,14 @@ export {
detectTransfer,
getHdrEncoderColorParams,
analyzeCompositionHdr,
+ findHdrAutoPromotion,
+ formatHdrAutoPromotionWarning,
+ sanitizeHdrAutoPromotionAsset,
DEFAULT_HDR10_MASTERING,
+ HDR_AUTO_PROMOTION_PIPELINE,
type HdrTransfer,
type HdrEncoderColorParams,
+ type HdrAutoPromotion,
type CompositionHdrInfo,
type HdrMasteringMetadata,
} from "./utils/hdr.js";
diff --git a/packages/engine/src/utils/hdr.test.ts b/packages/engine/src/utils/hdr.test.ts
index 79d3562b05..644b5a6825 100644
--- a/packages/engine/src/utils/hdr.test.ts
+++ b/packages/engine/src/utils/hdr.test.ts
@@ -4,6 +4,9 @@ import {
detectTransfer,
getHdrEncoderColorParams,
analyzeCompositionHdr,
+ findHdrAutoPromotion,
+ formatHdrAutoPromotionWarning,
+ sanitizeHdrAutoPromotionAsset,
DEFAULT_HDR10_MASTERING,
} from "./hdr.js";
import type { VideoColorSpace } from "./ffprobe.js";
@@ -189,3 +192,35 @@ describe("analyzeCompositionHdr", () => {
});
});
});
+
+describe("HDR auto-promotion reporting", () => {
+ const pq: VideoColorSpace = {
+ colorTransfer: "smpte2084",
+ colorPrimaries: "bt2020",
+ colorSpace: "bt2020nc",
+ };
+
+ it("reports the first HDR asset and the promoted output pipeline", () => {
+ const promotion = findHdrAutoPromotion([
+ {
+ asset: "assets/intro.mp4",
+ colorSpace: { colorTransfer: "bt709", colorPrimaries: "bt709", colorSpace: "bt709" },
+ },
+ { asset: "assets/hero-hdr.mp4?token=secret#preview", colorSpace: pq },
+ ]);
+
+ expect(promotion).toEqual({
+ triggeringAsset: "assets/hero-hdr.mp4",
+ output: { colorSpace: "BT.2020", codec: "HEVC Main10" },
+ });
+ expect(formatHdrAutoPromotionWarning(promotion!)).toBe(
+ '[Render] HDR auto-promotion triggered by "assets/hero-hdr.mp4" — output: BT.2020 / HEVC Main10',
+ );
+ });
+
+ it("removes line breaks before an asset reaches logs", () => {
+ expect(sanitizeHdrAutoPromotionAsset("assets/hero.mp4\r\n[ERROR] forged")).toBe(
+ "assets/hero.mp4",
+ );
+ });
+});
diff --git a/packages/engine/src/utils/hdr.ts b/packages/engine/src/utils/hdr.ts
index 1dee944cd3..7950962247 100644
--- a/packages/engine/src/utils/hdr.ts
+++ b/packages/engine/src/utils/hdr.ts
@@ -111,6 +111,36 @@ export interface CompositionHdrInfo {
dominantTransfer: HdrTransfer | null;
}
+export const HDR_AUTO_PROMOTION_PIPELINE = {
+ colorSpace: "BT.2020",
+ codec: "HEVC Main10",
+} as const;
+
+export interface HdrAutoPromotion {
+ triggeringAsset: string;
+ output: typeof HDR_AUTO_PROMOTION_PIPELINE;
+}
+
+export function sanitizeHdrAutoPromotionAsset(asset: string): string {
+ return asset.split(/[\r\n?#]/, 1)[0] ?? "";
+}
+
+export function findHdrAutoPromotion(
+ sources: readonly { asset: string; colorSpace: VideoColorSpace | null }[],
+): HdrAutoPromotion | null {
+ const source = sources.find(({ colorSpace }) => isHdrColorSpace(colorSpace));
+ return source
+ ? {
+ triggeringAsset: sanitizeHdrAutoPromotionAsset(source.asset),
+ output: HDR_AUTO_PROMOTION_PIPELINE,
+ }
+ : null;
+}
+
+export function formatHdrAutoPromotionWarning(promotion: HdrAutoPromotion): string {
+ return `[Render] HDR auto-promotion triggered by "${promotion.triggeringAsset}" — output: ${promotion.output.colorSpace} / ${promotion.output.codec}`;
+}
+
/**
* Analyze a set of video color spaces to determine if the composition
* contains HDR content and what the dominant transfer function is.
diff --git a/packages/producer/src/index.ts b/packages/producer/src/index.ts
index 4a91156f14..d8ecb626d0 100644
--- a/packages/producer/src/index.ts
+++ b/packages/producer/src/index.ts
@@ -108,6 +108,7 @@ export {
// ── Utilities ───────────────────────────────────────────────────────────────
export { normalizeErrorMessage } from "./utils/errorMessage.js";
+export { collectRenderMedia, type RenderMedia } from "./services/renderMediaCollector.js";
// Font localization: fetch + embed @font-face rules for requested families
// (including those declared only via a remote <link>) so a bundled composition
// renders with the real font instead of a fallback, regardless of network
diff --git a/packages/producer/src/services/render/hdrMode.test.ts b/packages/producer/src/services/render/hdrMode.test.ts
index b8ab196be4..071a061bd3 100644
--- a/packages/producer/src/services/render/hdrMode.test.ts
+++ b/packages/producer/src/services/render/hdrMode.test.ts
@@ -7,7 +7,7 @@
import { describe, expect, it, vi } from "vitest";
import type { ExtractionResult, VideoColorSpace } from "@hyperframes/engine";
-import { resolveEffectiveHdrMode } from "./hdrMode.js";
+import { findRenderHdrAutoPromotionTrigger, resolveEffectiveHdrMode } from "./hdrMode.js";
function makeLog() {
return { error: vi.fn(), warn: vi.fn(), info: vi.fn(), debug: vi.fn() };
@@ -53,14 +53,19 @@ describe("resolveEffectiveHdrMode", () => {
it("auto-detects HDR from video sources when format=mp4", () => {
const log = makeLog();
const result = resolveEffectiveHdrMode({
- hdrMode: "auto",
+ hdrMode: undefined,
outputFormat: "mp4",
extractionResult: extractionWith([HDR_PQ]),
imageColorSpaces: [],
+ autoPromotionTrigger: "assets/source-hdr.mp4?token=secret\r\n[ERROR] forged",
log,
});
expect(result).toEqual({ transfer: "pq" });
- expect(log.info).toHaveBeenCalledWith(expect.stringContaining("auto-detected from source(s)"));
+ expect(log.warn).toHaveBeenCalledTimes(1);
+ expect(log.warn).toHaveBeenCalledWith(
+ '[Render] HDR auto-promotion triggered by "assets/source-hdr.mp4" — output: BT.2020 / HEVC Main10',
+ );
+ expect(log.info).not.toHaveBeenCalled();
});
it("auto-detects SDR with no HDR sources", () => {
@@ -145,3 +150,30 @@ describe("resolveEffectiveHdrMode", () => {
);
});
});
+
+describe("findRenderHdrAutoPromotionTrigger", () => {
+ it("maps a successfully extracted remote HDR video back to its authored source", () => {
+ const extractionResult = extractionWith([HDR_PQ])!;
+ extractionResult.extracted[0]!.videoId = "remote-video";
+
+ expect(
+ findRenderHdrAutoPromotionTrigger({
+ extractionResult,
+ videos: [{ id: "remote-video", src: "https://media.example/hdr.mp4?token=secret" }],
+ images: [],
+ nativeHdrImageIds: new Set(),
+ }),
+ ).toBe("https://media.example/hdr.mp4?token=secret");
+ });
+
+ it("falls back to the native HDR image when no extracted video is HDR", () => {
+ expect(
+ findRenderHdrAutoPromotionTrigger({
+ extractionResult: undefined,
+ videos: [{ id: "unextracted-video", src: "assets/unextracted.mp4" }],
+ images: [{ id: "hero-image", src: "assets/hero.png" }],
+ nativeHdrImageIds: new Set(["hero-image"]),
+ }),
+ ).toBe("assets/hero.png");
+ });
+});
diff --git a/packages/producer/src/services/render/hdrMode.ts b/packages/producer/src/services/render/hdrMode.ts
index 4c74381a4f..5c54d18a97 100644
--- a/packages/producer/src/services/render/hdrMode.ts
+++ b/packages/producer/src/services/render/hdrMode.ts
@@ -9,18 +9,80 @@
* formats can carry an HDR signal.
*/
-import { analyzeCompositionHdr } from "@hyperframes/engine";
+import {
+ analyzeCompositionHdr,
+ formatHdrAutoPromotionWarning,
+ HDR_AUTO_PROMOTION_PIPELINE,
+ isHdrColorSpace,
+ sanitizeHdrAutoPromotionAsset,
+} from "@hyperframes/engine";
import type { ExtractionResult, HdrTransfer, VideoColorSpace } from "@hyperframes/engine";
import type { ProducerLogger } from "../../logger.js";
import type { RenderConfig } from "../renderOrchestrator.js";
-export function resolveEffectiveHdrMode(input: {
+type EffectiveHdr = { transfer: HdrTransfer } | undefined;
+type HdrModeInput = {
hdrMode: RenderConfig["hdrMode"];
outputFormat: NonNullable<RenderConfig["format"]>;
extractionResult: ExtractionResult | null | undefined;
imageColorSpaces: (VideoColorSpace | null)[];
+ autoPromotionTrigger?: string;
log: ProducerLogger;
-}): { transfer: HdrTransfer } | undefined {
+};
+
+export function findRenderHdrAutoPromotionTrigger(input: {
+ extractionResult: ExtractionResult | null | undefined;
+ videos: readonly { id: string; src: string }[];
+ images: readonly { id: string; src: string }[];
+ nativeHdrImageIds: ReadonlySet<string>;
+}): string | undefined {
+ for (const extracted of input.extractionResult?.extracted ?? []) {
+ if (!isHdrColorSpace(extracted.metadata.colorSpace)) continue;
+ const source = input.videos.find(({ id }) => id === extracted.videoId)?.src;
+ if (source) return source;
+ }
+ return input.images.find(({ id }) => input.nativeHdrImageIds.has(id))?.src;
+}
+
+function logHdrResolution(
+ input: HdrModeInput,
+ hdrMode: NonNullable<RenderConfig["hdrMode"]>,
+ effectiveHdr: EffectiveHdr,
+ forcedHdrWithoutSources: boolean,
+): void {
+ if (forcedHdrWithoutSources) {
+ input.log.warn(
+ "[Render] HDR forced by --hdr flag, but no HDR sources were detected — defaulting to HLG. SDR-only compositions may look perceptually wrong on HDR displays.",
+ );
+ }
+ if (!effectiveHdr) {
+ input.log.info(
+ hdrMode === "force-sdr"
+ ? "[Render] SDR forced by --sdr flag"
+ : "[Render] No HDR sources detected — rendering SDR",
+ );
+ return;
+ }
+ if (hdrMode === "auto") {
+ input.log.warn(
+ formatHdrAutoPromotionWarning({
+ triggeringAsset: sanitizeHdrAutoPromotionAsset(
+ input.autoPromotionTrigger ?? "an HDR-tagged asset",
+ ),
+ output: HDR_AUTO_PROMOTION_PIPELINE,
+ }),
+ );
+ return;
+ }
+ const reason = forcedHdrWithoutSources
+ ? "forced by --hdr flag (no HDR sources detected — defaulting to HLG)"
+ : "forced by --hdr flag";
+ input.log.info(
+ `[Render] HDR ${reason} — output: ${effectiveHdr.transfer.toUpperCase()} (BT.2020, 10-bit H.265)`,
+ );
+}
+
+export function resolveEffectiveHdrMode(input: HdrModeInput): EffectiveHdr {
const hdrMode = input.hdrMode ?? "auto";
const videoColorSpaces = (input.extractionResult?.extracted ?? []).map(
(ext) => ext.metadata.colorSpace,
@@ -28,7 +90,7 @@ export function resolveEffectiveHdrMode(input: {
const allColorSpaces = [...videoColorSpaces, ...input.imageColorSpaces];
const info = allColorSpaces.length > 0 ? analyzeCompositionHdr(allColorSpaces) : null;
- let effectiveHdr: { transfer: HdrTransfer } | undefined;
+ let effectiveHdr: EffectiveHdr;
let forcedHdrWithoutSources = false;
if (hdrMode === "force-sdr") {
@@ -55,28 +117,7 @@ export function resolveEffectiveHdrMode(input: {
effectiveHdr = undefined;
}
- if (forcedHdrWithoutSources) {
- input.log.warn(
- "[Render] HDR forced by --hdr flag, but no HDR sources were detected — defaulting to HLG. SDR-only compositions may look perceptually wrong on HDR displays.",
- );
- }
- if (effectiveHdr) {
- let reason: string;
- if (hdrMode === "force-hdr") {
- reason = forcedHdrWithoutSources
- ? "forced by --hdr flag (no HDR sources detected — defaulting to HLG)"
- : "forced by --hdr flag";
- } else {
- reason = "auto-detected from source(s)";
- }
- input.log.info(
- `[Render] HDR ${reason} — output: ${effectiveHdr.transfer.toUpperCase()} (BT.2020, 10-bit H.265)`,
- );
- } else if (hdrMode === "force-sdr") {
- input.log.info("[Render] SDR forced by --sdr flag");
- } else {
- input.log.info("[Render] No HDR sources detected — rendering SDR");
- }
+ logHdrResolution(input, hdrMode, effectiveHdr, forcedHdrWithoutSources);
return effectiveHdr;
}
diff --git a/packages/producer/src/services/renderOrchestrator.ts b/packages/producer/src/services/renderOrchestrator.ts
index 1d8a4b8562..5c11b78c81 100644
--- a/packages/producer/src/services/renderOrchestrator.ts
+++ b/packages/producer/src/services/renderOrchestrator.ts
@@ -127,7 +127,7 @@ import {
} from "./render/capturePlan.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
import { formatCaptureFrameName } from "../utils/paths.js";
-import { resolveEffectiveHdrMode } from "./render/hdrMode.js";
+import { findRenderHdrAutoPromotionTrigger, resolveEffectiveHdrMode } from "./render/hdrMode.js";
import {
buildRenderPerfSummary,
pushWorkerDedupPerfs,
@@ -2661,11 +2661,18 @@ async function executeRenderPipeline(input: {
assertVideoFrameCoverage(coverageReports, coverageThreshold);
// ── HDR auto-detection ──────────────────────────────────────────────
+ const autoPromotionTrigger = findRenderHdrAutoPromotionTrigger({
+ extractionResult,
+ videos: composition.videos,
+ images: composition.images,
+ nativeHdrImageIds,
+ });
const effectiveHdr = resolveEffectiveHdrMode({
hdrMode: job.config.hdrMode,
outputFormat,
extractionResult,
imageColorSpaces,
+ autoPromotionTrigger,
log,
});
observability.checkpoint("hdr_detection", "resolved", {
diff --git a/skills-manifest.json b/skills-manifest.json
index b97145e191..e411541e93 100644
--- a/skills-manifest.json
+++ b/skills-manifest.json
@@ -30,7 +30,7 @@
"files": 7
},
"hyperframes-cli": {
- "hash": "bafd44ef2c17c02b",
+ "hash": "3fa1be752aac3ae8",
"files": 11
},
"hyperframes-core": {
diff --git a/skills/hyperframes-cli/references/lint-validate-inspect.md b/skills/hyperframes-cli/references/lint-validate-inspect.md
index 2cb92660f1..73308c6910 100644
--- a/skills/hyperframes-cli/references/lint-validate-inspect.md
+++ b/skills/hyperframes-cli/references/lint-validate-inspect.md
@@ -30,7 +30,7 @@ Lints `index.html` and all files in `compositions/`. Reports errors (must fix),
```bash
npx hyperframes check # current directory: the full browser gate
npx hyperframes check ./my-project # specific project
-npx hyperframes check --json # agent-readable envelope {ok, lint, runtime, layout, motion, contrast, snapshots}
+npx hyperframes check --json # agent-readable envelope {ok, lint, runtime, layout, motion, contrast, hdr, snapshots}
npx hyperframes check --snapshots # also write overview frames (annotated) + per-finding crops
npx hyperframes check --samples 15 # denser timeline sweep (default 9)
npx hyperframes check --at 1.5,4,7.25 # explicit hero-frame timestamps