@softure-ai/marketing-kit 0.23.0 → 0.25.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.
- package/CHANGELOG.md +29 -0
- package/README.md +23 -0
- package/dist/footage/captions.d.ts +8 -1
- package/dist/footage/captions.d.ts.map +1 -1
- package/dist/footage/captions.js +5 -3
- package/dist/footage/captions.js.map +1 -1
- package/dist/footage/compose.d.ts +2 -0
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +3 -2
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/draft-overlays.d.ts +21 -4
- package/dist/footage/draft-overlays.d.ts.map +1 -1
- package/dist/footage/draft-overlays.js +242 -36
- package/dist/footage/draft-overlays.js.map +1 -1
- package/dist/footage/draft.d.ts +7 -2
- package/dist/footage/draft.d.ts.map +1 -1
- package/dist/footage/draft.js +13 -2
- package/dist/footage/draft.js.map +1 -1
- package/dist/footage/edl.d.ts +27 -0
- package/dist/footage/edl.d.ts.map +1 -1
- package/dist/footage/edl.js +1 -1
- package/dist/footage/edl.js.map +1 -1
- package/dist/footage/overlay-html.d.ts +21 -1
- package/dist/footage/overlay-html.d.ts.map +1 -1
- package/dist/footage/overlay-html.js +217 -56
- package/dist/footage/overlay-html.js.map +1 -1
- package/dist/footage/overlay-schema.d.ts +98 -6
- package/dist/footage/overlay-schema.d.ts.map +1 -1
- package/dist/footage/overlay-schema.js +215 -45
- package/dist/footage/overlay-schema.js.map +1 -1
- package/dist/footage/overlays.d.ts +121 -16
- package/dist/footage/overlays.d.ts.map +1 -1
- package/dist/footage/overlays.js +323 -52
- package/dist/footage/overlays.js.map +1 -1
- package/dist/footage/pipeline.d.ts +5 -0
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +3 -2
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/render/render.d.ts +4 -1
- package/dist/render/render.d.ts.map +1 -1
- package/dist/render/render.js +2 -1
- package/dist/render/render.js.map +1 -1
- package/package.json +1 -1
- package/schema/edl.schema.json +90 -8
- package/src/footage/captions.ts +13 -4
- package/src/footage/compose.ts +5 -3
- package/src/footage/draft-overlays.ts +291 -37
- package/src/footage/draft.ts +20 -4
- package/src/footage/edl.ts +1 -1
- package/src/footage/overlay-html.ts +239 -59
- package/src/footage/overlay-schema.ts +245 -40
- package/src/footage/overlays.ts +387 -55
- package/src/footage/pipeline.ts +8 -3
- package/src/index.ts +27 -0
- package/src/render/render.ts +3 -2
package/src/footage/overlays.ts
CHANGED
|
@@ -4,7 +4,17 @@ import { applySegmentCaption, CAPTION_SAFE_ZONES } from "./captions.js";
|
|
|
4
4
|
import { getEdlDuration, getSegmentStarts, findSegmentAt, type Edl } from "./edl.js";
|
|
5
5
|
import { getFootageEdit, type FootageFilm } from "./film.js";
|
|
6
6
|
import { FOOTAGE_FPS } from "./normalize.js";
|
|
7
|
-
import
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_OVERLAY_TYPING_SPEED,
|
|
9
|
+
isTypedOverlay,
|
|
10
|
+
type EdlOverlay,
|
|
11
|
+
type EdlOverlayColors,
|
|
12
|
+
type OverlayEntrance,
|
|
13
|
+
type OverlayKind,
|
|
14
|
+
type OverlayPosition,
|
|
15
|
+
type OverlaySide,
|
|
16
|
+
type OverlaySize,
|
|
17
|
+
} from "./overlay-schema.js";
|
|
8
18
|
import { getSegmentZoomEases } from "./compose.js";
|
|
9
19
|
import { normalizeWord } from "./words.js";
|
|
10
20
|
|
|
@@ -19,16 +29,37 @@ import { normalizeWord } from "./words.js";
|
|
|
19
29
|
export const PUNCH_IN_SCALES: Record<OverlaySize, number> = { s: 1.08, m: 1.12, l: 1.15 };
|
|
20
30
|
/** The `punch_in`'s ease into its zoom and back out, in seconds (shorter when the overlay is short). */
|
|
21
31
|
export const PUNCH_IN_EASE_SECONDS = 0.35;
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
|
|
33
|
+
/** The kinds drawn with text: every kind but `punch_in`, `arrow` and `highlight`. */
|
|
34
|
+
export type TextOverlayKind = Exclude<OverlayKind, "punch_in" | "arrow" | "highlight">;
|
|
35
|
+
|
|
36
|
+
/** A text overlay's main type size in px of a 1080 px wide frame, by kind and size step. */
|
|
37
|
+
export const OVERLAY_FONT_SIZES: Record<TextOverlayKind, Record<OverlaySize, number>> = {
|
|
24
38
|
keyword: { s: 64, m: 84, l: 108 },
|
|
25
39
|
lower_third: { s: 44, m: 52, l: 60 },
|
|
26
40
|
list: { s: 40, m: 48, l: 56 },
|
|
41
|
+
hook_title: { s: 52, m: 64, l: 76 },
|
|
42
|
+
search_bar: { s: 36, m: 42, l: 50 },
|
|
43
|
+
place_card: { s: 72, m: 92, l: 112 },
|
|
44
|
+
counter: { s: 84, m: 108, l: 132 },
|
|
45
|
+
date_stamp: { s: 30, m: 36, l: 44 },
|
|
27
46
|
};
|
|
47
|
+
/** A second line's type size in main font sizes: the hook title's place label, the subtitle, the unit, the stamp's place. */
|
|
48
|
+
export const OVERLAY_SECONDARY_SCALE = { hook_title: 0.55, place_card: 0.42, counter: 0.5, date_stamp: 0.78 } as const;
|
|
28
49
|
/** A text overlay's line height and its box's padding, in font sizes. */
|
|
29
50
|
export const OVERLAY_LINE_HEIGHT = 1.15;
|
|
30
51
|
export const OVERLAY_LIST_LINE_HEIGHT = 1.4;
|
|
52
|
+
/** A place card title's line height, tighter for its big type. */
|
|
53
|
+
export const OVERLAY_TITLE_LINE_HEIGHT = 1.05;
|
|
31
54
|
export const OVERLAY_PADDING_EM = { x: 0.6, y: 0.35 } as const;
|
|
55
|
+
/** The search field's padding round its query, in font sizes (its height is the line plus twice this). */
|
|
56
|
+
export const SEARCH_BAR_PADDING_EM = { x: 0.7, y: 0.55 } as const;
|
|
57
|
+
/** The room the search field's magnifier and its gap take before the query, in font sizes. */
|
|
58
|
+
export const SEARCH_BAR_ICON_EM = 1.5;
|
|
59
|
+
/** The average advance of a bold Latin letter, in font sizes: how wide a line is estimated before it is drawn. */
|
|
60
|
+
export const OVERLAY_CHAR_EM = 0.56;
|
|
61
|
+
/** The most lines a hook title or a place card's title wraps to. */
|
|
62
|
+
export const MAX_OVERLAY_TITLE_LINES = 2;
|
|
32
63
|
/** The room kept between an overlay and the safe zone's edge or the captions, in px. */
|
|
33
64
|
export const OVERLAY_MARGIN = 24;
|
|
34
65
|
/** How far an arrow's tail sits from the point it points at, in px. */
|
|
@@ -38,6 +69,21 @@ const MIN_HIGHLIGHT_SIDE = 40;
|
|
|
38
69
|
/** The safe zone of a frame that is not a 1080×1920 vertical: 80 px on every side. */
|
|
39
70
|
const DEFAULT_SAFE_MARGIN = 80;
|
|
40
71
|
|
|
72
|
+
/** The brand font a text overlay is drawn in: `heading` for titles and numbers, `interface` for labels and lists. */
|
|
73
|
+
export type OverlayFontRole = "heading" | "interface";
|
|
74
|
+
|
|
75
|
+
/** Each text kind's font role (the hook title's place label and a place card's subtitle are interface text). */
|
|
76
|
+
export const OVERLAY_FONT_ROLES: Record<TextOverlayKind, OverlayFontRole> = {
|
|
77
|
+
keyword: "heading",
|
|
78
|
+
hook_title: "heading",
|
|
79
|
+
place_card: "heading",
|
|
80
|
+
counter: "heading",
|
|
81
|
+
lower_third: "interface",
|
|
82
|
+
list: "interface",
|
|
83
|
+
search_bar: "interface",
|
|
84
|
+
date_stamp: "interface",
|
|
85
|
+
};
|
|
86
|
+
|
|
41
87
|
/** A box in the film's frame, in px. */
|
|
42
88
|
export interface OverlayBox {
|
|
43
89
|
left: number;
|
|
@@ -57,17 +103,37 @@ interface OverlayBase {
|
|
|
57
103
|
/** Film seconds. */
|
|
58
104
|
start: number;
|
|
59
105
|
end: number;
|
|
60
|
-
/** The segment it
|
|
106
|
+
/** The segment it starts in. */
|
|
61
107
|
segment: number;
|
|
62
108
|
}
|
|
63
109
|
|
|
64
|
-
/**
|
|
110
|
+
/** How a drawn overlay looks besides its place: its entrance (null: the kind's own), typing speed and own colours. */
|
|
111
|
+
export interface OverlayLook {
|
|
112
|
+
entrance: OverlayEntrance | null;
|
|
113
|
+
/** Characters per second when it types its text in, else null. */
|
|
114
|
+
typing: number | null;
|
|
115
|
+
/** Its own colours in place of the brand's (empty: the brand's). */
|
|
116
|
+
colors: EdlOverlayColors;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
type Drawn = OverlayBase & OverlayLook;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A text overlay's box: for `keyword`, `lower_third` and `list`, `left` and `top` of its outer edge and the most it
|
|
123
|
+
* may take (it shrinks to its text); for the others, the box its card takes.
|
|
124
|
+
*/
|
|
65
125
|
export type ResolvedOverlay =
|
|
66
126
|
| (OverlayBase & { kind: "punch_in"; scale: number; ease: number })
|
|
67
|
-
| (
|
|
68
|
-
| (
|
|
69
|
-
| (
|
|
70
|
-
| (
|
|
127
|
+
| (Drawn & { kind: "keyword"; text: string; fontSize: number; side: OverlaySide; box: OverlayBox })
|
|
128
|
+
| (Drawn & { kind: "lower_third"; text: string; fontSize: number; side: OverlaySide; box: OverlayBox })
|
|
129
|
+
| (Drawn & { kind: "list"; items: string[]; fontSize: number; side: OverlaySide; box: OverlayBox })
|
|
130
|
+
| (Drawn & { kind: "arrow"; from: OverlayPoint; to: OverlayPoint })
|
|
131
|
+
| (Drawn & { kind: "highlight"; rect: OverlayBox })
|
|
132
|
+
| (Drawn & { kind: "hook_title"; lines: string[]; place: string | null; fontSize: number; placeFontSize: number; box: OverlayBox })
|
|
133
|
+
| (Drawn & { kind: "search_bar"; text: string; fontSize: number; box: OverlayBox })
|
|
134
|
+
| (Drawn & { kind: "place_card"; lines: string[]; subtitle: string | null; fontSize: number; subtitleFontSize: number; box: OverlayBox })
|
|
135
|
+
| (Drawn & { kind: "counter"; value: number; from: number; decimals: number; unit: string | null; fontSize: number; unitFontSize: number; box: OverlayBox })
|
|
136
|
+
| (Drawn & { kind: "date_stamp"; text: string; place: string | null; fontSize: number; placeFontSize: number; side: OverlaySide; box: OverlayBox });
|
|
71
137
|
|
|
72
138
|
export type ResolvedOverlaysResult = { ok: true; overlays: ResolvedOverlay[] } | { ok: false; problems: string[] };
|
|
73
139
|
|
|
@@ -115,12 +181,84 @@ function findOverlayStart(overlay: EdlOverlay, words: TimedWord[]): { ok: true;
|
|
|
115
181
|
const r1 = (value: number): number => Math.round(value * 10) / 10;
|
|
116
182
|
const r3 = (value: number): number => Math.round(value * 1000) / 1000 || 0;
|
|
117
183
|
|
|
184
|
+
/** The estimated width of a line of text at a font size, in px (`OVERLAY_CHAR_EM` a letter). */
|
|
185
|
+
export function estimateTextWidth(text: string, fontSize: number): number {
|
|
186
|
+
return Math.ceil([...text].length * OVERLAY_CHAR_EM * fontSize - 1e-6);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Text broken into lines at spaces so each fits `width` at `fontSize` by the estimate; a word longer than a line stands alone. */
|
|
190
|
+
export function wrapOverlayText(text: string, fontSize: number, width: number): string[] {
|
|
191
|
+
const lines: string[] = [];
|
|
192
|
+
for (const word of text.split(/\s+/).filter((part) => part.length > 0)) {
|
|
193
|
+
const last = lines[lines.length - 1];
|
|
194
|
+
if (last !== undefined && estimateTextWidth(`${last} ${word}`, fontSize) <= width) lines[lines.length - 1] = `${last} ${word}`;
|
|
195
|
+
else lines.push(word);
|
|
196
|
+
}
|
|
197
|
+
return lines;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The decimals a number is written with: 0, 1 or 2. */
|
|
201
|
+
function countDecimals(number: number): number {
|
|
202
|
+
if (Number.isInteger(number)) return 0;
|
|
203
|
+
return Number.isInteger(Math.round(number * 100) / 10) ? 1 : 2;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** The number of decimals a counter shows: the most of its value's and its start's (at most two). */
|
|
207
|
+
export function getCounterDecimals(value: number, from: number): number {
|
|
208
|
+
return Math.max(countDecimals(value), countDecimals(from));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** A counter's number as the film shows it, grouped as `locale` writes numbers, with plain spaces for the group gaps. */
|
|
212
|
+
export function formatOverlayNumber(value: number, decimals: number, locale: string): string {
|
|
213
|
+
return new Intl.NumberFormat(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }).format(value).replace(/[\u00a0\u202f]/g, " ");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Whether two boxes share any px. */
|
|
217
|
+
function isOverlapping(a: OverlayBox, b: OverlayBox): boolean {
|
|
218
|
+
return a.left < b.left + b.width && b.left < a.left + a.width && a.top < b.top + b.height && b.top < a.top + a.height;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** The box a drawn overlay takes in the frame, or null for a `punch_in` (it draws nothing). */
|
|
222
|
+
export function getOverlayBounds(overlay: ResolvedOverlay): OverlayBox | null {
|
|
223
|
+
if (overlay.kind === "punch_in") return null;
|
|
224
|
+
if (overlay.kind === "highlight") return overlay.rect;
|
|
225
|
+
if (overlay.kind === "arrow") {
|
|
226
|
+
const [left, top] = [Math.min(overlay.from.x, overlay.to.x), Math.min(overlay.from.y, overlay.to.y)];
|
|
227
|
+
return { left, top, width: Math.max(overlay.from.x, overlay.to.x) - left, height: Math.max(overlay.from.y, overlay.to.y) - top };
|
|
228
|
+
}
|
|
229
|
+
return overlay.box;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
type SideTextOverlay = Extract<ResolvedOverlay, { kind: "keyword" | "lower_third" | "list" }>;
|
|
233
|
+
|
|
234
|
+
/** A keyword's, a lower third's or a list's lines as the draft draws them: a list's points with their bullets. */
|
|
235
|
+
export function getSideTextLines(overlay: SideTextOverlay): string[] {
|
|
236
|
+
const lines = overlay.kind === "list" ? overlay.items.map((item) => `• ${item}`) : [overlay.text];
|
|
237
|
+
return lines.map((line) => line.replace(/\s+/g, " ").trim());
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The card a drawn overlay shows, in px of the frame, or null for a `punch_in`. A keyword, a lower third and a list
|
|
242
|
+
* are placed in the whole width they may take (`box`); their card fits their widest line (by `estimateTextWidth`)
|
|
243
|
+
* plus its padding, on its side, as tall as the box. Every other kind's card is its box (`getOverlayBounds`). The
|
|
244
|
+
* draft draws this card, so a report of where an overlay sits (does it cover a face?) reads the same box.
|
|
245
|
+
*/
|
|
246
|
+
export function getDrawnOverlayCard(overlay: ResolvedOverlay): OverlayBox | null {
|
|
247
|
+
if (overlay.kind !== "keyword" && overlay.kind !== "lower_third" && overlay.kind !== "list") return getOverlayBounds(overlay);
|
|
248
|
+
const { box, fontSize, side } = overlay;
|
|
249
|
+
const padX = Math.round(fontSize * OVERLAY_PADDING_EM.x);
|
|
250
|
+
const textWidth = Math.max(0, ...getSideTextLines(overlay).map((line) => estimateTextWidth(line, fontSize)));
|
|
251
|
+
const width = Math.min(box.width, Math.ceil(textWidth + 2 * padX));
|
|
252
|
+
return { left: side === "right" ? box.left + box.width - width : box.left, top: box.top, width, height: box.height };
|
|
253
|
+
}
|
|
254
|
+
|
|
118
255
|
/**
|
|
119
256
|
* The overlays of an EDL resolved to film time and placed, or every reason one cannot be drawn: its word is not said,
|
|
120
|
-
* it is too short or runs past the cut or into the next segment, two overlap,
|
|
121
|
-
* `overlayMinSpacing`, a text overlay does not fit between the safe zone and the captions, an
|
|
122
|
-
* zone or sits on the captions, or a `punch_in` falls on a `kenburns` segment or inside a zoom
|
|
123
|
-
*
|
|
257
|
+
* it is too short or runs past the cut or into the next segment (a `hook_title` may stay across cuts), two overlap,
|
|
258
|
+
* two start closer than `overlayMinSpacing`, a text overlay does not fit between the safe zone and the captions, an
|
|
259
|
+
* anchor leaves the safe zone or sits on the captions, or a `punch_in` falls on a `kenburns` segment or inside a zoom
|
|
260
|
+
* cut's ease. A `hook_title` lives in the top band: it does not count against one overlay at a time or the spacing,
|
|
261
|
+
* but nothing drawn while it shows may sit on it. An EDL without overlays resolves to none.
|
|
124
262
|
*/
|
|
125
263
|
export function resolveEdlOverlays(input: ResolveOverlaysInput): ResolvedOverlaysResult {
|
|
126
264
|
const overlays = input.edl.overlays ?? [];
|
|
@@ -149,7 +287,7 @@ export function resolveEdlOverlays(input: ResolveOverlaysInput): ResolvedOverlay
|
|
|
149
287
|
const segmentStart = starts[segment] as number;
|
|
150
288
|
const segmentEnd = r3(segmentStart + ((edl.segments[segment]?.end ?? 0) - (edl.segments[segment]?.start ?? 0)));
|
|
151
289
|
const segmentId = edl.segments[segment]?.id ?? "";
|
|
152
|
-
if (end > segmentEnd + 0.01) {
|
|
290
|
+
if (overlay.kind !== "hook_title" && end > segmentEnd + 0.01) {
|
|
153
291
|
problems.push(`${at}: runs ${r1(end - segmentEnd)} s past the cut at ${segmentEnd} s; keep it inside segment "${segmentId}" (${segmentStart}-${segmentEnd} s) or shorten it`);
|
|
154
292
|
return;
|
|
155
293
|
}
|
|
@@ -173,9 +311,21 @@ export function resolveEdlOverlays(input: ResolveOverlaysInput): ResolvedOverlay
|
|
|
173
311
|
resolved.push(placed.overlay);
|
|
174
312
|
});
|
|
175
313
|
const ordered = [...resolved].sort((a, b) => a.start - b.start);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
314
|
+
problems.push(...findTimingProblems(ordered, film.overlayMinSpacing ?? 0));
|
|
315
|
+
return problems.length > 0 ? { ok: false, problems } : { ok: true, overlays: ordered };
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** Whether two overlays are on screen at the same time. */
|
|
319
|
+
function isConcurrent(a: ResolvedOverlay, b: ResolvedOverlay): boolean {
|
|
320
|
+
return a.start < b.end - 0.001 && b.start < a.end - 0.001;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Two overlays on screen at once, two too close, two hook titles at once, or a drawing on a hook title while it shows. */
|
|
324
|
+
function findTimingProblems(ordered: readonly ResolvedOverlay[], spacing: number): string[] {
|
|
325
|
+
const problems: string[] = [];
|
|
326
|
+
const counted = ordered.filter((overlay) => overlay.kind !== "hook_title");
|
|
327
|
+
counted.forEach((overlay, place) => {
|
|
328
|
+
const previous = counted[place - 1];
|
|
179
329
|
if (previous === undefined) return;
|
|
180
330
|
if (overlay.start < previous.end - 0.001) {
|
|
181
331
|
problems.push(`overlays[${overlay.index}]: starts at ${overlay.start} s while overlays[${previous.index}] is on screen (until ${previous.end} s); one overlay at a time`);
|
|
@@ -183,7 +333,20 @@ export function resolveEdlOverlays(input: ResolveOverlaysInput): ResolvedOverlay
|
|
|
183
333
|
problems.push(`overlays[${overlay.index}]: starts ${r1(overlay.start - previous.start)} s after overlays[${previous.index}]; the film keeps overlays ${spacing} s apart (overlayMinSpacing)`);
|
|
184
334
|
}
|
|
185
335
|
});
|
|
186
|
-
|
|
336
|
+
const titles = ordered.filter((overlay) => overlay.kind === "hook_title");
|
|
337
|
+
titles.forEach((title, place) => {
|
|
338
|
+
const previous = titles[place - 1];
|
|
339
|
+
if (previous !== undefined && isConcurrent(title, previous)) {
|
|
340
|
+
problems.push(`overlays[${title.index}]: starts at ${title.start} s while the hook title overlays[${previous.index}] is on screen (until ${previous.end} s); one hook title at a time`);
|
|
341
|
+
}
|
|
342
|
+
const titleBox = title.box;
|
|
343
|
+
for (const other of counted) {
|
|
344
|
+
const bounds = getOverlayBounds(other);
|
|
345
|
+
if (bounds === null || !isConcurrent(title, other) || !isOverlapping(bounds, titleBox)) continue;
|
|
346
|
+
problems.push(`overlays[${other.index}]: the ${other.kind.replace("_", " ")} would sit on the hook title overlays[${title.index}] (on screen until ${title.end} s); move it lower or start it after the title`);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
return problems;
|
|
187
350
|
}
|
|
188
351
|
|
|
189
352
|
interface Placement {
|
|
@@ -213,60 +376,229 @@ function isInsideZone(place: Placement, point: OverlayPoint): boolean {
|
|
|
213
376
|
return point.x >= zone.left && point.x <= frame.width - zone.right && point.y >= zone.top && point.y <= frame.height - zone.bottom;
|
|
214
377
|
}
|
|
215
378
|
|
|
379
|
+
/** The top of a box `height` tall at a named position of the text region. */
|
|
380
|
+
function getPositionTop(region: { top: number; bottom: number }, position: OverlayPosition, height: number): number {
|
|
381
|
+
if (position === "top") return region.top;
|
|
382
|
+
if (position === "bottom") return region.bottom - height;
|
|
383
|
+
return Math.round(region.top + (region.bottom - region.top) * 0.4 - height / 2);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function getLook(overlay: EdlOverlay): OverlayLook {
|
|
387
|
+
return {
|
|
388
|
+
entrance: overlay.style?.entrance ?? null,
|
|
389
|
+
typing: isTypedOverlay(overlay) ? (overlay.style?.typing_speed ?? DEFAULT_OVERLAY_TYPING_SPEED) : null,
|
|
390
|
+
colors: { ...overlay.style?.colors },
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
|
|
216
394
|
function placeOverlay(overlay: EdlOverlay, base: OverlayBase, place: Placement): Placed {
|
|
217
|
-
const size = overlay.style?.size ?? "m";
|
|
218
395
|
if (overlay.kind === "punch_in") {
|
|
219
396
|
const ease = r3(Math.min(PUNCH_IN_EASE_SECONDS, (base.end - base.start) / 2));
|
|
220
|
-
return { ok: true, overlay: { ...base, kind: "punch_in", scale: PUNCH_IN_SCALES[size], ease } };
|
|
397
|
+
return { ok: true, overlay: { ...base, kind: "punch_in", scale: PUNCH_IN_SCALES[overlay.style?.size ?? "m"], ease } };
|
|
221
398
|
}
|
|
399
|
+
const drawn = { ...base, ...getLook(overlay) };
|
|
400
|
+
if (overlay.kind === "arrow" || overlay.kind === "highlight") return placeMark(overlay, drawn, place);
|
|
401
|
+
if (overlay.kind === "keyword" || overlay.kind === "lower_third" || overlay.kind === "list") return placeSideText({ ...overlay, kind: overlay.kind }, drawn, place);
|
|
402
|
+
return placeCard({ ...overlay, kind: overlay.kind }, drawn, place);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** An arrow's tail and point, or a highlight's rectangle. */
|
|
406
|
+
function placeMark(overlay: EdlOverlay, drawn: Drawn, place: Placement): Placed {
|
|
222
407
|
const { zone, frame } = place;
|
|
223
408
|
const scale = frame.width / 1080;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return { ok: true, overlay: { ...base, kind: "arrow", from, to } };
|
|
238
|
-
}
|
|
239
|
-
const rect = { left: anchor.x, top: anchor.y, width: anchor.width ?? 0, height: anchor.height ?? 0 };
|
|
240
|
-
if (rect.width < MIN_HIGHLIGHT_SIDE || rect.height < MIN_HIGHLIGHT_SIDE) return { ok: false, error: `the highlight is smaller than ${MIN_HIGHLIGHT_SIDE}×${MIN_HIGHLIGHT_SIDE} px` };
|
|
241
|
-
const corner = { x: rect.left + rect.width, y: rect.top + rect.height };
|
|
242
|
-
if (!isInsideZone(place, { x: rect.left, y: rect.top }) || !isInsideZone(place, corner)) return { ok: false, error: "the highlight reaches outside the platform safe zone" };
|
|
243
|
-
if (isOnCaptions(place, rect.top, corner.y)) return { ok: false, error: "the highlight overlaps the captions" };
|
|
244
|
-
return { ok: true, overlay: { ...base, kind: "highlight", rect } };
|
|
409
|
+
const anchor = overlay.anchor as NonNullable<EdlOverlay["anchor"]>;
|
|
410
|
+
if (overlay.kind === "arrow") {
|
|
411
|
+
const to = { x: anchor.x, y: anchor.y };
|
|
412
|
+
if (!isInsideZone(place, to)) return { ok: false, error: `the arrow's point (${to.x}, ${to.y}) is outside the platform safe zone` };
|
|
413
|
+
if (isOnCaptions(place, to.y, to.y)) return { ok: false, error: `the arrow's point (${to.x}, ${to.y}) sits on the captions` };
|
|
414
|
+
const clampX = (x: number) => Math.min(frame.width - zone.right, Math.max(zone.left, x));
|
|
415
|
+
const clampY = (y: number) => Math.min(frame.height - zone.bottom, Math.max(zone.top, y));
|
|
416
|
+
const dx = Math.round(ARROW_REACH.x * scale);
|
|
417
|
+
const dy = Math.round(ARROW_REACH.y * scale);
|
|
418
|
+
// The tail sits towards the frame's middle and above the point (below it near the top), so the arrow reads inward.
|
|
419
|
+
const from = { x: clampX(to.x > frame.width / 2 ? to.x - dx : to.x + dx), y: clampY(to.y - dy >= zone.top ? to.y - dy : to.y + dy) };
|
|
420
|
+
if (isOnCaptions(place, Math.min(from.y, to.y), Math.max(from.y, to.y))) return { ok: false, error: "the arrow would cross the captions; point at something further from them" };
|
|
421
|
+
return { ok: true, overlay: { ...drawn, kind: "arrow", from, to } };
|
|
245
422
|
}
|
|
423
|
+
const rect = { left: anchor.x, top: anchor.y, width: anchor.width ?? 0, height: anchor.height ?? 0 };
|
|
424
|
+
if (rect.width < MIN_HIGHLIGHT_SIDE || rect.height < MIN_HIGHLIGHT_SIDE) return { ok: false, error: `the highlight is smaller than ${MIN_HIGHLIGHT_SIDE}×${MIN_HIGHLIGHT_SIDE} px` };
|
|
425
|
+
const corner = { x: rect.left + rect.width, y: rect.top + rect.height };
|
|
426
|
+
if (!isInsideZone(place, { x: rect.left, y: rect.top }) || !isInsideZone(place, corner)) return { ok: false, error: "the highlight reaches outside the platform safe zone" };
|
|
427
|
+
if (isOnCaptions(place, rect.top, corner.y)) return { ok: false, error: "the highlight overlaps the captions" };
|
|
428
|
+
return { ok: true, overlay: { ...drawn, kind: "highlight", rect } };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/** A keyword, a lower third or a list: a card on one side, its box the whole width it may take. */
|
|
432
|
+
function placeSideText(overlay: EdlOverlay & { kind: "keyword" | "lower_third" | "list" }, drawn: Drawn, place: Placement): Placed {
|
|
433
|
+
const { zone, frame } = place;
|
|
434
|
+
const scale = frame.width / 1080;
|
|
246
435
|
const side = overlay.style?.side ?? (overlay.kind === "keyword" ? "right" : "left");
|
|
247
|
-
const fontSize = Math.round(OVERLAY_FONT_SIZES[overlay.kind][size] * scale);
|
|
436
|
+
const fontSize = Math.round(OVERLAY_FONT_SIZES[overlay.kind][overlay.style?.size ?? "m"] * scale);
|
|
248
437
|
const padY = Math.round(fontSize * OVERLAY_PADDING_EM.y);
|
|
249
438
|
const lines = overlay.kind === "list" ? (overlay.items ?? []).length : 1;
|
|
250
439
|
const lineHeight = overlay.kind === "list" ? OVERLAY_LIST_LINE_HEIGHT : OVERLAY_LINE_HEIGHT;
|
|
251
440
|
const height = Math.ceil(lines * fontSize * lineHeight + 2 * padY);
|
|
252
441
|
const region = getTextRegion(place);
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
const top =
|
|
256
|
-
overlay.kind === "lower_third"
|
|
257
|
-
? region.bottom - height
|
|
258
|
-
: overlay.kind === "keyword"
|
|
259
|
-
? Math.round(region.top + regionHeight * 0.4 - height / 2)
|
|
260
|
-
: Math.round(region.top + regionHeight * 0.15);
|
|
442
|
+
// Without a position, each kind's own place: the lower third on the captions' room, the keyword in the middle, the list high.
|
|
443
|
+
const position = overlay.style?.position ?? (overlay.kind === "lower_third" ? "bottom" : overlay.kind === "keyword" ? "middle" : null);
|
|
444
|
+
const top = position === null ? Math.round(region.top + (region.bottom - region.top) * 0.15) : getPositionTop(region, position, height);
|
|
261
445
|
if (top < region.top || top + height > region.bottom) {
|
|
262
446
|
return { ok: false, error: `the ${overlay.kind.replace("_", " ")} (${height} px tall) does not fit between the platform safe zone and the captions; use a smaller size or fewer points` };
|
|
263
447
|
}
|
|
448
|
+
const margin = Math.round(OVERLAY_MARGIN * scale);
|
|
264
449
|
const box = { left: zone.left + margin, top, width: frame.width - zone.left - zone.right - 2 * margin, height };
|
|
265
|
-
if (overlay.kind === "list") return { ok: true, overlay: { ...
|
|
266
|
-
|
|
450
|
+
if (overlay.kind === "list") return { ok: true, overlay: { ...drawn, kind: "list", items: overlay.items ?? [], fontSize, side, box } };
|
|
451
|
+
const fields = { text: overlay.text ?? "", fontSize, side, box };
|
|
452
|
+
return { ok: true, overlay: overlay.kind === "keyword" ? { ...drawn, kind: "keyword", ...fields } : { ...drawn, kind: "lower_third", ...fields } };
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
type CardKind = "hook_title" | "search_bar" | "place_card" | "counter" | "date_stamp";
|
|
456
|
+
|
|
457
|
+
/** The default position of each card. */
|
|
458
|
+
const CARD_POSITIONS: Record<CardKind, OverlayPosition> = { hook_title: "top", search_bar: "middle", place_card: "middle", counter: "middle", date_stamp: "top" };
|
|
459
|
+
|
|
460
|
+
interface CardContent {
|
|
461
|
+
/** The card's content box without its padding, in px. */
|
|
462
|
+
width: number;
|
|
463
|
+
height: number;
|
|
464
|
+
/** The overlay's own fields. */
|
|
465
|
+
fields: Record<string, unknown>;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
type CardResult = { ok: true; content: CardContent } | { ok: false; error: string };
|
|
469
|
+
|
|
470
|
+
interface CardMetrics {
|
|
471
|
+
fontSize: number;
|
|
472
|
+
pad: { x: number; y: number };
|
|
473
|
+
/** The widest the content may be, in px. */
|
|
474
|
+
room: number;
|
|
475
|
+
label: string;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const tooWide = (metrics: CardMetrics, what: string): CardResult => ({ ok: false, error: `the ${metrics.label}'s ${what} is too wide for one line; shorten it or use a smaller size` });
|
|
479
|
+
|
|
480
|
+
/** A hook title's or a place card's lines and second line. */
|
|
481
|
+
function measureTitle(overlay: EdlOverlay & { kind: "hook_title" | "place_card" }, metrics: CardMetrics): CardResult {
|
|
482
|
+
const { fontSize, room, label } = metrics;
|
|
483
|
+
const lines = wrapOverlayText(overlay.text ?? "", fontSize, room);
|
|
484
|
+
if (lines.length > MAX_OVERLAY_TITLE_LINES || lines.some((line) => estimateTextWidth(line, fontSize) > room)) {
|
|
485
|
+
return { ok: false, error: `the ${label} takes more than ${MAX_OVERLAY_TITLE_LINES} lines; shorten it or use a smaller size` };
|
|
486
|
+
}
|
|
487
|
+
const isHook = overlay.kind === "hook_title";
|
|
488
|
+
const second = (isHook ? overlay.place : overlay.subtitle) ?? null;
|
|
489
|
+
const secondSize = Math.round(fontSize * OVERLAY_SECONDARY_SCALE[overlay.kind]);
|
|
490
|
+
// The hook title's place label carries a pin about one label line wide before it.
|
|
491
|
+
const secondWidth = second === null ? 0 : estimateTextWidth(second, secondSize) + (isHook ? Math.round(secondSize * 1.1) : 0);
|
|
492
|
+
if (secondWidth > room) return tooWide(metrics, isHook ? "place label" : "subtitle");
|
|
493
|
+
const lineHeight = isHook ? OVERLAY_LINE_HEIGHT : OVERLAY_TITLE_LINE_HEIGHT;
|
|
494
|
+
return {
|
|
495
|
+
ok: true,
|
|
496
|
+
content: {
|
|
497
|
+
width: Math.max(secondWidth, ...lines.map((line) => estimateTextWidth(line, fontSize))),
|
|
498
|
+
height: lines.length * fontSize * lineHeight + (second === null ? 0 : secondSize * 1.3 + fontSize * 0.12),
|
|
499
|
+
fields: isHook ? { kind: "hook_title", lines, place: second, fontSize, placeFontSize: secondSize } : { kind: "place_card", lines, subtitle: second, fontSize, subtitleFontSize: secondSize },
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/** A search field: wide whatever its query (a search field, not a pill round a word), its query on one line. */
|
|
505
|
+
function measureSearchBar(overlay: EdlOverlay, metrics: CardMetrics): CardResult {
|
|
506
|
+
const { fontSize, pad, room } = metrics;
|
|
507
|
+
const text = overlay.text ?? "";
|
|
508
|
+
const searchPad = { x: Math.round(fontSize * SEARCH_BAR_PADDING_EM.x), y: Math.round(fontSize * SEARCH_BAR_PADDING_EM.y) };
|
|
509
|
+
const width = Math.round(fontSize * SEARCH_BAR_ICON_EM) + estimateTextWidth(text, fontSize) + 2 * searchPad.x;
|
|
510
|
+
if (width > room + 2 * pad.x) return tooWide(metrics, "query");
|
|
511
|
+
const fieldWidth = Math.max(Math.round((room + 2 * pad.x) * 0.82), width);
|
|
512
|
+
const height = Math.ceil(fontSize * OVERLAY_LINE_HEIGHT + 2 * searchPad.y);
|
|
513
|
+
return { ok: true, content: { width: fieldWidth - 2 * pad.x, height: height - 2 * pad.y, fields: { kind: "search_bar", text, fontSize } } };
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** A counter: its widest number (the final value, grouped as en-US groups, as widely as any locale) and its unit. */
|
|
517
|
+
function measureCounter(overlay: EdlOverlay, metrics: CardMetrics): CardResult {
|
|
518
|
+
const { fontSize, room } = metrics;
|
|
519
|
+
const value = overlay.value ?? 0;
|
|
520
|
+
const from = overlay.from ?? 0;
|
|
521
|
+
const decimals = getCounterDecimals(value, from);
|
|
522
|
+
const unit = overlay.unit ?? null;
|
|
523
|
+
const unitSize = Math.round(fontSize * OVERLAY_SECONDARY_SCALE.counter);
|
|
524
|
+
const width = estimateTextWidth(formatOverlayNumber(value, decimals, "en-US"), fontSize) + (unit === null ? 0 : Math.round(unitSize * 0.3) + estimateTextWidth(unit, unitSize));
|
|
525
|
+
if (width > room) return tooWide(metrics, "number");
|
|
526
|
+
return { ok: true, content: { width, height: fontSize * 1.1, fields: { kind: "counter", value, from, decimals, unit, fontSize, unitFontSize: unitSize } } };
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** A date stamp: its day or date, and its place on a second line. */
|
|
530
|
+
function measureDateStamp(overlay: EdlOverlay, metrics: CardMetrics): CardResult {
|
|
531
|
+
const { fontSize, room } = metrics;
|
|
532
|
+
const text = overlay.text ?? "";
|
|
533
|
+
const place = overlay.place ?? null;
|
|
534
|
+
const placeSize = Math.round(fontSize * OVERLAY_SECONDARY_SCALE.date_stamp);
|
|
535
|
+
const textWidth = estimateTextWidth(text, fontSize);
|
|
536
|
+
const placeWidth = place === null ? 0 : estimateTextWidth(place, placeSize);
|
|
537
|
+
if (textWidth > room) return tooWide(metrics, "text");
|
|
538
|
+
if (placeWidth > room) return tooWide(metrics, "place");
|
|
539
|
+
return {
|
|
540
|
+
ok: true,
|
|
541
|
+
content: {
|
|
542
|
+
width: Math.max(textWidth, placeWidth),
|
|
543
|
+
height: fontSize * OVERLAY_LINE_HEIGHT + (place === null ? 0 : placeSize * 1.25),
|
|
544
|
+
fields: { kind: "date_stamp", text, place, fontSize, placeFontSize: placeSize, side: overlay.style?.side ?? "left" },
|
|
545
|
+
},
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** A hook title, a search bar, a place card, a counter or a date stamp: a card sized to its estimated content. */
|
|
550
|
+
function placeCard(overlay: EdlOverlay & { kind: CardKind }, drawn: Drawn, place: Placement): Placed {
|
|
551
|
+
const { zone, frame } = place;
|
|
552
|
+
const scale = frame.width / 1080;
|
|
553
|
+
const margin = Math.round(OVERLAY_MARGIN * scale);
|
|
554
|
+
const outer = frame.width - zone.left - zone.right - 2 * margin;
|
|
555
|
+
const fontSize = Math.round(OVERLAY_FONT_SIZES[overlay.kind][overlay.style?.size ?? "m"] * scale);
|
|
556
|
+
const pad = { x: Math.round(fontSize * OVERLAY_PADDING_EM.x), y: Math.round(fontSize * OVERLAY_PADDING_EM.y) };
|
|
557
|
+
const metrics = { fontSize, pad, room: outer - 2 * pad.x, label: overlay.kind.replace("_", " ") };
|
|
558
|
+
const measured =
|
|
559
|
+
overlay.kind === "hook_title" || overlay.kind === "place_card"
|
|
560
|
+
? measureTitle({ ...overlay, kind: overlay.kind }, metrics)
|
|
561
|
+
: overlay.kind === "search_bar"
|
|
562
|
+
? measureSearchBar(overlay, metrics)
|
|
563
|
+
: overlay.kind === "counter"
|
|
564
|
+
? measureCounter(overlay, metrics)
|
|
565
|
+
: measureDateStamp(overlay, metrics);
|
|
566
|
+
if (!measured.ok) return measured;
|
|
567
|
+
const { content } = measured;
|
|
568
|
+
const width = Math.ceil(content.width + 2 * pad.x);
|
|
569
|
+
const height = Math.ceil(content.height + 2 * pad.y);
|
|
570
|
+
const region = getTextRegion(place);
|
|
571
|
+
const top = getPositionTop(region, overlay.style?.position ?? CARD_POSITIONS[overlay.kind], height);
|
|
572
|
+
if (top < region.top || top + height > region.bottom) {
|
|
573
|
+
return { ok: false, error: `the ${metrics.label} (${height} px tall) does not fit between the platform safe zone and the captions; use a smaller size or shorter text` };
|
|
574
|
+
}
|
|
575
|
+
const left =
|
|
576
|
+
overlay.kind !== "date_stamp" ? Math.round(zone.left + margin + (outer - width) / 2) : content.fields.side === "right" ? frame.width - zone.right - margin - width : zone.left + margin;
|
|
577
|
+
return { ok: true, overlay: { ...drawn, ...content.fields, box: { left, top, width, height } } as ResolvedOverlay };
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/** The texts the overlays draw, by the brand font that draws them, for the glyph check. */
|
|
581
|
+
export function getOverlayTextsByRole(overlays: readonly ResolvedOverlay[], locale = "en-US"): Record<OverlayFontRole, string[]> {
|
|
582
|
+
const texts: Record<OverlayFontRole, string[]> = { heading: [], interface: [] };
|
|
583
|
+
for (const overlay of overlays) {
|
|
584
|
+
if (overlay.kind === "keyword" || overlay.kind === "lower_third" || overlay.kind === "search_bar") texts[OVERLAY_FONT_ROLES[overlay.kind]].push(overlay.text);
|
|
585
|
+
else if (overlay.kind === "list") texts.interface.push(...overlay.items);
|
|
586
|
+
else if (overlay.kind === "hook_title" || overlay.kind === "place_card") {
|
|
587
|
+
texts.heading.push(...overlay.lines);
|
|
588
|
+
const second = overlay.kind === "hook_title" ? overlay.place : overlay.subtitle;
|
|
589
|
+
if (second !== null) texts.interface.push(second);
|
|
590
|
+
} else if (overlay.kind === "counter") {
|
|
591
|
+
// Every digit shows while it counts.
|
|
592
|
+
texts.heading.push(formatOverlayNumber(overlay.value, overlay.decimals, locale), "0123456789", ...(overlay.unit === null ? [] : [overlay.unit]));
|
|
593
|
+
} else if (overlay.kind === "date_stamp") {
|
|
594
|
+
texts.interface.push(overlay.text, ...(overlay.place === null ? [] : [overlay.place]));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return texts;
|
|
267
598
|
}
|
|
268
599
|
|
|
269
|
-
/** The texts the overlays draw,
|
|
270
|
-
export function getOverlayTexts(overlays: readonly ResolvedOverlay[]): string[] {
|
|
271
|
-
|
|
600
|
+
/** The texts the overlays draw, every role together. */
|
|
601
|
+
export function getOverlayTexts(overlays: readonly ResolvedOverlay[], locale = "en-US"): string[] {
|
|
602
|
+
const texts = getOverlayTextsByRole(overlays, locale);
|
|
603
|
+
return [...texts.heading, ...texts.interface];
|
|
272
604
|
}
|
package/src/footage/pipeline.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { prepareClipSounds, type SpeechPeaks, type SpeechPreGain } from "./clip-
|
|
|
16
16
|
import { readCachedTranscript, writeCacheFile, writeTranscript } from "./cache.js";
|
|
17
17
|
import { composeFootage, getFootageFilmSeconds, getFootageSfxCues } from "./compose.js";
|
|
18
18
|
import { getCaptionHighlight } from "./caption-highlight.js";
|
|
19
|
-
import {
|
|
19
|
+
import { getOverlayTextsByRole, resolveEdlOverlays } from "./overlays.js";
|
|
20
20
|
import { findMissingCaptionGlyphs, getCaptionBounds, getFootageCaptionLayout } from "./captions.js";
|
|
21
21
|
import { err, getProviderFootageFailure, ok, type FootageResult } from "./failure.js";
|
|
22
22
|
import { findLowDiskProblems, getFreeBytes, getRenderTempDir, type FreeBytesReader } from "./disk.js";
|
|
@@ -115,7 +115,11 @@ export interface FootageBrand {
|
|
|
115
115
|
/** BCP 47, e.g. `en-US`. */
|
|
116
116
|
locale: string;
|
|
117
117
|
colors: BrandColors;
|
|
118
|
-
|
|
118
|
+
/**
|
|
119
|
+
* The heading font (titles, keywords, numbers, the end card), the body font (captions) and the interface font
|
|
120
|
+
* (labels, lists, the search query, the date stamp); an absent or null interface font falls back to the body font.
|
|
121
|
+
*/
|
|
122
|
+
fonts: { heading: BrandFont | null; body: BrandFont | null; interface?: BrandFont | null };
|
|
119
123
|
logo: string | null;
|
|
120
124
|
}
|
|
121
125
|
|
|
@@ -849,7 +853,8 @@ async function runRenderFootage(
|
|
|
849
853
|
const layout = { ...base, caption: getFootageCaptionLayout(film, options.layout ?? {}) };
|
|
850
854
|
const missing = findMissingCaptionGlyphs({
|
|
851
855
|
fonts: options.brand.fonts,
|
|
852
|
-
captions:
|
|
856
|
+
captions: film.captions ? words.map((word) => word.text) : [],
|
|
857
|
+
overlays: getOverlayTextsByRole(overlays.overlays, options.brand.locale),
|
|
853
858
|
endCard: getEndCardTexts(film.endCard),
|
|
854
859
|
brandName: options.brand.name,
|
|
855
860
|
});
|
package/src/index.ts
CHANGED
|
@@ -71,30 +71,57 @@ export {
|
|
|
71
71
|
type CaptionHighlightResult,
|
|
72
72
|
} from "./footage/caption-highlight.js";
|
|
73
73
|
export {
|
|
74
|
+
DEFAULT_OVERLAY_TYPING_SPEED,
|
|
75
|
+
MAX_HOOK_TITLE_SECONDS,
|
|
76
|
+
MAX_OVERLAY_COUNTER_VALUE,
|
|
77
|
+
MAX_OVERLAY_DATE_LENGTH,
|
|
78
|
+
MAX_OVERLAY_HOOK_TITLE_LENGTH,
|
|
74
79
|
MAX_OVERLAY_KEYWORD_LENGTH,
|
|
75
80
|
MAX_OVERLAY_LIST_ITEM_LENGTH,
|
|
76
81
|
MAX_OVERLAY_LOWER_THIRD_LENGTH,
|
|
82
|
+
MAX_OVERLAY_PLACE_LENGTH,
|
|
83
|
+
MAX_OVERLAY_PLACE_TITLE_LENGTH,
|
|
84
|
+
MAX_OVERLAY_SEARCH_LENGTH,
|
|
77
85
|
MAX_OVERLAY_SECONDS,
|
|
86
|
+
MAX_OVERLAY_SUBTITLE_LENGTH,
|
|
87
|
+
MAX_OVERLAY_TYPING_SPEED,
|
|
88
|
+
MAX_OVERLAY_UNIT_LENGTH,
|
|
78
89
|
MIN_OVERLAY_SECONDS,
|
|
90
|
+
MIN_OVERLAY_TYPING_SPEED,
|
|
91
|
+
OVERLAY_ENTRANCES,
|
|
92
|
+
OVERLAY_ENTRANCES_BY_KIND,
|
|
79
93
|
OVERLAY_KINDS,
|
|
94
|
+
OVERLAY_POSITIONS,
|
|
95
|
+
OVERLAY_POSITIONS_BY_KIND,
|
|
96
|
+
OVERLAY_SIDED_KINDS,
|
|
80
97
|
OVERLAY_SIDES,
|
|
81
98
|
OVERLAY_SIZES,
|
|
99
|
+
isTypedOverlay,
|
|
82
100
|
type EdlOverlay,
|
|
83
101
|
type EdlOverlayAnchor,
|
|
102
|
+
type EdlOverlayColors,
|
|
84
103
|
type EdlOverlayStyle,
|
|
85
104
|
type EdlOverlayWord,
|
|
105
|
+
type OverlayEntrance,
|
|
86
106
|
type OverlayKind,
|
|
107
|
+
type OverlayPosition,
|
|
87
108
|
type OverlaySide,
|
|
88
109
|
type OverlaySize,
|
|
89
110
|
} from "./footage/overlay-schema.js";
|
|
90
111
|
export {
|
|
112
|
+
OVERLAY_FONT_ROLES,
|
|
91
113
|
OVERLAY_FONT_SIZES,
|
|
92
114
|
PUNCH_IN_EASE_SECONDS,
|
|
93
115
|
PUNCH_IN_SCALES,
|
|
116
|
+
formatOverlayNumber,
|
|
117
|
+
getDrawnOverlayCard,
|
|
118
|
+
getOverlayBounds,
|
|
94
119
|
getOverlaySafeZone,
|
|
95
120
|
getOverlayTexts,
|
|
121
|
+
getOverlayTextsByRole,
|
|
96
122
|
resolveEdlOverlays,
|
|
97
123
|
type OverlayBox,
|
|
124
|
+
type OverlayFontRole,
|
|
98
125
|
type OverlayPoint,
|
|
99
126
|
type ResolveOverlaysInput,
|
|
100
127
|
type ResolvedOverlay,
|
package/src/render/render.ts
CHANGED
|
@@ -47,7 +47,7 @@ function run(command: string, args: string[]): void {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/** Copies each font file as `<n>.<ext>`: two files with one name cannot overwrite each other, and the name is safe inside url("…"). */
|
|
50
|
-
export function copyFonts(fonts: RenderInput["fonts"], dir: string): { heading: ComposeFont | null; body: ComposeFont | null } {
|
|
50
|
+
export function copyFonts(fonts: RenderInput["fonts"] & { interface?: BrandFont | null }, dir: string): { heading: ComposeFont | null; body: ComposeFont | null; interface?: ComposeFont | null } {
|
|
51
51
|
rmSync(dir, { recursive: true, force: true });
|
|
52
52
|
mkdirSync(dir, { recursive: true });
|
|
53
53
|
let count = 0;
|
|
@@ -64,7 +64,8 @@ export function copyFonts(fonts: RenderInput["fonts"], dir: string): { heading:
|
|
|
64
64
|
}),
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
-
|
|
67
|
+
const copied = { body: copy(fonts.body), heading: copy(fonts.heading) };
|
|
68
|
+
return fonts.interface === undefined ? copied : { ...copied, interface: copy(fonts.interface) };
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
function getFramePath(dir: string, index: number): string {
|