@aicopycoders/exodus 2026.11.1200-beta.2 → 2026.11.1200-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/docs/CLAUDE.md +3 -3
- package/assets/docs/PIPELINES.md +2 -2
- package/assets/skills/exodus/SKILL.md +3 -2
- package/assets/skills/exodus-video/SKILL.md +812 -291
- package/assets/skills/exodus-video/scripts/first-cut-sync.d.mts +82 -0
- package/assets/skills/exodus-video/scripts/first-cut-sync.mjs +248 -0
- package/assets/skills/exodus-video/scripts/first-cut.d.mts +76 -2
- package/assets/skills/exodus-video/scripts/first-cut.mjs +467 -118
- package/assets/skills/exodus-video/swipe-sheet.md +17 -0
- package/assets/skills/swipe/SKILL.md +3 -3
- package/assets/skills/ugc-ads/SKILL.md +5 -3
- package/assets/skills/ugc-preproduction/SKILL.md +1 -1
- package/assets/skills/ugc-swipe/SKILL.md +3 -1
- package/dist/bin/exodus.js +6 -5
- package/dist/commands/video-customer.d.ts +56 -0
- package/dist/commands/video-customer.js +119 -6
- package/dist/commands/video-swipe.d.ts +197 -7
- package/dist/commands/video-swipe.js +834 -50
- package/dist/commands/video.d.ts +69 -1
- package/dist/commands/video.js +618 -54
- package/dist/commands/workflow.d.ts +10 -1
- package/dist/commands/workflow.js +8 -2
- package/dist/lib/args.js +1 -1
- package/dist/lib/client.js +1 -0
- package/dist/lib/helperLedgerBase.d.ts +1 -0
- package/dist/lib/helperLedgerBase.js +1 -0
- package/dist/lib/oneTakeHolds.d.ts +1 -0
- package/dist/lib/oneTakeHolds.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** COP-300: two sync checks on a finished cut, in numbers only (first-cut-sync.mjs). */
|
|
2
|
+
|
|
3
|
+
/** Check A's limit: the finished sound and picture end at most this far apart. */
|
|
4
|
+
export const SOUND_PICTURE_LIMIT_MS: number;
|
|
5
|
+
/** Check B's default limits. */
|
|
6
|
+
export const CAPTION_SYNC_LIMITS: Readonly<CaptionSyncLimits>;
|
|
7
|
+
/** A section is judged on at least this many paired captions. */
|
|
8
|
+
export const MIN_SECTION_CAPTIONS: number;
|
|
9
|
+
|
|
10
|
+
export interface CaptionSyncLimits {
|
|
11
|
+
/** The most a section's median offset may be, either way, in ms. */
|
|
12
|
+
sectionMs: number;
|
|
13
|
+
/** The most the median offset may grow from the first judged section to the last, in ms. */
|
|
14
|
+
growthMs: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A caption and the time it is first seen in the finished film. */
|
|
18
|
+
export interface SeenCaption {
|
|
19
|
+
text: string;
|
|
20
|
+
seenSec: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A word of the finished film and when it starts (and ends) there. */
|
|
24
|
+
export interface HeardWord {
|
|
25
|
+
text: string;
|
|
26
|
+
start: number;
|
|
27
|
+
end?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SyncSection {
|
|
31
|
+
id: number | string;
|
|
32
|
+
startSec: number;
|
|
33
|
+
endSec: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check B's verdict, each section judged on its median offset. `pass` covers the judged sections and is null when none
|
|
38
|
+
* was judged; `unjudged` names the sections that hold captions but too few paired ones to judge.
|
|
39
|
+
*/
|
|
40
|
+
export interface CaptionSyncVerdict {
|
|
41
|
+
pass: boolean | null;
|
|
42
|
+
worstMs: number | null;
|
|
43
|
+
worstSection: number | string | null;
|
|
44
|
+
growthMs: number | null;
|
|
45
|
+
judged: Array<number | string>;
|
|
46
|
+
unjudged: Array<number | string>;
|
|
47
|
+
limits: CaptionSyncLimits;
|
|
48
|
+
captions: number;
|
|
49
|
+
paired: number;
|
|
50
|
+
sections: Array<{ id: number | string; captions: number; n: number; judged: boolean; meanMs: number | null; medianMs: number | null }>;
|
|
51
|
+
rows: Array<{ text: string; seenSec: number; heardSec: number; offsetMs: number }>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Check A's numbers: the film's frames against its decoded sound samples. */
|
|
55
|
+
export interface SoundPictureCheck {
|
|
56
|
+
frames: number;
|
|
57
|
+
fps: number;
|
|
58
|
+
pictureSec: number;
|
|
59
|
+
samples: number;
|
|
60
|
+
sampleRate: number;
|
|
61
|
+
soundSec: number;
|
|
62
|
+
soundMinusPictureMs: number;
|
|
63
|
+
limitMs: number;
|
|
64
|
+
pass: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function wordKey(text: string): string;
|
|
68
|
+
export function alignWords(a: readonly string[], b: readonly string[]): Array<[number, number]>;
|
|
69
|
+
export function captionSync(args: {
|
|
70
|
+
captions: readonly SeenCaption[];
|
|
71
|
+
heard: readonly HeardWord[];
|
|
72
|
+
sections: readonly SyncSection[];
|
|
73
|
+
limits?: CaptionSyncLimits;
|
|
74
|
+
minCaptions?: number;
|
|
75
|
+
}): CaptionSyncVerdict;
|
|
76
|
+
export function soundPictureCheck(file: string, options?: { limitMs?: number }): SoundPictureCheck | null;
|
|
77
|
+
export function placementHeard(args: {
|
|
78
|
+
film: string;
|
|
79
|
+
speed?: number;
|
|
80
|
+
takes: ReadonlyArray<{ file: string; heard: readonly HeardWord[]; words: readonly HeardWord[] }>;
|
|
81
|
+
}): Array<{ text: string; start: number; end: number; lagMs: number; match: number }>;
|
|
82
|
+
export function retimeWords<T extends { text: string; start: number; end: number }>(rows: readonly T[], heard: readonly HeardWord[], speed?: number): T[];
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// COP-300: two sync checks on a finished cut, in numbers only.
|
|
2
|
+
//
|
|
3
|
+
// Check A: the finished film's sound against its picture, its decoded samples
|
|
4
|
+
// against its frames: under SOUND_PICTURE_LIMIT_MS apart.
|
|
5
|
+
// Check B: each caption, at the frame it is first seen, against the start of
|
|
6
|
+
// its first word in the finished film's sound: no section (a take of the cut,
|
|
7
|
+
// a verse of a song) off by more than `sectionMs` at its median, and no growth
|
|
8
|
+
// of more than `growthMs` from the first section to the last.
|
|
9
|
+
//
|
|
10
|
+
// The finished film's word times come from a listen of the film (the worker's
|
|
11
|
+
// paid one), or from placementHeard: each take's own word times, moved by where
|
|
12
|
+
// that take's sound is found in the finished sound, word by word, by matching
|
|
13
|
+
// their loudness. It needs no transcriber and no paid call.
|
|
14
|
+
//
|
|
15
|
+
// A second cut (a song laid whole, say) calls captionSync with its own
|
|
16
|
+
// sections and limits; nothing here reads a kind of ad.
|
|
17
|
+
import { spawnSync } from "node:child_process";
|
|
18
|
+
|
|
19
|
+
/** Check A's limit: the finished sound and picture end at most this far apart. */
|
|
20
|
+
export const SOUND_PICTURE_LIMIT_MS = 40;
|
|
21
|
+
/** Check B's default limits: each section's median offset, and its growth from the first section to the last. */
|
|
22
|
+
export const CAPTION_SYNC_LIMITS = Object.freeze({ sectionMs: 80, growthMs: 60 });
|
|
23
|
+
/** A section is judged on at least this many captions whose first word was heard; fewer are listed, not judged. */
|
|
24
|
+
export const MIN_SECTION_CAPTIONS = 3;
|
|
25
|
+
/** A caption is tied to a heard word at most this far from where it is seen. */
|
|
26
|
+
const MAX_PAIR_SEC = 1.5;
|
|
27
|
+
/** placementHeard keeps a word whose loudness matches its take's at least this well. */
|
|
28
|
+
const MIN_MATCH = 0.8;
|
|
29
|
+
const LISTEN_RATE = 16000;
|
|
30
|
+
|
|
31
|
+
const round1 = (n) => Math.round(n * 10) / 10;
|
|
32
|
+
const round4 = (n) => Math.round(n * 10000) / 10000;
|
|
33
|
+
const mean = (xs) => xs.reduce((a, b) => a + b, 0) / xs.length;
|
|
34
|
+
const median = (xs) => {
|
|
35
|
+
const s = [...xs].sort((a, b) => a - b);
|
|
36
|
+
return s.length % 2 ? s[(s.length - 1) / 2] : (s[s.length / 2 - 1] + s[s.length / 2]) / 2;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** A word for matching: lower case, accents and punctuation off. */
|
|
40
|
+
export const wordKey = (text) => String(text ?? "").normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "");
|
|
41
|
+
|
|
42
|
+
/** The longest run of equal words of `a` and `b` in order (each by wordKey): pairs [i, j]. */
|
|
43
|
+
export function alignWords(a, b) {
|
|
44
|
+
const ka = a.map(wordKey);
|
|
45
|
+
const kb = b.map(wordKey);
|
|
46
|
+
const [n, m] = [ka.length, kb.length];
|
|
47
|
+
const table = new Int32Array((n + 1) * (m + 1));
|
|
48
|
+
for (let i = n - 1; i >= 0; i--) {
|
|
49
|
+
for (let j = m - 1; j >= 0; j--) {
|
|
50
|
+
table[i * (m + 1) + j] = ka[i] && ka[i] === kb[j]
|
|
51
|
+
? table[(i + 1) * (m + 1) + j + 1] + 1
|
|
52
|
+
: Math.max(table[(i + 1) * (m + 1) + j], table[i * (m + 1) + j + 1]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const pairs = [];
|
|
56
|
+
for (let i = 0, j = 0; i < n && j < m;) {
|
|
57
|
+
if (ka[i] && ka[i] === kb[j]) pairs.push([i++, j++]);
|
|
58
|
+
else if (table[(i + 1) * (m + 1) + j] >= table[i * (m + 1) + j + 1]) i++;
|
|
59
|
+
else j++;
|
|
60
|
+
}
|
|
61
|
+
return pairs;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Check B on any cut. `captions`: [{ text, seenSec }], each caption's words and the time it is first seen in the
|
|
66
|
+
* finished film. `heard`: [{ text, start }], the finished film's words. `sections`: [{ id, startSec, endSec }]. A
|
|
67
|
+
* caption is tied to the heard word that says its first word (the two word lists aligned in order), at most 1.5 s
|
|
68
|
+
* away. Each section is judged on the median of its captions' offsets (seen minus heard, in ms; below zero the
|
|
69
|
+
* caption is early), so one caption tied to the wrong word cannot fail it, when at least `minCaptions` of its
|
|
70
|
+
* captions were tied. A section that holds captions but too few tied ones is listed in `unjudged`: it was not
|
|
71
|
+
* checked. `pass` covers the judged sections only, and is null when none was judged; growth is the last judged
|
|
72
|
+
* section's median minus the first's, null with fewer than two judged.
|
|
73
|
+
*/
|
|
74
|
+
export function captionSync({ captions, heard, sections, limits = CAPTION_SYNC_LIMITS, minCaptions = MIN_SECTION_CAPTIONS }) {
|
|
75
|
+
const flat = [];
|
|
76
|
+
const owner = [];
|
|
77
|
+
captions.forEach((c, k) => String(c.text ?? "").split(/\s+/).filter(Boolean).forEach((word, n) => {
|
|
78
|
+
flat.push(word);
|
|
79
|
+
owner.push([k, n]);
|
|
80
|
+
}));
|
|
81
|
+
const firstHeard = new Map();
|
|
82
|
+
for (const [i, j] of alignWords(flat, heard.map((h) => h.text))) {
|
|
83
|
+
const [k, n] = owner[i];
|
|
84
|
+
if (n === 0 && Math.abs(heard[j].start - captions[k].seenSec) <= MAX_PAIR_SEC) firstHeard.set(k, heard[j].start);
|
|
85
|
+
}
|
|
86
|
+
const rows = captions.flatMap((c, k) => firstHeard.has(k)
|
|
87
|
+
? [{ text: c.text, seenSec: round4(c.seenSec), heardSec: round4(firstHeard.get(k)), offsetMs: round1((c.seenSec - firstHeard.get(k)) * 1000) }]
|
|
88
|
+
: []);
|
|
89
|
+
const per = sections.map((s) => {
|
|
90
|
+
const inside = (t) => t >= s.startSec && t < s.endSec;
|
|
91
|
+
const offsets = rows.filter((r) => inside(r.seenSec)).map((r) => r.offsetMs);
|
|
92
|
+
return {
|
|
93
|
+
id: s.id, captions: captions.filter((c) => inside(c.seenSec)).length, n: offsets.length, judged: offsets.length >= minCaptions,
|
|
94
|
+
meanMs: offsets.length ? round1(mean(offsets)) : null, medianMs: offsets.length ? round1(median(offsets)) : null,
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
const judged = per.filter((s) => s.judged);
|
|
98
|
+
const worst = judged.reduce((w, s) => (!w || Math.abs(s.medianMs) > Math.abs(w.medianMs) ? s : w), null);
|
|
99
|
+
const growthMs = judged.length >= 2 ? round1(judged.at(-1).medianMs - judged[0].medianMs) : null;
|
|
100
|
+
const worstMs = worst ? Math.abs(worst.medianMs) : null;
|
|
101
|
+
return {
|
|
102
|
+
pass: worst ? worstMs <= limits.sectionMs && (growthMs === null || Math.abs(growthMs) <= limits.growthMs) : null,
|
|
103
|
+
worstMs, worstSection: worst?.id ?? null, growthMs,
|
|
104
|
+
judged: judged.map((s) => s.id), unjudged: per.filter((s) => !s.judged && s.captions > 0).map((s) => s.id),
|
|
105
|
+
limits: { sectionMs: limits.sectionMs, growthMs: limits.growthMs },
|
|
106
|
+
captions: captions.length, paired: rows.length, sections: per, rows,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Check A: a film's frames against its decoded sound samples, or null when either cannot be read. */
|
|
111
|
+
export function soundPictureCheck(file, { limitMs = SOUND_PICTURE_LIMIT_MS } = {}) {
|
|
112
|
+
const probe = spawnSync("ffprobe", [
|
|
113
|
+
"-v", "error", "-count_packets", "-show_entries", "stream=codec_type,nb_read_packets,r_frame_rate,sample_rate", "-of", "json", file,
|
|
114
|
+
], { encoding: "utf8", maxBuffer: 1 << 24 });
|
|
115
|
+
if (probe.status !== 0) return null;
|
|
116
|
+
const streams = JSON.parse(probe.stdout || "{}").streams ?? [];
|
|
117
|
+
const video = streams.find((s) => s.codec_type === "video");
|
|
118
|
+
const audio = streams.find((s) => s.codec_type === "audio");
|
|
119
|
+
if (!video || !audio) return null;
|
|
120
|
+
const [num, den] = String(video.r_frame_rate).split("/").map(Number);
|
|
121
|
+
const frames = Number(video.nb_read_packets);
|
|
122
|
+
const sampleRate = Number(audio.sample_rate);
|
|
123
|
+
const pcm = spawnSync("ffmpeg", ["-v", "error", "-i", file, "-map", "0:a:0", "-ac", "1", "-f", "s16le", "-"], { maxBuffer: 1 << 30 });
|
|
124
|
+
if (pcm.status !== 0 || !(frames > 0) || !(num > 0) || !(den > 0) || !(sampleRate > 0)) return null;
|
|
125
|
+
const samples = pcm.stdout.length / 2;
|
|
126
|
+
const pictureSec = (frames * den) / num;
|
|
127
|
+
const soundSec = samples / sampleRate;
|
|
128
|
+
const soundMinusPictureMs = round1((soundSec - pictureSec) * 1000);
|
|
129
|
+
return {
|
|
130
|
+
frames, fps: num / den, pictureSec: round4(pictureSec), samples, sampleRate, soundSec: round4(soundSec),
|
|
131
|
+
soundMinusPictureMs, limitMs, pass: Math.abs(soundMinusPictureMs) < limitMs,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** A file's first sound, mono, at LISTEN_RATE, or null. */
|
|
136
|
+
function decodeMono(file) {
|
|
137
|
+
const res = spawnSync("ffmpeg", ["-v", "error", "-i", file, "-map", "0:a:0", "-ac", "1", "-ar", String(LISTEN_RATE), "-f", "f32le", "-"], { maxBuffer: 1 << 30 });
|
|
138
|
+
if (res.status !== 0) return null;
|
|
139
|
+
const bytes = res.stdout;
|
|
140
|
+
return new Float32Array(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.length));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Loudness in dB on a 1 ms grid, each from a window of `winSec` centred on it; read at any time by `at`. */
|
|
144
|
+
function envelope(x, winSec) {
|
|
145
|
+
const sums = new Float64Array(x.length + 1);
|
|
146
|
+
for (let i = 0; i < x.length; i++) sums[i + 1] = sums[i] + x[i] * x[i];
|
|
147
|
+
const width = Math.max(1, Math.round(winSec * LISTEN_RATE));
|
|
148
|
+
const grid = new Float32Array(Math.ceil((x.length / LISTEN_RATE) * 1000) + 1);
|
|
149
|
+
for (let k = 0; k < grid.length; k++) {
|
|
150
|
+
const c = Math.round((k / 1000) * LISTEN_RATE);
|
|
151
|
+
const a = Math.min(Math.max(c - (width >> 1), 0), x.length);
|
|
152
|
+
const b = Math.min(a + width, x.length);
|
|
153
|
+
grid[k] = 10 * Math.log10((sums[b] - sums[a]) / Math.max(1, b - a) + 1e-12);
|
|
154
|
+
}
|
|
155
|
+
return (t) => grid[Math.min(grid.length - 1, Math.max(0, Math.round(t * 1000)))];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Each value raised to 40 dB under the loudest, so silence does not decide a match. */
|
|
159
|
+
const floored = (v) => {
|
|
160
|
+
let top = -Infinity;
|
|
161
|
+
for (const x of v) if (x > top) top = x;
|
|
162
|
+
return v.map((x) => Math.max(x, top - 40));
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/** Where one word of a take sits in the finished sound, against where the cut planned it: the lag in seconds and how well it matched. */
|
|
166
|
+
function lagOf(take, film, lo, hi, offset, speed) {
|
|
167
|
+
const taus = [];
|
|
168
|
+
for (let t = lo; t < hi; t += 0.001) taus.push(t);
|
|
169
|
+
const a = floored(taus.map(take));
|
|
170
|
+
const ma = mean(a);
|
|
171
|
+
const da = a.map((x) => x - ma);
|
|
172
|
+
const na = Math.sqrt(da.reduce((sum, d) => sum + d * d, 0));
|
|
173
|
+
const lags = [];
|
|
174
|
+
for (let k = -250; k <= 250; k++) lags.push(k / 1000);
|
|
175
|
+
const r = lags.map((lag) => {
|
|
176
|
+
const b = floored(taus.map((t) => film((t - offset) / speed + lag)));
|
|
177
|
+
const mb = mean(b);
|
|
178
|
+
let dot = 0;
|
|
179
|
+
let nb = 0;
|
|
180
|
+
for (let i = 0; i < b.length; i++) { const d = b[i] - mb; dot += d * da[i]; nb += d * d; }
|
|
181
|
+
return dot / (na * Math.sqrt(nb) + 1e-9);
|
|
182
|
+
});
|
|
183
|
+
let j = 0;
|
|
184
|
+
for (let i = 1; i < r.length; i++) if (r[i] > r[j]) j = i;
|
|
185
|
+
let lag = lags[j];
|
|
186
|
+
if (j > 0 && j < r.length - 1) {
|
|
187
|
+
const den = r[j - 1] - 2 * r[j] + r[j + 1];
|
|
188
|
+
if (den < 0) lag += 0.001 * 0.5 * (r[j - 1] - r[j + 1]) / den;
|
|
189
|
+
}
|
|
190
|
+
return { lag, corr: r[j] };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The free listener. `film`: the finished cut's file; `speed`: its speed-up. `takes`: [{ file, heard, words }], each
|
|
195
|
+
* take's file, its own word times in that file (`heard`: [{ text, start, end }]) and the cut's words of that take on
|
|
196
|
+
* the finished film's clock (`words`: [{ text, start, end }]). Each cut word is tied to its take word (the two lists
|
|
197
|
+
* aligned in order); the take's loudness around it is found in the finished sound, at most 250 ms either way. Returns
|
|
198
|
+
* the finished film's words, each moved by what was found: [{ text, start, end, lagMs, match }]. A word whose loudness
|
|
199
|
+
* matches poorly (a shared pause, a breath) is left out.
|
|
200
|
+
*/
|
|
201
|
+
export function placementHeard({ film, takes, speed = 1 }) {
|
|
202
|
+
const filmSound = decodeMono(film);
|
|
203
|
+
if (!filmSound) return [];
|
|
204
|
+
const filmAt = envelope(filmSound, 0.020 / speed);
|
|
205
|
+
const out = [];
|
|
206
|
+
for (const take of takes) {
|
|
207
|
+
const sound = decodeMono(take.file);
|
|
208
|
+
if (!sound) continue;
|
|
209
|
+
const takeAt = envelope(sound, 0.020);
|
|
210
|
+
const pairs = alignWords(take.words.map((w) => w.text), take.heard.map((h) => h.text))
|
|
211
|
+
.map(([i, j]) => ({ word: take.words[i], src: take.heard[j], offset: Math.round((take.heard[j].start - speed * take.words[i].start) * 24) / 24 }));
|
|
212
|
+
pairs.forEach((p, k) => {
|
|
213
|
+
let lo = p.src.start - 0.3;
|
|
214
|
+
let hi = p.src.end + 0.3;
|
|
215
|
+
// A neighbour cut elsewhere in the take bounds the window, so its sound is not matched here.
|
|
216
|
+
if (k > 0 && Math.abs(pairs[k - 1].offset - p.offset) > 1e-6) lo = Math.max(lo, pairs[k - 1].src.end + 0.02);
|
|
217
|
+
if (k + 1 < pairs.length && Math.abs(pairs[k + 1].offset - p.offset) > 1e-6) hi = Math.min(hi, pairs[k + 1].src.start - 0.02);
|
|
218
|
+
if (hi - lo < 0.25) return;
|
|
219
|
+
const { lag, corr } = lagOf(takeAt, filmAt, lo, hi, p.offset, speed);
|
|
220
|
+
if (corr < MIN_MATCH) return;
|
|
221
|
+
out.push({ text: p.word.text, start: round4(p.word.start + lag), end: round4(p.word.end + lag), lagMs: round1(lag * 1000), match: Math.round(corr * 1000) / 1000 });
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return out.sort((a, b) => a.start - b.start);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The cut's words timed by the finished film's heard words (a cut made again after Check B failed). `rows`: the
|
|
229
|
+
* cut's words before its speed-up, [{ text, start, end, ... }]; `heard`: the finished film's words on its own clock;
|
|
230
|
+
* `speed`: the cut's speed-up. Each row tied to a heard word (the two lists aligned in order) takes that word's
|
|
231
|
+
* times; any other row moves with the nearest row before it that was tied (else the nearest after). The words stay
|
|
232
|
+
* the rows' own.
|
|
233
|
+
*/
|
|
234
|
+
export function retimeWords(rows, heard, speed = 1) {
|
|
235
|
+
const tied = new Map(alignWords(rows.map((r) => r.text), heard.map((h) => h.text)).map(([i, j]) => [i, heard[j]]));
|
|
236
|
+
if (tied.size === 0) return rows;
|
|
237
|
+
const shifts = rows.map((r, i) => (tied.has(i) ? tied.get(i).start * speed - r.start : null));
|
|
238
|
+
return rows.map((r, i) => {
|
|
239
|
+
if (tied.has(i)) {
|
|
240
|
+
const h = tied.get(i);
|
|
241
|
+
return { ...r, start: round4(h.start * speed), end: round4(Math.max(h.end ?? 0, h.start + 0.01) * speed) };
|
|
242
|
+
}
|
|
243
|
+
let shift = null;
|
|
244
|
+
for (let k = i - 1; k >= 0 && shift === null; k--) shift = shifts[k];
|
|
245
|
+
for (let k = i + 1; k < rows.length && shift === null; k++) shift = shifts[k];
|
|
246
|
+
return { ...r, start: round4(r.start + shift), end: round4(r.end + shift) };
|
|
247
|
+
});
|
|
248
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// #2988: the types of the exports the Trigger worker calls. The script is
|
|
2
2
|
// plain JS so the CLI can run it with `node` and no build.
|
|
3
3
|
import type { SourceIdentity, TextItem, TextPlan, PlanTextInput, VerifyObservation, RasterMeasurement, MeasureText } from "./first-cut-text.mjs";
|
|
4
|
+
import type { CaptionSyncVerdict, SeenCaption, SoundPictureCheck, SyncSection } from "./first-cut-sync.mjs";
|
|
4
5
|
|
|
5
6
|
// The worker's shapes (scout cut-sounds.ts, temporal-action-evidence.ts), kept loose here: the root typecheck
|
|
6
7
|
// runs without scout's packages, so the tool's types must not load the worker.
|
|
@@ -82,6 +83,9 @@ export class FirstCutError extends Error {
|
|
|
82
83
|
readonly code: 1 | 2;
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
/** Why a finished cut is refused for its loudness (LoudnessRefusal's message), or null when its true peak is at or under -1 dBTP. */
|
|
87
|
+
export function truePeakRefusal(measured: { i: number; tp: number } | null): string | null;
|
|
88
|
+
|
|
85
89
|
/** The finished cut's true peak is over -1 dBTP, or could not be measured, after the loudness pass. */
|
|
86
90
|
export class LoudnessRefusal extends FirstCutError {
|
|
87
91
|
constructor(message: string, measured: { i: number; tp: number } | null);
|
|
@@ -94,6 +98,34 @@ export class SourceMapRefusal extends FirstCutError {
|
|
|
94
98
|
readonly findings: SourceMapFinding[];
|
|
95
99
|
}
|
|
96
100
|
|
|
101
|
+
/** A heard word on the cut's clock before its speed-up. */
|
|
102
|
+
export interface CutWordRow { text: string; start: number; end: number; scene: number }
|
|
103
|
+
|
|
104
|
+
/** #4585: the heard words the end card would cover; empty with no card or when every word ends before it. */
|
|
105
|
+
export function voiceUnderEndCard(rows: CutWordRow[], endCard: { in: number } | null): CutWordRow[];
|
|
106
|
+
|
|
107
|
+
/** #4585: the staff message of a cut refused because the end card would cover some of its voice. */
|
|
108
|
+
export function voiceUnderEndCardMessage(words: CutWordRow[]): string;
|
|
109
|
+
|
|
110
|
+
/** #4585: the end card's place and length, after the last heard word; `holdSec` is how long the picture runs on under it. */
|
|
111
|
+
export function endCardLayersOf(
|
|
112
|
+
brand: unknown, storyboard: unknown, pictureSec: number, speed?: number, voiceEndSec?: number | null,
|
|
113
|
+
): { file: string; in: number; out: number; seconds: number; holdSec?: number } | null;
|
|
114
|
+
|
|
115
|
+
/** #4585: the seconds between the last heard word's end and the end card. */
|
|
116
|
+
export const END_CARD_AFTER_VOICE_SEC: number;
|
|
117
|
+
|
|
118
|
+
/** #4585: the end card on the cut, holding the last scene's picture under it; throws VoiceUnderEndCardRefusal when it would cover a word. */
|
|
119
|
+
export function placeEndCard(
|
|
120
|
+
timeline: unknown, brand: unknown, storyboard: unknown, pictureSec: number, speed: number, notes: string[],
|
|
121
|
+
): ReturnType<typeof endCardLayersOf>;
|
|
122
|
+
|
|
123
|
+
/** #4585: the end card would cover some of the cut's voice, so the cut is not delivered. */
|
|
124
|
+
export class VoiceUnderEndCardRefusal extends FirstCutError {
|
|
125
|
+
constructor(words: CutWordRow[]);
|
|
126
|
+
readonly words: CutWordRow[];
|
|
127
|
+
}
|
|
128
|
+
|
|
97
129
|
export interface SourceMapFinding {
|
|
98
130
|
/** "refuse" stops the cut and nothing is delivered; "declared" is a measured fact the cut carries out. */
|
|
99
131
|
severity: "refuse" | "declared";
|
|
@@ -265,14 +297,50 @@ export interface CutPace {
|
|
|
265
297
|
nameCheck?: true;
|
|
266
298
|
/** With pacePass, the speed the cut played at in place of 1.12. */
|
|
267
299
|
paceSpeed?: number;
|
|
300
|
+
/** COP-300: the finished cut was checked against its own sound (cutSync). */
|
|
301
|
+
captionCheck?: true;
|
|
268
302
|
};
|
|
269
|
-
/**
|
|
270
|
-
|
|
303
|
+
/**
|
|
304
|
+
* `limited`: limitPeaks' limiter ran after the loudness pass. #4573: `limitedAgain` times it ran again lower, from
|
|
305
|
+
* the same mix, because the finished file was over -1 dBTP; `limit` is the ceiling the kept cut was made at.
|
|
306
|
+
*/
|
|
307
|
+
loudness?: { lufs: number; truePeak: number; passes: 1 | 2; limited?: true; limitedAgain?: number; limit?: number };
|
|
271
308
|
/** Present only with cutChecks. */
|
|
272
309
|
checks?: CutChecks;
|
|
310
|
+
/** COP-300: present when a sped-up cut burned its captions: the caption file is on the finished cut's clock. */
|
|
311
|
+
captionClock?: "final";
|
|
312
|
+
/**
|
|
313
|
+
* COP-300, captionCheck: the checks' verdicts (CutSync without its lists, and Check B without its rows). The worker
|
|
314
|
+
* replaces it with Check B judged on its listen of the finished film (`listens`, `model`), and the first cut's Check B
|
|
315
|
+
* as `before` when a fail made the cut again.
|
|
316
|
+
*/
|
|
317
|
+
sync?: {
|
|
318
|
+
checkA: SoundPictureCheck | null; checkB: Omit<CaptionSyncVerdict, "rows"> | null; listener: string | null;
|
|
319
|
+
model?: string; listens?: number; before?: Omit<CaptionSyncVerdict, "rows">;
|
|
320
|
+
/** The cut made again that was not kept: its own free check, and the listen's when one judged it. */
|
|
321
|
+
remadeNotKept?: { free: Omit<CaptionSyncVerdict, "rows"> | null; listen: Omit<CaptionSyncVerdict, "rows"> | null };
|
|
322
|
+
/** The sentences a member reads about the check (video/lib/captionSync.ts), as in `notes`. */
|
|
323
|
+
notes?: string[];
|
|
324
|
+
};
|
|
273
325
|
notes?: string[];
|
|
274
326
|
}
|
|
275
327
|
|
|
328
|
+
/** COP-300, captionCheck: the finished cut checked against its own sound, written beside it as <name>.sync.json. */
|
|
329
|
+
export interface CutSync {
|
|
330
|
+
/** Check A: null when ffmpeg could not read the film's frames or sound. */
|
|
331
|
+
checkA: SoundPictureCheck | null;
|
|
332
|
+
/** Check B by the free listener; null when no caption was burned. */
|
|
333
|
+
checkB: CaptionSyncVerdict | null;
|
|
334
|
+
listener: "placement" | null;
|
|
335
|
+
captionClock: "final";
|
|
336
|
+
/** Each burned caption and the time it is first seen in the finished film. */
|
|
337
|
+
captions: SeenCaption[];
|
|
338
|
+
/** The cut's takes on the finished film's clock. */
|
|
339
|
+
sections: SyncSection[];
|
|
340
|
+
/** The free listener's words of the finished film. */
|
|
341
|
+
heard: Array<{ text: string; start: number; end: number; lagMs: number; match: number }>;
|
|
342
|
+
}
|
|
343
|
+
|
|
276
344
|
/** What cutChecks measured on the finished cut, and what fails its bars. */
|
|
277
345
|
export interface CutChecks {
|
|
278
346
|
/** Caption screens holding words of two script lines, in the cut's time before any speed-up; null when no captions were burned. */
|
|
@@ -349,6 +417,8 @@ export interface FirstCutOptions {
|
|
|
349
417
|
stillFill?: boolean;
|
|
350
418
|
/** Render immutable pre-text pixels for mapped cuts or trusted Template authored text, then complete with completeFirstCutText. */
|
|
351
419
|
prepareText?: boolean;
|
|
420
|
+
/** COP-300: the finished film's heard words, on its own clock: the captions are timed by them (a cut made again after its caption check failed). */
|
|
421
|
+
heardWords?: ReadonlyArray<{ text: string; start: number; end?: number }> | null;
|
|
352
422
|
}
|
|
353
423
|
|
|
354
424
|
/** Semantic preservation and visible final-clock windows, not generated-quality proof.
|
|
@@ -409,6 +479,10 @@ export interface FirstCut {
|
|
|
409
479
|
planningTiming?: FinalPlanningTiming;
|
|
410
480
|
/** Present only when the manifest turned a finishing setting on. */
|
|
411
481
|
pace?: CutPace;
|
|
482
|
+
/** COP-300: present only with captionCheck. */
|
|
483
|
+
sync?: CutSync;
|
|
484
|
+
/** The cut's words on the finished film's clock, as written beside it. */
|
|
485
|
+
rows?: Array<{ text: string; start: number; end: number; scene?: number }>;
|
|
412
486
|
/** Present only when the manifest names sounds, beds, a ducked music bed or a music-only master. */
|
|
413
487
|
sound?: CutSound;
|
|
414
488
|
/** The music-only master's path, when one was made. */
|