fix(engine,producer): render media readers skip private project files and text-art input (#7928)

* fix(engine,producer): render media readers treat private project files as missing

A video, audio, GIF or HEIC src that names a file the file servers refuse
(git metadata, env, credentials, tool state, app records), as written or
through a link, is now treated as missing by every render-time reader:
the compile-time duration probe and keyframe advisory, GIF and HEIC prep,
the media drop step, the HDR probe, frame extraction and the audio mixer.

The engine's isPrivateUnderAssetRoots judges a path from every asset root
that holds it, so a render's own work folder inside the project's
.hyperframes/ keeps its downloaded and prepared files.

* fix(engine): probe refuses a text file that ffmpeg reads as text-art video

ffmpeg's tty and bintext demuxers turn a text file (such as .asc or .nfo)
into a video stream that draws the text into frames. Every probe now
refuses an input whose container is tty or whose video codec is ansi,
bintext, xbin or idf, as not media. Probing, frame extraction and audio
reads all go through the same probe, on every render. No demuxer for real
video or audio produces these, so local renders keep every other format.

* fix(engine,producer,cli): playlist entries and check probes skip private files

- A media playlist (HLS segment, key or map URI, ffconcat file) that names a
  private file inside its own folder is refused as not media, like one that
  names a file outside it.
- `hyperframes check` no longer probes a media source outside the project or
  private in it: mediaPath returns null for such a file and the audio,
  heard-clip and HDR checks skip it.
- The compiler's duration probe and keyframe check judge privacy from every
  asset root, as the render-time readers do.
This commit is contained in:
Michael Wang
2026-11-16 06:22:17 +00:00
committed by GitHub
parent 1b29623f18
commit 6411df4e35
22 changed files with 427 additions and 46 deletions
+3 -4
View File
@@ -139,9 +139,8 @@ async function videoSoundsAutoDetected(
dependencies: AudioCheckDependencies,
): Promise<boolean> {
for (const video of media.videos) {
if (!video.hasAudio) continue;
if (await dependencies.videoHasAudio(mediaPath(video.src, projectDir)).catch(() => false))
return true;
const path = video.hasAudio ? mediaPath(video.src, projectDir) : null;
if (path && (await dependencies.videoHasAudio(path).catch(() => false))) return true;
}
return false;
}
@@ -156,7 +155,7 @@ async function inspectClip(
): Promise<CheckFinding[]> {
const path = mediaPath(clip.src, projectDir);
// ponytail: remote sources are not fetched; missing local files are lint's audio_src_not_found.
if (path === clip.src || !existsSync(path)) return [];
if (path === null || path === clip.src || !existsSync(path)) return [];
const problem = await clipProblem(path, clip, dependencies);
if (!problem) return [];
const id = clip.type === "video" ? clip.id.replace(/-audio$/, "") : clip.id;
+3 -4
View File
@@ -20,11 +20,10 @@ export async function inspectHdrAutoPromotion(
colorSpace: Awaited<ReturnType<typeof extractMediaMetadata>>["colorSpace"];
}> = [];
for (const { src } of [...media.videos, ...media.images]) {
const path = mediaPath(src, project.dir);
if (path === null) continue;
try {
assets.push({
asset: src,
colorSpace: (await extractMetadata(mediaPath(src, project.dir))).colorSpace,
});
assets.push({ asset: src, colorSpace: (await extractMetadata(path)).colorSpace });
} catch {
continue;
}
+31 -1
View File
@@ -2,7 +2,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { heardClips } from "./projectMedia.js";
import { heardClips, mediaPath } from "./projectMedia.js";
let dir = "";
afterEach(() => rmSync(dir, { recursive: true, force: true }));
@@ -29,6 +29,36 @@ ${scene}
const probe = { seconds: async () => 6 };
describe("mediaPath", () => {
it("never hands check a local file outside the project or private in it", () => {
dir = mkdtempSync(join(tmpdir(), "hf-media-path-"));
for (const rel of [
".git/clip.mp4",
".hyperframes/clip.mp4",
"media/id_rsa",
"media/clip.mp4",
]) {
mkdirSync(join(dir, rel, ".."), { recursive: true });
writeFileSync(join(dir, rel), "x");
}
expect(mediaPath(".git/clip.mp4", dir)).toBeNull();
expect(mediaPath(".hyperframes/clip.mp4", dir)).toBeNull();
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");
});
it("does not probe a private file a scene's audio names", async () => {
const seen: string[] = [];
const root = project('<audio id="a" src="../.git/voice.wav" data-start="0"></audio>');
mkdirSync(join(root, ".git"));
writeFileSync(join(root, ".git", "voice.wav"), "x");
await heardClips(root, { seconds: async (path) => (seen.push(path), 6) });
expect(seen).toEqual([]);
});
});
describe("heardClips", () => {
it("hears a speaking video inside a timed wrapper in a scene, where the render plays it", async () => {
const clips = await heardClips(
+7 -3
View File
@@ -1,4 +1,5 @@
import {
assetRootsRefusal,
extractAudioMetadata,
resolveProjectRelativeSrc,
type AudioElement,
@@ -26,9 +27,11 @@ export async function collectProjectMedia(projectDir: string): Promise<ProjectMe
return { ...producer.collectRenderMedia(html), html };
}
/** The path the render reads a media `src` from: remote URLs as they are, local ones resolved like render. */
export function mediaPath(src: string, projectDir: string): string {
return /^https?:\/\//i.test(src) ? src : resolveProjectRelativeSrc(src, projectDir, projectDir);
/** The path the render reads a media `src` from, resolved like render; null for a local file it never opens. */
export function mediaPath(src: string, projectDir: string): string | null {
if (/^https?:\/\//i.test(src)) return src;
const path = resolveProjectRelativeSrc(src, projectDir, projectDir);
return assetRootsRefusal(path, [projectDir]) === null ? path : null;
}
/** A clip the render mixes into the film, on the film's clock; `end` 0 means it runs to its media's end. */
@@ -55,6 +58,7 @@ export async function heardClips(
const lengths = new Map<string, Promise<number | null>>();
const length = (src: string): Promise<number | null> => {
const path = mediaPath(src, projectDir);
if (path === null) return Promise.resolve(null);
const known = lengths.get(path) ?? probe.seconds(path).catch(() => null);
lengths.set(path, known);
return known;