mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* 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
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import type { CheckFinding, CheckSeverity } from "./checkTypes.js";
|
|
|
|
const SEVERITY = { info: 0, warning: 1, error: 2 } satisfies Record<
|
|
CheckFinding["severity"],
|
|
number
|
|
>;
|
|
|
|
export function findingAtRoot(
|
|
code: string,
|
|
severity: CheckSeverity,
|
|
message: string,
|
|
sourceFile: string,
|
|
): CheckFinding {
|
|
return {
|
|
code,
|
|
severity,
|
|
message,
|
|
selector: "[data-composition-id]",
|
|
dataAttributes: {},
|
|
sourceFile,
|
|
bbox: { x: 0, y: 0, width: 0, height: 0 },
|
|
time: 0,
|
|
};
|
|
}
|
|
|
|
/** Element identity is scoped to the source document, not the whole project. */
|
|
export function findingElementKey(finding: Pick<CheckFinding, "sourceFile" | "selector">): string {
|
|
return JSON.stringify([finding.sourceFile, finding.selector]);
|
|
}
|
|
|
|
/** Group observations without changing their grading; retain one matching evidence anchor. */
|
|
export function groupSampledFindings<T extends CheckFinding>(
|
|
findings: T[],
|
|
compareEvidence: (next: T, current: T) => number = () => 0,
|
|
): (T & { times: number[] })[] {
|
|
const groups = new Map<string, { finding: T; times: Set<number> }>();
|
|
for (const finding of findings) {
|
|
const key = JSON.stringify([findingElementKey(finding), finding.code]);
|
|
const times = finding.times ?? [finding.time];
|
|
const group = groups.get(key);
|
|
if (!group) {
|
|
groups.set(key, { finding, times: new Set(times) });
|
|
continue;
|
|
}
|
|
for (const time of times) group.times.add(time);
|
|
const severity = SEVERITY[finding.severity] - SEVERITY[group.finding.severity];
|
|
if (severity > 0 || (severity === 0 && compareEvidence(finding, group.finding) > 0)) {
|
|
group.finding = finding;
|
|
}
|
|
}
|
|
return [...groups.values()].map(({ finding, times }) => ({
|
|
...finding,
|
|
times: [...times].sort((a, b) => a - b),
|
|
}));
|
|
}
|
|
|
|
export function formatFindingTimes(finding: Pick<CheckFinding, "time" | "times">): string {
|
|
return `t=${(finding.times ?? [finding.time]).join(", ")}s`;
|
|
}
|