fix(cli): check and info never probe a composition's remote media URLs (#7942)

* 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
This commit is contained in:
Michael Wang
2026-11-16 11:11:31 +00:00
committed by GitHub
parent a2e7306b2f
commit 78648113db
10 changed files with 133 additions and 35 deletions
+6 -2
View File
@@ -1291,6 +1291,10 @@ a source with no audio track or that cannot be read as audio (error: render
stops), a clip that starts past the end of its file, a clip whose played part is
silent (warnings), and a film with no sound at all (info).
`check` opens no remote media. A remote `src` is not probed for audio or HDR: a
remote `<video>` the render may hear counts as sound, and `hdr.remoteNotInspected`
lists the remote videos and images whose HDR colour space was not read.
When the browser never ran (no composition to load, a linter crash, or a
browser launch failure), `browserSkipped` is `true` and the `layout`, `motion` and `contrast`
sections are empty, not clean.
@@ -1420,7 +1424,7 @@ whole-composition `keepsMoving` assertion sets its own limit.
#### Audio findings
The `audio` section checks the clips the render mixes. It runs even when lint
stops the browser pass, and remote sources are not fetched.
stops the browser pass, and remote sources are not probed.
| Code | Severity | Triggers when | Fix |
| ------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
@@ -2221,7 +2225,7 @@ duration, element counts by type, track count, and total size.
ID, duration, resolution, and element count. Both take `--json`.
`npx hyperframes info --media --json` adds `heard`: every clip the render mixes, scenes included, on the film's clock,
each with `src`, `start`, `end` (where it stops, or where its media runs out if sooner; `0` runs to the media's end),
`mediaStart`, `playbackRate`, `volume` and `type`.
`mediaStart`, `playbackRate`, `volume` and `type`. A remote clip is not probed, so it keeps the end it was given.
### `update`
+24 -1
View File
@@ -332,6 +332,7 @@ function dependencies(
writeSnapshot?: CheckDependencies["writeSnapshot"];
captureFindingCrops?: CheckDependencies["captureFindingCrops"];
captureFindingFrames?: CheckDependencies["captureFindingFrames"];
collectMedia?: NonNullable<CheckDependencies["collectMedia"]>;
inspectHdrAutoPromotion?: NonNullable<CheckDependencies["inspectHdrAutoPromotion"]>;
inspectAudio?: NonNullable<CheckDependencies["inspectAudio"]>;
} = {},
@@ -360,7 +361,8 @@ function dependencies(
captureFindingCrops: options.captureFindingCrops ?? vi.fn(async () => []),
captureFindingFrames:
options.captureFindingFrames ?? vi.fn(async () => ({ written: [], inspected: [] })),
collectMedia: vi.fn(async () => ({ videos: [], images: [], audios: [], html: "" })),
collectMedia:
options.collectMedia ?? vi.fn(async () => ({ videos: [], images: [], audios: [], html: "" })),
inspectHdrAutoPromotion: options.inspectHdrAutoPromotion ?? vi.fn(async () => null),
inspectAudio: options.inspectAudio ?? vi.fn(async () => []),
};
@@ -803,6 +805,27 @@ it("distinguishes unavailable HDR inspection from no promotion", async () => {
expect(report.hdr).toEqual({ autoPromotion: null, inspection: "unavailable" });
});
it("names the remote sources HDR inspection did not probe", async () => {
const { report } = await runScenario(
fakeDriver(),
{},
{
collectMedia: vi.fn(async () => ({
videos: [{ src: "https://media.example/clip.mp4?token=secret", hasAudio: false }],
images: [{ src: "assets/still.png" }, { src: "http://127.0.0.1:8080/still.png" }],
audios: [],
html: "",
})),
},
);
expect(report.hdr).toEqual({
autoPromotion: null,
inspection: "available",
remoteNotInspected: ["https://media.example/clip.mp4", "http://127.0.0.1:8080/still.png"],
});
});
it("prints composition text in a finding with its control characters as visible escapes", async () => {
const planted: CheckFinding = {
code: "audio_source_unreadable",
+19
View File
@@ -189,6 +189,25 @@ describe.skipIf(!ffmpeg)("inspectAudio", () => {
});
});
describe("inspectAudio on a remote video", () => {
it("does not probe a remote video, and does not call a film it may sound in silent", async () => {
const probed: string[] = [];
const findings = await inspectAudio(
dir,
"index.html",
media([], [{ src: "http://127.0.0.1:8080/talk.mp4", hasAudio: true }]),
{
renderAccepts: () => Promise.reject(new Error("no audio clips to probe")),
probeAudio: () => Promise.reject(new Error("no audio clips to probe")),
isSilent: () => Promise.reject(new Error("no audio clips to decode")),
videoHasAudio: async (path) => (probed.push(path), false),
},
);
expect(probed).toEqual([]);
expect(findings).toEqual([]);
});
});
describe("inspectAudio on a project of many clips trimmed from few files", () => {
it("probes each file once, however many clips are cut from it", async () => {
const probes = { accepts: 0, audio: 0, silence: 0 };
+6 -4
View File
@@ -14,7 +14,7 @@ import { createProbeGate } from "../timeline/describeProject.js";
import { findingAtRoot } from "./checkFindings.js";
import { loadProducer } from "./producer.js";
import type { CheckFinding } from "./checkTypes.js";
import { mediaPath, type ProjectMedia } from "./projectMedia.js";
import { isRemoteMediaSrc, mediaPath, type ProjectMedia } from "./projectMedia.js";
export interface AudioCheckDependencies {
/** Render's own media-type rule for a mixed clip; `null` when the file does not probe. */
@@ -132,14 +132,16 @@ export async function inspectAudio(
return findings.flat();
}
/** Render adds an unmuted video's own sound when its file has an audio stream. */
/** Render adds an unmuted video's own sound when its file has an audio stream; a remote video is not probed, so it may. */
async function videoSoundsAutoDetected(
projectDir: string,
media: ProjectMedia,
dependencies: AudioCheckDependencies,
): Promise<boolean> {
for (const video of media.videos) {
const path = video.hasAudio ? mediaPath(video.src, projectDir) : null;
if (!video.hasAudio) continue;
if (isRemoteMediaSrc(video.src)) return true;
const path = mediaPath(video.src, projectDir);
if (path && (await dependencies.videoHasAudio(path).catch(() => false))) return true;
}
return false;
@@ -154,7 +156,7 @@ async function inspectClip(
dependencies: AudioCheckDependencies,
): Promise<CheckFinding[]> {
const path = mediaPath(clip.src, projectDir);
// ponytail: remote sources are not fetched; missing local files are lint's audio_src_not_found.
// ponytail: mediaPath is null for a remote source; missing local files are lint's audio_src_not_found.
if (path === null || path === clip.src || !existsSync(path)) return [];
const problem = await clipProblem(path, clip, dependencies);
if (!problem) return [];
+13 -10
View File
@@ -58,7 +58,7 @@ import {
} from "./motionAudit.js";
import { findMotionSpec, readMotionSpec, type MotionAssertion } from "./motionSpec.js";
import { auditCraft } from "./craftAudit.js";
import { inspectHdrAutoPromotion } from "./hdrPromotion.js";
import { inspectHdrAutoPromotion, remoteMediaNotInspected } from "./hdrPromotion.js";
import { collectProjectMedia, type ProjectMedia } from "./projectMedia.js";
import { normalizeErrorMessage } from "./errorMessage.js";
import {
@@ -1767,8 +1767,7 @@ export async function runCheckPipeline(
{ kind: "none" },
[],
[],
hdr.autoPromotion,
hdr.inspection,
hdr,
await audio,
);
}
@@ -1813,8 +1812,7 @@ export async function runCheckPipeline(
motion,
specFindings,
snapshotFiles,
hdr.autoPromotion,
hdr.inspection,
hdr,
await audio,
);
outcome = {
@@ -2085,8 +2083,7 @@ function buildReport(
motion: MotionSpecResolution,
extraMotionFindings: CheckFinding[],
snapshotFiles: string[],
hdrPromotion: CheckReport["hdr"]["autoPromotion"] = null,
hdrInspection: CheckReport["hdr"]["inspection"] = "available",
hdr: CheckReport["hdr"] = { autoPromotion: null, inspection: "available" },
audioFindings: CheckFinding[] = [],
): CheckReport {
const shaping = options.components?.length
@@ -2148,7 +2145,7 @@ function buildReport(
samples: browser.craft.samples,
},
audio: audioSection,
hdr: { autoPromotion: hdrPromotion, inspection: hdrInspection },
hdr,
snapshots: {
enabled: options.snapshots,
files: snapshotFiles,
@@ -2454,11 +2451,17 @@ async function inspectProjectMedia(
const media = (dependencies.collectMedia ?? collectMedia)(project);
let hdr: CheckReport["hdr"];
try {
const found = await media;
const promotion = (dependencies.inspectHdrAutoPromotion ?? inspectHdrAutoPromotion)(
project,
await media,
found,
);
hdr = { autoPromotion: await promotion, inspection: "available" };
const remote = remoteMediaNotInspected(found);
hdr = {
autoPromotion: await promotion,
inspection: "available",
...(remote.length > 0 ? { remoteNotInspected: remote } : {}),
};
} catch {
hdr = { autoPromotion: null, inspection: "unavailable" };
}
+5 -1
View File
@@ -424,7 +424,11 @@ export interface CheckReport {
};
craft: CheckSection<CraftFinding> & { enabled: boolean; step: number; samples: number };
audio: CheckSection;
hdr: { autoPromotion: HdrAutoPromotion | null; inspection: "available" | "unavailable" };
hdr: {
autoPromotion: HdrAutoPromotion | null;
inspection: "available" | "unavailable";
remoteNotInspected?: string[];
};
snapshots: { enabled: boolean; files: string[]; times: number[]; findingFiles: string[] };
}
+26 -13
View File
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import type { VideoColorSpace } from "@hyperframes/engine";
import { resolveProjectRelativeSrc } from "@hyperframes/engine";
import { inspectHdrAutoPromotion } from "./hdrPromotion.js";
import { inspectHdrAutoPromotion, remoteMediaNotInspected } from "./hdrPromotion.js";
const PROJECT = { dir: "/project", name: "hdr-check", indexPath: "/project/index.html" };
const HDR: VideoColorSpace = {
@@ -70,21 +70,32 @@ describe("inspectHdrAutoPromotion", () => {
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";
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, bundledMedia([remote], []), extractMetadata),
).resolves.toEqual({
triggeringAsset: "https://media.example/remote-hdr.mp4",
output: { colorSpace: "BT.2020", codec: "HEVC Main10" },
});
expect(extractMetadata).toHaveBeenCalledWith(remote);
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 = "https://media.example/first-hdr-video.mp4?token=secret";
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),
@@ -96,11 +107,13 @@ describe("inspectHdrAutoPromotion", () => {
bundledMedia(["assets/sdr.mp4", firstVideo], [image]),
extractMetadata,
),
).resolves.toMatchObject({ triggeringAsset: "https://media.example/first-hdr-video.mp4" });
).resolves.toMatchObject({ triggeringAsset: "assets/first-hdr-video.mp4" });
expect(extractMetadata).toHaveBeenCalledWith(
resolveProjectRelativeSrc("assets/sdr.mp4", PROJECT.dir, PROJECT.dir),
);
expect(extractMetadata).toHaveBeenCalledWith(firstVideo);
expect(extractMetadata).toHaveBeenCalledWith(
resolveProjectRelativeSrc(firstVideo, PROJECT.dir, PROJECT.dir),
);
expect(extractMetadata).toHaveBeenCalledWith(
resolveProjectRelativeSrc("assets/fallback-hdr-image.png", PROJECT.dir, PROJECT.dir),
);
+14 -1
View File
@@ -2,10 +2,11 @@ import {
extractMediaMetadata,
findHdrAutoPromotion,
gradingKeepsSdr,
sanitizeHdrAutoPromotionAsset,
type HdrAutoPromotion,
} from "@hyperframes/engine";
import type { ProjectDir } from "./project.js";
import { mediaPath, type ProjectMedia } from "./projectMedia.js";
import { isRemoteMediaSrc, mediaPath, type ProjectMedia } from "./projectMedia.js";
type ExtractMetadata = typeof extractMediaMetadata;
@@ -30,3 +31,15 @@ export async function inspectHdrAutoPromotion(
}
return findHdrAutoPromotion(assets);
}
export function remoteMediaNotInspected(media: Pick<ProjectMedia, "videos" | "images">): string[] {
if (gradingKeepsSdr("auto", media)) return [];
const remote = [...media.videos, ...media.images].filter(({ src }) => isRemoteMediaSrc(src));
return [
...new Set(remote.map(({ src }) => withoutCredentials(sanitizeHdrAutoPromotionAsset(src)))),
];
}
function withoutCredentials(url: string): string {
return url.replace(/^(https?:\/\/)[^/@]*@/i, "$1");
}
+14 -1
View File
@@ -46,7 +46,8 @@ describe("mediaPath", () => {
expect(mediaPath("media/id_rsa", dir)).toBeNull();
expect(mediaPath("../../outside.mp4", dir)).toBeNull();
expect(mediaPath("media/clip.mp4", dir)).toBe(join(dir, "media", "clip.mp4"));
expect(mediaPath("https://cdn.example.com/a.mp4", dir)).toBe("https://cdn.example.com/a.mp4");
expect(mediaPath("https://cdn.example.com/a.mp4", dir)).toBeNull();
expect(mediaPath("HTTP://127.0.0.1:8080/a.mp4", dir)).toBeNull();
});
it("does not probe a private file a scene's audio names", async () => {
@@ -57,6 +58,18 @@ describe("mediaPath", () => {
await heardClips(root, { seconds: async (path) => (seen.push(path), 6) });
expect(seen).toEqual([]);
});
it("does not probe a remote clip, which keeps the end it was given", async () => {
const seen: string[] = [];
const root = project(
'<audio id="a" src="http://127.0.0.1:8080/voice.wav" data-start="0" data-duration="4"></audio>',
);
const clips = await heardClips(root, { seconds: async (path) => (seen.push(path), 2) });
expect(seen).toEqual([]);
expect(clips.map(({ src, start, end }) => ({ src, start, end }))).toEqual([
{ src: "http://127.0.0.1:8080/voice.wav", start: 10, end: 14 },
]);
});
});
describe("heardClips", () => {
+6 -2
View File
@@ -27,9 +27,13 @@ export async function collectProjectMedia(projectDir: string): Promise<ProjectMe
return { ...producer.collectRenderMedia(html), html };
}
/** The path the render reads a media `src` from, resolved like render; null for a local file it never opens. */
export function isRemoteMediaSrc(src: string): boolean {
return /^https?:\/\//i.test(src);
}
/** The local file the render reads a media `src` from, resolved like render; null for a remote source or a local file it never opens. */
export function mediaPath(src: string, projectDir: string): string | null {
if (/^https?:\/\//i.test(src)) return src;
if (isRemoteMediaSrc(src)) return null;
const path = resolveProjectRelativeSrc(src, projectDir, projectDir);
return assetRootsRefusal(path, [projectDir]) === null ? path : null;
}