@softure-ai/marketing-kit 0.23.0 → 0.24.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 +17 -0
- package/README.md +17 -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 +24 -4
- package/dist/footage/draft-overlays.d.ts.map +1 -1
- package/dist/footage/draft-overlays.js +232 -34
- 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 +109 -16
- package/dist/footage/overlays.d.ts.map +1 -1
- package/dist/footage/overlays.js +303 -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 +276 -35
- 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 +364 -55
- package/src/footage/pipeline.ts +8 -3
- package/src/index.ts +26 -0
- package/src/render/render.ts +3 -2
package/schema/edl.schema.json
CHANGED
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"description": "The kept parts of the clips, in film order."
|
|
122
122
|
},
|
|
123
123
|
"overlays": {
|
|
124
|
-
"description": "Small graphics and emphasis zooms placed on a word of the transcript (at_word) or a film second (at), one at a time, each inside one segment: punch_in, keyword, lower_third, list, arrow, highlight. Without it, none.",
|
|
124
|
+
"description": "Small graphics and emphasis zooms placed on a word of the transcript (at_word) or a film second (at), one at a time, each inside one segment: punch_in, keyword, lower_third, list, arrow, highlight, search_bar, place_card, counter, date_stamp; and a hook_title at the top, which may stay across cuts beside the others. Without it, none.",
|
|
125
125
|
"maxItems": 40,
|
|
126
126
|
"type": "array",
|
|
127
127
|
"items": {
|
|
@@ -135,9 +135,14 @@
|
|
|
135
135
|
"lower_third",
|
|
136
136
|
"list",
|
|
137
137
|
"arrow",
|
|
138
|
-
"highlight"
|
|
138
|
+
"highlight",
|
|
139
|
+
"hook_title",
|
|
140
|
+
"search_bar",
|
|
141
|
+
"place_card",
|
|
142
|
+
"counter",
|
|
143
|
+
"date_stamp"
|
|
139
144
|
],
|
|
140
|
-
"description": "punch_in (an emphasis zoom on a word), keyword, lower_third, list, arrow or
|
|
145
|
+
"description": "punch_in (an emphasis zoom on a word), keyword, lower_third, list, arrow, highlight, hook_title, search_bar, place_card, counter or date_stamp."
|
|
141
146
|
},
|
|
142
147
|
"at_word": {
|
|
143
148
|
"description": "The transcript word the overlay starts on (its start after the cut); give this or at.",
|
|
@@ -168,11 +173,11 @@
|
|
|
168
173
|
"duration": {
|
|
169
174
|
"type": "number",
|
|
170
175
|
"minimum": 1,
|
|
171
|
-
"maximum":
|
|
172
|
-
"description": "Seconds on screen (1-8)."
|
|
176
|
+
"maximum": 180,
|
|
177
|
+
"description": "Seconds on screen (1-8; a hook_title up to 180)."
|
|
173
178
|
},
|
|
174
179
|
"text": {
|
|
175
|
-
"description": "The keyword (up to 24 characters) or
|
|
180
|
+
"description": "The text: keyword (up to 24 characters), lower_third (40), hook_title (64, one or two lines), search_bar (40), place_card title (28) or date_stamp (24).",
|
|
176
181
|
"type": "string",
|
|
177
182
|
"minLength": 1
|
|
178
183
|
},
|
|
@@ -218,8 +223,38 @@
|
|
|
218
223
|
],
|
|
219
224
|
"additionalProperties": false
|
|
220
225
|
},
|
|
226
|
+
"place": {
|
|
227
|
+
"description": "A hook_title's place label above it (drawn with a pin) or a date_stamp's place, e.g. \"Hanoi, Vietnam\" (up to 40 characters).",
|
|
228
|
+
"type": "string",
|
|
229
|
+
"minLength": 1,
|
|
230
|
+
"maxLength": 40
|
|
231
|
+
},
|
|
232
|
+
"subtitle": {
|
|
233
|
+
"description": "A place_card's one-line subtitle (up to 40 characters).",
|
|
234
|
+
"type": "string",
|
|
235
|
+
"minLength": 1,
|
|
236
|
+
"maxLength": 40
|
|
237
|
+
},
|
|
238
|
+
"value": {
|
|
239
|
+
"description": "The number a counter counts up to (at most two decimals).",
|
|
240
|
+
"type": "number",
|
|
241
|
+
"minimum": 0,
|
|
242
|
+
"maximum": 999999999
|
|
243
|
+
},
|
|
244
|
+
"from": {
|
|
245
|
+
"description": "The number a counter counts from (0 by default), below its value.",
|
|
246
|
+
"type": "number",
|
|
247
|
+
"minimum": 0,
|
|
248
|
+
"maximum": 999999999
|
|
249
|
+
},
|
|
250
|
+
"unit": {
|
|
251
|
+
"description": "A counter's unit after the number, e.g. km (up to 12 characters).",
|
|
252
|
+
"type": "string",
|
|
253
|
+
"minLength": 1,
|
|
254
|
+
"maxLength": 12
|
|
255
|
+
},
|
|
221
256
|
"style": {
|
|
222
|
-
"description": "The overlay's size
|
|
257
|
+
"description": "The overlay's look: size, side, position, entrance, typing speed and colours; fonts are the brand's.",
|
|
223
258
|
"type": "object",
|
|
224
259
|
"properties": {
|
|
225
260
|
"size": {
|
|
@@ -232,12 +267,59 @@
|
|
|
232
267
|
]
|
|
233
268
|
},
|
|
234
269
|
"side": {
|
|
235
|
-
"description": "The side a keyword, lower third or
|
|
270
|
+
"description": "The side a keyword, lower third, list or date stamp sits on.",
|
|
236
271
|
"type": "string",
|
|
237
272
|
"enum": [
|
|
238
273
|
"left",
|
|
239
274
|
"right"
|
|
240
275
|
]
|
|
276
|
+
},
|
|
277
|
+
"position": {
|
|
278
|
+
"description": "top, middle or bottom of the room above the captions: keyword, search_bar, place_card, counter (any), lower_third (top or bottom), list (top or middle).",
|
|
279
|
+
"type": "string",
|
|
280
|
+
"enum": [
|
|
281
|
+
"top",
|
|
282
|
+
"middle",
|
|
283
|
+
"bottom"
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
"entrance": {
|
|
287
|
+
"description": "fade, slide, type (text typed in letter by letter) or none; without it the kind's own. Never a bounce or a pop.",
|
|
288
|
+
"type": "string",
|
|
289
|
+
"enum": [
|
|
290
|
+
"fade",
|
|
291
|
+
"slide",
|
|
292
|
+
"type",
|
|
293
|
+
"none"
|
|
294
|
+
]
|
|
295
|
+
},
|
|
296
|
+
"typing_speed": {
|
|
297
|
+
"description": "Characters per second of a typed entrance or a search bar (4-40, 14 by default).",
|
|
298
|
+
"type": "number",
|
|
299
|
+
"minimum": 4,
|
|
300
|
+
"maximum": 40
|
|
301
|
+
},
|
|
302
|
+
"colors": {
|
|
303
|
+
"description": "The overlay's own colours in place of the brand's.",
|
|
304
|
+
"type": "object",
|
|
305
|
+
"properties": {
|
|
306
|
+
"card": {
|
|
307
|
+
"description": "The card's colour (#rrggbb); the brand's background without it.",
|
|
308
|
+
"type": "string",
|
|
309
|
+
"pattern": "^#[0-9a-fA-F]{6}$"
|
|
310
|
+
},
|
|
311
|
+
"text": {
|
|
312
|
+
"description": "The text's colour; the brand's foreground without it.",
|
|
313
|
+
"type": "string",
|
|
314
|
+
"pattern": "^#[0-9a-fA-F]{6}$"
|
|
315
|
+
},
|
|
316
|
+
"accent": {
|
|
317
|
+
"description": "The accent (dot, pin, magnifier, arrow, marker); the brand's accent without it.",
|
|
318
|
+
"type": "string",
|
|
319
|
+
"pattern": "^#[0-9a-fA-F]{6}$"
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
"additionalProperties": false
|
|
241
323
|
}
|
|
242
324
|
},
|
|
243
325
|
"additionalProperties": false
|
package/src/footage/captions.ts
CHANGED
|
@@ -258,17 +258,26 @@ function findMissingInFamily(font: BrandFont | null, texts: string[], read: (pat
|
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
260
|
* Glyphs the film's fonts lack: the body font against the captions and the end card's url and note, the heading font
|
|
261
|
-
* (the body font without one) against the brand name and the
|
|
261
|
+
* (the body font without one) against the brand name, the headline and the heading overlays' texts, and the interface
|
|
262
|
+
* font (the body font without one) against the interface overlays' texts. Empty when every letter is drawn.
|
|
262
263
|
*/
|
|
263
264
|
export function findMissingCaptionGlyphs(
|
|
264
|
-
input: {
|
|
265
|
+
input: {
|
|
266
|
+
fonts: { heading: BrandFont | null; body: BrandFont | null; interface?: BrandFont | null };
|
|
267
|
+
captions: string[];
|
|
268
|
+
/** The overlays' texts by the font that draws them (`getOverlayTextsByRole`). */
|
|
269
|
+
overlays?: { heading: string[]; interface: string[] };
|
|
270
|
+
endCard: { headline: string; url: string; note: string } | null;
|
|
271
|
+
brandName: string;
|
|
272
|
+
},
|
|
265
273
|
read: (path: string) => Buffer = readFileSync,
|
|
266
274
|
): MissingCaptionGlyphs[] {
|
|
267
275
|
const { fonts, endCard } = input;
|
|
268
276
|
const body = findMissingInFamily(fonts.body, [...input.captions, ...(endCard === null ? [] : [endCard.url, endCard.note])], read);
|
|
269
|
-
const headingTexts = endCard === null ? [] : [input.brandName, endCard.headline];
|
|
277
|
+
const headingTexts = [...(endCard === null ? [] : [input.brandName, endCard.headline]), ...(input.overlays?.heading ?? [])];
|
|
270
278
|
const heading = findMissingInFamily(fonts.heading ?? fonts.body, headingTexts, read);
|
|
271
|
-
const
|
|
279
|
+
const ui = findMissingInFamily(fonts.interface ?? fonts.body, input.overlays?.interface ?? [], read);
|
|
280
|
+
const missing = [body, heading, ui].filter((entry): entry is MissingCaptionGlyphs => entry !== null);
|
|
272
281
|
// One family serving both roles is reported once.
|
|
273
282
|
const merged = new Map<string, Set<string>>();
|
|
274
283
|
for (const entry of missing) merged.set(entry.font, new Set([...(merged.get(entry.font) ?? []), ...entry.characters]));
|
package/src/footage/compose.ts
CHANGED
|
@@ -75,7 +75,8 @@ export interface FootageComposeInput {
|
|
|
75
75
|
/** The end card's headline size. */
|
|
76
76
|
headlineSize: number;
|
|
77
77
|
colors: BrandColors;
|
|
78
|
-
|
|
78
|
+
/** The heading font (titles, keywords, numbers), the body font (captions) and the interface font (labels, lists); null falls back to the body font. */
|
|
79
|
+
fonts: { heading: ComposeFont | null; body: ComposeFont | null; interface?: ComposeFont | null };
|
|
79
80
|
assets: FootageComposeAssets;
|
|
80
81
|
brandName: string;
|
|
81
82
|
locale: string;
|
|
@@ -276,8 +277,9 @@ export function composeFootage(input: FootageComposeInput): string {
|
|
|
276
277
|
|
|
277
278
|
const bodyFont = fontStack(fonts.body, "sans-serif");
|
|
278
279
|
const headingFont = fonts.heading === null ? bodyFont : fontStack(fonts.heading, "sans-serif");
|
|
279
|
-
const
|
|
280
|
-
const
|
|
280
|
+
const interfaceFont = fonts.interface == null ? bodyFont : fontStack(fonts.interface, "sans-serif");
|
|
281
|
+
const faces = [...fontFaces(fonts.body), ...fontFaces(fonts.heading), ...fontFaces(fonts.interface ?? null)];
|
|
282
|
+
const overlayMarkup = getOverlayMarkup(overlays, { colors: c, headingFont, interfaceFont, locale: input.locale, frame });
|
|
281
283
|
|
|
282
284
|
return assertLocalReferences(`<!doctype html>
|
|
283
285
|
<html lang="${escapeHtml(input.locale)}">
|
|
@@ -1,25 +1,51 @@
|
|
|
1
1
|
import { toAssColor } from "./draft-color.js";
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
2
|
+
import { getCounterSeconds, getOverlayColors, getTypingTimes, type OverlayColors } from "./overlay-html.js";
|
|
3
|
+
import {
|
|
4
|
+
OVERLAY_FONT_ROLES,
|
|
5
|
+
OVERLAY_LINE_HEIGHT,
|
|
6
|
+
OVERLAY_PADDING_EM,
|
|
7
|
+
OVERLAY_TITLE_LINE_HEIGHT,
|
|
8
|
+
SEARCH_BAR_ICON_EM,
|
|
9
|
+
SEARCH_BAR_PADDING_EM,
|
|
10
|
+
estimateTextWidth,
|
|
11
|
+
formatOverlayNumber,
|
|
12
|
+
type OverlayFontRole,
|
|
13
|
+
type OverlayPoint,
|
|
14
|
+
type ResolvedOverlay,
|
|
15
|
+
} from "./overlays.js";
|
|
4
16
|
|
|
5
17
|
/**
|
|
6
18
|
* The draft's overlays as ASS (issue #1200): the same places and times as the render, simplified. Text overlays are
|
|
7
|
-
* cards of the brand's background (libass's opaque box) with the text in its foreground; an
|
|
8
|
-
* and head in the accent; a highlight the accent's outline round its rectangle
|
|
9
|
-
*
|
|
19
|
+
* cards of the brand's background (libass's opaque box, or a drawn rounded card) with the text in its foreground; an
|
|
20
|
+
* arrow is a straight shaft and head in the accent; a highlight the accent's outline round its rectangle; a pin and a
|
|
21
|
+
* magnifier are drawings in the accent. A typed text shows letter by letter (the rest transparent, so its card keeps
|
|
22
|
+
* its size), a counter steps up to its value every tenth of a second, a slide moves up into place. A `punch_in` is drawn
|
|
23
|
+
* by the picture's zoom (`buildPictureFilters`), not here. They sit on layers 3 and 4, over the captions' 0 to 2.
|
|
10
24
|
*/
|
|
11
25
|
|
|
12
26
|
/** An arrow's or a highlight's stroke and the arrow head's length, in px of a 1080 px wide frame (as the render). */
|
|
13
27
|
const STROKE_WIDTH = 10;
|
|
14
28
|
const ARROW_HEAD = 46;
|
|
15
|
-
const
|
|
29
|
+
const FADE_IN_MS = 150;
|
|
30
|
+
const FADE_OUT_MS = 250;
|
|
31
|
+
const FADE = `\\fad(${FADE_IN_MS},${FADE_OUT_MS})`;
|
|
32
|
+
/** How far a slide starts below its place, in px of a 1080 px wide frame, and how long it takes. */
|
|
33
|
+
const SLIDE_PX = 28;
|
|
34
|
+
const SLIDE_MS = 300;
|
|
35
|
+
/** A counter's step in the draft, in seconds. */
|
|
36
|
+
const COUNT_STEP = 0.1;
|
|
37
|
+
/** A transparent primary colour: the typed text not shown yet. */
|
|
38
|
+
const HIDDEN = "{\\1a&HFF&}";
|
|
16
39
|
|
|
17
40
|
const r0 = (value: number): number => Math.round(value);
|
|
18
41
|
|
|
19
42
|
/** An ASS colour for an override tag (`&HBBGGRR&`). */
|
|
20
43
|
const toTagColor = (hex: string): string => `${toAssColor(hex).replace(/^&H../, "&H")}&`;
|
|
21
44
|
|
|
22
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The three styles the overlays use: `Overlay` (text on an opaque card), `OverlayShape` (drawings) and `OverlayPlain`
|
|
47
|
+
* (text over a drawn card).
|
|
48
|
+
*/
|
|
23
49
|
export function getDraftOverlayStyles(family: string, colors: OverlayColors): string[] {
|
|
24
50
|
const card = toAssColor(colors.background);
|
|
25
51
|
const text = toAssColor(colors.foreground);
|
|
@@ -27,6 +53,7 @@ export function getDraftOverlayStyles(family: string, colors: OverlayColors): st
|
|
|
27
53
|
return [
|
|
28
54
|
`Style: Overlay,${family},48,${text},${text},${card},${card},-1,0,0,0,100,100,0,0,3,16,0,7,0,0,0,1`,
|
|
29
55
|
`Style: OverlayShape,${family},48,${accent},${accent},${accent},${accent},0,0,0,0,100,100,0,0,1,0,0,7,0,0,0,1`,
|
|
56
|
+
`Style: OverlayPlain,${family},48,${text},${text},${text},${text},-1,0,0,0,100,100,0,0,1,0,0,7,0,0,0,1`,
|
|
30
57
|
];
|
|
31
58
|
}
|
|
32
59
|
|
|
@@ -57,35 +84,249 @@ export function getArrowDrawing(from: OverlayPoint, to: OverlayPoint, scale: num
|
|
|
57
84
|
return `${shaft} ${tip}`;
|
|
58
85
|
}
|
|
59
86
|
|
|
60
|
-
/**
|
|
61
|
-
export function
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
/** A rounded rectangle as an ASS drawing: straight sides and quarter-circle corners of radius `radius` (bezier). */
|
|
88
|
+
export function getRoundedRectDrawing(box: { left: number; top: number; width: number; height: number }, radius: number): string {
|
|
89
|
+
const r = Math.min(radius, box.width / 2, box.height / 2);
|
|
90
|
+
const k = r * 0.4477; // 1 - 0.5523, the bezier handle of a quarter circle
|
|
91
|
+
const [x0, y0, x1, y1] = [box.left, box.top, box.left + box.width, box.top + box.height];
|
|
92
|
+
const p = (x: number, y: number) => `${r0(x)} ${r0(y)}`;
|
|
93
|
+
return [
|
|
94
|
+
`m ${p(x0 + r, y0)} l ${p(x1 - r, y0)}`,
|
|
95
|
+
`b ${p(x1 - k, y0)} ${p(x1, y0 + k)} ${p(x1, y0 + r)} l ${p(x1, y1 - r)}`,
|
|
96
|
+
`b ${p(x1, y1 - k)} ${p(x1 - k, y1)} ${p(x1 - r, y1)} l ${p(x0 + r, y1)}`,
|
|
97
|
+
`b ${p(x0 + k, y1)} ${p(x0, y1 - k)} ${p(x0, y1 - r)} l ${p(x0, y0 + r)}`,
|
|
98
|
+
`b ${p(x0, y0 + k)} ${p(x0 + k, y0)} ${p(x0 + r, y0)}`,
|
|
99
|
+
].join(" ");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A circle as an ASS drawing (four bezier quarters), clockwise, or the other way round to cut a hole. */
|
|
103
|
+
function getCircleDrawing(center: OverlayPoint, radius: number, isReversed = false): string {
|
|
104
|
+
const k = radius * 0.5523;
|
|
105
|
+
const p = (x: number, y: number) => `${r0(center.x + x)} ${r0(center.y + y)}`;
|
|
106
|
+
const turn = isReversed ? -1 : 1;
|
|
107
|
+
return `m ${p(0, -radius)} b ${p(turn * k, -radius)} ${p(turn * radius, -k)} ${p(turn * radius, 0)} b ${p(turn * radius, k)} ${p(turn * k, radius)} ${p(0, radius)} b ${p(-turn * k, radius)} ${p(-turn * radius, k)} ${p(-turn * radius, 0)} b ${p(-turn * radius, -k)} ${p(-turn * k, -radius)} ${p(0, -radius)}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** A map pin `size` px tall with its top left at `at`: a drop, its hole cut by drawing it the other way round. */
|
|
111
|
+
export function getPinDrawing(at: OverlayPoint, size: number): string {
|
|
112
|
+
const s = size / 24;
|
|
113
|
+
const p = (x: number, y: number) => `${r0(at.x + x * s)} ${r0(at.y + y * s)}`;
|
|
114
|
+
const drop = `m ${p(12, 22.5)} b ${p(9, 19)} ${p(4.25, 13.5)} ${p(4.25, 9.1)} b ${p(4.25, 4.9)} ${p(7.7, 1.5)} ${p(12, 1.5)} b ${p(16.3, 1.5)} ${p(19.75, 4.9)} ${p(19.75, 9.1)} b ${p(19.75, 13.5)} ${p(15, 19)} ${p(12, 22.5)}`;
|
|
115
|
+
const hole = `m ${p(12, 6.1)} b ${p(10.3, 6.1)} ${p(9, 7.4)} ${p(9, 9.1)} b ${p(9, 10.8)} ${p(10.3, 12.1)} ${p(12, 12.1)} b ${p(13.7, 12.1)} ${p(15, 10.8)} ${p(15, 9.1)} b ${p(15, 7.4)} ${p(13.7, 6.1)} ${p(12, 6.1)}`;
|
|
116
|
+
return `${drop} ${hole}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** A magnifier `size` px wide with its top left at `at`: a ring and a handle. */
|
|
120
|
+
export function getGlassDrawing(at: OverlayPoint, size: number): string {
|
|
121
|
+
const s = size / 24;
|
|
122
|
+
const center = { x: at.x + 10 * s, y: at.y + 10 * s };
|
|
123
|
+
const ring = `${getCircleDrawing(center, 7.9 * s)} ${getCircleDrawing(center, 5.3 * s, true)}`;
|
|
124
|
+
const half = 1.3 * s;
|
|
125
|
+
const p = (x: number, y: number) => `${r0(at.x + x * s)} ${r0(at.y + y * s)}`;
|
|
126
|
+
const handle = `m ${p(15 - half, 15 + half)} l ${p(15 + half, 15 - half)} ${p(21 + half, 21 - half)} ${p(21 - half, 21 + half)}`;
|
|
127
|
+
return `${ring} ${handle}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface DraftContext {
|
|
131
|
+
brand: OverlayColors;
|
|
132
|
+
scale: number;
|
|
133
|
+
locale: string;
|
|
134
|
+
/** The font family per role, when it is not the styles' own. */
|
|
135
|
+
fonts: Partial<Record<OverlayFontRole, string>>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** One stretch of an overlay's text: what shows from `from` to `to`, and its tags. */
|
|
139
|
+
interface TextStep {
|
|
140
|
+
from: number;
|
|
141
|
+
to: number;
|
|
142
|
+
text: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The entrance and exit tags of a run of events: the first fades or slides in, the last fades out. */
|
|
146
|
+
function getMotionTags(entrance: "fade" | "slide" | "none", isFirst: boolean, isLast: boolean, slide: { x: number; y: number; dy: number } | null): string {
|
|
147
|
+
const fadeIn = isFirst && entrance !== "none" ? FADE_IN_MS : 0;
|
|
148
|
+
const fadeOut = isLast ? FADE_OUT_MS : 0;
|
|
149
|
+
const fade = fadeIn === 0 && fadeOut === 0 ? "" : `\\fad(${fadeIn},${fadeOut})`;
|
|
150
|
+
const move = isFirst && entrance === "slide" && slide !== null ? `\\move(${r0(slide.x)},${r0(slide.y + slide.dy)},${r0(slide.x)},${r0(slide.y)},0,${SLIDE_MS})` : "";
|
|
151
|
+
return `${move}${fade}`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Text events for a run of steps, positioned at `pos` with `tags`, the entrance on the first and the fade out on the last. */
|
|
155
|
+
function getTextEvents(input: { layer: number; style: string; pos: OverlayPoint; tags: string; steps: TextStep[]; entrance: "fade" | "slide" | "none"; slidePx: number }): string[] {
|
|
156
|
+
return input.steps.map((step, index) => {
|
|
157
|
+
const motion = getMotionTags(input.entrance, index === 0, index === input.steps.length - 1, { x: input.pos.x, y: input.pos.y, dy: input.slidePx });
|
|
158
|
+
const pos = motion.includes("\\move") ? "" : `\\pos(${r0(input.pos.x)},${r0(input.pos.y)})`;
|
|
159
|
+
return `Dialogue: ${input.layer},${toAssTime(step.from)},${toAssTime(step.to)},${input.style},,0,0,0,,{${input.tags}${pos}${motion}}${step.text}`;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** The steps of a text that types in letter by letter (the rest transparent), or one step showing it all. */
|
|
164
|
+
function getTypedSteps(text: string, span: { start: number; end: number }, typing: number | null): TextStep[] {
|
|
165
|
+
const clean = toAssText(text);
|
|
166
|
+
if (typing === null || clean.length === 0) return [{ from: span.start, to: span.end, text: clean }];
|
|
167
|
+
const chars = [...clean];
|
|
168
|
+
const times = getTypingTimes(span.start, clean, typing).map((time) => Math.min(time, span.end));
|
|
169
|
+
const steps: TextStep[] = [{ from: span.start, to: times[0] as number, text: `${HIDDEN}${clean}` }];
|
|
170
|
+
times.forEach((time, index) => {
|
|
171
|
+
const shown = chars.slice(0, index + 1).join("");
|
|
172
|
+
const rest = chars.slice(index + 1).join("");
|
|
173
|
+
steps.push({ from: time, to: times[index + 1] ?? span.end, text: rest.length === 0 ? shown : `${shown}${HIDDEN}${rest}` });
|
|
174
|
+
});
|
|
175
|
+
return steps.filter((step) => step.to > step.from);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The colour and font override tags of an overlay's text: only what differs from the style. */
|
|
179
|
+
function getTextTags(overlay: ResolvedOverlay, colors: OverlayColors, context: DraftContext, role: OverlayFontRole, withCard: boolean): string {
|
|
180
|
+
if (overlay.kind === "punch_in") return "";
|
|
181
|
+
const own = overlay.colors;
|
|
182
|
+
const font = context.fonts[role];
|
|
183
|
+
return [
|
|
184
|
+
font === undefined ? "" : `\\fn${font}`,
|
|
185
|
+
own.text === undefined ? "" : `\\1c${toTagColor(colors.foreground)}`,
|
|
186
|
+
withCard && own.card === undefined ? "" : withCard ? `\\3c${toTagColor(colors.background)}` : "",
|
|
187
|
+
].join("");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** A keyword, a lower third or a list: text on libass's opaque box. */
|
|
191
|
+
function getSideTextEvents(overlay: Extract<ResolvedOverlay, { kind: "keyword" | "lower_third" | "list" }>, context: DraftContext): string[] {
|
|
192
|
+
const colors = getOverlayColors(overlay, context.brand);
|
|
193
|
+
const { box, fontSize, side } = overlay;
|
|
194
|
+
const pad = r0(fontSize * OVERLAY_PADDING_EM.y);
|
|
195
|
+
const isRight = side === "right";
|
|
196
|
+
const x = isRight ? box.left + box.width - pad : box.left + pad;
|
|
197
|
+
const isFoot = overlay.kind === "lower_third";
|
|
198
|
+
const y = isFoot ? box.top + box.height - pad : box.top + pad;
|
|
199
|
+
// \an: 7 top left, 9 top right, 1 bottom left, 3 bottom right.
|
|
200
|
+
const align = isFoot ? (isRight ? 3 : 1) : isRight ? 9 : 7;
|
|
201
|
+
const tags = `\\an${align}${getTextTags(overlay, colors, context, OVERLAY_FONT_ROLES[overlay.kind], true)}`;
|
|
202
|
+
const span = { start: overlay.start, end: overlay.end };
|
|
203
|
+
if (overlay.entrance === null) {
|
|
204
|
+
const text = overlay.kind === "list" ? overlay.items.map((item) => `• ${toAssText(item)}`).join("\\N") : toAssText(overlay.text);
|
|
205
|
+
return [`Dialogue: 3,${toAssTime(overlay.start)},${toAssTime(overlay.end)},Overlay,,0,0,0,,{${tags}\\pos(${r0(x)},${r0(y)})\\fs${fontSize}\\bord${pad}${FADE}}${text}`];
|
|
206
|
+
}
|
|
207
|
+
const steps = overlay.kind === "list" ? [{ from: overlay.start, to: overlay.end, text: overlay.items.map((item) => `• ${toAssText(item)}`).join("\\N") }] : getTypedSteps(overlay.text, span, overlay.typing);
|
|
208
|
+
const entrance = overlay.entrance === "type" ? "fade" : overlay.entrance;
|
|
209
|
+
return getTextEvents({ layer: 3, style: "Overlay", pos: { x, y }, tags: `${tags}\\fs${fontSize}\\bord${pad}`, steps, entrance, slidePx: SLIDE_PX * context.scale });
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
type CardOverlay = Extract<ResolvedOverlay, { kind: "hook_title" | "search_bar" | "place_card" | "counter" | "date_stamp" }>;
|
|
213
|
+
|
|
214
|
+
/** Each card's own entrance when the overlay names none (a typed card fades its card in). */
|
|
215
|
+
const DEFAULT_ENTRANCES = { hook_title: "slide", search_bar: "fade", place_card: "slide", counter: "fade", date_stamp: "fade" } as const;
|
|
216
|
+
|
|
217
|
+
/** A drawing event in the overlay's card colour (or accent), with the overlay's entrance. */
|
|
218
|
+
function getShapeEvent(overlay: CardOverlay, drawing: string, colour: string, entrance: "fade" | "slide" | "none", scale: number): string {
|
|
219
|
+
const motion = getMotionTags(entrance, true, true, { x: 0, y: 0, dy: SLIDE_PX * scale });
|
|
220
|
+
const pos = motion.includes("\\move") ? "" : "\\pos(0,0)";
|
|
221
|
+
return `Dialogue: 3,${toAssTime(overlay.start)},${toAssTime(overlay.end)},OverlayShape,,0,0,0,,{\\an7${pos}${motion}\\1c${toTagColor(colour)}\\p1}${drawing}{\\p0}`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** A hook title, a search bar, a place card, a counter or a date stamp: a drawn rounded card and its text on layer 4. */
|
|
225
|
+
function getCardEvents(overlay: CardOverlay, context: DraftContext): string[] {
|
|
226
|
+
const colors = getOverlayColors(overlay, context.brand);
|
|
227
|
+
const { box, fontSize } = overlay;
|
|
228
|
+
const entrance = overlay.entrance === null || overlay.entrance === "type" ? (overlay.typing !== null ? "fade" : DEFAULT_ENTRANCES[overlay.kind]) : overlay.entrance;
|
|
229
|
+
const slidePx = SLIDE_PX * context.scale;
|
|
230
|
+
const span = { start: overlay.start, end: overlay.end };
|
|
231
|
+
const radius = overlay.kind === "search_bar" ? box.height / 2 : fontSize * 0.42;
|
|
232
|
+
const events = [getShapeEvent(overlay, getRoundedRectDrawing(box, radius), colors.background, entrance, context.scale)];
|
|
233
|
+
const padX = r0(fontSize * OVERLAY_PADDING_EM.x);
|
|
234
|
+
const padY = r0(fontSize * OVERLAY_PADDING_EM.y);
|
|
235
|
+
const centerX = box.left + box.width / 2;
|
|
236
|
+
const tagsFor = (role: OverlayFontRole) => getTextTags(overlay, colors, context, role, false);
|
|
237
|
+
const text = (pos: OverlayPoint, align: number, size: number, role: OverlayFontRole, steps: TextStep[]) =>
|
|
238
|
+
getTextEvents({ layer: 4, style: "OverlayPlain", pos, tags: `\\an${align}\\fs${r0(size)}${tagsFor(role)}`, steps, entrance, slidePx });
|
|
239
|
+
if (overlay.kind === "hook_title" || overlay.kind === "place_card") {
|
|
240
|
+
let y = box.top + padY;
|
|
241
|
+
if (overlay.kind === "hook_title" && overlay.place !== null) {
|
|
242
|
+
const size = overlay.placeFontSize;
|
|
243
|
+
const pin = Math.round(size * 1.05);
|
|
244
|
+
const rowWidth = pin + Math.round(size * 0.25) + estimateTextWidth(overlay.place, size);
|
|
245
|
+
const rowLeft = centerX - rowWidth / 2;
|
|
246
|
+
events.push(getShapeEvent(overlay, getPinDrawing({ x: rowLeft, y: y + (size * OVERLAY_LINE_HEIGHT - pin) / 2 }, pin), colors.accent, entrance, context.scale).replace("Dialogue: 3,", "Dialogue: 4,"));
|
|
247
|
+
events.push(...text({ x: rowLeft + pin + Math.round(size * 0.25), y }, 7, size, OVERLAY_FONT_ROLES.date_stamp, [{ from: span.start, to: span.end, text: toAssText(overlay.place) }]));
|
|
248
|
+
y += size * 1.3 + fontSize * 0.12;
|
|
69
249
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
250
|
+
const lineHeight = overlay.kind === "hook_title" ? OVERLAY_LINE_HEIGHT : OVERLAY_TITLE_LINE_HEIGHT;
|
|
251
|
+
let typedBefore = 0;
|
|
252
|
+
overlay.lines.forEach((line) => {
|
|
253
|
+
// The lines type one after the other, as the render's characters do.
|
|
254
|
+
const lineStart = overlay.typing === null ? span.start : span.start + typedBefore / overlay.typing;
|
|
255
|
+
events.push(...text({ x: centerX, y }, 8, fontSize, "heading", getTypedSteps(line, { start: lineStart, end: span.end }, overlay.typing).map((step, index) => (index === 0 ? { ...step, from: span.start } : step))));
|
|
256
|
+
typedBefore += [...line].length;
|
|
257
|
+
y += fontSize * lineHeight;
|
|
258
|
+
});
|
|
259
|
+
if (overlay.kind === "place_card" && overlay.subtitle !== null) {
|
|
260
|
+
events.push(...text({ x: centerX, y: y + fontSize * 0.12 }, 8, overlay.subtitleFontSize, "interface", [{ from: span.start, to: span.end, text: toAssText(overlay.subtitle) }]));
|
|
79
261
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
262
|
+
return events;
|
|
263
|
+
}
|
|
264
|
+
if (overlay.kind === "search_bar") {
|
|
265
|
+
const searchPadX = r0(fontSize * SEARCH_BAR_PADDING_EM.x);
|
|
266
|
+
const middle = box.top + box.height / 2;
|
|
267
|
+
events.push(getShapeEvent(overlay, getGlassDrawing({ x: box.left + searchPadX, y: middle - fontSize / 2 }, fontSize), colors.accent, entrance, context.scale).replace("Dialogue: 3,", "Dialogue: 4,"));
|
|
268
|
+
events.push(...text({ x: box.left + searchPadX + Math.round(fontSize * SEARCH_BAR_ICON_EM), y: middle }, 4, fontSize, "interface", getTypedSteps(overlay.text, span, overlay.typing)));
|
|
269
|
+
return events;
|
|
270
|
+
}
|
|
271
|
+
if (overlay.kind === "counter") {
|
|
272
|
+
const unit = overlay.unit === null ? "" : `{\\fs${overlay.unitFontSize}} ${toAssText(overlay.unit)}`;
|
|
273
|
+
const count = getCounterSeconds(overlay);
|
|
274
|
+
const steps: TextStep[] = [];
|
|
275
|
+
const ticks = Math.max(1, Math.round(count.duration / COUNT_STEP));
|
|
276
|
+
const show = (value: number) => `${formatOverlayNumber(value, overlay.decimals, context.locale)}${unit}`;
|
|
277
|
+
steps.push({ from: span.start, to: count.start, text: show(overlay.from) });
|
|
278
|
+
for (let tick = 1; tick <= ticks; tick++) {
|
|
279
|
+
const progress = tick / ticks;
|
|
280
|
+
// power2.out, as the render's tween eases.
|
|
281
|
+
const eased = 1 - (1 - progress) ** 2;
|
|
282
|
+
const value = overlay.from + (overlay.value - overlay.from) * eased;
|
|
283
|
+
steps.push({ from: count.start + (tick - 1) * COUNT_STEP, to: tick === ticks ? span.end : count.start + tick * COUNT_STEP, text: show(value) });
|
|
284
|
+
}
|
|
285
|
+
return [...events, ...text({ x: centerX, y: box.top + box.height / 2 }, 5, fontSize, "heading", steps.filter((step) => step.to > step.from))];
|
|
286
|
+
}
|
|
287
|
+
const isRight = overlay.side === "right";
|
|
288
|
+
const x = isRight ? box.left + box.width - padX : box.left + padX;
|
|
289
|
+
events.push(...text({ x, y: box.top + padY }, isRight ? 9 : 7, fontSize, "interface", getTypedSteps(overlay.text, span, overlay.typing)));
|
|
290
|
+
if (overlay.place !== null) {
|
|
291
|
+
events.push(...text({ x, y: box.top + padY + fontSize * OVERLAY_LINE_HEIGHT }, isRight ? 9 : 7, overlay.placeFontSize, "interface", [{ from: span.start, to: span.end, text: toAssText(overlay.place) }]));
|
|
292
|
+
}
|
|
293
|
+
return events;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** An arrow or a highlight in its accent. */
|
|
297
|
+
function getMarkEvents(overlay: Extract<ResolvedOverlay, { kind: "arrow" | "highlight" }>, context: DraftContext): string[] {
|
|
298
|
+
const at = `${toAssTime(overlay.start)},${toAssTime(overlay.end)}`;
|
|
299
|
+
const accent = toTagColor(getOverlayColors(overlay, context.brand).accent);
|
|
300
|
+
const fade = overlay.entrance === "none" ? `\\fad(0,${FADE_OUT_MS})` : FADE;
|
|
301
|
+
const colour = overlay.colors.accent === undefined ? "" : `\\1c${accent}`;
|
|
302
|
+
if (overlay.kind === "arrow") {
|
|
303
|
+
return [`Dialogue: 3,${at},OverlayShape,,0,0,0,,{\\an7\\pos(0,0)${fade}${colour}\\p1}${getArrowDrawing(overlay.from, overlay.to, context.scale)}{\\p0}`];
|
|
304
|
+
}
|
|
305
|
+
// libass grows a drawing's border outwards only: the shape is inset by half the stroke and bordered by all of
|
|
306
|
+
// it, so the stroke straddles the rectangle's edge as the render's SVG stroke does.
|
|
307
|
+
const stroke = r0(STROKE_WIDTH * context.scale);
|
|
308
|
+
const half = stroke / 2;
|
|
309
|
+
const [left, top] = [overlay.rect.left + half, overlay.rect.top + half];
|
|
310
|
+
const [right, bottom] = [overlay.rect.left + overlay.rect.width - half, overlay.rect.top + overlay.rect.height - half];
|
|
311
|
+
const shape = `m ${r0(left)} ${r0(top)} l ${r0(right)} ${r0(top)} ${r0(right)} ${r0(bottom)} ${r0(left)} ${r0(bottom)}`;
|
|
312
|
+
return [`Dialogue: 3,${at},OverlayShape,,0,0,0,,{\\an7\\pos(0,0)${fade}\\1a&HFF&\\3c${accent}\\bord${stroke}\\p1}${shape}{\\p0}`];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* The overlays as ASS events, layers 3 and 4. `fonts` names the heading and interface families where they are not the
|
|
317
|
+
* styles' own (the captions' font); `locale` groups a counter's number as the render does.
|
|
318
|
+
*/
|
|
319
|
+
export function buildDraftOverlayEvents(
|
|
320
|
+
overlays: readonly ResolvedOverlay[],
|
|
321
|
+
colors: OverlayColors,
|
|
322
|
+
frame: { width: number; height: number },
|
|
323
|
+
options: { fonts?: Partial<Record<OverlayFontRole, string>>; locale?: string } = {},
|
|
324
|
+
): string[] {
|
|
325
|
+
const context: DraftContext = { brand: colors, scale: frame.width / 1080, locale: options.locale ?? "en-US", fonts: options.fonts ?? {} };
|
|
326
|
+
return overlays.flatMap((overlay) => {
|
|
327
|
+
if (overlay.kind === "punch_in") return [];
|
|
328
|
+
if (overlay.kind === "arrow" || overlay.kind === "highlight") return getMarkEvents(overlay, context);
|
|
329
|
+
if (overlay.kind === "keyword" || overlay.kind === "lower_third" || overlay.kind === "list") return getSideTextEvents(overlay, context);
|
|
330
|
+
return getCardEvents(overlay, context);
|
|
90
331
|
});
|
|
91
332
|
}
|
package/src/footage/draft.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { getSegmentScales, getSegmentZoomEases } from "./compose.js";
|
|
|
12
12
|
import { toAssColor } from "./draft-color.js";
|
|
13
13
|
import { buildDraftOverlayEvents, getDraftOverlayStyles } from "./draft-overlays.js";
|
|
14
14
|
import type { OverlayColors } from "./overlay-html.js";
|
|
15
|
-
import { resolveEdlOverlays, type ResolvedOverlay } from "./overlays.js";
|
|
15
|
+
import { resolveEdlOverlays, type OverlayFontRole, type ResolvedOverlay } from "./overlays.js";
|
|
16
16
|
import { chooseFootageDraftFont } from "./draft-font.js";
|
|
17
17
|
import { getEdlDuration, getSegmentStarts, remapWords, type Edl } from "./edl.js";
|
|
18
18
|
import { declickSpeech, describeDeclick, type DeclickReport } from "./declick.js";
|
|
@@ -134,6 +134,10 @@ export interface FootageDraftCaptionsInput {
|
|
|
134
134
|
overlays?: ResolvedOverlay[];
|
|
135
135
|
/** The overlays' card, text and accent colours; default `FOOTAGE_DRAFT_OVERLAY_COLORS`. */
|
|
136
136
|
overlayColors?: OverlayColors;
|
|
137
|
+
/** The overlays' heading and interface font families where they are not `fontFamily` (as the font files name them). */
|
|
138
|
+
overlayFonts?: Partial<Record<OverlayFontRole, string>>;
|
|
139
|
+
/** How a counter groups its number (BCP 47); default `en-US`. */
|
|
140
|
+
locale?: string;
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
/** The pieces of a `highlight` chunk's span: cut wherever a word lights up or goes out (in centiseconds), with the words lit in each. */
|
|
@@ -279,7 +283,10 @@ export function buildFootageDraftCaptions(input: FootageDraftCaptionsInput): str
|
|
|
279
283
|
"[Events]",
|
|
280
284
|
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
|
|
281
285
|
...events,
|
|
282
|
-
...buildDraftOverlayEvents(overlays, input.overlayColors ?? FOOTAGE_DRAFT_OVERLAY_COLORS, input.frame
|
|
286
|
+
...buildDraftOverlayEvents(overlays, input.overlayColors ?? FOOTAGE_DRAFT_OVERLAY_COLORS, input.frame, {
|
|
287
|
+
...(input.overlayFonts === undefined ? {} : { fonts: input.overlayFonts }),
|
|
288
|
+
...(input.locale === undefined ? {} : { locale: input.locale }),
|
|
289
|
+
}),
|
|
283
290
|
"",
|
|
284
291
|
].join("\n");
|
|
285
292
|
}
|
|
@@ -519,7 +526,7 @@ export interface RenderFootageDraftOptions extends Pick<FootageRunOptions, "buil
|
|
|
519
526
|
* OpenType file; DejaVu Sans when it has none) and its caption colours. Without it, DejaVu Sans and
|
|
520
527
|
* `FOOTAGE_DRAFT_CAPTION_COLORS`.
|
|
521
528
|
*/
|
|
522
|
-
brand?: { colors: FootageDraftCaptionColors & Partial<OverlayColors>; fonts: Pick<FootageBrand["fonts"], "body"> };
|
|
529
|
+
brand?: { colors: FootageDraftCaptionColors & Partial<OverlayColors>; fonts: Pick<FootageBrand["fonts"], "body"> & Partial<Pick<FootageBrand["fonts"], "heading" | "interface">>; locale?: string };
|
|
523
530
|
/**
|
|
524
531
|
* ffmpeg's threads for the draft's decoders, filter graph and encoder (`buildFootageDraftArgs`); by default ffmpeg's
|
|
525
532
|
* own choice, which follows the host's cores. Set it from a CPU-limited container's quota.
|
|
@@ -633,6 +640,13 @@ async function runRenderFootageDraft(
|
|
|
633
640
|
: FOOTAGE_DRAFT_OVERLAY_COLORS;
|
|
634
641
|
const brandFont = chooseFootageDraftFont(options.brand?.fonts.body ?? null);
|
|
635
642
|
const font = brandFont ?? FOOTAGE_DRAFT_FONT;
|
|
643
|
+
// The overlays' heading and interface fonts, where the brand has a TrueType or OpenType file for them.
|
|
644
|
+
const roleFonts = Object.fromEntries(
|
|
645
|
+
(["heading", "interface"] as const).flatMap((role) => {
|
|
646
|
+
const chosen = overlays.length === 0 ? null : chooseFootageDraftFont(options.brand?.fonts[role] ?? null);
|
|
647
|
+
return chosen === null || chosen.family === font.family ? [] : [[role, chosen]];
|
|
648
|
+
}),
|
|
649
|
+
) as Partial<Record<OverlayFontRole, { family: string; file: string }>>;
|
|
636
650
|
const captions = buildFootageDraftCaptions({
|
|
637
651
|
film,
|
|
638
652
|
edl,
|
|
@@ -642,11 +656,13 @@ async function runRenderFootageDraft(
|
|
|
642
656
|
fontFamily: font.family,
|
|
643
657
|
...(options.brand === undefined ? {} : { colors: options.brand.colors }),
|
|
644
658
|
...(overlays.length === 0 ? {} : { overlays, overlayColors }),
|
|
659
|
+
...(Object.keys(roleFonts).length === 0 ? {} : { overlayFonts: Object.fromEntries(Object.entries(roleFonts).map(([role, chosen]) => [role, chosen.family])) }),
|
|
660
|
+
...(options.brand?.locale === undefined ? {} : { locale: options.brand.locale }),
|
|
645
661
|
});
|
|
646
662
|
if (captions !== null) {
|
|
647
663
|
writeFileSync(join(draftDir, "captions.ass"), captions);
|
|
648
664
|
mkdirSync(join(draftDir, "fonts"));
|
|
649
|
-
|
|
665
|
+
for (const file of new Set([font.file, ...Object.values(roleFonts).map((chosen) => chosen.file)])) copyFileSync(file, join(draftDir, "fonts", basename(file)));
|
|
650
666
|
if (brandFont === null && options.brand?.fonts.body != null) {
|
|
651
667
|
log(`draft: the brand's body font ${options.brand.fonts.body.family} has no TrueType or OpenType file ffmpeg can read; the captions use ${FOOTAGE_DRAFT_FONT.family}.`);
|
|
652
668
|
}
|
package/src/footage/edl.ts
CHANGED
|
@@ -109,7 +109,7 @@ export const edlSchema = z
|
|
|
109
109
|
.max(40)
|
|
110
110
|
.optional()
|
|
111
111
|
.describe(
|
|
112
|
-
"Small graphics and emphasis zooms placed on a word of the transcript (at_word) or a film second (at), one at a time, each inside one segment: punch_in, keyword, lower_third, list, arrow, highlight. Without it, none.",
|
|
112
|
+
"Small graphics and emphasis zooms placed on a word of the transcript (at_word) or a film second (at), one at a time, each inside one segment: punch_in, keyword, lower_third, list, arrow, highlight, search_bar, place_card, counter, date_stamp; and a hook_title at the top, which may stay across cuts beside the others. Without it, none.",
|
|
113
113
|
),
|
|
114
114
|
})
|
|
115
115
|
.describe("The edit decision list of a footage film (edl.json).");
|