Files
hyperframes/packages/cli/src/utils/hdrPromotion.ts
T
Miguel Ángel 60f711686c fix(producer): auto renders with color-graded media stay SDR instead of promoting to HDR (#6671)
* fix(producer): auto renders with color-graded media stay SDR instead of promoting to HDR

* fix(producer): keep auto renders SDR when a graded canvas is present
2026-10-31 16:16:06 +00:00

34 lines
989 B
TypeScript

import {
extractMediaMetadata,
findHdrAutoPromotion,
gradingKeepsSdr,
type HdrAutoPromotion,
} from "@hyperframes/engine";
import type { ProjectDir } from "./project.js";
import { mediaPath, type ProjectMedia } from "./projectMedia.js";
type ExtractMetadata = typeof extractMediaMetadata;
export async function inspectHdrAutoPromotion(
project: ProjectDir,
media: Pick<ProjectMedia, "videos" | "images">,
extractMetadata: ExtractMetadata = extractMediaMetadata,
): Promise<HdrAutoPromotion | null> {
if (gradingKeepsSdr("auto", media)) return null;
const assets: Array<{
asset: string;
colorSpace: Awaited<ReturnType<typeof extractMediaMetadata>>["colorSpace"];
}> = [];
for (const { src } of [...media.videos, ...media.images]) {
try {
assets.push({
asset: src,
colorSpace: (await extractMetadata(mediaPath(src, project.dir))).colorSpace,
});
} catch {
continue;
}
}
return findHdrAutoPromotion(assets);
}