@softure-ai/marketing-kit 0.8.0 → 0.9.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 +15 -0
- package/README.md +25 -10
- package/dist/footage/draft-font.d.ts +18 -0
- package/dist/footage/draft-font.d.ts.map +1 -0
- package/dist/footage/draft-font.js +105 -0
- package/dist/footage/draft-font.js.map +1 -0
- package/dist/footage/draft.d.ts +49 -12
- package/dist/footage/draft.d.ts.map +1 -1
- package/dist/footage/draft.js +165 -35
- package/dist/footage/draft.js.map +1 -1
- package/dist/footage/pipeline.d.ts +20 -0
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +32 -11
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/footage/draft-font.ts +105 -0
- package/src/footage/draft.ts +184 -40
- package/src/footage/pipeline.ts +40 -10
- package/src/index.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ Newest first. Each version lists what changed for an app that uses `@softure-ai/
|
|
|
4
4
|
production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
|
|
5
5
|
"Definition of done"). Versions before the first one below are described in their GitHub Releases (`marketing-kit@x.y.z`).
|
|
6
6
|
|
|
7
|
+
## 0.9.0
|
|
8
|
+
|
|
9
|
+
- **The footage draft looks and sounds like the render (#1050):** `renderFootageDraft` follows the film's
|
|
10
|
+
`captionStyle`: a `highlight` film gets the render's chunks of up to four words on an opaque box of
|
|
11
|
+
`captionBackground`, in `captionText`, the word being said in `captionHighlight` for 0.32 s. New options `brand`
|
|
12
|
+
(the `FootageBrand` the render takes: the body font's TrueType or OpenType file, named by its own family, and the
|
|
13
|
+
caption colours; DejaVu Sans when the font has no such file) and `cacheDir` / `providers`: a `file` music source, or
|
|
14
|
+
generated music already in the paid cache, plays ducked, looped and faded as in the render. The draft never calls a
|
|
15
|
+
provider; the result gains `music` (`"none"`, `"played"`, `"not_cached"`) and `captionFont`, and the log says why
|
|
16
|
+
there is no music. `buildFootageDraftCaptions` takes `film.captionStyle` and `colors`, `buildFootageDraftArgs` takes
|
|
17
|
+
`music`. New exports: `findFootageMusic` (the render's music lookup, now shared), `chooseFootageDraftFont`,
|
|
18
|
+
`readFontFamilyName`, `toAssColor`, `FOOTAGE_DRAFT_CAPTION_COLORS`, `FootageDraftMusic`, `FootageMusicLookup`.
|
|
19
|
+
A call without the new options draws a `phrase` film exactly as before. README "A fast draft before the render":
|
|
20
|
+
what the draft matches and what it leaves out.
|
|
21
|
+
|
|
7
22
|
## 0.8.0
|
|
8
23
|
|
|
9
24
|
- **A faster HDR tone map in footage normalize (#1037):** `normalizeFootage` (and so `prepareFootage`) tone-maps an
|
package/README.md
CHANGED
|
@@ -893,25 +893,40 @@ CMD ["node", "dist/worker.js"]
|
|
|
893
893
|
|
|
894
894
|
`renderFootageDraft` makes a free draft of a cut film with ffmpeg alone (no hyperframes, no browser), so an app can
|
|
895
895
|
show the owner what the paid render will look like in seconds instead of minutes: the cut at a small width (540×960
|
|
896
|
-
for 9:16 by default), the film's captions burned in
|
|
897
|
-
|
|
898
|
-
|
|
896
|
+
for 9:16 by default), the film's captions burned in (placed like the render's, the caption preset included), zoom
|
|
897
|
+
cuts, cross-fades and Ken Burns b-roll as the render draws them, the speech track and the film's music when it costs
|
|
898
|
+
nothing. It takes the same clips, transcript and EDL as `renderFootage` and spends nothing:
|
|
899
899
|
|
|
900
900
|
```ts
|
|
901
901
|
import { checkFootageTools, cutFootage, prepareFootage, renderFootageDraft, transcribeFootage } from "@softure-ai/marketing-kit";
|
|
902
902
|
|
|
903
903
|
const problems = await checkFootageTools({ needsRender: false, needsDraft: true }); // ass (libass + libfreetype), xfade, zoompan
|
|
904
|
-
const draft = await renderFootageDraft(film, clips, transcript, edl, { buildDir, output: "draft.mp4", width: 540, log, signal: job.signal, onProgress });
|
|
905
|
-
// draft.value: { output, seconds, width, height, bytes }: H.264 yuv420p and AAC with fast start, exactly the cut's length
|
|
904
|
+
const draft = await renderFootageDraft(film, clips, transcript, edl, { buildDir, output: "draft.mp4", width: 540, brand, cacheDir, providers, log, signal: job.signal, onProgress });
|
|
905
|
+
// draft.value: { output, music, captionFont, seconds, width, height, bytes }: H.264 yuv420p and AAC with fast start, exactly the cut's length
|
|
906
906
|
```
|
|
907
907
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
-
|
|
911
|
-
|
|
908
|
+
What the draft matches and what it leaves out:
|
|
909
|
+
|
|
910
|
+
- **Captions follow `captionStyle`.** `phrase`: the render's phrases in white with a dark outline and shadow.
|
|
911
|
+
`highlight`: the render's chunks of up to four words on an opaque box of the brand's `captionBackground` (its alpha
|
|
912
|
+
kept), in `captionText`, each word in `captionHighlight` for the 0.32 s the render lights it. libass draws a square
|
|
913
|
+
box per line: no rounded corners, no drop shadow, no pop-in, and the colour switches instead of fading back.
|
|
914
|
+
- **The brand's body font** (`brand`, the value `renderFootage` takes): the TrueType or OpenType file of
|
|
915
|
+
`brand.fonts.body` closest to the captions' weight (650, normal style first) is copied to the draft's `fonts/`
|
|
916
|
+
and named by the family the file itself declares (libass matches that, not the CSS family). A body font shipped only
|
|
917
|
+
as WOFF or WOFF2, or no `brand`, draws in DejaVu Sans Bold subset to Latin with every Polish letter, shipped in
|
|
918
|
+
[`fonts/`](fonts/README.md) (`FOOTAGE_DRAFT_FONT`), and the log says so. Without `brand` a highlight film uses
|
|
919
|
+
`FOOTAGE_DRAFT_CAPTION_COLORS`. `captionMaxLines` is not applied: the draft wraps at the caption box.
|
|
920
|
+
- **Music without spending** (`cacheDir`, `providers`, as `renderFootage` takes them): a `file` source plays as is;
|
|
921
|
+
a `prompt` or `video` source plays only when its paid cache entry exists (`findFootageMusic`, the render's lookup).
|
|
922
|
+
It is ducked under the speech, looped and faded to the cut's length exactly as in the render. No provider is ever
|
|
923
|
+
called: music that is not cached yet (or a draft without `cacheDir` and `providers`) gives a draft without music,
|
|
924
|
+
`music: "not_cached"` in the result and a log line; `"none"` when the film has none, `"played"` otherwise.
|
|
925
|
+
- **Left out:** the loudness pass (speech and music are mixed as they are), the end card, the cover and the sound
|
|
926
|
+
effects (whoosh, pop).
|
|
912
927
|
- `buildFootageDraftArgs`, `buildFootageDraftCaptions` (an ASS file) and `planFootageDraft` are the pure builders, for an
|
|
913
928
|
app that runs ffmpeg its own way. ffmpeg runs in `<buildDir>/draft/`, so the captions and font paths are relative.
|
|
914
|
-
- `onProgress` reports the stage `draft` (the speech track, then the film).
|
|
929
|
+
- `onProgress` reports the stage `draft` (the speech track, the music track when it plays, then the film).
|
|
915
930
|
- `threads` sets ffmpeg's threads for every segment's decoder, the filter graph and the encoder. ffmpeg otherwise
|
|
916
931
|
follows the host's cores, not a container's CPU quota, and the draft opens one decoder per segment: pass the
|
|
917
932
|
worker's CPU limit (`threads: 1` on a 1-CPU worker), as with `normalize.threads`. The extra threads buy no speed
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BrandFont } from "../config/config.js";
|
|
2
|
+
import { type TtsResult } from "../voice/provider.js";
|
|
3
|
+
/**
|
|
4
|
+
* The family a TrueType or OpenType file names itself (name ID 1): the Windows Unicode record first, US English
|
|
5
|
+
* first among those, else the Macintosh Roman one. An error value for WOFF, WOFF2, a collection or a broken file.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readFontFamilyName(data: Buffer): TtsResult<string>;
|
|
8
|
+
/** The font file the draft draws captions with, and the family libass knows it by. */
|
|
9
|
+
export interface FootageDraftFontChoice {
|
|
10
|
+
file: string;
|
|
11
|
+
family: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The body font's file closest to the render's caption weight (normal style first) that libass can read, with its own
|
|
15
|
+
* family name; null when the brand has no body font or none of its files is a readable TrueType or OpenType font.
|
|
16
|
+
*/
|
|
17
|
+
export declare function chooseFootageDraftFont(font: BrandFont | null, read?: (path: string) => Buffer): FootageDraftFontChoice | null;
|
|
18
|
+
//# sourceMappingURL=draft-font.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-font.d.ts","sourceRoot":"","sources":["../../src/footage/draft-font.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AA2C/D;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAyBlE;AAWD,sFAAsF;AACtF,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAqB,GAAG,sBAAsB,GAAG,IAAI,CAQ3I"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { err, ok } from "../voice/provider.js";
|
|
3
|
+
/**
|
|
4
|
+
* The font file a footage draft's captions are drawn with. libass (ffmpeg's `ass` filter) loads the files in the
|
|
5
|
+
* draft's `fonts/` folder and matches a style's font name against the family each file names in its own `name` table,
|
|
6
|
+
* not against the CSS family a brand config gives it, so the draft reads that name from the file. FreeType reads
|
|
7
|
+
* TrueType and OpenType files; a brand font shipped only as WOFF or WOFF2 is not used.
|
|
8
|
+
*/
|
|
9
|
+
const SFNT_SIGNATURES = new Set([0x00010000, 0x74727565 /* true */, 0x4f54544f /* OTTO */]);
|
|
10
|
+
const NAME_TAG = 0x6e616d65; // name
|
|
11
|
+
const FAMILY_NAME_ID = 1;
|
|
12
|
+
/** The caption weight of the render's CSS (`getCaptionPillCss`, `.phrase`). */
|
|
13
|
+
const CAPTION_WEIGHT = 650;
|
|
14
|
+
class OutOfBounds extends Error {
|
|
15
|
+
}
|
|
16
|
+
function readUint16(data, offset) {
|
|
17
|
+
if (offset < 0 || offset + 2 > data.length)
|
|
18
|
+
throw new OutOfBounds();
|
|
19
|
+
return data.readUInt16BE(offset);
|
|
20
|
+
}
|
|
21
|
+
function readUint32(data, offset) {
|
|
22
|
+
if (offset < 0 || offset + 4 > data.length)
|
|
23
|
+
throw new OutOfBounds();
|
|
24
|
+
return data.readUInt32BE(offset);
|
|
25
|
+
}
|
|
26
|
+
function decodeName(bytes, platform) {
|
|
27
|
+
if (platform === 1)
|
|
28
|
+
return bytes.toString("latin1");
|
|
29
|
+
let text = "";
|
|
30
|
+
for (let index = 0; index + 1 < bytes.length; index += 2)
|
|
31
|
+
text += String.fromCharCode(bytes.readUInt16BE(index));
|
|
32
|
+
return text;
|
|
33
|
+
}
|
|
34
|
+
function findNameTable(data) {
|
|
35
|
+
const count = readUint16(data, 4);
|
|
36
|
+
for (let index = 0; index < count; index++) {
|
|
37
|
+
const record = 12 + index * 16;
|
|
38
|
+
if (readUint32(data, record) === NAME_TAG)
|
|
39
|
+
return readUint32(data, record + 8);
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The family a TrueType or OpenType file names itself (name ID 1): the Windows Unicode record first, US English
|
|
45
|
+
* first among those, else the Macintosh Roman one. An error value for WOFF, WOFF2, a collection or a broken file.
|
|
46
|
+
*/
|
|
47
|
+
export function readFontFamilyName(data) {
|
|
48
|
+
try {
|
|
49
|
+
if (!SFNT_SIGNATURES.has(readUint32(data, 0)))
|
|
50
|
+
return err("the file is not a TrueType or OpenType font");
|
|
51
|
+
const table = findNameTable(data);
|
|
52
|
+
if (table === null)
|
|
53
|
+
return err("the font has no name table");
|
|
54
|
+
const count = readUint16(data, table + 2);
|
|
55
|
+
const strings = table + readUint16(data, table + 4);
|
|
56
|
+
let best = null;
|
|
57
|
+
for (let index = 0; index < count; index++) {
|
|
58
|
+
const record = table + 6 + index * 12;
|
|
59
|
+
const platform = readUint16(data, record);
|
|
60
|
+
const language = readUint16(data, record + 4);
|
|
61
|
+
if (readUint16(data, record + 6) !== FAMILY_NAME_ID || (platform !== 3 && platform !== 1))
|
|
62
|
+
continue;
|
|
63
|
+
const length = readUint16(data, record + 8);
|
|
64
|
+
const start = strings + readUint16(data, record + 10);
|
|
65
|
+
if (start + length > data.length)
|
|
66
|
+
throw new OutOfBounds();
|
|
67
|
+
const rank = platform === 3 ? (language === 0x0409 ? 0 : 1) : 2;
|
|
68
|
+
const name = decodeName(data.subarray(start, start + length), platform).trim();
|
|
69
|
+
if (name.length > 0 && (best === null || rank < best.rank))
|
|
70
|
+
best = { rank, name };
|
|
71
|
+
}
|
|
72
|
+
return best === null ? err("the font names no family") : ok(best.name);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof OutOfBounds)
|
|
76
|
+
return err("the font file is cut short");
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** How far a file's weight (`400`, or a variable range `100 900`) is from the caption weight; 0 inside a range. */
|
|
81
|
+
function getWeightDistance(file) {
|
|
82
|
+
const [low, high] = file.weight.split(/\s+/).map(Number);
|
|
83
|
+
if (low === undefined || Number.isNaN(low))
|
|
84
|
+
return Number.POSITIVE_INFINITY;
|
|
85
|
+
const top = high === undefined || Number.isNaN(high) ? low : high;
|
|
86
|
+
if (CAPTION_WEIGHT >= low && CAPTION_WEIGHT <= top)
|
|
87
|
+
return 0;
|
|
88
|
+
return Math.min(Math.abs(CAPTION_WEIGHT - low), Math.abs(CAPTION_WEIGHT - top));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The body font's file closest to the render's caption weight (normal style first) that libass can read, with its own
|
|
92
|
+
* family name; null when the brand has no body font or none of its files is a readable TrueType or OpenType font.
|
|
93
|
+
*/
|
|
94
|
+
export function chooseFootageDraftFont(font, read = readFileSync) {
|
|
95
|
+
if (font === null)
|
|
96
|
+
return null;
|
|
97
|
+
const files = [...font.files].sort((a, b) => Number(a.style === "italic") - Number(b.style === "italic") || getWeightDistance(a) - getWeightDistance(b));
|
|
98
|
+
for (const file of files) {
|
|
99
|
+
const family = readFontFamilyName(read(file.path));
|
|
100
|
+
if (family.ok)
|
|
101
|
+
return { file: file.path, family: family.value };
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=draft-font.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-font.js","sourceRoot":"","sources":["../../src/footage/draft-font.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAkB,MAAM,sBAAsB,CAAC;AAE/D;;;;;GAKG;AAEH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;AAC5F,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,OAAO;AACpC,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,+EAA+E;AAC/E,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,WAAY,SAAQ,KAAK;CAAG;AAElC,SAAS,UAAU,CAAC,IAAY,EAAE,MAAc;IAC9C,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,WAAW,EAAE,CAAC;IACpE,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,MAAc;IAC9C,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,GAAG,IAAI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C,IAAsB,EAAE,OAAiC,YAAY;IAC1G,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IACzJ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,IAAI,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IAClE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/footage/draft.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CaptionLayout, type LayoutOverride } from "../compose/timeline.js";
|
|
2
|
+
import type { BrandColors } from "../config/colors.js";
|
|
2
3
|
import type { TimedWord } from "../voice/voiceover.js";
|
|
3
4
|
import { type Edl } from "./edl.js";
|
|
4
5
|
import { type FootageFilm } from "./film.js";
|
|
5
6
|
import { type Frame } from "./normalize.js";
|
|
6
|
-
import { type FootageResult, type FootageRunOptions, type PreparedClip, type TranscribeOutcome } from "./pipeline.js";
|
|
7
|
+
import { type FootageBrand, type FootageResult, type FootageRunOptions, type PreparedClip, type TranscribeOutcome } from "./pipeline.js";
|
|
7
8
|
/**
|
|
8
9
|
* A fast draft of a footage film, ffmpeg only (no hyperframes, no browser): the cut at a small width with the film's
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* captions burned in (its caption style, in the brand's body font and caption colours), its zoom cuts (eased as in the
|
|
11
|
+
* render), cross-fades and Ken Burns b-roll drawn as the full render draws them, the speech track and the ducked music
|
|
12
|
+
* when it costs nothing. No loudness pass, end card, cover or sound effects. What an app shows the owner before the paid
|
|
13
|
+
* render.
|
|
11
14
|
*/
|
|
12
15
|
/** The draft's default width: 540 makes a 540×960 draft of a 9:16 film. */
|
|
13
16
|
export declare const FOOTAGE_DRAFT_WIDTH = 540;
|
|
@@ -16,10 +19,23 @@ export declare const FOOTAGE_DRAFT_FONT: {
|
|
|
16
19
|
readonly family: "DejaVu Sans";
|
|
17
20
|
readonly file: string;
|
|
18
21
|
};
|
|
22
|
+
/** The caption colours of a `highlight` draft made without a brand. */
|
|
23
|
+
export declare const FOOTAGE_DRAFT_CAPTION_COLORS: {
|
|
24
|
+
readonly captionBackground: "#111111";
|
|
25
|
+
readonly captionText: "#ffffff";
|
|
26
|
+
readonly captionHighlight: "#ffd400";
|
|
27
|
+
};
|
|
19
28
|
/** The draft's frame: the film's frame scaled to `width`, both sides even (H.264 yuv420p needs them even). */
|
|
20
29
|
export declare function getFootageDraftFrame(frame: Frame, width?: number): Frame;
|
|
30
|
+
/**
|
|
31
|
+
* A hex colour (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`) as an ASS colour, `&HAABBGGRR&`-style without the closing
|
|
32
|
+
* `&`: ASS writes blue first and counts alpha the other way round (00 is opaque).
|
|
33
|
+
*/
|
|
34
|
+
export declare function toAssColor(hex: string): string;
|
|
35
|
+
/** The caption colours the draft paints with (`BrandColors`). */
|
|
36
|
+
export type FootageDraftCaptionColors = Pick<BrandColors, "captionBackground" | "captionText" | "captionHighlight">;
|
|
21
37
|
export interface FootageDraftCaptionsInput {
|
|
22
|
-
film: Pick<FootageFilm, "captions">;
|
|
38
|
+
film: Pick<FootageFilm, "captions" | "captionStyle">;
|
|
23
39
|
edl: Edl;
|
|
24
40
|
/** The film's words in film time (`remapWords`). */
|
|
25
41
|
words: TimedWord[];
|
|
@@ -27,13 +43,17 @@ export interface FootageDraftCaptionsInput {
|
|
|
27
43
|
caption: CaptionLayout;
|
|
28
44
|
/** The film's full frame; the ASS file is laid out in it and libass scales it to the draft. */
|
|
29
45
|
frame: Frame;
|
|
30
|
-
/** The font family the captions are drawn in; default `FOOTAGE_DRAFT_FONT.family`. */
|
|
46
|
+
/** The font family the captions are drawn in, as the font file names it; default `FOOTAGE_DRAFT_FONT.family`. */
|
|
31
47
|
fontFamily?: string;
|
|
48
|
+
/** The `highlight` pill's colours; default `FOOTAGE_DRAFT_CAPTION_COLORS`. A `phrase` caption is white, as in the render. */
|
|
49
|
+
colors?: FootageDraftCaptionColors;
|
|
32
50
|
}
|
|
33
51
|
/**
|
|
34
|
-
* The draft's captions as an ASS subtitle file
|
|
35
|
-
*
|
|
36
|
-
*
|
|
52
|
+
* The draft's captions as an ASS subtitle file, shown for the render's spans (`getCaptionSpans`) and centred in the
|
|
53
|
+
* caption box from its top (or from its foot, with `bottom`). `phrase` (the default): the film's phrases
|
|
54
|
+
* (`phraseChunks`), white bold text with a dark outline and shadow. `highlight`: the render's chunks of up to four
|
|
55
|
+
* words (`captionChunks`) on an opaque box of `captionBackground`, in `captionText`, the word being said in
|
|
56
|
+
* `captionHighlight`. Null when the film has no captions or nothing is said.
|
|
37
57
|
*/
|
|
38
58
|
export declare function buildFootageDraftCaptions(input: FootageDraftCaptionsInput): string | null;
|
|
39
59
|
export interface FootageDraftArgsInput {
|
|
@@ -43,6 +63,8 @@ export interface FootageDraftArgsInput {
|
|
|
43
63
|
clips: Record<string, string>;
|
|
44
64
|
/** The cut speech track (`buildSpeechArgs`). */
|
|
45
65
|
speech: string;
|
|
66
|
+
/** The ducked music track (`buildMusicArgs`, as long as the cut), mixed under the speech; null or absent for none. */
|
|
67
|
+
music?: string | null;
|
|
46
68
|
/** The film's full frame (the normalized clips' size). */
|
|
47
69
|
frame: Frame;
|
|
48
70
|
/** The draft's width; default 540. */
|
|
@@ -88,21 +110,35 @@ export declare function planFootageDraft(film: Pick<FootageFilm, "edit">, edl: E
|
|
|
88
110
|
* speech track under it; H.264 yuv420p and AAC with fast start, exactly the cut's length.
|
|
89
111
|
*/
|
|
90
112
|
export declare function buildFootageDraftArgs(input: FootageDraftArgsInput): string[];
|
|
91
|
-
export interface RenderFootageDraftOptions extends Pick<FootageRunOptions, "buildDir" | "log" | "signal" | "onProgress"
|
|
113
|
+
export interface RenderFootageDraftOptions extends Pick<FootageRunOptions, "buildDir" | "log" | "signal" | "onProgress">, Partial<Pick<FootageRunOptions, "cacheDir" | "providers">> {
|
|
92
114
|
/** The draft MP4. */
|
|
93
115
|
output: string;
|
|
94
116
|
/** The draft's width; default 540 (540×960 for a 9:16 film). */
|
|
95
117
|
width?: number;
|
|
96
118
|
/** A project's override of the format's caption box (`marketing.json` `layout`), as the render takes it. */
|
|
97
119
|
layout?: LayoutOverride;
|
|
120
|
+
/**
|
|
121
|
+
* The brand the render takes (`renderFootage`'s `brand`): the captions are drawn in its body font (a TrueType or
|
|
122
|
+
* OpenType file; DejaVu Sans when it has none) and its caption colours. Without it, DejaVu Sans and
|
|
123
|
+
* `FOOTAGE_DRAFT_CAPTION_COLORS`.
|
|
124
|
+
*/
|
|
125
|
+
brand?: {
|
|
126
|
+
colors: FootageDraftCaptionColors;
|
|
127
|
+
fonts: Pick<FootageBrand["fonts"], "body">;
|
|
128
|
+
};
|
|
98
129
|
/**
|
|
99
130
|
* ffmpeg's threads for the draft's decoders, filter graph and encoder (`buildFootageDraftArgs`); by default ffmpeg's
|
|
100
131
|
* own choice, which follows the host's cores. Set it from a CPU-limited container's quota.
|
|
101
132
|
*/
|
|
102
133
|
threads?: number;
|
|
103
134
|
}
|
|
135
|
+
/** The draft's music: the film has none, it played (a file, or generated music from the cache), or it is not cached yet. */
|
|
136
|
+
export type FootageDraftMusic = "none" | "played" | "not_cached";
|
|
104
137
|
export interface FootageDraft {
|
|
105
138
|
output: string;
|
|
139
|
+
music: FootageDraftMusic;
|
|
140
|
+
/** The family the captions are drawn in; null without captions. */
|
|
141
|
+
captionFont: string | null;
|
|
106
142
|
/** The draft's length: the cut's. */
|
|
107
143
|
seconds: number;
|
|
108
144
|
width: number;
|
|
@@ -110,8 +146,9 @@ export interface FootageDraft {
|
|
|
110
146
|
bytes: number;
|
|
111
147
|
}
|
|
112
148
|
/**
|
|
113
|
-
* Makes the draft of a cut film: the speech track, the
|
|
114
|
-
* ffmpeg run (`buildFootageDraftArgs`). Spends nothing
|
|
149
|
+
* Makes the draft of a cut film: the speech track, the ducked music track (when it costs nothing), the captions file
|
|
150
|
+
* and its font in `<buildDir>/draft/`, then one ffmpeg run (`buildFootageDraftArgs`). Spends nothing: no provider is
|
|
151
|
+
* called; takes the same clips, transcript and EDL as `renderFootage`.
|
|
115
152
|
*/
|
|
116
153
|
export declare function renderFootageDraft(film: FootageFilm, clips: PreparedClip[], transcript: Extract<TranscribeOutcome, {
|
|
117
154
|
kind: "ready";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../../src/footage/draft.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../../src/footage/draft.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAgD,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAA8B,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAA8B,KAAK,YAAY,EAAE,K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