@softure-ai/marketing-kit 0.17.0 → 0.18.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 +40 -0
- package/README.md +45 -11
- package/dist/config/actions-schema.d.ts +14 -14
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +11 -1
- package/dist/config/config.js.map +1 -1
- package/dist/config/schema.d.ts +78 -70
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +25 -8
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shot-steps.d.ts +16 -16
- package/dist/footage/compose.d.ts +17 -3
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +61 -17
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/declick.d.ts +49 -41
- package/dist/footage/declick.d.ts.map +1 -1
- package/dist/footage/declick.js +181 -92
- package/dist/footage/declick.js.map +1 -1
- package/dist/footage/film.d.ts +45 -2
- package/dist/footage/film.d.ts.map +1 -1
- package/dist/footage/film.js +23 -0
- package/dist/footage/film.js.map +1 -1
- package/dist/footage/paid.d.ts +1 -1
- package/dist/footage/paid.d.ts.map +1 -1
- package/dist/footage/paid.js +3 -2
- package/dist/footage/paid.js.map +1 -1
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +13 -8
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/footage/render.d.ts +5 -1
- package/dist/footage/render.d.ts.map +1 -1
- package/dist/footage/render.js +6 -2
- package/dist/footage/render.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/og/character-map.d.ts +2 -1
- package/dist/og/character-map.d.ts.map +1 -1
- package/dist/og/character-map.js +7 -63
- package/dist/og/character-map.js.map +1 -1
- package/dist/og/font-file.d.ts +53 -0
- package/dist/og/font-file.d.ts.map +1 -0
- package/dist/og/font-file.js +153 -0
- package/dist/og/font-file.js.map +1 -0
- package/dist/og/font-tables.d.ts +25 -0
- package/dist/og/font-tables.d.ts.map +1 -0
- package/dist/og/font-tables.js +212 -0
- package/dist/og/font-tables.js.map +1 -0
- package/dist/og/index.d.ts +3 -1
- package/dist/og/index.d.ts.map +1 -1
- package/dist/og/index.js +2 -1
- package/dist/og/index.js.map +1 -1
- package/dist/og/photo-cover.d.ts +22 -0
- package/dist/og/photo-cover.d.ts.map +1 -1
- package/dist/og/photo-cover.js +27 -9
- package/dist/og/photo-cover.js.map +1 -1
- package/package.json +1 -1
- package/schema/marketing.schema.json +76 -23
- package/src/config/config.ts +10 -2
- package/src/config/schema.ts +24 -5
- package/src/footage/compose.ts +72 -17
- package/src/footage/declick.ts +172 -97
- package/src/footage/film.ts +54 -2
- package/src/footage/paid.ts +3 -3
- package/src/footage/pipeline.ts +12 -7
- package/src/footage/render.ts +7 -3
- package/src/index.ts +26 -5
- package/src/og/character-map.ts +8 -61
- package/src/og/font-file.ts +172 -0
- package/src/og/font-tables.ts +221 -0
- package/src/og/index.ts +14 -0
- package/src/og/photo-cover.ts +46 -11
|
@@ -2940,30 +2940,83 @@
|
|
|
2940
2940
|
"additionalProperties": false
|
|
2941
2941
|
},
|
|
2942
2942
|
"endCard": {
|
|
2943
|
-
"description": "The closing card after the last segment; without it, the film ends with its last segment.",
|
|
2944
|
-
"
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
"
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2943
|
+
"description": "The closing card after the last segment (\"full\", the default, or the short \"logo\" card); without it, the film ends with its last segment.",
|
|
2944
|
+
"oneOf": [
|
|
2945
|
+
{
|
|
2946
|
+
"type": "object",
|
|
2947
|
+
"properties": {
|
|
2948
|
+
"layout": {
|
|
2949
|
+
"description": "\"full\" (the default): the brand row, headline, link pill and note.",
|
|
2950
|
+
"type": "string",
|
|
2951
|
+
"const": "full"
|
|
2952
|
+
},
|
|
2953
|
+
"headline": {
|
|
2954
|
+
"type": "string",
|
|
2955
|
+
"minLength": 1,
|
|
2956
|
+
"description": "The end card's headline."
|
|
2957
|
+
},
|
|
2958
|
+
"url": {
|
|
2959
|
+
"type": "string",
|
|
2960
|
+
"minLength": 1,
|
|
2961
|
+
"description": "The address shown in the end card's link pill, as written (e.g. example.com)."
|
|
2962
|
+
},
|
|
2963
|
+
"note": {
|
|
2964
|
+
"default": "",
|
|
2965
|
+
"description": "A small line under the link; empty: none.",
|
|
2966
|
+
"type": "string"
|
|
2967
|
+
},
|
|
2968
|
+
"seconds": {
|
|
2969
|
+
"description": "The card's length in seconds after the cut (1-3). Default 3.",
|
|
2970
|
+
"type": "number",
|
|
2971
|
+
"minimum": 1,
|
|
2972
|
+
"maximum": 3
|
|
2973
|
+
}
|
|
2974
|
+
},
|
|
2975
|
+
"required": [
|
|
2976
|
+
"headline",
|
|
2977
|
+
"url"
|
|
2978
|
+
],
|
|
2979
|
+
"additionalProperties": false
|
|
2955
2980
|
},
|
|
2956
|
-
|
|
2957
|
-
"
|
|
2958
|
-
"
|
|
2959
|
-
|
|
2981
|
+
{
|
|
2982
|
+
"type": "object",
|
|
2983
|
+
"properties": {
|
|
2984
|
+
"layout": {
|
|
2985
|
+
"type": "string",
|
|
2986
|
+
"const": "logo",
|
|
2987
|
+
"description": "\"logo\": a short brand card, the logo and one line on the brand background, the music fading out under it."
|
|
2988
|
+
},
|
|
2989
|
+
"line": {
|
|
2990
|
+
"default": "",
|
|
2991
|
+
"description": "One short line under the logo, e.g. \"Follow for more\"; empty: the logo alone.",
|
|
2992
|
+
"type": "string",
|
|
2993
|
+
"maxLength": 80
|
|
2994
|
+
},
|
|
2995
|
+
"logo": {
|
|
2996
|
+
"description": "The card's logo, an .svg or a .png with alpha, relative to the folder of marketing.json; without it brand.logo, or the brand name.",
|
|
2997
|
+
"type": "string",
|
|
2998
|
+
"minLength": 1,
|
|
2999
|
+
"pattern": "\\.(svg|png)$"
|
|
3000
|
+
},
|
|
3001
|
+
"seconds": {
|
|
3002
|
+
"description": "The card's length in seconds after the cut (1-3). Default 1.5.",
|
|
3003
|
+
"type": "number",
|
|
3004
|
+
"minimum": 1,
|
|
3005
|
+
"maximum": 3
|
|
3006
|
+
},
|
|
3007
|
+
"fadeSeconds": {
|
|
3008
|
+
"description": "How long the card fades in over the last frame, in seconds (0-1). Default 0.2.",
|
|
3009
|
+
"type": "number",
|
|
3010
|
+
"minimum": 0,
|
|
3011
|
+
"maximum": 1
|
|
3012
|
+
}
|
|
3013
|
+
},
|
|
3014
|
+
"required": [
|
|
3015
|
+
"layout"
|
|
3016
|
+
],
|
|
3017
|
+
"additionalProperties": false
|
|
2960
3018
|
}
|
|
2961
|
-
|
|
2962
|
-
"required": [
|
|
2963
|
-
"headline",
|
|
2964
|
-
"url"
|
|
2965
|
-
],
|
|
2966
|
-
"additionalProperties": false
|
|
3019
|
+
]
|
|
2967
3020
|
},
|
|
2968
3021
|
"speech": {
|
|
2969
3022
|
"description": "The speech track's cleanup before its loudness normalization.",
|
|
@@ -2972,7 +3025,7 @@
|
|
|
2972
3025
|
"properties": {
|
|
2973
3026
|
"declick": {
|
|
2974
3027
|
"default": "off",
|
|
2975
|
-
"description": "Mouth clicks and lip smacks
|
|
3028
|
+
"description": "Mouth clicks and lip smacks in the pauses, repaired before the loudness pass: each single impulse in a pause is replaced by AR interpolation with a 3 ms crossfade, nothing within 80 ms of a word is touched and no gain changes; gentle detects strong impulses only, strong is more sensitive; off (the default) leaves the speech track as cut.",
|
|
2976
3029
|
"type": "string",
|
|
2977
3030
|
"enum": [
|
|
2978
3031
|
"off",
|
package/src/config/config.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { dirname, resolve } from "node:path";
|
|
|
3
3
|
|
|
4
4
|
import { getLayoutName } from "../compose/timeline.js";
|
|
5
5
|
import type { Device, FilmScript } from "../film.js";
|
|
6
|
-
import { DEFAULT_MUSIC_VOLUME, getDefaultFillers, type FootageFilm, type MusicSource } from "../footage/film.js";
|
|
6
|
+
import { DEFAULT_MUSIC_VOLUME, getDefaultFillers, type FootageEndCard, type FootageFilm, type MusicSource } from "../footage/film.js";
|
|
7
7
|
import { normalizeKeyTerms } from "../footage/keyterms.js";
|
|
8
8
|
import type { LayoutOverride } from "../compose/timeline.js";
|
|
9
9
|
import { getMarketingMessages, type MarketingMessages } from "../messages/index.js";
|
|
@@ -202,6 +202,13 @@ function resolveMusicSource(music: NonNullable<MarketingJson["footage"][number][
|
|
|
202
202
|
return { kind: "video", description: fromVideo.description, tags: fromVideo.tags };
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/** A footage film's end card with its own logo resolved against the folder of marketing.json; null without a card. */
|
|
206
|
+
function resolveFootageEndCard(card: MarketingJson["footage"][number]["endCard"], at: (relative: string) => string): FootageEndCard | null {
|
|
207
|
+
if (card === undefined) return null;
|
|
208
|
+
if (card.layout !== "logo") return card;
|
|
209
|
+
return { ...card, ...(card.logo === undefined ? {} : { logo: at(card.logo) }) };
|
|
210
|
+
}
|
|
211
|
+
|
|
205
212
|
/** The film's key terms, normalized (the schema has checked them); none when absent or empty. */
|
|
206
213
|
function resolveKeyTerms(terms: string[] | undefined): { keyTerms?: string[] } {
|
|
207
214
|
const normalized = normalizeKeyTerms(terms ?? []);
|
|
@@ -257,7 +264,7 @@ function resolveFootage(data: MarketingJson, at: (relative: string) => string):
|
|
|
257
264
|
cutAudioFadeMs: film.edit.cutAudioFadeMs,
|
|
258
265
|
isCutAudioCrossfade: film.edit.cutAudioCrossfade,
|
|
259
266
|
},
|
|
260
|
-
endCard: film.endCard
|
|
267
|
+
endCard: resolveFootageEndCard(film.endCard, at),
|
|
261
268
|
...(film.speech.declick === "off" ? {} : { speech: { declick: film.speech.declick } }),
|
|
262
269
|
loudness: film.loudness === false ? null : film.loudness,
|
|
263
270
|
mixLoudness: film.mixLoudness === false ? null : film.mixLoudness,
|
|
@@ -381,6 +388,7 @@ export function findMissingFootageFiles(config: MarketingConfig, film: FootageCo
|
|
|
381
388
|
if (film.music.source.kind === "file") check(["footage", film.index, "music", "file"], film.music.source.path);
|
|
382
389
|
if (!isRendering) return issues;
|
|
383
390
|
if (config.brand.logo !== null) check(["brand", "logo", "svg"], config.brand.logo);
|
|
391
|
+
if (film.endCard?.layout === "logo" && film.endCard.logo !== undefined) check(["footage", film.index, "endCard", "logo"], film.endCard.logo);
|
|
384
392
|
for (const kind of ["heading", "body"] as const) {
|
|
385
393
|
config.brand.fonts[kind]?.files.forEach((font, index) => check(["brand", "fonts", kind, "files", index, "path"], font.path));
|
|
386
394
|
}
|
package/src/config/schema.ts
CHANGED
|
@@ -453,12 +453,29 @@ const videoSchema = z
|
|
|
453
453
|
});
|
|
454
454
|
});
|
|
455
455
|
|
|
456
|
-
const
|
|
457
|
-
.
|
|
456
|
+
const endCardSeconds = (fallback: number) =>
|
|
457
|
+
z.number().min(1).max(3).optional().describe(`The card's length in seconds after the cut (1-3). Default ${fallback}.`);
|
|
458
|
+
|
|
459
|
+
/** A footage film's end card: the full card (`layout` absent or "full") or the short logo card (issue #1173). */
|
|
460
|
+
const footageEndCardSchema = z.discriminatedUnion("layout", [
|
|
461
|
+
z.strictObject({
|
|
462
|
+
layout: z.literal("full").optional().describe('"full" (the default): the brand row, headline, link pill and note.'),
|
|
458
463
|
headline: nonEmpty.describe("The end card's headline."),
|
|
459
464
|
url: nonEmpty.describe("The address shown in the end card's link pill, as written (e.g. example.com)."),
|
|
460
465
|
note: z.string().default("").describe("A small line under the link; empty: none."),
|
|
461
|
-
|
|
466
|
+
seconds: endCardSeconds(3),
|
|
467
|
+
}),
|
|
468
|
+
z.strictObject({
|
|
469
|
+
layout: z.literal("logo").describe('"logo": a short brand card, the logo and one line on the brand background, the music fading out under it.'),
|
|
470
|
+
line: z.string().max(80).default("").describe('One short line under the logo, e.g. "Follow for more"; empty: the logo alone.'),
|
|
471
|
+
logo: relativePath
|
|
472
|
+
.regex(/\.(svg|png)$/i, "must be an .svg or a .png file")
|
|
473
|
+
.optional()
|
|
474
|
+
.describe("The card's logo, an .svg or a .png with alpha, relative to the folder of marketing.json; without it brand.logo, or the brand name."),
|
|
475
|
+
seconds: endCardSeconds(1.5),
|
|
476
|
+
fadeSeconds: z.number().min(0).max(1).optional().describe("How long the card fades in over the last frame, in seconds (0-1). Default 0.2."),
|
|
477
|
+
}),
|
|
478
|
+
]);
|
|
462
479
|
|
|
463
480
|
const clipSource = z
|
|
464
481
|
.string()
|
|
@@ -601,14 +618,16 @@ const footageSchema = z
|
|
|
601
618
|
})
|
|
602
619
|
.prefault({})
|
|
603
620
|
.describe("The cut's look; the defaults read as an ordinary phone video."),
|
|
604
|
-
endCard:
|
|
621
|
+
endCard: footageEndCardSchema
|
|
622
|
+
.optional()
|
|
623
|
+
.describe('The closing card after the last segment ("full", the default, or the short "logo" card); without it, the film ends with its last segment.'),
|
|
605
624
|
speech: z
|
|
606
625
|
.strictObject({
|
|
607
626
|
declick: z
|
|
608
627
|
.enum(DECLICK_LEVELS)
|
|
609
628
|
.default("off")
|
|
610
629
|
.describe(
|
|
611
|
-
"Mouth clicks and lip smacks
|
|
630
|
+
"Mouth clicks and lip smacks in the pauses, repaired before the loudness pass: each single impulse in a pause is replaced by AR interpolation with a 3 ms crossfade, nothing within 80 ms of a word is touched and no gain changes; gentle detects strong impulses only, strong is more sensitive; off (the default) leaves the speech track as cut.",
|
|
612
631
|
),
|
|
613
632
|
})
|
|
614
633
|
.prefault({})
|
package/src/footage/compose.ts
CHANGED
|
@@ -4,9 +4,19 @@ import type { ComposeFont } from "../compose/compose.js";
|
|
|
4
4
|
import { escapeHtml, fontFaces, fontStack } from "../compose/html.js";
|
|
5
5
|
import { CAPTION_LINE_HEIGHT, getCaptionPillCss, getCaptionPositionCss, type CaptionLayout } from "../compose/timeline.js";
|
|
6
6
|
import type { TimedWord } from "../voice/voiceover.js";
|
|
7
|
-
import { getCaptionChunkLayouts, getCaptionSpans, getFootageCaptionChunks, isSameCaptionPlace, type CaptionSpan } from "./captions.js";
|
|
7
|
+
import { CAPTION_SAFE_ZONES, getCaptionChunkLayouts, getCaptionSpans, getFootageCaptionChunks, isSameCaptionPlace, type CaptionSpan } from "./captions.js";
|
|
8
8
|
import { getEdlDuration, getSegmentStarts, type Edl } from "./edl.js";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
CAPTION_MIN_FONT_SCALE,
|
|
11
|
+
DEFAULT_EDIT,
|
|
12
|
+
DEFAULT_END_CARD_SECONDS,
|
|
13
|
+
DEFAULT_LOGO_END_CARD_FADE_SECONDS,
|
|
14
|
+
getEndCardSeconds,
|
|
15
|
+
getFootageEdit,
|
|
16
|
+
type FootageEdit,
|
|
17
|
+
type FootageFilm,
|
|
18
|
+
type LogoFootageEndCard,
|
|
19
|
+
} from "./film.js";
|
|
10
20
|
import { FOOTAGE_FPS } from "./normalize.js";
|
|
11
21
|
|
|
12
22
|
const r3 = (value: number): number => Math.round(value * 1000) / 1000 || 0;
|
|
@@ -16,7 +26,8 @@ const r3 = (value: number): number => Math.round(value * 1000) / 1000 || 0;
|
|
|
16
26
|
* EDL segment over the normalized clip with its media start, the transitions (`fade` cross-fades from the segment
|
|
17
27
|
* before over `fadeFrames`, `zoom` punches in by `zoomPercent` on alternate jump cuts, eased over `zoomEaseFrames`, `whoosh` plays the whoosh
|
|
18
28
|
* sound), a slow zoom on `kenburns` segments, the captions (plain phrases, or the word-highlight pill), the end card
|
|
19
|
-
* over the cut's last frame (its whoosh only with `isEndCardWhoosh`), the cut
|
|
29
|
+
* over the cut's last frame (the full card, or the short logo card; its whoosh only with `isEndCardWhoosh`), the cut
|
|
30
|
+
* speech track and the ducked music.
|
|
20
31
|
*/
|
|
21
32
|
|
|
22
33
|
const COMPOSITION_ID = "film";
|
|
@@ -24,8 +35,12 @@ const COMPOSITION_ID = "film";
|
|
|
24
35
|
export const FADE_SECONDS = r3(DEFAULT_EDIT.fadeFrames / FOOTAGE_FPS);
|
|
25
36
|
/** How far a segment marked `kenburns` zooms when the film's `kenBurnsPercent` is 0 (a hand edit asked for it). */
|
|
26
37
|
const HAND_KEN_BURNS_PERCENT = 4;
|
|
27
|
-
/** The end card's length after the cut. */
|
|
28
|
-
export const END_CARD_SECONDS =
|
|
38
|
+
/** The full end card's length after the cut when it sets no `seconds` (`DEFAULT_END_CARD_SECONDS`). */
|
|
39
|
+
export const END_CARD_SECONDS = DEFAULT_END_CARD_SECONDS;
|
|
40
|
+
/** The logo card's line, in px. */
|
|
41
|
+
const LOGO_CARD_LINE_SIZE = 64;
|
|
42
|
+
/** The largest box the logo card's logo is drawn in, in px: an SVG fills it, a PNG is never drawn past its own pixels. */
|
|
43
|
+
const LOGO_CARD_MARK = { width: 720, height: 480 };
|
|
29
44
|
|
|
30
45
|
export interface FootageComposeAssets {
|
|
31
46
|
/** The normalized clips by id (read when there is no `picture`). */
|
|
@@ -42,6 +57,7 @@ export interface FootageComposeAssets {
|
|
|
42
57
|
music: string | null;
|
|
43
58
|
/** The cut's last frame, under the end card. */
|
|
44
59
|
lastFrame: string;
|
|
60
|
+
/** The end card's logo (the logo card's own, else the brand's), an SVG or a PNG; null for the brand name alone. */
|
|
45
61
|
logo: string | null;
|
|
46
62
|
sfx: Partial<Record<SfxEvent, string>>;
|
|
47
63
|
}
|
|
@@ -62,9 +78,9 @@ export interface FootageComposeInput {
|
|
|
62
78
|
locale: string;
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
/** The film's length: the cut plus the end card. */
|
|
81
|
+
/** The film's length: the cut plus the end card (`getEndCardSeconds`). */
|
|
66
82
|
export function getFootageFilmSeconds(film: Pick<FootageFilm, "endCard">, edl: Edl): number {
|
|
67
|
-
return r3(getEdlDuration(edl) + (film.endCard
|
|
83
|
+
return r3(getEdlDuration(edl) + getEndCardSeconds(film.endCard));
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
/** The picture scale each segment starts at: `zoom` cuts alternate between punched in (`zoomPercent`) and back out. */
|
|
@@ -99,7 +115,7 @@ export interface FootageSfxCue {
|
|
|
99
115
|
|
|
100
116
|
/**
|
|
101
117
|
* The film's sound effects in film time: a whoosh before every `whoosh` cut, and the end card's whoosh and pop with
|
|
102
|
-
* `isEndCardWhoosh
|
|
118
|
+
* `isEndCardWhoosh` (the pop only when it starts before the film's end); an event without a file in `sfx` plays nothing. The composition and the film's mix
|
|
103
119
|
* (`buildFilmMixArgs`) both play these.
|
|
104
120
|
*/
|
|
105
121
|
export function getFootageSfxCues(film: FootageFilm, edl: Edl, sfx: Partial<Record<SfxEvent, string>>): FootageSfxCue[] {
|
|
@@ -116,7 +132,8 @@ export function getFootageSfxCues(film: FootageFilm, edl: Edl, sfx: Partial<Reco
|
|
|
116
132
|
});
|
|
117
133
|
if (film.endCard !== null && edit.isEndCardWhoosh) {
|
|
118
134
|
play("whoosh", cutEnd, 0.3, 0.57);
|
|
119
|
-
|
|
135
|
+
const pop = r3(cutEnd + 0.9);
|
|
136
|
+
if (pop < getFootageFilmSeconds(film, edl)) play("pop", pop, 0.35, 0.72);
|
|
120
137
|
}
|
|
121
138
|
return cues;
|
|
122
139
|
}
|
|
@@ -202,10 +219,17 @@ export function composeFootage(input: FootageComposeInput): string {
|
|
|
202
219
|
|
|
203
220
|
const tail = r3(end - cutEnd);
|
|
204
221
|
const endCard = film.endCard;
|
|
222
|
+
const lastFrameHtml = `<img id="last" class="clip shot" src="${escapeHtml(assets.lastFrame)}" data-start="${cutEnd}" data-duration="${tail}" />`;
|
|
223
|
+
// The full card's entrances were timed for 3 s; a shorter card plays them faster, so the last one ends on screen.
|
|
224
|
+
const pace = endCard === null ? 1 : Math.min(1, getEndCardSeconds(endCard) / DEFAULT_END_CARD_SECONDS);
|
|
225
|
+
const paced = (seconds: number): number => r3(seconds * pace);
|
|
205
226
|
const endCardHtml =
|
|
206
227
|
endCard === null
|
|
207
228
|
? ""
|
|
208
|
-
:
|
|
229
|
+
: endCard.layout === "logo"
|
|
230
|
+
? `${lastFrameHtml}
|
|
231
|
+
${getLogoCardHtml(endCard, assets.logo, input.brandName)}`
|
|
232
|
+
: `${lastFrameHtml}
|
|
209
233
|
<div class="shade" id="shade"></div>
|
|
210
234
|
<div class="endcard">
|
|
211
235
|
<div class="brand" id="ec-brand">${assets.logo === null ? "" : `<img class="logo" src="${escapeHtml(assets.logo)}" alt="" />`}<span>${escapeHtml(input.brandName)}</span></div>
|
|
@@ -216,13 +240,16 @@ export function composeFootage(input: FootageComposeInput): string {
|
|
|
216
240
|
const endCardTweens =
|
|
217
241
|
endCard === null
|
|
218
242
|
? []
|
|
219
|
-
:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
243
|
+
: endCard.layout === "logo"
|
|
244
|
+
? [`tl.fromTo("#ec-logo-card", { opacity: 0 }, { opacity: 1, duration: ${r3(endCard.fadeSeconds ?? DEFAULT_LOGO_END_CARD_FADE_SECONDS)}, ease: "none" }, ${cutEnd});`]
|
|
245
|
+
: [
|
|
246
|
+
`tl.fromTo("#shade", { opacity: 0 }, { opacity: 0.82, duration: ${paced(0.45)}, ease: "power2.out" }, ${cutEnd});`,
|
|
247
|
+
`tl.fromTo("#ec-brand", { y: 30, opacity: 0 }, { y: 0, opacity: 1, duration: ${paced(0.5)}, ease: "power3.out" }, ${r3(cutEnd + paced(0.3))});`,
|
|
248
|
+
`tl.fromTo("#ec-headline", { y: 40, opacity: 0 }, { y: 0, opacity: 1, duration: ${paced(0.6)}, ease: "power3.out" }, ${r3(cutEnd + paced(0.45))});`,
|
|
249
|
+
`tl.fromTo("#ec-url", { y: 30, opacity: 0, scale: 0.94 }, { y: 0, opacity: 1, scale: 1, duration: ${paced(0.55)}, ease: "power3.out" }, ${r3(cutEnd + paced(0.9))});`,
|
|
250
|
+
...(endCard.note.length > 0 ? [`tl.fromTo("#ec-note", { opacity: 0 }, { opacity: 1, duration: ${paced(0.5)}, ease: "power2.out" }, ${r3(cutEnd + paced(1.3))});`] : []),
|
|
251
|
+
];
|
|
252
|
+
const logoBox = getLogoCardBox(film, frame);
|
|
226
253
|
|
|
227
254
|
const bodyFont = fontStack(fonts.body, "sans-serif");
|
|
228
255
|
const headingFont = fonts.heading === null ? bodyFont : fontStack(fonts.heading, "sans-serif");
|
|
@@ -252,6 +279,12 @@ html,body{width:${frame.width}px;height:${frame.height}px;overflow:hidden;backgr
|
|
|
252
279
|
.headline{font-family:${headingFont};font-weight:500;font-size:${input.headlineSize}px;letter-spacing:-.025em;line-height:1.02;margin-top:44px}
|
|
253
280
|
.url{display:inline-block;margin-top:40px;padding:20px 38px;border-radius:999px;font-size:44px;font-weight:600;color:${c.onCta};background:${c.cta}}
|
|
254
281
|
.note{margin-top:26px;font-size:30px;color:${c.muted}}
|
|
282
|
+
.logocard{position:absolute;inset:0;background:${c.background};opacity:0}
|
|
283
|
+
.logobox{position:absolute;top:${logoBox.top}px;bottom:${logoBox.bottom}px;left:${logoBox.left}px;right:${logoBox.right}px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:48px;text-align:center}
|
|
284
|
+
.mark{display:block;max-width:min(100%,${LOGO_CARD_MARK.width}px);max-height:${LOGO_CARD_MARK.height}px;width:auto;height:auto}
|
|
285
|
+
.mark.vector{width:min(100%,${LOGO_CARD_MARK.width}px);height:${LOGO_CARD_MARK.height}px;object-fit:contain}
|
|
286
|
+
.markname{font-family:${headingFont};font-weight:600;font-size:96px;letter-spacing:-.02em}
|
|
287
|
+
.logoline{font-family:${headingFont};font-weight:600;font-size:${LOGO_CARD_LINE_SIZE}px;line-height:1.15;letter-spacing:-.01em}
|
|
255
288
|
</style>
|
|
256
289
|
</head>
|
|
257
290
|
<body>
|
|
@@ -279,6 +312,28 @@ window.__timelines["${COMPOSITION_ID}"] = tl;
|
|
|
279
312
|
`;
|
|
280
313
|
}
|
|
281
314
|
|
|
315
|
+
/**
|
|
316
|
+
* The logo card (`layout: "logo"`): the brand's background over the whole frame, the logo (an SVG drawn as a vector to
|
|
317
|
+
* fill its box, a PNG at most at its own size, so neither is drawn soft) or the brand name, and the optional line.
|
|
318
|
+
*/
|
|
319
|
+
function getLogoCardHtml(card: LogoFootageEndCard, logo: string | null, brandName: string): string {
|
|
320
|
+
const isVector = logo !== null && /\.svg$/i.test(logo);
|
|
321
|
+
const mark = logo === null ? `<span class="markname">${escapeHtml(brandName)}</span>` : `<img class="mark${isVector ? " vector" : ""}" src="${escapeHtml(logo)}" alt="" />`;
|
|
322
|
+
const line = card.line.trim().length > 0 ? `<p class="logoline">${escapeHtml(card.line)}</p>` : "";
|
|
323
|
+
return `<div class="logocard" id="ec-logo-card"><div class="logobox">${mark}${line}</div></div>`;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Where the logo card's content sits, in px from the frame's edges: a 9:16 film keeps it inside its caption preset's
|
|
328
|
+
* safe zone (`CAPTION_SAFE_ZONES`, `all` without a preset), centred between equal sides; other frames keep 80 px.
|
|
329
|
+
*/
|
|
330
|
+
export function getLogoCardBox(film: Pick<FootageFilm, "format" | "captionPreset">, frame: { width: number; height: number }): { top: number; bottom: number; left: number; right: number } {
|
|
331
|
+
if (film.format !== "9:16" || frame.height !== 1920) return { top: 80, bottom: 80, left: 80, right: 80 };
|
|
332
|
+
const zone = CAPTION_SAFE_ZONES[film.captionPreset ?? "all"];
|
|
333
|
+
const side = Math.max(zone.left, zone.right);
|
|
334
|
+
return { top: zone.top, bottom: zone.bottom, left: side, right: side };
|
|
335
|
+
}
|
|
336
|
+
|
|
282
337
|
/**
|
|
283
338
|
* A page script that shrinks each caption's font in 1 px steps until its text takes at most `maxLines` lines, or the
|
|
284
339
|
* font reaches `minFontSize`. Only the browser knows how the font wraps, so it measures there: once at load and again
|