mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
* fix(cli): check and info --media leave remote media sources unprobed mediaPath handed an http(s) src to ffprobe, so check's HDR and sound probes and info --media's clip lengths opened composition URLs from the CLI process. Remote sources are now left unprobed, as timeline and check's clip audit already do. check's report lists the remote video and image sources HDR inspection skipped under hdr.remoteNotInspected, and a remote video that may carry sound keeps the film from being reported as silent. * fix(cli): drop credentials from remoteNotInspected and document unprobed remote media
135 lines
4.5 KiB
TypeScript
135 lines
4.5 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import type { VideoColorSpace } from "@hyperframes/engine";
|
|
import { resolveProjectRelativeSrc } from "@hyperframes/engine";
|
|
import { inspectHdrAutoPromotion, remoteMediaNotInspected } 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 {
|
|
videos: videos.map((src) => ({ src, hasAudio: false })),
|
|
images: images.map((src) => ({ src })),
|
|
};
|
|
}
|
|
|
|
describe("inspectHdrAutoPromotion", () => {
|
|
it("reports no promotion when graded media keeps the render SDR, without probing", async () => {
|
|
const extractMetadata = vi.fn(async () => metadata(HDR));
|
|
const media = bundledMedia(["assets/source-hdr.mp4"], []);
|
|
|
|
await expect(
|
|
inspectHdrAutoPromotion(
|
|
PROJECT,
|
|
{ ...media, images: [{ src: "assets/look.png", graded: true }] },
|
|
extractMetadata,
|
|
),
|
|
).resolves.toBeNull();
|
|
expect(extractMetadata).not.toHaveBeenCalled();
|
|
});
|
|
|
|
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,
|
|
bundledMedia(["assets/source-hdr.mp4?token=secret#preview"], []),
|
|
extractMetadata,
|
|
),
|
|
).resolves.toEqual({
|
|
triggeringAsset: "assets/source-hdr.mp4",
|
|
output: { colorSpace: "BT.2020", codec: "HEVC Main10" },
|
|
});
|
|
expect(extractMetadata).toHaveBeenCalledOnce();
|
|
expect(extractMetadata).toHaveBeenCalledWith(assetPath);
|
|
});
|
|
|
|
it("does not probe a remote video or image, and names it as not inspected", async () => {
|
|
const extractMetadata = vi.fn(async () => metadata(HDR));
|
|
const media = bundledMedia(
|
|
["https://media.example/remote-hdr.mp4?token=secret"],
|
|
["http://user:pass@127.0.0.1:8080/hdr.png"],
|
|
);
|
|
|
|
await expect(inspectHdrAutoPromotion(PROJECT, media, extractMetadata)).resolves.toBeNull();
|
|
expect(extractMetadata).not.toHaveBeenCalled();
|
|
expect(remoteMediaNotInspected(media)).toEqual([
|
|
"https://media.example/remote-hdr.mp4",
|
|
"http://127.0.0.1:8080/hdr.png",
|
|
]);
|
|
});
|
|
|
|
it("names no remote source when graded media keeps the render SDR", () => {
|
|
expect(
|
|
remoteMediaNotInspected({
|
|
videos: [{ src: "https://media.example/remote-hdr.mp4", hasAudio: false }],
|
|
images: [{ src: "assets/look.png", graded: true }],
|
|
}),
|
|
).toEqual([]);
|
|
});
|
|
|
|
it("uses the first HDR video before an HDR image and still inspects images", async () => {
|
|
const firstVideo = "assets/first-hdr-video.mp4";
|
|
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,
|
|
bundledMedia(["assets/sdr.mp4", firstVideo], [image]),
|
|
extractMetadata,
|
|
),
|
|
).resolves.toMatchObject({ triggeringAsset: "assets/first-hdr-video.mp4" });
|
|
expect(extractMetadata).toHaveBeenCalledWith(
|
|
resolveProjectRelativeSrc("assets/sdr.mp4", PROJECT.dir, PROJECT.dir),
|
|
);
|
|
expect(extractMetadata).toHaveBeenCalledWith(
|
|
resolveProjectRelativeSrc(firstVideo, PROJECT.dir, PROJECT.dir),
|
|
);
|
|
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, bundledMedia([], ["assets/hdr.png"]), extractMetadata),
|
|
).resolves.toMatchObject({ triggeringAsset: "assets/hdr.png" });
|
|
});
|
|
});
|