Files
hyperframes/packages/cli/src/utils/projectMedia.ts
T
Miguel Ángel d83bf997b0 feat(cli): check catches audio the render would lose or play as silence (#6439)
* feat(cli): check catches audio the render would lose or play as silence

check gains an Audio section, read from the media list the render mixes:
- error: a clip's source has no audio the render can read (its mix fails,
  the film ships without sound)
- warning: a clip starts past the end of its file, or the part it plays
  is silent
- info: the film has no sound at all

The bundle and media list are now built once and shared with the HDR
inspection; the audio pass runs while the browser pass does.

Fixes #2775

* fix(cli): check reports an unreadable audio source the way render handles it

A source with no audio track is refused by render's own media-type rule, now exported from the producer and called by check; a source that does not decode as audio fails the mix and stops the render.

* perf(cli): check samples a long clip at a few spots before reading all of it for silence

Sound at any spot ends the decode; a clip is only called silent after its whole played part is read.

* chore(cli): drop a comment the shared finding helper's name already says
2026-10-26 17:02:57 +00:00

31 lines
1.2 KiB
TypeScript

import {
resolveProjectRelativeSrc,
type AudioElement,
type VideoElement,
} from "@hyperframes/engine";
import { loadProducer } from "./producer.js";
/** The render's own media list for a project: what it extracts, probes and mixes. */
export interface ProjectMedia {
videos: readonly Pick<VideoElement, "src" | "hasAudio">[];
images: readonly { src: string }[];
audios: readonly AudioElement[];
/** The bundled document the lists were read from. */
html: string;
}
export async function collectProjectMedia(projectDir: string): Promise<ProjectMedia> {
const { bundleToSingleHtml } = await import("@hyperframes/core/compiler");
const html = await bundleToSingleHtml(projectDir);
const producer = (await loadProducer()) as {
collectRenderMedia?: (source: string) => Omit<ProjectMedia, "html">;
};
if (!producer.collectRenderMedia) throw new Error("Render media collector unavailable");
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);
}