@softure-ai/marketing-kit 0.3.1 → 0.5.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 +57 -0
- package/README.md +135 -14
- package/dist/cli/footage.d.ts.map +1 -1
- package/dist/cli/footage.js +15 -6
- package/dist/cli/footage.js.map +1 -1
- package/dist/config/actions-schema.d.ts +14 -14
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +5 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/schema.d.ts +92 -69
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +40 -4
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shot-steps.d.ts +16 -16
- package/dist/footage/audio.d.ts +52 -0
- package/dist/footage/audio.d.ts.map +1 -0
- package/dist/footage/audio.js +100 -0
- package/dist/footage/audio.js.map +1 -0
- package/dist/footage/captions.d.ts +57 -0
- package/dist/footage/captions.d.ts.map +1 -0
- package/dist/footage/captions.js +112 -0
- package/dist/footage/captions.js.map +1 -0
- package/dist/footage/compose.d.ts +5 -5
- package/dist/footage/compose.d.ts.map +1 -1
- package/dist/footage/compose.js +31 -22
- package/dist/footage/compose.js.map +1 -1
- package/dist/footage/edl.d.ts +54 -16
- package/dist/footage/edl.d.ts.map +1 -1
- package/dist/footage/edl.js +204 -52
- package/dist/footage/edl.js.map +1 -1
- package/dist/footage/elevenlabs.d.ts +4 -1
- package/dist/footage/elevenlabs.d.ts.map +1 -1
- package/dist/footage/elevenlabs.js +18 -6
- package/dist/footage/elevenlabs.js.map +1 -1
- package/dist/footage/fake.d.ts +2 -0
- package/dist/footage/fake.d.ts.map +1 -1
- package/dist/footage/fake.js +2 -1
- package/dist/footage/fake.js.map +1 -1
- package/dist/footage/film.d.ts +35 -1
- package/dist/footage/film.d.ts.map +1 -1
- package/dist/footage/film.js +9 -1
- package/dist/footage/film.js.map +1 -1
- package/dist/footage/frames.d.ts +38 -0
- package/dist/footage/frames.d.ts.map +1 -0
- package/dist/footage/frames.js +40 -0
- package/dist/footage/frames.js.map +1 -0
- package/dist/footage/loudness.d.ts +49 -0
- package/dist/footage/loudness.d.ts.map +1 -0
- package/dist/footage/loudness.js +114 -0
- package/dist/footage/loudness.js.map +1 -0
- package/dist/footage/normalize.d.ts +6 -2
- package/dist/footage/normalize.d.ts.map +1 -1
- package/dist/footage/normalize.js +7 -9
- package/dist/footage/normalize.js.map +1 -1
- package/dist/footage/paid.d.ts +70 -0
- package/dist/footage/paid.d.ts.map +1 -0
- package/dist/footage/paid.js +172 -0
- package/dist/footage/paid.js.map +1 -0
- package/dist/footage/pipeline.d.ts +34 -10
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +294 -85
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/footage/probe.d.ts +18 -4
- package/dist/footage/probe.d.ts.map +1 -1
- package/dist/footage/probe.js +18 -13
- package/dist/footage/probe.js.map +1 -1
- package/dist/footage/process.d.ts +45 -0
- package/dist/footage/process.d.ts.map +1 -0
- package/dist/footage/process.js +109 -0
- package/dist/footage/process.js.map +1 -0
- package/dist/footage/providers.d.ts +49 -5
- package/dist/footage/providers.d.ts.map +1 -1
- package/dist/footage/providers.js +4 -0
- package/dist/footage/providers.js.map +1 -1
- package/dist/footage/publish.d.ts +62 -0
- package/dist/footage/publish.d.ts.map +1 -0
- package/dist/footage/publish.js +164 -0
- package/dist/footage/publish.js.map +1 -0
- package/dist/footage/render.d.ts +5 -4
- package/dist/footage/render.d.ts.map +1 -1
- package/dist/footage/render.js +29 -17
- package/dist/footage/render.js.map +1 -1
- package/dist/footage/sentences.d.ts +44 -0
- package/dist/footage/sentences.d.ts.map +1 -0
- package/dist/footage/sentences.js +102 -0
- package/dist/footage/sentences.js.map +1 -0
- package/dist/footage/tools.d.ts +33 -0
- package/dist/footage/tools.d.ts.map +1 -0
- package/dist/footage/tools.js +108 -0
- package/dist/footage/tools.js.map +1 -0
- package/dist/footage/words.d.ts +6 -0
- package/dist/footage/words.d.ts.map +1 -0
- package/dist/footage/words.js +14 -0
- package/dist/footage/words.js.map +1 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/docker/footage-worker.Dockerfile +29 -0
- package/package.json +2 -1
- package/schema/edl.schema.json +115 -0
- package/schema/marketing.schema.json +112 -5
- package/src/cli/footage.ts +13 -5
- package/src/config/config.ts +5 -0
- package/src/config/schema.ts +40 -4
- package/src/footage/audio.ts +123 -0
- package/src/footage/captions.ts +146 -0
- package/src/footage/compose.ts +32 -24
- package/src/footage/edl.ts +225 -56
- package/src/footage/elevenlabs.ts +21 -8
- package/src/footage/fake.ts +4 -1
- package/src/footage/film.ts +43 -2
- package/src/footage/frames.ts +65 -0
- package/src/footage/loudness.ts +143 -0
- package/src/footage/normalize.ts +7 -9
- package/src/footage/paid.ts +213 -0
- package/src/footage/pipeline.ts +344 -89
- package/src/footage/probe.ts +20 -12
- package/src/footage/process.ts +135 -0
- package/src/footage/providers.ts +56 -6
- package/src/footage/publish.ts +180 -0
- package/src/footage/render.ts +29 -19
- package/src/footage/sentences.ts +137 -0
- package/src/footage/tools.ts +119 -0
- package/src/footage/words.ts +15 -0
- package/src/index.ts +84 -0
package/dist/footage/film.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { VideoFormat } from "../compose/timeline.js";
|
|
2
2
|
import type { EndCard } from "../film.js";
|
|
3
|
+
import type { LoudnessTarget } from "./loudness.js";
|
|
3
4
|
/**
|
|
4
5
|
* A footage film: filmed clips (a person talking to camera, b-roll) cut by their transcript into a captioned
|
|
5
6
|
* vertical film. Built from `marketing.json` (`footage[]`) or passed to `renderFootageFilm` as it is.
|
|
@@ -85,17 +86,50 @@ export interface FootageFilm {
|
|
|
85
86
|
cut: CutOptions;
|
|
86
87
|
transitions: FootageTransitions;
|
|
87
88
|
music: FootageMusic;
|
|
88
|
-
/**
|
|
89
|
+
/** Captions from the transcript. */
|
|
89
90
|
captions: boolean;
|
|
91
|
+
/** `phrase` (the default): 2-6 words of plain text with a soft shadow; `highlight`: a pill that lights each word as it is said. */
|
|
92
|
+
captionStyle?: CaptionStyle;
|
|
93
|
+
/** Places the 9:16 caption box inside a platform's safe zone (`CAPTION_SAFE_ZONES`); absent: the layout as it is. */
|
|
94
|
+
captionPreset?: CaptionPreset;
|
|
95
|
+
/** The cut's look: zoom size, fade length, Ken Burns, the end card's whoosh. Absent fields take `DEFAULT_EDIT`. */
|
|
96
|
+
edit?: Partial<FootageEdit>;
|
|
90
97
|
/** The closing card after the last segment; null: the film ends with its last segment. */
|
|
91
98
|
endCard: EndCard | null;
|
|
99
|
+
/** The speech track's loudness, normalized before the music is mixed under it. Absent: −14 LUFS, −1 dBTP; null: left as filmed. */
|
|
100
|
+
loudness?: LoudnessTarget | null;
|
|
101
|
+
/**
|
|
102
|
+
* The cover JPG written next to the film. Absent or without `at`: the middle of the first talking segment; `at`:
|
|
103
|
+
* that second of the film; null: no cover.
|
|
104
|
+
*/
|
|
105
|
+
cover?: {
|
|
106
|
+
at?: number;
|
|
107
|
+
} | null;
|
|
92
108
|
}
|
|
93
109
|
/** Filler words per language, written with repeated letters collapsed (`yyy` and `yyyy` are both `y`). */
|
|
94
110
|
export declare const DEFAULT_FILLERS: Record<string, string[]>;
|
|
95
111
|
/** The default fillers of a language; none for a language without a list. */
|
|
96
112
|
export declare function getDefaultFillers(language: string): string[];
|
|
97
113
|
export declare const DEFAULT_CUT: Omit<CutOptions, "fillers">;
|
|
114
|
+
/** Hard cuts everywhere: an ordinary phone video, not a promo. */
|
|
98
115
|
export declare const DEFAULT_TRANSITIONS: FootageTransitions;
|
|
116
|
+
export declare const CAPTION_STYLES: readonly ["phrase", "highlight"];
|
|
117
|
+
export type CaptionStyle = (typeof CAPTION_STYLES)[number];
|
|
118
|
+
export declare const CAPTION_PRESETS: readonly ["reels", "shorts", "tiktok", "all"];
|
|
119
|
+
export type CaptionPreset = (typeof CAPTION_PRESETS)[number];
|
|
120
|
+
export interface FootageEdit {
|
|
121
|
+
/** How far a `zoom` cut punches in, in percent of the frame (105-110). */
|
|
122
|
+
zoomPercent: number;
|
|
123
|
+
/** A `fade` cut's length in frames at 30 fps (1-30). */
|
|
124
|
+
fadeFrames: number;
|
|
125
|
+
/** How far b-roll zooms over its length (0-5 %); 0 keeps b-roll still and `buildEdl` marks none `kenburns`. */
|
|
126
|
+
kenBurnsPercent: number;
|
|
127
|
+
/** Play the whoosh (and pop) as the end card comes in. */
|
|
128
|
+
isEndCardWhoosh: boolean;
|
|
129
|
+
}
|
|
130
|
+
export declare const DEFAULT_EDIT: FootageEdit;
|
|
131
|
+
/** The film's edit settings with the defaults filled in. */
|
|
132
|
+
export declare function getFootageEdit(film: Pick<FootageFilm, "edit">): FootageEdit;
|
|
99
133
|
export declare const DEFAULT_MUSIC_VOLUME: {
|
|
100
134
|
readonly volume: 0.35;
|
|
101
135
|
readonly duckedVolume: 0.1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"film.d.ts","sourceRoot":"","sources":["../../src/footage/film.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"film.d.ts","sourceRoot":"","sources":["../../src/footage/film.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;GAGG;AAEH,2HAA2H;AAC3H,eAAO,MAAM,UAAU,4BAA6B,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAA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,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAA6D,CAAC;AAElH,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,EAAE,kBAAiD,CAAC;AAEpF,eAAO,MAAM,cAAc,kCAAmC,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,eAAO,MAAM,eAAe,+CAAgD,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,+GAA+G;IAC/G,eAAe,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,YAAY,EAAE,WAA8F,CAAC;AAE1H,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,WAAW,CAE3E;AAED,eAAO,MAAM,oBAAoB;;;CAA+C,CAAC"}
|
package/dist/footage/film.js
CHANGED
|
@@ -24,6 +24,14 @@ export function getDefaultFillers(language) {
|
|
|
24
24
|
return DEFAULT_FILLERS[language] ?? [];
|
|
25
25
|
}
|
|
26
26
|
export const DEFAULT_CUT = { pauseSeconds: 0.6, padSeconds: 0.12, maxSeconds: null };
|
|
27
|
-
|
|
27
|
+
/** Hard cuts everywhere: an ordinary phone video, not a promo. */
|
|
28
|
+
export const DEFAULT_TRANSITIONS = { jump: "cut", clip: "cut" };
|
|
29
|
+
export const CAPTION_STYLES = ["phrase", "highlight"];
|
|
30
|
+
export const CAPTION_PRESETS = ["reels", "shorts", "tiktok", "all"];
|
|
31
|
+
export const DEFAULT_EDIT = { zoomPercent: 108, fadeFrames: 10, kenBurnsPercent: 0, isEndCardWhoosh: false };
|
|
32
|
+
/** The film's edit settings with the defaults filled in. */
|
|
33
|
+
export function getFootageEdit(film) {
|
|
34
|
+
return { ...DEFAULT_EDIT, ...film.edit };
|
|
35
|
+
}
|
|
28
36
|
export const DEFAULT_MUSIC_VOLUME = { volume: 0.35, duckedVolume: 0.1 };
|
|
29
37
|
//# sourceMappingURL=film.js.map
|
package/dist/footage/film.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"film.js","sourceRoot":"","sources":["../../src/footage/film.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"film.js","sourceRoot":"","sources":["../../src/footage/film.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAEH,2HAA2H;AAC3H,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,CAAU,CAAC;AAIrD;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAI3D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC;AAmF1E,0GAA0G;AAC1G,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC;IAChE,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC;CACxD,CAAC;AAEF,6EAA6E;AAC7E,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,OAAO,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAgC,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAElH,kEAAkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAuB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAEpF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAU,CAAC;AAI/D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAe7E,MAAM,CAAC,MAAM,YAAY,GAAgB,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;AAE1H,4DAA4D;AAC5D,MAAM,UAAU,cAAc,CAAC,IAA+B;IAC5D,OAAO,EAAE,GAAG,YAAY,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frames of a clip as JPG files (a contact sheet), so an agent can look at the footage and choose the opening shot or
|
|
3
|
+
* the b-roll. Read from the normalized clip, so the frames are upright and in SDR as the film will show them.
|
|
4
|
+
*/
|
|
5
|
+
export type FrameSpacing = {
|
|
6
|
+
count: number;
|
|
7
|
+
} | {
|
|
8
|
+
everySeconds: number;
|
|
9
|
+
};
|
|
10
|
+
export interface ExtractFramesOptions {
|
|
11
|
+
/** The folder the JPGs go to (`<name>-<n>.jpg`); created when missing. */
|
|
12
|
+
outDir: string;
|
|
13
|
+
/** The frames' width in px (the height keeps the aspect); 360 by default. */
|
|
14
|
+
width?: number;
|
|
15
|
+
/** The files' name before the number; `frame` by default. */
|
|
16
|
+
name?: string;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
export interface ExtractedFrame {
|
|
20
|
+
file: string;
|
|
21
|
+
/** Seconds in the clip. */
|
|
22
|
+
seconds: number;
|
|
23
|
+
}
|
|
24
|
+
/** The most frames one call writes, so a long clip with a short spacing stays a sheet, not a film. */
|
|
25
|
+
export declare const MAX_FRAMES = 120;
|
|
26
|
+
/** The times to take frames at: `count` frames at the middles of equal parts, or one every `everySeconds` from its half. */
|
|
27
|
+
export declare function getFrameTimes(duration: number, spacing: FrameSpacing): number[];
|
|
28
|
+
/** One frame at `seconds`, scaled to `width`. */
|
|
29
|
+
export declare function buildFrameArgs(file: string, seconds: number, width: number, output: string): string[];
|
|
30
|
+
/** Writes the frames and answers their files and times; an error names the file. Rejects on abort. */
|
|
31
|
+
export declare function extractFrames(file: string, spacing: FrameSpacing, options: ExtractFramesOptions): Promise<{
|
|
32
|
+
ok: true;
|
|
33
|
+
frames: ExtractedFrame[];
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
error: string;
|
|
37
|
+
}>;
|
|
38
|
+
//# sourceMappingURL=frames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frames.d.ts","sourceRoot":"","sources":["../../src/footage/frames.ts"],"names":[],"mappings":"AAMA;;;GAGG;AAEH,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD,sGAAsG;AACtG,eAAO,MAAM,UAAU,MAAM,CAAC;AAI9B,4HAA4H;AAC5H,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,EAAE,CAM/E;AAED,iDAAiD;AACjD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAErG;AAED,sGAAsG;AACtG,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,cAAc,EAAE,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CActL"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { mkdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { probeFile } from "./probe.js";
|
|
4
|
+
import { runFfmpeg } from "./process.js";
|
|
5
|
+
const DEFAULT_WIDTH = 360;
|
|
6
|
+
/** The most frames one call writes, so a long clip with a short spacing stays a sheet, not a film. */
|
|
7
|
+
export const MAX_FRAMES = 120;
|
|
8
|
+
const r3 = (value) => Math.round(value * 1000) / 1000 || 0;
|
|
9
|
+
/** The times to take frames at: `count` frames at the middles of equal parts, or one every `everySeconds` from its half. */
|
|
10
|
+
export function getFrameTimes(duration, spacing) {
|
|
11
|
+
if (duration <= 0)
|
|
12
|
+
return [];
|
|
13
|
+
const count = "count" in spacing ? spacing.count : Math.floor(duration / spacing.everySeconds);
|
|
14
|
+
const step = "count" in spacing ? duration / spacing.count : spacing.everySeconds;
|
|
15
|
+
const total = Math.min(MAX_FRAMES, Math.max(1, Math.floor(count)));
|
|
16
|
+
return Array.from({ length: total }, (_, index) => r3(Math.min(duration - 0.01, (index + 0.5) * step)));
|
|
17
|
+
}
|
|
18
|
+
/** One frame at `seconds`, scaled to `width`. */
|
|
19
|
+
export function buildFrameArgs(file, seconds, width, output) {
|
|
20
|
+
return ["-v", "error", "-y", "-ss", String(seconds), "-i", file, "-frames:v", "1", "-vf", `scale=${width}:-2`, "-q:v", "3", output];
|
|
21
|
+
}
|
|
22
|
+
/** Writes the frames and answers their files and times; an error names the file. Rejects on abort. */
|
|
23
|
+
export async function extractFrames(file, spacing, options) {
|
|
24
|
+
if ("count" in spacing ? !(spacing.count >= 1) : !(spacing.everySeconds > 0))
|
|
25
|
+
return { ok: false, error: "frames: count must be at least 1, everySeconds above 0" };
|
|
26
|
+
const signal = options.signal === undefined ? {} : { signal: options.signal };
|
|
27
|
+
const probed = await probeFile(file, signal);
|
|
28
|
+
if (!probed.ok)
|
|
29
|
+
return probed;
|
|
30
|
+
mkdirSync(options.outDir, { recursive: true });
|
|
31
|
+
const width = options.width ?? DEFAULT_WIDTH;
|
|
32
|
+
const frames = [];
|
|
33
|
+
for (const [index, seconds] of getFrameTimes(probed.probe.duration, spacing).entries()) {
|
|
34
|
+
const output = join(options.outDir, `${options.name ?? "frame"}-${String(index + 1).padStart(3, "0")}.jpg`);
|
|
35
|
+
await runFfmpeg(`A frame of ${file} at ${seconds} s`, buildFrameArgs(file, seconds, width, output), { ...signal, output });
|
|
36
|
+
frames.push({ file: output, seconds });
|
|
37
|
+
}
|
|
38
|
+
return { ok: true, frames };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frames.js","sourceRoot":"","sources":["../../src/footage/frames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,E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AAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5G,MAAM,SAAS,CAAC,cAAc,IAAI,OAAO,OAAO,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3H,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The speech track's loudness, measured and normalized in two passes of ffmpeg's `loudnorm` (EBU R128): the first
|
|
3
|
+
* pass measures, the second applies one linear gain from that measurement, so a quiet phone clip is not left quiet
|
|
4
|
+
* and a loud one does not clip. It runs before the music is mixed under the speech.
|
|
5
|
+
*/
|
|
6
|
+
export interface LoudnessTarget {
|
|
7
|
+
/** Integrated loudness in LUFS. */
|
|
8
|
+
target: number;
|
|
9
|
+
/** The highest true peak in dBTP. */
|
|
10
|
+
truePeak: number;
|
|
11
|
+
}
|
|
12
|
+
/** What the platforms play short videos at. */
|
|
13
|
+
export declare const DEFAULT_LOUDNESS: LoudnessTarget;
|
|
14
|
+
/** The first pass's measurement, as `loudnorm` prints it with `print_format=json`. */
|
|
15
|
+
export interface LoudnessMeasurement {
|
|
16
|
+
inputI: number;
|
|
17
|
+
inputTp: number;
|
|
18
|
+
inputLra: number;
|
|
19
|
+
inputThresh: number;
|
|
20
|
+
targetOffset: number;
|
|
21
|
+
}
|
|
22
|
+
/** The first pass: decodes the track, prints the measurement on stderr, writes nothing. */
|
|
23
|
+
export declare function buildLoudnessMeasureArgs(input: string, target: LoudnessTarget): string[];
|
|
24
|
+
/** The measurement from the first pass's stderr (its last JSON block); null when there is none or it is incomplete. */
|
|
25
|
+
export declare function readLoudnessMeasurement(stderr: string): LoudnessMeasurement | null;
|
|
26
|
+
/** True when the measured track is silence, which no gain can bring to the target. */
|
|
27
|
+
export declare function isSilent(measurement: LoudnessMeasurement): boolean;
|
|
28
|
+
/** The second pass: one linear gain from the measurement, resampled back to the film's rate (`loudnorm` runs at 192 kHz). */
|
|
29
|
+
export declare function buildLoudnessArgs(options: {
|
|
30
|
+
input: string;
|
|
31
|
+
measurement: LoudnessMeasurement;
|
|
32
|
+
target: LoudnessTarget;
|
|
33
|
+
output: string;
|
|
34
|
+
}): string[];
|
|
35
|
+
export type LoudnessOutcome = {
|
|
36
|
+
kind: "normalized";
|
|
37
|
+
measured: number;
|
|
38
|
+
} | {
|
|
39
|
+
kind: "silent";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Measures `input` and writes it normalized to `output`; a silent track is copied as it is. Throws naming the step
|
|
43
|
+
* when ffmpeg fails, rejects with the signal's reason on abort.
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeLoudness(input: string, output: string, target: LoudnessTarget, options?: {
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
onSeconds?: (seconds: number) => void;
|
|
48
|
+
}): Promise<LoudnessOutcome>;
|
|
49
|
+
//# sourceMappingURL=loudness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loudness.d.ts","sourceRoot":"","sources":["../../src/footage/loudness.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,EAAE,cAA8C,CAAC;AAQ9E,sFAA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ize.js";
|
|
4
|
+
import { runFfmpeg, runProcess } from "./process.js";
|
|
5
|
+
/** What the platforms play short videos at. */
|
|
6
|
+
export const DEFAULT_LOUDNESS = { target: -14, truePeak: -1 };
|
|
7
|
+
/** Loudness range target in LU (ffmpeg's default); the gain stays linear, so the speech keeps its dynamics. */
|
|
8
|
+
const LOUDNESS_RANGE = 11;
|
|
9
|
+
/** Below this the track is silence: there is nothing to normalize. */
|
|
10
|
+
const SILENCE_LUFS = -70;
|
|
11
|
+
const measurementSchema = z.looseObject({
|
|
12
|
+
input_i: z.string(),
|
|
13
|
+
input_tp: z.string(),
|
|
14
|
+
input_lra: z.string(),
|
|
15
|
+
input_thresh: z.string(),
|
|
16
|
+
target_offset: z.string(),
|
|
17
|
+
});
|
|
18
|
+
function getLoudnormFilter(target) {
|
|
19
|
+
return `loudnorm=I=${target.target}:TP=${target.truePeak}:LRA=${LOUDNESS_RANGE}`;
|
|
20
|
+
}
|
|
21
|
+
/** The first pass: decodes the track, prints the measurement on stderr, writes nothing. */
|
|
22
|
+
export function buildLoudnessMeasureArgs(input, target) {
|
|
23
|
+
return ["-hide_banner", "-nostats", "-i", input, "-af", `${getLoudnormFilter(target)}:print_format=json`, "-f", "null", "-"];
|
|
24
|
+
}
|
|
25
|
+
/** The measurement from the first pass's stderr (its last JSON block); null when there is none or it is incomplete. */
|
|
26
|
+
export function readLoudnessMeasurement(stderr) {
|
|
27
|
+
// The block around the last `"input_i"`, found by position (a regex over ffmpeg's whole stderr could backtrack).
|
|
28
|
+
const key = stderr.lastIndexOf('"input_i"');
|
|
29
|
+
const open = key === -1 ? -1 : stderr.lastIndexOf("{", key);
|
|
30
|
+
const close = key === -1 ? -1 : stderr.indexOf("}", key);
|
|
31
|
+
if (open === -1 || close === -1)
|
|
32
|
+
return null;
|
|
33
|
+
const block = stderr.slice(open, close + 1);
|
|
34
|
+
let json;
|
|
35
|
+
try {
|
|
36
|
+
json = JSON.parse(block);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const parsed = measurementSchema.safeParse(json);
|
|
42
|
+
if (!parsed.success)
|
|
43
|
+
return null;
|
|
44
|
+
const value = parsed.data;
|
|
45
|
+
// `-inf` (silence) reads as -Infinity, which `isSilent` tells apart.
|
|
46
|
+
const read = (text) => (text.trim() === "-inf" ? -Infinity : Number(text));
|
|
47
|
+
const measurement = {
|
|
48
|
+
inputI: read(value.input_i),
|
|
49
|
+
inputTp: read(value.input_tp),
|
|
50
|
+
inputLra: read(value.input_lra),
|
|
51
|
+
inputThresh: read(value.input_thresh),
|
|
52
|
+
targetOffset: read(value.target_offset),
|
|
53
|
+
};
|
|
54
|
+
return Object.values(measurement).some((number) => Number.isNaN(number)) ? null : measurement;
|
|
55
|
+
}
|
|
56
|
+
/** True when the measured track is silence, which no gain can bring to the target. */
|
|
57
|
+
export function isSilent(measurement) {
|
|
58
|
+
return !Number.isFinite(measurement.inputI) || measurement.inputI < SILENCE_LUFS || !Number.isFinite(measurement.inputThresh);
|
|
59
|
+
}
|
|
60
|
+
/** The second pass: one linear gain from the measurement, resampled back to the film's rate (`loudnorm` runs at 192 kHz). */
|
|
61
|
+
export function buildLoudnessArgs(options) {
|
|
62
|
+
const { measurement } = options;
|
|
63
|
+
const filter = [
|
|
64
|
+
getLoudnormFilter(options.target),
|
|
65
|
+
`measured_I=${measurement.inputI}`,
|
|
66
|
+
`measured_TP=${measurement.inputTp}`,
|
|
67
|
+
`measured_LRA=${measurement.inputLra}`,
|
|
68
|
+
`measured_thresh=${measurement.inputThresh}`,
|
|
69
|
+
`offset=${measurement.targetOffset}`,
|
|
70
|
+
"linear=true",
|
|
71
|
+
].join(":");
|
|
72
|
+
return [
|
|
73
|
+
"-v",
|
|
74
|
+
"error",
|
|
75
|
+
"-y",
|
|
76
|
+
"-i",
|
|
77
|
+
options.input,
|
|
78
|
+
"-af",
|
|
79
|
+
`${filter},aresample=${FOOTAGE_SAMPLE_RATE}`,
|
|
80
|
+
"-ar",
|
|
81
|
+
String(FOOTAGE_SAMPLE_RATE),
|
|
82
|
+
"-c:a",
|
|
83
|
+
"libmp3lame",
|
|
84
|
+
"-q:a",
|
|
85
|
+
"2",
|
|
86
|
+
options.output,
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Measures `input` and writes it normalized to `output`; a silent track is copied as it is. Throws naming the step
|
|
91
|
+
* when ffmpeg fails, rejects with the signal's reason on abort.
|
|
92
|
+
*/
|
|
93
|
+
export async function normalizeLoudness(input, output, target, options = {}) {
|
|
94
|
+
const signal = options.signal === undefined ? {} : { signal: options.signal };
|
|
95
|
+
const measured = await runProcess({ command: "ffmpeg", args: buildLoudnessMeasureArgs(input, target), ...signal });
|
|
96
|
+
if (measured.kind === "not-started")
|
|
97
|
+
throw new Error(`Measuring the speech track's loudness: ffmpeg did not start (${measured.error}).`);
|
|
98
|
+
if (measured.code !== 0)
|
|
99
|
+
throw new Error(`Measuring the speech track's loudness: ffmpeg ended with code ${String(measured.code)}: ${measured.stderr.trim().split("\n").slice(-3).join(" | ")}.`);
|
|
100
|
+
const measurement = readLoudnessMeasurement(measured.stderr);
|
|
101
|
+
if (measurement === null)
|
|
102
|
+
throw new Error(`Measuring the speech track's loudness: ffmpeg printed no loudnorm measurement for ${input}.`);
|
|
103
|
+
if (isSilent(measurement)) {
|
|
104
|
+
copyFileSync(input, output);
|
|
105
|
+
return { kind: "silent" };
|
|
106
|
+
}
|
|
107
|
+
await runFfmpeg("Normalizing the speech track's loudness", buildLoudnessArgs({ input, measurement, target, output }), {
|
|
108
|
+
...signal,
|
|
109
|
+
output,
|
|
110
|
+
...(options.onSeconds === undefined ? {} : { onSeconds: options.onSeconds }),
|
|
111
|
+
});
|
|
112
|
+
return { kind: "normalized", measured: measurement.inputI };
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=loudness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loudness.js","sourceR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AC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE;QACpH,GAAG,MAAM;QACT,MAAM;QACN,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;KAC7E,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClipFit, FootageClip } from "./film.js";
|
|
2
2
|
import { type FootageProbe, type HdrKind } from "./probe.js";
|
|
3
|
+
import { type FfmpegRunOptions } from "./process.js";
|
|
3
4
|
/**
|
|
4
5
|
* One intermediate format for every clip, so the composition can cut between them freely: the film's frame at
|
|
5
6
|
* 30 fps, upright (ffmpeg applies the stored rotation while decoding), SDR BT.709 (HDR tone-mapped), filled by a crop
|
|
@@ -36,6 +37,9 @@ export interface NormalizeInput {
|
|
|
36
37
|
}
|
|
37
38
|
/** ffmpeg's arguments for one clip; pure, so the graph is tested without ffmpeg. */
|
|
38
39
|
export declare function buildNormalizeArgs(input: NormalizeInput): string[];
|
|
39
|
-
/**
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Runs ffmpeg for one clip without blocking; throws with the clip's id when it fails (a broken file is not an expected
|
|
42
|
+
* outcome here). An abort removes the partial output and rejects with the signal's reason.
|
|
43
|
+
*/
|
|
44
|
+
export declare function normalizeFootage(input: NormalizeInput, options?: Omit<FfmpegRunOptions, "output">): Promise<void>;
|
|
41
45
|
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/footage/normalize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot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,EAAE,CAgDlE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3H"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
1
|
import { getTrimmedDuration } from "./probe.js";
|
|
2
|
+
import { runFfmpeg } from "./process.js";
|
|
3
3
|
/**
|
|
4
4
|
* One intermediate format for every clip, so the composition can cut between them freely: the film's frame at
|
|
5
5
|
* 30 fps, upright (ffmpeg applies the stored rotation while decoding), SDR BT.709 (HDR tone-mapped), filled by a crop
|
|
@@ -102,13 +102,11 @@ export function buildNormalizeArgs(input) {
|
|
|
102
102
|
output,
|
|
103
103
|
];
|
|
104
104
|
}
|
|
105
|
-
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
throw new Error(`Normalizing clip ${input.clip.id} (${input.file}): ffmpeg ended with code ${String(result.status)} (signal ${result.signal ?? "-"}).`);
|
|
112
|
-
}
|
|
105
|
+
/**
|
|
106
|
+
* Runs ffmpeg for one clip without blocking; throws with the clip's id when it fails (a broken file is not an expected
|
|
107
|
+
* outcome here). An abort removes the partial output and rejects with the signal's reason.
|
|
108
|
+
*/
|
|
109
|
+
export async function normalizeFootage(input, options = {}) {
|
|
110
|
+
await runFfmpeg(`Normalizing clip ${input.clip.id} (${input.file})`, buildNormalizeArgs(input), { ...options, output: input.output });
|
|
113
111
|
}
|
|
114
112
|
//# sourceMappingURL=normalize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/footage/normalize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/footage/normalize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAk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AC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,IAAI,GAAG,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;AACxI,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type TtsResult } from "../voice/provider.js";
|
|
2
|
+
import { type Edl } from "./edl.js";
|
|
3
|
+
import type { FootageClip, FootageFilm } from "./film.js";
|
|
4
|
+
import type { FootageProviders, FootageRates, PaidStepKind } from "./providers.js";
|
|
5
|
+
/**
|
|
6
|
+
* Where each paid result of a footage film is cached, shared by the pipeline and by the questions an app asks before
|
|
7
|
+
* a run: is this step cached (`findCachedStep`), and what will the film cost (`estimateFootageFilm`). Neither question
|
|
8
|
+
* normalizes a clip or calls a provider.
|
|
9
|
+
*/
|
|
10
|
+
export interface FootageCacheOptions {
|
|
11
|
+
/** The paid cache's root; files are in `<cacheDir>/<film id>/`. */
|
|
12
|
+
cacheDir: string;
|
|
13
|
+
providers: FootageProviders;
|
|
14
|
+
/** The film's build folder: downloaded URL clips (`sources/`) and the cut (`edl.json`) are looked up there. */
|
|
15
|
+
buildDir?: string;
|
|
16
|
+
/** The cut, when the caller holds it; otherwise `<buildDir>/edl.json` is read. Video-scored music depends on it. */
|
|
17
|
+
edl?: Edl;
|
|
18
|
+
}
|
|
19
|
+
export interface CacheEntry {
|
|
20
|
+
key: string;
|
|
21
|
+
path: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const isUrl: (source: string) => boolean;
|
|
24
|
+
export declare function getEdlPath(buildDir: string, isPlaceholder: boolean): string;
|
|
25
|
+
/** Where a URL clip is downloaded to inside `dir` (`<buildDir>/sources`). */
|
|
26
|
+
export declare function getDownloadPath(url: string, dir: string): string;
|
|
27
|
+
/** The clip's local file: the file itself, or a URL's downloaded copy in the build folder; null when there is none yet. */
|
|
28
|
+
export declare function findLocalSource(clip: Pick<FootageClip, "source">, buildDir: string | undefined): string | null;
|
|
29
|
+
/** The cache identity of a clip's source part: its bytes and its trim. */
|
|
30
|
+
export declare function getClipCacheKey(source: string, clip: Pick<FootageClip, "trim">): Promise<string>;
|
|
31
|
+
/** The cleaned voice of a clip; null when the film does not isolate the voice. */
|
|
32
|
+
export declare function getIsolatedCache(film: FootageFilm, clipKey: string, options: Pick<FootageCacheOptions, "cacheDir" | "providers">): CacheEntry | null;
|
|
33
|
+
export declare function getTranscriptCache(film: FootageFilm, clipKey: string, options: Pick<FootageCacheOptions, "cacheDir" | "providers">): CacheEntry;
|
|
34
|
+
/** Music generated from the film's prompt: keyed by the prompt, so a re-cut never pays again. */
|
|
35
|
+
export declare function getPromptMusicCache(film: FootageFilm, options: Pick<FootageCacheOptions, "cacheDir" | "providers">): CacheEntry;
|
|
36
|
+
/** Music scored to the cut: keyed by the cut and the clips' bytes. `clipKeys` maps every clip id to its cache key. */
|
|
37
|
+
export declare function getVideoMusicCache(film: FootageFilm, edl: Edl, clipKeys: Record<string, string>, options: Pick<FootageCacheOptions, "cacheDir" | "providers">): CacheEntry;
|
|
38
|
+
/**
|
|
39
|
+
* Whether a paid step costs nothing now because its result is in the cache, without network or ffmpeg. `item` is a
|
|
40
|
+
* clip id (`transcribe`, `isolate`) or `film` (`music`). An unknown clip, a step the film does not take (isolation
|
|
41
|
+
* when it keeps the raw voice), a URL clip not downloaded yet and video-scored music without a cut answer false.
|
|
42
|
+
*/
|
|
43
|
+
export declare function findCachedStep(film: FootageFilm, step: PaidStepKind, item: string, options: FootageCacheOptions): Promise<boolean>;
|
|
44
|
+
export interface FootageEstimateItem {
|
|
45
|
+
step: PaidStepKind;
|
|
46
|
+
/** A clip id, or `film` for the music. */
|
|
47
|
+
item: string;
|
|
48
|
+
provider: string;
|
|
49
|
+
units: number;
|
|
50
|
+
unit: "seconds";
|
|
51
|
+
/** `units` × the step's rate; 0 when cached. */
|
|
52
|
+
credits: number;
|
|
53
|
+
cached: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface FootageEstimate {
|
|
56
|
+
items: FootageEstimateItem[];
|
|
57
|
+
totalCredits: number;
|
|
58
|
+
}
|
|
59
|
+
export interface EstimateFootageOptions extends FootageCacheOptions {
|
|
60
|
+
rates: FootageRates;
|
|
61
|
+
signal?: AbortSignal;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* What a footage film will cost in the caller's credits, before anything runs: every clip probed (a URL clip not yet
|
|
65
|
+
* downloaded is probed at its URL), nothing normalized, no provider called. Talking clips need speech to text (and
|
|
66
|
+
* isolation when the film cleans the voice); generated music lasts the cut's length when the cut is known, else the
|
|
67
|
+
* clips' length plus the end card. A cached step costs 0.
|
|
68
|
+
*/
|
|
69
|
+
export declare function estimateFootageFilm(film: FootageFilm, options: EstimateFootageOptions): Promise<TtsResult<FootageEstimate>>;
|
|
70
|
+
//# sourceMappingURL=paid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paid.d.ts","sourceRoot":"","sources":["../../src/footage/paid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnF;;;;GAIG;AAEH,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,+GAA+G;IAC/G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oHAAoH;IACpH,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,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