@softure-ai/marketing-kit 0.11.0 → 0.12.0

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +66 -9
  3. package/dist/cli/footage.js +1 -1
  4. package/dist/cli/footage.js.map +1 -1
  5. package/dist/compose/timeline.d.ts +23 -3
  6. package/dist/compose/timeline.d.ts.map +1 -1
  7. package/dist/compose/timeline.js +31 -11
  8. package/dist/compose/timeline.js.map +1 -1
  9. package/dist/config/actions-schema.d.ts +14 -14
  10. package/dist/config/config.d.ts.map +1 -1
  11. package/dist/config/config.js +2 -0
  12. package/dist/config/config.js.map +1 -1
  13. package/dist/config/schema.d.ts +83 -70
  14. package/dist/config/schema.d.ts.map +1 -1
  15. package/dist/config/schema.js +21 -1
  16. package/dist/config/schema.js.map +1 -1
  17. package/dist/config/shot-steps.d.ts +16 -16
  18. package/dist/footage/captions.d.ts +45 -3
  19. package/dist/footage/captions.d.ts.map +1 -1
  20. package/dist/footage/captions.js +65 -5
  21. package/dist/footage/captions.js.map +1 -1
  22. package/dist/footage/compose.d.ts.map +1 -1
  23. package/dist/footage/compose.js +8 -4
  24. package/dist/footage/compose.js.map +1 -1
  25. package/dist/footage/declick.d.ts +106 -0
  26. package/dist/footage/declick.d.ts.map +1 -0
  27. package/dist/footage/declick.js +296 -0
  28. package/dist/footage/declick.js.map +1 -0
  29. package/dist/footage/draft.d.ts +8 -3
  30. package/dist/footage/draft.d.ts.map +1 -1
  31. package/dist/footage/draft.js +55 -22
  32. package/dist/footage/draft.js.map +1 -1
  33. package/dist/footage/edl.d.ts +28 -2
  34. package/dist/footage/edl.d.ts.map +1 -1
  35. package/dist/footage/edl.js +53 -2
  36. package/dist/footage/edl.js.map +1 -1
  37. package/dist/footage/film.d.ts +29 -3
  38. package/dist/footage/film.d.ts.map +1 -1
  39. package/dist/footage/film.js +12 -0
  40. package/dist/footage/film.js.map +1 -1
  41. package/dist/footage/isolate-ranges.d.ts +37 -0
  42. package/dist/footage/isolate-ranges.d.ts.map +1 -0
  43. package/dist/footage/isolate-ranges.js +113 -0
  44. package/dist/footage/isolate-ranges.js.map +1 -0
  45. package/dist/footage/loudness.d.ts +58 -0
  46. package/dist/footage/loudness.d.ts.map +1 -1
  47. package/dist/footage/loudness.js +80 -0
  48. package/dist/footage/loudness.js.map +1 -1
  49. package/dist/footage/paid.d.ts +18 -0
  50. package/dist/footage/paid.d.ts.map +1 -1
  51. package/dist/footage/paid.js +32 -2
  52. package/dist/footage/paid.js.map +1 -1
  53. package/dist/footage/pipeline.d.ts +43 -5
  54. package/dist/footage/pipeline.d.ts.map +1 -1
  55. package/dist/footage/pipeline.js +103 -20
  56. package/dist/footage/pipeline.js.map +1 -1
  57. package/dist/footage/providers.d.ts +5 -0
  58. package/dist/footage/providers.d.ts.map +1 -1
  59. package/dist/footage/publish.d.ts +11 -2
  60. package/dist/footage/publish.d.ts.map +1 -1
  61. package/dist/footage/publish.js +14 -10
  62. package/dist/footage/publish.js.map +1 -1
  63. package/dist/footage/speech-ranges.d.ts +65 -0
  64. package/dist/footage/speech-ranges.d.ts.map +1 -0
  65. package/dist/footage/speech-ranges.js +98 -0
  66. package/dist/footage/speech-ranges.js.map +1 -0
  67. package/dist/index.d.ts +10 -7
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +10 -7
  70. package/dist/index.js.map +1 -1
  71. package/package.json +1 -1
  72. package/schema/edl.schema.json +17 -0
  73. package/schema/marketing.schema.json +43 -1
  74. package/src/cli/footage.ts +1 -1
  75. package/src/compose/timeline.ts +41 -10
  76. package/src/config/config.ts +2 -0
  77. package/src/config/schema.ts +23 -1
  78. package/src/footage/captions.ts +81 -6
  79. package/src/footage/compose.ts +8 -4
  80. package/src/footage/declick.ts +353 -0
  81. package/src/footage/draft.ts +58 -23
  82. package/src/footage/edl.ts +69 -2
  83. package/src/footage/film.ts +37 -3
  84. package/src/footage/isolate-ranges.ts +161 -0
  85. package/src/footage/loudness.ts +112 -0
  86. package/src/footage/paid.ts +40 -2
  87. package/src/footage/pipeline.ts +155 -22
  88. package/src/footage/providers.ts +2 -0
  89. package/src/footage/publish.ts +20 -11
  90. package/src/footage/speech-ranges.ts +131 -0
  91. package/src/index.ts +70 -0
@@ -0,0 +1,296 @@
1
+ import { readFileSync, rmSync, writeFileSync } from "node:fs";
2
+ import { extname } from "node:path";
3
+ import { FOOTAGE_SAMPLE_RATE } from "./normalize.js";
4
+ import { runFfmpeg } from "./process.js";
5
+ /**
6
+ * The speech track's declick stage (issue #1084), between the cut speech track and its loudness normalization: mouth
7
+ * clicks and lip smacks between words are short broadband bursts well below the speech peaks, which ffmpeg's
8
+ * `adeclick` does not see. Two steps over the cut speech, both from the words' film times:
9
+ *
10
+ * - a gate: outside each word's window (start and end ± 40 ms) the speech is lowered, with a 20 ms linear fade that
11
+ * sits outside the window, so no word onset or tail is touched;
12
+ * - impulse removal: outside the words' own spans, bursts under 30 ms that jump above the 2-8 kHz band's running median
13
+ * are lowered by 30 dB with a short crossfade on both sides.
14
+ *
15
+ * The gain is applied per sample to the decoded PCM (a `volume` expression is evaluated only once per audio frame,
16
+ * about 21 ms, coarser than the crossfades).
17
+ */
18
+ export const DECLICK_LEVELS = ["off", "gentle", "strong"];
19
+ export const DECLICK_SETTINGS = {
20
+ gentle: { gateDb: -15, jumpDb: 15, crossfadeSeconds: 0.005 },
21
+ strong: { gateDb: -20, jumpDb: 9, crossfadeSeconds: 0.008 },
22
+ };
23
+ /** Seconds a word's window reaches past its start and end; the gate leaves the window untouched. */
24
+ export const DECLICK_WORD_WINDOW = 0.04;
25
+ /** The gate's fade, outside the window. */
26
+ export const DECLICK_GATE_FADE = 0.02;
27
+ /** The longest burst that counts as an impulse. */
28
+ export const DECLICK_MAX_IMPULSE = 0.03;
29
+ /** How far an impulse is lowered, in dB. */
30
+ export const DECLICK_IMPULSE_DB = -30;
31
+ const BAND_LOW_HZ = 2000;
32
+ const BAND_HIGH_HZ = 8000;
33
+ const FRAME_SECONDS = 0.002;
34
+ const HOP_SECONDS = 0.001;
35
+ /** The running median's reach on each side of a frame. */
36
+ const MEDIAN_SECONDS = 0.1;
37
+ /** A lowered impulse reaches this far past its detected frames, for the band filter's delay and the frames' edges. */
38
+ const IMPULSE_MARGIN = 0.001;
39
+ /** A frame quieter than this (mean square, dB) is never an impulse: digital silence with a stray bit is not a click. */
40
+ const BAND_FLOOR_DB = -90;
41
+ const fromDb = (db) => 10 ** (db / 20);
42
+ const sortSpans = (words) => [...words].filter((word) => word.end > word.start).sort((a, b) => a.start - b.start);
43
+ /**
44
+ * The windows the gate leaves open: each word's start and end ± `DECLICK_WORD_WINDOW`, merged when two windows (with
45
+ * their fades) would touch, so the gain never dips between two close words.
46
+ */
47
+ export function getGateWindows(words) {
48
+ const windows = [];
49
+ for (const word of sortSpans(words)) {
50
+ const start = Math.max(0, word.start - DECLICK_WORD_WINDOW);
51
+ const end = word.end + DECLICK_WORD_WINDOW;
52
+ const last = windows.at(-1);
53
+ if (last !== undefined && start - last.end < 2 * DECLICK_GATE_FADE)
54
+ last.end = Math.max(last.end, end);
55
+ else
56
+ windows.push({ start, end });
57
+ }
58
+ return windows;
59
+ }
60
+ /** One second-order section (RBJ cookbook), run in place over the samples. */
61
+ function runBiquad(samples, kind, frequency, sampleRate) {
62
+ const w0 = (2 * Math.PI * Math.min(frequency, sampleRate * 0.45)) / sampleRate;
63
+ const cos = Math.cos(w0);
64
+ const alpha = Math.sin(w0) / (2 * Math.SQRT1_2);
65
+ const a0 = 1 + alpha;
66
+ const b0 = (kind === "lowpass" ? (1 - cos) / 2 : (1 + cos) / 2) / a0;
67
+ const b1 = (kind === "lowpass" ? 1 - cos : -(1 + cos)) / a0;
68
+ const b2 = b0;
69
+ const a1 = (-2 * cos) / a0;
70
+ const a2 = (1 - alpha) / a0;
71
+ let x1 = 0;
72
+ let x2 = 0;
73
+ let y1 = 0;
74
+ let y2 = 0;
75
+ for (let index = 0; index < samples.length; index++) {
76
+ const x = samples[index] ?? 0;
77
+ const y = b0 * x + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2;
78
+ x2 = x1;
79
+ x1 = x;
80
+ y2 = y1;
81
+ y1 = y;
82
+ samples[index] = y;
83
+ }
84
+ }
85
+ /** The 2-8 kHz band of the signal: two high-pass and two low-pass sections (fourth order on each side). */
86
+ function getBand(mono, sampleRate) {
87
+ const band = Float64Array.from(mono);
88
+ runBiquad(band, "highpass", BAND_LOW_HZ, sampleRate);
89
+ runBiquad(band, "highpass", BAND_LOW_HZ, sampleRate);
90
+ runBiquad(band, "lowpass", BAND_HIGH_HZ, sampleRate);
91
+ runBiquad(band, "lowpass", BAND_HIGH_HZ, sampleRate);
92
+ return band;
93
+ }
94
+ /** Each frame's mean square in dB, frames of `frameLength` samples every `hop` samples. */
95
+ function getFrameEnergies(band, frameLength, hop) {
96
+ const sums = new Float64Array(band.length + 1);
97
+ for (let index = 0; index < band.length; index++) {
98
+ const value = band[index] ?? 0;
99
+ sums[index + 1] = (sums[index] ?? 0) + value * value;
100
+ }
101
+ const count = band.length < frameLength ? 0 : Math.floor((band.length - frameLength) / hop) + 1;
102
+ const energies = new Float64Array(count);
103
+ for (let frame = 0; frame < count; frame++) {
104
+ const from = frame * hop;
105
+ const power = ((sums[from + frameLength] ?? 0) - (sums[from] ?? 0)) / frameLength;
106
+ energies[frame] = 10 * Math.log10(Math.max(power, 1e-20));
107
+ }
108
+ return energies;
109
+ }
110
+ /** The index of the first entry of the sorted list not below `value`. */
111
+ function findInsertIndex(sorted, value) {
112
+ let low = 0;
113
+ let high = sorted.length;
114
+ while (low < high) {
115
+ const middle = (low + high) >> 1;
116
+ if ((sorted[middle] ?? 0) < value)
117
+ low = middle + 1;
118
+ else
119
+ high = middle;
120
+ }
121
+ return low;
122
+ }
123
+ /** The running median of the values over `reach` entries on each side (fewer at the ends). */
124
+ export function getRunningMedian(values, reach) {
125
+ const medians = new Float64Array(values.length);
126
+ const window = [];
127
+ let from = 0;
128
+ let to = 0;
129
+ for (let index = 0; index < values.length; index++) {
130
+ const wantedTo = Math.min(values.length, index + reach + 1);
131
+ for (; to < wantedTo; to++) {
132
+ const value = values[to] ?? 0;
133
+ window.splice(findInsertIndex(window, value), 0, value);
134
+ }
135
+ const wantedFrom = Math.max(0, index - reach);
136
+ for (; from < wantedFrom; from++)
137
+ window.splice(findInsertIndex(window, values[from] ?? 0), 1);
138
+ const middle = window.length >> 1;
139
+ medians[index] = window.length % 2 === 1 ? (window[middle] ?? 0) : ((window[middle - 1] ?? 0) + (window[middle] ?? 0)) / 2;
140
+ }
141
+ return medians;
142
+ }
143
+ /** True when the span overlaps a word's own span. */
144
+ const isInsideWord = (span, words) => words.some((word) => span.start < word.end && span.end > word.start);
145
+ /**
146
+ * The impulses of a mono signal: runs of 2 ms frames (1 ms hop) whose 2-8 kHz energy jumps more than the level's
147
+ * `jumpDb` above the band's running median (±100 ms), shorter than `DECLICK_MAX_IMPULSE`, overlapping no word's own
148
+ * span. Times in seconds, widened by a millisecond on each side.
149
+ */
150
+ export function findImpulses(mono, sampleRate, words, level) {
151
+ const { jumpDb } = DECLICK_SETTINGS[level];
152
+ const frameLength = Math.max(1, Math.round(FRAME_SECONDS * sampleRate));
153
+ const hop = Math.max(1, Math.round(HOP_SECONDS * sampleRate));
154
+ const energies = getFrameEnergies(getBand(mono, sampleRate), frameLength, hop);
155
+ const medians = getRunningMedian(energies, Math.round(MEDIAN_SECONDS / HOP_SECONDS));
156
+ const spoken = sortSpans(words);
157
+ const seconds = mono.length / sampleRate;
158
+ const impulses = [];
159
+ let runStart = -1;
160
+ const closeRun = (lastFrame) => {
161
+ const start = (runStart * hop) / sampleRate;
162
+ const end = (lastFrame * hop + frameLength) / sampleRate;
163
+ runStart = -1;
164
+ if (end - start >= DECLICK_MAX_IMPULSE)
165
+ return;
166
+ const span = { start: Math.max(0, start - IMPULSE_MARGIN), end: Math.min(seconds, end + IMPULSE_MARGIN) };
167
+ if (!isInsideWord(span, spoken))
168
+ impulses.push(span);
169
+ };
170
+ for (let frame = 0; frame < energies.length; frame++) {
171
+ const energy = energies[frame] ?? 0;
172
+ const isJump = energy > BAND_FLOOR_DB && energy - (medians[frame] ?? 0) > jumpDb;
173
+ if (isJump && runStart === -1)
174
+ runStart = frame;
175
+ else if (!isJump && runStart !== -1)
176
+ closeRun(frame - 1);
177
+ }
178
+ if (runStart !== -1)
179
+ closeRun(energies.length - 1);
180
+ return impulses;
181
+ }
182
+ /** Sets the gain to `value` from sample `from` up to (not including) `to`, multiplying what is there. */
183
+ function scaleRange(gain, from, to, value) {
184
+ for (let index = Math.max(0, from); index < Math.min(gain.length, to); index++)
185
+ gain[index] = (gain[index] ?? 1) * value(index);
186
+ }
187
+ /** A linear ramp from `fromValue` at sample `from` to `toValue` at sample `to`. */
188
+ const ramp = (from, to, fromValue, toValue) => (index) => (to <= from ? toValue : fromValue + ((toValue - fromValue) * (index - from)) / (to - from));
189
+ /**
190
+ * The stage's gain per sample: the gate (1 inside the windows, a linear fade outside them, the gate's level beyond)
191
+ * times a dip for every impulse (its crossfades clamped to the neighbouring words, so no word is touched). With no
192
+ * words, no gate.
193
+ */
194
+ export function getDeclickGain(options) {
195
+ const { length, sampleRate, level } = options;
196
+ const settings = DECLICK_SETTINGS[level];
197
+ const at = (seconds) => Math.round(seconds * sampleRate);
198
+ const windows = getGateWindows(options.words);
199
+ const gate = windows.length === 0 ? 1 : fromDb(settings.gateDb);
200
+ const gain = new Float32Array(length).fill(1);
201
+ if (gate < 1) {
202
+ const fade = at(DECLICK_GATE_FADE);
203
+ const open = new Float32Array(length).fill(gate);
204
+ for (const window of windows) {
205
+ const start = at(window.start);
206
+ const end = at(window.end);
207
+ for (let index = Math.max(0, start - fade); index < Math.min(length, end + fade); index++) {
208
+ const value = index < start ? gate + ((1 - gate) * (index - (start - fade))) / fade : index >= end ? 1 - ((1 - gate) * (index - end)) / fade : 1;
209
+ open[index] = Math.max(open[index] ?? gate, value);
210
+ }
211
+ }
212
+ gain.set(open);
213
+ }
214
+ const spoken = sortSpans(options.words);
215
+ const dip = fromDb(DECLICK_IMPULSE_DB);
216
+ const crossfade = settings.crossfadeSeconds;
217
+ for (const impulse of options.impulses) {
218
+ const before = spoken.filter((word) => word.end <= impulse.start).reduce((latest, word) => Math.max(latest, word.end), 0);
219
+ const after = spoken.filter((word) => word.start >= impulse.end).reduce((earliest, word) => Math.min(earliest, word.start), Infinity);
220
+ const start = at(impulse.start);
221
+ const end = at(impulse.end);
222
+ const fadeIn = at(Math.max(before, impulse.start - crossfade));
223
+ const fadeOut = at(Math.min(after, impulse.end + crossfade));
224
+ scaleRange(gain, fadeIn, start, ramp(fadeIn, start, 1, dip));
225
+ scaleRange(gain, start, end, () => dip);
226
+ scaleRange(gain, end, fadeOut, ramp(end, fadeOut, dip, 1));
227
+ }
228
+ return gain;
229
+ }
230
+ /** The stage over interleaved samples: the impulses found on the channels' average, then the gain on every channel. */
231
+ export function declickSamples(options) {
232
+ const { samples, channels, sampleRate, words, level } = options;
233
+ const length = Math.floor(samples.length / channels);
234
+ const mono = new Float32Array(length);
235
+ for (let index = 0; index < length; index++) {
236
+ let sum = 0;
237
+ for (let channel = 0; channel < channels; channel++)
238
+ sum += samples[index * channels + channel] ?? 0;
239
+ mono[index] = sum / channels;
240
+ }
241
+ const impulses = findImpulses(mono, sampleRate, words, level);
242
+ const gain = getDeclickGain({ length, sampleRate, words, impulses, level });
243
+ const output = new Float32Array(samples.length);
244
+ for (let index = 0; index < samples.length; index++)
245
+ output[index] = (samples[index] ?? 0) * (gain[Math.floor(index / channels)] ?? 1);
246
+ const hasGate = getGateWindows(words).length > 0;
247
+ return { samples: output, impulses, report: { level, impulses: impulses.length, gateDb: hasGate ? DECLICK_SETTINGS[level].gateDb : null } };
248
+ }
249
+ const CHANNELS = 2;
250
+ const PCM_FORMAT = ["-f", "f32le", "-ar", String(FOOTAGE_SAMPLE_RATE), "-ac", String(CHANNELS)];
251
+ /** The cut speech decoded to raw 32-bit float PCM at the film's rate, stereo. */
252
+ export function buildDeclickDecodeArgs(input, output) {
253
+ return ["-v", "error", "-y", "-i", input, "-vn", "-c:a", "pcm_f32le", ...PCM_FORMAT, output];
254
+ }
255
+ /** The declicked PCM encoded: WAV (float) when a loudness pass follows, else mp3 as the speech track is. */
256
+ export function buildDeclickEncodeArgs(input, output) {
257
+ const codec = extname(output).toLowerCase() === ".wav" ? ["-c:a", "pcm_f32le"] : ["-c:a", "libmp3lame", "-q:a", "2"];
258
+ return ["-v", "error", "-y", ...PCM_FORMAT, "-i", input, ...codec, output];
259
+ }
260
+ /** Raw little-endian float32 bytes as samples (copied, so the view is aligned). */
261
+ function readFloats(file) {
262
+ const bytes = readFileSync(file);
263
+ const samples = new Float32Array(Math.floor(bytes.length / 4));
264
+ for (let index = 0; index < samples.length; index++)
265
+ samples[index] = bytes.readFloatLE(index * 4);
266
+ return samples;
267
+ }
268
+ function writeFloats(file, samples) {
269
+ const bytes = Buffer.alloc(samples.length * 4);
270
+ for (let index = 0; index < samples.length; index++)
271
+ bytes.writeFloatLE(samples[index] ?? 0, index * 4);
272
+ writeFileSync(file, bytes);
273
+ }
274
+ /** Runs the stage on a speech track file: decode, find and lower, encode. The raw PCM next to the output is removed. */
275
+ export async function declickSpeech(options) {
276
+ const { input, output, seconds } = options;
277
+ const aborting = options.signal === undefined ? {} : { signal: options.signal };
278
+ const raw = `${output}.f32`;
279
+ const report = (done) => options.onSeconds?.(Math.min(seconds, Math.max(0, done)));
280
+ try {
281
+ await runFfmpeg("The speech declick's decode", buildDeclickDecodeArgs(input, raw), { ...aborting, output: raw, onSeconds: (done) => report(done / 2) });
282
+ const declicked = declickSamples({ samples: readFloats(raw), channels: CHANNELS, sampleRate: FOOTAGE_SAMPLE_RATE, words: options.words, level: options.level });
283
+ writeFloats(raw, declicked.samples);
284
+ await runFfmpeg("The speech declick's encode", buildDeclickEncodeArgs(raw, output), { ...aborting, output, onSeconds: (done) => report(seconds / 2 + done / 2) });
285
+ return declicked.report;
286
+ }
287
+ finally {
288
+ rmSync(raw, { force: true });
289
+ }
290
+ }
291
+ /** The stage's log line. */
292
+ export function describeDeclick(report) {
293
+ const gate = report.gateDb === null ? "no words, so no gate" : `the pauses lowered by ${String(-report.gateDb)} dB`;
294
+ return `declick (${report.level}): ${String(report.impulses)} impulse${report.impulses === 1 ? "" : "s"} removed, ${gate}.`;
295
+ }
296
+ //# sourceMappingURL=declick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declick.js","sourceRoot":"","sources":["../../src/footage/declick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAgBnE,MAAM,CAAC,MAAM,gBAAgB,GAAgD;IAC3E,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE;IAC5D,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE;CAC5D,CAAC;AAEF,oGAAoG;AACpG,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,2CAA2C;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,mDAAmD;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,CAAC;AAEtC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,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QAClK,OAAO,SAAS,CAAC,MAAM,CAAC;IAC1B,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,4BAA4B;AAC5B,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,yBAAyB,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IACpH,OAAO,YAAY,MAAM,CAAC,KAAK,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,aAAa,IAAI,GAAG,CAAC;AAC9H,CAAC"}
@@ -1,7 +1,9 @@
1
- import { type CaptionLayout, type LayoutOverride } from "../compose/timeline.js";
1
+ import type { CaptionLayout, LayoutOverride } from "../compose/timeline.js";
2
2
  import type { BrandColors } from "../config/colors.js";
3
3
  import type { TimedWord } from "../voice/voiceover.js";
4
+ import { type CaptionWordsFilm } from "./captions.js";
4
5
  import { type Edl } from "./edl.js";
6
+ import { type DeclickReport } from "./declick.js";
5
7
  import { type FootageFilm } from "./film.js";
6
8
  import { type Frame } from "./normalize.js";
7
9
  import { type FootageBrand, type FootageResult, type FootageRunOptions, type PreparedClip, type TranscribeOutcome } from "./pipeline.js";
@@ -35,7 +37,7 @@ export declare function toAssColor(hex: string): string;
35
37
  /** The caption colours the draft paints with (`BrandColors`). */
36
38
  export type FootageDraftCaptionColors = Pick<BrandColors, "captionBackground" | "captionText" | "captionHighlight">;
37
39
  export interface FootageDraftCaptionsInput {
38
- film: Pick<FootageFilm, "captions" | "captionStyle">;
40
+ film: Pick<FootageFilm, "captions" | "captionStyle"> & CaptionWordsFilm;
39
41
  edl: Edl;
40
42
  /** The film's words in film time (`remapWords`). */
41
43
  words: TimedWord[];
@@ -53,7 +55,8 @@ export interface FootageDraftCaptionsInput {
53
55
  * caption box from its top (or from its foot, with `bottom`). `phrase` (the default): the film's phrases
54
56
  * (`phraseChunks`), white bold text with a dark outline and shadow. `highlight`: the render's chunks of up to four
55
57
  * words (`captionChunks`) on an opaque box of `captionBackground`, in `captionText`, the word being said in
56
- * `captionHighlight`. Null when the film has no captions or nothing is said.
58
+ * `captionHighlight`. Both keep the film's kept words with the next, as the render does. Null when the film has no
59
+ * captions or nothing is said.
57
60
  */
58
61
  export declare function buildFootageDraftCaptions(input: FootageDraftCaptionsInput): string | null;
59
62
  export interface FootageDraftArgsInput {
@@ -144,6 +147,8 @@ export interface FootageDraft {
144
147
  width: number;
145
148
  height: number;
146
149
  bytes: number;
150
+ /** What the speech track's declick stage did, as the render does it; null when the film's declick is off. */
151
+ declick: DeclickReport | null;
147
152
  }
148
153
  /**
149
154
  * Makes the draft of a cut film: the speech track, the ducked music track (when it costs nothing), the captions file
@@ -1 +1 @@
1
- {"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../../src/footage/draft.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAgD,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAA8B,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACxE,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IAAI,CAAC;CAC/B;AA0BD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,iBAAiB,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAE1N"}
@@ -1,13 +1,13 @@
1
1
  import { copyFileSync, existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
2
2
  import { basename, dirname, join, resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import { captionChunks } from "../compose/timeline.js";
5
4
  import { err, ok } from "../voice/provider.js";
6
- import { getCaptionSpans, getFootageCaptionLayout, phraseChunks } from "./captions.js";
5
+ import { getCaptionChunkLayouts, getCaptionSpans, getFootageCaptionChunks, getFootageCaptionLayout, isSameCaptionPlace } from "./captions.js";
7
6
  import { getSegmentScales, getSegmentZoomEases } from "./compose.js";
8
7
  import { chooseFootageDraftFont } from "./draft-font.js";
9
8
  import { getEdlDuration, getSegmentStarts, remapWords } from "./edl.js";
10
- import { getFootageEdit } from "./film.js";
9
+ import { declickSpeech, describeDeclick } from "./declick.js";
10
+ import { getDeclickLevel, getFootageEdit } from "./film.js";
11
11
  import { duckingKeyframes, getDuckingOptions } from "./music.js";
12
12
  import { FOOTAGE_FPS, getThreadArgs } from "./normalize.js";
13
13
  import { findFootageMusic, getFfmpegReporting, getFrame } from "./pipeline.js";
@@ -68,15 +68,24 @@ export function toAssColor(hex) {
68
68
  const alpha = full.length === 8 ? (255 - parseInt(full.slice(6, 8), 16)).toString(16).padStart(2, "0").toUpperCase() : "00";
69
69
  return `&H${alpha}${pair(4)}${pair(2)}${pair(0)}`;
70
70
  }
71
- /** Caption text as ASS dialogue: override braces and backslashes would be read as tags, line breaks end the line. */
71
+ /**
72
+ * Caption text as ASS dialogue: override braces and backslashes would be read as tags, line breaks end the line. A
73
+ * no-break space (U+00A0) becomes ASS's hard space `\h`, which libass never breaks a line at, as the render's HTML.
74
+ */
72
75
  function toAssText(text) {
73
- return text.replace(/\\/g, "/").replace(/\{/g, "(").replace(/\}/g, ")").replace(/\s+/g, " ").trim();
76
+ return text
77
+ .replace(/\\/g, "/")
78
+ .replace(/\{/g, "(")
79
+ .replace(/\}/g, ")")
80
+ .replace(/[^\S\u00a0]+/g, " ")
81
+ .replace(/^ +| +$/g, "")
82
+ .replace(/\u00a0/g, "\\h");
74
83
  }
75
84
  /**
76
85
  * A `highlight` chunk as ASS events: its span cut wherever a word lights up or goes out, each piece showing the chunk
77
86
  * with the words lit then in `highlight` (a word stays lit for the render's 0.32 s from its start).
78
87
  */
79
- function buildHighlightEvents(chunk, span, colors) {
88
+ function buildHighlightEvents(chunk, span, colors, styleName) {
80
89
  const cs = (seconds) => Math.round(seconds * 100);
81
90
  const [from, to] = [cs(span.start), cs(span.end)];
82
91
  const lights = chunk.words.map((word) => ({ on: cs(word.start), off: cs(word.start + HIGHLIGHT_SECONDS) }));
@@ -91,7 +100,7 @@ function buildHighlightEvents(chunk, span, colors) {
91
100
  return light.on <= at && at < light.off ? `{\\1c${colors.highlight}&}${shown}{\\1c${colors.text}&}` : shown;
92
101
  })
93
102
  .join(" ");
94
- events.push(`Dialogue: 0,${toAssTime(at / 100)},${toAssTime(next / 100)},Caption,,0,0,0,,${text}`);
103
+ events.push(`Dialogue: 0,${toAssTime(at / 100)},${toAssTime(next / 100)},${styleName},,0,0,0,,${text}`);
95
104
  });
96
105
  return events;
97
106
  }
@@ -100,13 +109,14 @@ function buildHighlightEvents(chunk, span, colors) {
100
109
  * caption box from its top (or from its foot, with `bottom`). `phrase` (the default): the film's phrases
101
110
  * (`phraseChunks`), white bold text with a dark outline and shadow. `highlight`: the render's chunks of up to four
102
111
  * words (`captionChunks`) on an opaque box of `captionBackground`, in `captionText`, the word being said in
103
- * `captionHighlight`. Null when the film has no captions or nothing is said.
112
+ * `captionHighlight`. Both keep the film's kept words with the next, as the render does. Null when the film has no
113
+ * captions or nothing is said.
104
114
  */
105
115
  export function buildFootageDraftCaptions(input) {
106
116
  if (!input.film.captions)
107
117
  return null;
108
118
  const isHighlight = input.film.captionStyle === "highlight";
109
- const chunks = isHighlight ? captionChunks(input.words) : phraseChunks(input.words);
119
+ const chunks = getFootageCaptionChunks(input.film, input.words);
110
120
  if (chunks.length === 0)
111
121
  return null;
112
122
  const spans = getCaptionSpans(chunks, getEdlDuration(input.edl));
@@ -126,8 +136,8 @@ export function buildFootageDraftCaptions(input) {
126
136
  outline: Math.max(1, Math.round(caption.fontSize / 16)),
127
137
  shadow: Math.max(1, Math.round(caption.fontSize / 25)),
128
138
  };
129
- const style = [
130
- "Caption",
139
+ const toStyle = (name, place) => [
140
+ name,
131
141
  family,
132
142
  caption.fontSize,
133
143
  look.primary,
@@ -146,19 +156,33 @@ export function buildFootageDraftCaptions(input) {
146
156
  look.outline,
147
157
  look.shadow,
148
158
  // ASS alignment 2 hangs the text from MarginV above the bottom, 8 from MarginV below the top.
149
- caption.bottom === undefined ? 8 : 2,
150
- Math.round(caption.left),
151
- Math.round(caption.right),
152
- Math.round(caption.bottom ?? caption.top),
159
+ place.bottom === undefined ? 8 : 2,
160
+ Math.round(place.left),
161
+ Math.round(place.right),
162
+ Math.round(place.bottom ?? place.top),
153
163
  1,
154
164
  ].join(",");
165
+ // A chunk in a segment's own box gets a style of that box (Caption2, Caption3, ...); the film's box stays `Caption`.
166
+ const styles = [toStyle("Caption", caption)];
167
+ const moved = [];
168
+ const styleNames = getCaptionChunkLayouts(chunks, input.edl, caption).map((place) => {
169
+ if (isSameCaptionPlace(place, caption))
170
+ return "Caption";
171
+ let index = moved.findIndex((other) => isSameCaptionPlace(other, place));
172
+ if (index === -1) {
173
+ index = moved.push(place) - 1;
174
+ styles.push(toStyle(`Caption${index + 2}`, place));
175
+ }
176
+ return `Caption${index + 2}`;
177
+ });
155
178
  const highlight = { text: text.replace(/^&H../, "&H"), highlight: toAssColor(colors.captionHighlight).replace(/^&H../, "&H") };
156
179
  const events = chunks.flatMap((chunk, index) => {
157
180
  const span = spans[index];
181
+ const styleName = styleNames[index] ?? "Caption";
158
182
  if (isHighlight)
159
- return buildHighlightEvents(chunk, span, highlight);
183
+ return buildHighlightEvents(chunk, span, highlight, styleName);
160
184
  const line = toAssText(chunk.words.map((word) => word.text).join(" "));
161
- return [`Dialogue: 0,${toAssTime(span.start)},${toAssTime(span.end)},Caption,,0,0,0,,${line}`];
185
+ return [`Dialogue: 0,${toAssTime(span.start)},${toAssTime(span.end)},${styleName},,0,0,0,,${line}`];
162
186
  });
163
187
  return [
164
188
  "[Script Info]",
@@ -170,7 +194,7 @@ export function buildFootageDraftCaptions(input) {
170
194
  "",
171
195
  "[V4+ Styles]",
172
196
  "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding",
173
- `Style: ${style}`,
197
+ ...styles.map((style) => `Style: ${style}`),
174
198
  "",
175
199
  "[Events]",
176
200
  "Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
@@ -362,13 +386,16 @@ async function runRenderFootageDraft(film, clips, transcript, edl, options) {
362
386
  const draftDir = resolve(options.buildDir, "draft");
363
387
  rmSync(draftDir, { recursive: true, force: true });
364
388
  mkdirSync(draftDir, { recursive: true });
365
- const items = music.value.kind === "file" ? ["speech", "music", "film"] : ["speech", "film"];
389
+ const declickLevel = getDeclickLevel(film);
390
+ const items = ["speech", ...(declickLevel === "off" ? [] : ["declick"]), ...(music.value.kind === "file" ? ["music"] : []), "film"];
366
391
  const report = (item, done) => {
367
392
  const itemIndex = items.indexOf(item) + 1;
368
393
  options.onProgress?.({ step: "draft", item, itemIndex, itemCount: items.length, done: Math.min(seconds * items.length, (itemIndex - 1) * seconds + done), total: seconds * items.length });
369
394
  };
370
395
  const clipFiles = Object.fromEntries(clips.map((clip) => [clip.clip.id, resolve(clip.file)]));
371
- const speech = join(draftDir, "speech.mp3");
396
+ const cutSpeech = join(draftDir, "speech.mp3");
397
+ // The declicked track stays WAV: the draft's one encode is its only lossy step after the cut.
398
+ const speech = declickLevel === "off" ? cutSpeech : join(draftDir, "speech.declicked.wav");
372
399
  const words = remapWords(edl, transcript.words, film.cut.fillers);
373
400
  const frame = getFrame(film);
374
401
  const brandFont = chooseFootageDraftFont(options.brand?.fonts.body ?? null);
@@ -393,7 +420,13 @@ async function runRenderFootageDraft(film, clips, transcript, edl, options) {
393
420
  const output = resolve(options.output);
394
421
  mkdirSync(dirname(output), { recursive: true });
395
422
  report("speech", 0);
396
- await runFfmpeg("The draft's speech track", buildSpeechArgs(edl, transcript.speech, speech, getSpeechCutOptions(getFootageEdit(film))), { ...aborting, output: speech, onSeconds: (done) => report("speech", done) });
423
+ await runFfmpeg("The draft's speech track", buildSpeechArgs(edl, transcript.speech, cutSpeech, getSpeechCutOptions(getFootageEdit(film))), { ...aborting, output: cutSpeech, onSeconds: (done) => report("speech", done) });
424
+ let declick = null;
425
+ if (declickLevel !== "off") {
426
+ report("declick", 0);
427
+ declick = await declickSpeech({ input: cutSpeech, output: speech, words, level: declickLevel, seconds, ...aborting, onSeconds: (done) => report("declick", done) });
428
+ log(describeDeclick(declick));
429
+ }
397
430
  let musicFile = null;
398
431
  if (music.value.kind === "file") {
399
432
  musicFile = join(draftDir, "music.mp3");
@@ -427,6 +460,6 @@ async function runRenderFootageDraft(film, clips, transcript, edl, options) {
427
460
  const draftMusic = music.value.kind === "file" ? "played" : music.value.kind;
428
461
  const notes = [captions === null ? "no captions" : `captions in ${font.family}`, draftMusic === "played" ? "music" : draftMusic === "none" ? "no music" : "music not cached"];
429
462
  log(`draft: ${output}, ${draft.width}×${draft.height}, ${seconds.toFixed(1)} s, ${bytes} bytes, ${notes.join(", ")}.`);
430
- return ok({ output, music: draftMusic, captionFont: captions === null ? null : font.family, seconds, width: draft.width, height: draft.height, bytes });
463
+ return ok({ output, music: draftMusic, captionFont: captions === null ? null : font.family, seconds, width: draft.width, height: draft.height, bytes, declick });
431
464
  }
432
465
  //# sourceMappingURL=draft.js.map