@softure-ai/marketing-kit 0.2.0 → 0.3.1
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 +20 -0
- package/README.md +108 -3
- package/dist/cli/footage.d.ts +6 -0
- package/dist/cli/footage.d.ts.map +1 -0
- package/dist/cli/footage.js +95 -0
- package/dist/cli/footage.js.map +1 -0
- package/dist/cli/main.js +18 -1
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/options.d.ts +18 -3
- package/dist/cli/options.d.ts.map +1 -1
- package/dist/cli/options.js +41 -2
- package/dist/cli/options.js.map +1 -1
- package/dist/compose/compose.d.ts.map +1 -1
- package/dist/compose/compose.js +1 -22
- package/dist/compose/compose.js.map +1 -1
- package/dist/compose/html.d.ts +6 -0
- package/dist/compose/html.d.ts.map +1 -0
- package/dist/compose/html.js +24 -0
- package/dist/compose/html.js.map +1 -0
- package/dist/config/actions-schema.d.ts +14 -14
- package/dist/config/config.d.ts +16 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +88 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/schema.d.ts +133 -70
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +110 -3
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shot-steps.d.ts +16 -16
- package/dist/footage/cache.d.ts +23 -0
- package/dist/footage/cache.d.ts.map +1 -0
- package/dist/footage/cache.js +51 -0
- package/dist/footage/cache.js.map +1 -0
- package/dist/footage/compose.d.ts +50 -0
- package/dist/footage/compose.d.ts.map +1 -0
- package/dist/footage/compose.js +166 -0
- package/dist/footage/compose.js.map +1 -0
- package/dist/footage/edl.d.ts +83 -0
- package/dist/footage/edl.d.ts.map +1 -0
- package/dist/footage/edl.js +166 -0
- package/dist/footage/edl.js.map +1 -0
- package/dist/footage/elevenlabs.d.ts +31 -0
- package/dist/footage/elevenlabs.d.ts.map +1 -0
- package/dist/footage/elevenlabs.js +140 -0
- package/dist/footage/elevenlabs.js.map +1 -0
- package/dist/footage/fake.d.ts +38 -0
- package/dist/footage/fake.d.ts.map +1 -0
- package/dist/footage/fake.js +66 -0
- package/dist/footage/fake.js.map +1 -0
- package/dist/footage/film.d.ts +103 -0
- package/dist/footage/film.d.ts.map +1 -0
- package/dist/footage/film.js +29 -0
- package/dist/footage/film.js.map +1 -0
- package/dist/footage/music.d.ts +37 -0
- package/dist/footage/music.d.ts.map +1 -0
- package/dist/footage/music.js +63 -0
- package/dist/footage/music.js.map +1 -0
- package/dist/footage/normalize.d.ts +41 -0
- package/dist/footage/normalize.d.ts.map +1 -0
- package/dist/footage/normalize.js +114 -0
- package/dist/footage/normalize.js.map +1 -0
- package/dist/footage/pipeline.d.ts +105 -0
- package/dist/footage/pipeline.d.ts.map +1 -0
- package/dist/footage/pipeline.js +385 -0
- package/dist/footage/pipeline.js.map +1 -0
- package/dist/footage/probe.d.ts +64 -0
- package/dist/footage/probe.d.ts.map +1 -0
- package/dist/footage/probe.js +138 -0
- package/dist/footage/probe.js.map +1 -0
- package/dist/footage/providers.d.ts +61 -0
- package/dist/footage/providers.d.ts.map +1 -0
- package/dist/footage/providers.js +13 -0
- package/dist/footage/providers.js.map +1 -0
- package/dist/footage/render.d.ts +20 -0
- package/dist/footage/render.d.ts.map +1 -0
- package/dist/footage/render.js +76 -0
- package/dist/footage/render.js.map +1 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/render/render.d.ts +6 -0
- package/dist/render/render.d.ts.map +1 -1
- package/dist/render/render.js +1 -1
- package/dist/render/render.js.map +1 -1
- package/package.json +1 -1
- package/schema/marketing.schema.json +254 -2
- package/src/cli/footage.ts +87 -0
- package/src/cli/main.ts +17 -1
- package/src/cli/options.ts +51 -4
- package/src/compose/compose.ts +1 -25
- package/src/compose/html.ts +28 -0
- package/src/config/config.ts +97 -0
- package/src/config/schema.ts +114 -4
- package/src/footage/cache.ts +66 -0
- package/src/footage/compose.ts +213 -0
- package/src/footage/edl.ts +204 -0
- package/src/footage/elevenlabs.ts +154 -0
- package/src/footage/fake.ts +92 -0
- package/src/footage/film.ts +111 -0
- package/src/footage/music.ts +86 -0
- package/src/footage/normalize.ts +133 -0
- package/src/footage/pipeline.ts +447 -0
- package/src/footage/probe.ts +172 -0
- package/src/footage/providers.ts +71 -0
- package/src/footage/render.ts +82 -0
- package/src/index.ts +109 -1
- package/src/render/render.ts +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { ELEVENLABS_API_KEY_ENV } from "../voice/elevenlabs.js";
|
|
5
|
+
import { err, ok } from "../voice/provider.js";
|
|
6
|
+
import { ELEVENLABS_API_URL } from "../voice/voiceover.js";
|
|
7
|
+
/**
|
|
8
|
+
* ElevenLabs behind the footage providers (API reference checked 2026-10-29): Scribe speech to text
|
|
9
|
+
* (`/v1/speech-to-text`, word timestamps), Voice Isolator (`/v1/audio-isolation`), Music (`/v1/music`) and Video to
|
|
10
|
+
* Music (`/v1/music/video-to-music`). Each takes an injected `fetch`, so tests reach no network.
|
|
11
|
+
*/
|
|
12
|
+
export const ELEVENLABS_STT_MODEL = "scribe_v2";
|
|
13
|
+
export const ELEVENLABS_MUSIC_MODEL = "music_v1";
|
|
14
|
+
const ERROR_DETAIL_LENGTH = 300;
|
|
15
|
+
/** ElevenLabs Music takes 3 s to 10 min. */
|
|
16
|
+
const MUSIC_MIN_MS = 3000;
|
|
17
|
+
const MUSIC_MAX_MS = 600_000;
|
|
18
|
+
const scribeSchema = z.looseObject({
|
|
19
|
+
language_code: z.string().optional(),
|
|
20
|
+
words: z.array(z.looseObject({ text: z.string(), start: z.number().nullish(), end: z.number().nullish(), type: z.string().optional() })),
|
|
21
|
+
});
|
|
22
|
+
const round = (value) => Math.round(value * 1000) / 1000 || 0;
|
|
23
|
+
/** Scribe's response read as timed words: entries of type `word` only (no spacing, no sound events). */
|
|
24
|
+
export function readScribeResponse(body, language) {
|
|
25
|
+
const parsed = scribeSchema.safeParse(body);
|
|
26
|
+
if (!parsed.success)
|
|
27
|
+
return err("ElevenLabs speech to text: the response has no words list.");
|
|
28
|
+
const words = [];
|
|
29
|
+
for (const word of parsed.data.words) {
|
|
30
|
+
if ((word.type ?? "word") !== "word")
|
|
31
|
+
continue;
|
|
32
|
+
const text = word.text.trim();
|
|
33
|
+
if (text.length === 0 || word.start == null || word.end == null)
|
|
34
|
+
continue;
|
|
35
|
+
words.push({ text, start: round(word.start), end: round(word.end) });
|
|
36
|
+
}
|
|
37
|
+
return ok({ words, language: parsed.data.language_code ?? language });
|
|
38
|
+
}
|
|
39
|
+
function fileBlob(path) {
|
|
40
|
+
return new Blob([readFileSync(path)]);
|
|
41
|
+
}
|
|
42
|
+
async function send(options, label, path, init) {
|
|
43
|
+
if (options.apiKey === undefined || options.apiKey.length === 0)
|
|
44
|
+
return err(`no ${ELEVENLABS_API_KEY_ENV} in the environment.`);
|
|
45
|
+
const request = options.fetch ?? globalThis.fetch;
|
|
46
|
+
let response;
|
|
47
|
+
try {
|
|
48
|
+
response = await request(`${ELEVENLABS_API_URL}${path}`, { ...init, headers: { ...init.headers, "xi-api-key": options.apiKey } });
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return err(`ElevenLabs ${label}: the connection failed (${String(error)}).`);
|
|
52
|
+
}
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const detail = await response.text().catch((error) => `(unreadable body: ${String(error)})`);
|
|
55
|
+
return err(`ElevenLabs ${label} answered ${response.status}: ${detail.slice(0, ERROR_DETAIL_LENGTH)}`);
|
|
56
|
+
}
|
|
57
|
+
return ok(response);
|
|
58
|
+
}
|
|
59
|
+
async function readAudio(label, response) {
|
|
60
|
+
try {
|
|
61
|
+
const audio = Buffer.from(await response.arrayBuffer());
|
|
62
|
+
return audio.length > 0 ? ok(audio) : err(`ElevenLabs ${label}: the response has no audio.`);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return err(`ElevenLabs ${label}: reading the audio failed (${String(error)}).`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function createElevenLabsSttProvider(options) {
|
|
69
|
+
const model = options.sttModel ?? ELEVENLABS_STT_MODEL;
|
|
70
|
+
return {
|
|
71
|
+
id: "elevenlabs",
|
|
72
|
+
model,
|
|
73
|
+
async transcribe(input) {
|
|
74
|
+
const form = new FormData();
|
|
75
|
+
form.append("model_id", model);
|
|
76
|
+
form.append("file", fileBlob(input.audio), basename(input.audio));
|
|
77
|
+
form.append("language_code", input.language);
|
|
78
|
+
form.append("timestamps_granularity", "word");
|
|
79
|
+
form.append("tag_audio_events", "false");
|
|
80
|
+
const response = await send(options, "speech to text", "/v1/speech-to-text", { method: "POST", body: form });
|
|
81
|
+
if (!response.ok)
|
|
82
|
+
return response;
|
|
83
|
+
let body;
|
|
84
|
+
try {
|
|
85
|
+
body = (await response.value.json());
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
return err(`ElevenLabs speech to text: the response is not JSON (${String(error)}).`);
|
|
89
|
+
}
|
|
90
|
+
return readScribeResponse(body, input.language);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function createElevenLabsIsolationProvider(options) {
|
|
95
|
+
return {
|
|
96
|
+
id: "elevenlabs",
|
|
97
|
+
async isolate(input) {
|
|
98
|
+
const form = new FormData();
|
|
99
|
+
form.append("audio", fileBlob(input.audio), basename(input.audio));
|
|
100
|
+
const response = await send(options, "voice isolation", "/v1/audio-isolation", { method: "POST", body: form });
|
|
101
|
+
return response.ok ? readAudio("voice isolation", response.value) : response;
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** The length ElevenLabs Music is asked for: the film's, within the service's 3 s to 10 min. */
|
|
106
|
+
export function getMusicLengthMs(seconds) {
|
|
107
|
+
return Math.min(MUSIC_MAX_MS, Math.max(MUSIC_MIN_MS, Math.ceil(seconds * 1000)));
|
|
108
|
+
}
|
|
109
|
+
export function createElevenLabsMusicProvider(options) {
|
|
110
|
+
const model = options.musicModel ?? ELEVENLABS_MUSIC_MODEL;
|
|
111
|
+
return {
|
|
112
|
+
id: "elevenlabs",
|
|
113
|
+
model,
|
|
114
|
+
async compose(input) {
|
|
115
|
+
const body = { prompt: input.prompt, music_length_ms: getMusicLengthMs(input.seconds), model_id: model, force_instrumental: true };
|
|
116
|
+
const response = await send(options, "music", "/v1/music?output_format=mp3_44100_128", {
|
|
117
|
+
method: "POST",
|
|
118
|
+
headers: { "Content-Type": "application/json" },
|
|
119
|
+
body: JSON.stringify(body),
|
|
120
|
+
});
|
|
121
|
+
return response.ok ? readAudio("music", response.value) : response;
|
|
122
|
+
},
|
|
123
|
+
async scoreVideo(input) {
|
|
124
|
+
const form = new FormData();
|
|
125
|
+
form.append("videos", fileBlob(input.video), basename(input.video));
|
|
126
|
+
if (input.description.length > 0)
|
|
127
|
+
form.append("description", input.description);
|
|
128
|
+
for (const tag of input.tags)
|
|
129
|
+
form.append("tags", tag);
|
|
130
|
+
const response = await send(options, "video to music", "/v1/music/video-to-music?output_format=mp3_44100_128", { method: "POST", body: form });
|
|
131
|
+
return response.ok ? readAudio("video to music", response.value) : response;
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** The ElevenLabs footage providers with the key from the environment (read, never logged). */
|
|
136
|
+
export function createElevenLabsFootageProviders(env, fetch) {
|
|
137
|
+
const options = { apiKey: env[ELEVENLABS_API_KEY_ENV], ...(fetch === undefined ? {} : { fetch }) };
|
|
138
|
+
return { stt: createElevenLabsSttProvider(options), isolation: createElevenLabsIsolationProvider(options), music: createElevenLabsMusicProvider(options) };
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=elevenlabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,KAA+B;IACvH,MAAM,OAAO,GAA6B,EAAE,MAAM,EAAE,GAAG,CAAC,sBAAsB,CAAC,EAAE,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC7H,OAAO,EAAE,GAAG,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,iCAAiC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,6BAA6B,CAAC,OAAO,CAAC,EAAE,CAAC;AAC7J,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TimedWord } from "../voice/voiceover.js";
|
|
2
|
+
import type { IsolationProvider, MusicProvider, SttInput, SttProvider } from "./providers.js";
|
|
3
|
+
/** Providers that spend nothing and reach no network, for tests of the footage pipeline and of a project's own flows. */
|
|
4
|
+
export interface FakeSttOptions {
|
|
5
|
+
/** Words per audio file, by the file's name up to its first dot (the pipeline names a clip's audio `<clip id>.*`). */
|
|
6
|
+
transcripts?: Record<string, TimedWord[]>;
|
|
7
|
+
/** Makes every call fail with this message. */
|
|
8
|
+
failWith?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface FakeSttProvider extends SttProvider {
|
|
11
|
+
readonly calls: SttInput[];
|
|
12
|
+
}
|
|
13
|
+
export declare function createFakeSttProvider(options?: FakeSttOptions): FakeSttProvider;
|
|
14
|
+
export interface FakeIsolationProvider extends IsolationProvider {
|
|
15
|
+
readonly calls: string[];
|
|
16
|
+
}
|
|
17
|
+
/** Returns the input file's bytes unchanged: a valid audio file, so a pipeline with it still renders. */
|
|
18
|
+
export declare function createFakeIsolationProvider(): FakeIsolationProvider;
|
|
19
|
+
export interface FakeMusicProvider extends MusicProvider {
|
|
20
|
+
readonly calls: ({
|
|
21
|
+
kind: "compose";
|
|
22
|
+
prompt: string;
|
|
23
|
+
seconds: number;
|
|
24
|
+
} | {
|
|
25
|
+
kind: "video";
|
|
26
|
+
video: string;
|
|
27
|
+
description: string;
|
|
28
|
+
tags: string[];
|
|
29
|
+
})[];
|
|
30
|
+
}
|
|
31
|
+
/** Returns `audio` (by default a few bytes that are not audio: enough for tests that never decode it). */
|
|
32
|
+
export declare function createFakeMusicProvider(audio?: Buffer): FakeMusicProvider;
|
|
33
|
+
/**
|
|
34
|
+
* The free stand-in transcript of `--placeholder`: the script's words spread evenly over the clip, each lasting 80 %
|
|
35
|
+
* of its slot. No script, no words: the clip is kept whole.
|
|
36
|
+
*/
|
|
37
|
+
export declare function makePlaceholderTranscript(script: string | null, duration: number): TimedWord[];
|
|
38
|
+
//# sourceMappingURL=fake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake.d.ts","sourceRoot":"","sources":["../../src/footage/fake.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAiB,MAAM,gBAAgB,CAAC;AAE7G,yHAAyH;AAEzH,MAAM,WAAW,cAAc;IAC7B,sHAAsH;IACtH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1C,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;CAC5B;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,cAAmB,GAAG,eAAe,CAanF;AAED,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,yGAAyG;AACzG,wBAAgB,2BAA2B,IAAI,qBAAqB,CAUnE;AAED,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,QAAQ,CAAC,KAAK,EAAE,CAAC;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,EAAE,CAAC;CAClJ;AAED,0GAA0G;AAC1G,wBAAgB,uBAAuB,CAAC,KAAK,GAAE,MAAkC,GAAG,iBAAiB,CAepG;AAMD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAS9F"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { ok } from "../voice/provider.js";
|
|
4
|
+
export function createFakeSttProvider(options = {}) {
|
|
5
|
+
const calls = [];
|
|
6
|
+
return {
|
|
7
|
+
id: "fake",
|
|
8
|
+
model: "fake-stt",
|
|
9
|
+
calls,
|
|
10
|
+
transcribe(input) {
|
|
11
|
+
calls.push(input);
|
|
12
|
+
if (options.failWith !== undefined)
|
|
13
|
+
return Promise.resolve({ ok: false, error: options.failWith });
|
|
14
|
+
const name = basename(input.audio).split(".")[0] ?? "";
|
|
15
|
+
return Promise.resolve(ok({ words: options.transcripts?.[name] ?? [], language: input.language }));
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Returns the input file's bytes unchanged: a valid audio file, so a pipeline with it still renders. */
|
|
20
|
+
export function createFakeIsolationProvider() {
|
|
21
|
+
const calls = [];
|
|
22
|
+
return {
|
|
23
|
+
id: "fake",
|
|
24
|
+
calls,
|
|
25
|
+
isolate(input) {
|
|
26
|
+
calls.push(input.audio);
|
|
27
|
+
return Promise.resolve(ok(readFileSync(input.audio)));
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Returns `audio` (by default a few bytes that are not audio: enough for tests that never decode it). */
|
|
32
|
+
export function createFakeMusicProvider(audio = Buffer.from("fake music")) {
|
|
33
|
+
const calls = [];
|
|
34
|
+
return {
|
|
35
|
+
id: "fake",
|
|
36
|
+
model: "fake-music",
|
|
37
|
+
calls,
|
|
38
|
+
compose(input) {
|
|
39
|
+
calls.push({ kind: "compose", ...input });
|
|
40
|
+
return Promise.resolve(ok(audio));
|
|
41
|
+
},
|
|
42
|
+
scoreVideo(input) {
|
|
43
|
+
calls.push({ kind: "video", ...input });
|
|
44
|
+
return Promise.resolve(ok(audio));
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const round = (value) => Math.round(value * 1000) / 1000 || 0;
|
|
49
|
+
/** Silence kept before the first and after the last placeholder word. */
|
|
50
|
+
const PLACEHOLDER_MARGIN = 0.3;
|
|
51
|
+
/**
|
|
52
|
+
* The free stand-in transcript of `--placeholder`: the script's words spread evenly over the clip, each lasting 80 %
|
|
53
|
+
* of its slot. No script, no words: the clip is kept whole.
|
|
54
|
+
*/
|
|
55
|
+
export function makePlaceholderTranscript(script, duration) {
|
|
56
|
+
const texts = (script ?? "").trim().split(/\s+/).filter((text) => text.length > 0);
|
|
57
|
+
const span = duration - 2 * PLACEHOLDER_MARGIN;
|
|
58
|
+
if (texts.length === 0 || span <= 0)
|
|
59
|
+
return [];
|
|
60
|
+
const slot = span / texts.length;
|
|
61
|
+
return texts.map((text, index) => {
|
|
62
|
+
const start = PLACEHOLDER_MARGIN + index * slot;
|
|
63
|
+
return { text, start: round(start), end: round(start + slot * 0.8) };
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=fake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake.js","sourceRoot":"","sources":["../../src/footage/fake.ts"],"names":[],"m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,GAAG,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;IACjC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/B,MAAM,KAAK,GAAG,kBAAkB,GAAG,KAAK,GAAG,IAAI,CAAC;QAChD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { VideoFormat } from "../compose/timeline.js";
|
|
2
|
+
import type { EndCard } from "../film.js";
|
|
3
|
+
/**
|
|
4
|
+
* A footage film: filmed clips (a person talking to camera, b-roll) cut by their transcript into a captioned
|
|
5
|
+
* vertical film. Built from `marketing.json` (`footage[]`) or passed to `renderFootageFilm` as it is.
|
|
6
|
+
*/
|
|
7
|
+
/** `talk`: someone speaks, so the cut follows the words. `broll`: pictures without speech, kept whole with a slow zoom. */
|
|
8
|
+
export declare const CLIP_ROLES: readonly ["talk", "broll"];
|
|
9
|
+
export type ClipRole = (typeof CLIP_ROLES)[number];
|
|
10
|
+
/**
|
|
11
|
+
* How a clip whose aspect differs from the film's fills the frame: `crop` (scaled to cover, edges cut), `blur` (the
|
|
12
|
+
* whole picture over a blurred, enlarged copy of itself) or `auto` (crop when the aspects are within 15 %, else blur).
|
|
13
|
+
*/
|
|
14
|
+
export declare const CLIP_FITS: readonly ["auto", "crop", "blur"];
|
|
15
|
+
export type ClipFit = (typeof CLIP_FITS)[number];
|
|
16
|
+
/**
|
|
17
|
+
* How a segment of the cut starts: `cut` (hard), `fade` (a short cross-fade from the previous segment), `zoom` (a
|
|
18
|
+
* punch-in that hides a jump cut inside one talking clip) or `whoosh` (a hard cut with the whoosh sound).
|
|
19
|
+
*/
|
|
20
|
+
export declare const CUT_TRANSITIONS: readonly ["cut", "fade", "zoom", "whoosh"];
|
|
21
|
+
export type CutTransition = (typeof CUT_TRANSITIONS)[number];
|
|
22
|
+
export interface FootageClip {
|
|
23
|
+
/** Unique within the film; the EDL refers to the clip by it. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** A local file (absolute path) or an `https://` URL, downloaded once into the build folder. */
|
|
26
|
+
source: string;
|
|
27
|
+
role: ClipRole;
|
|
28
|
+
fit: ClipFit;
|
|
29
|
+
/** The part of the source the film uses, in seconds; `end: null` is the source's end. */
|
|
30
|
+
trim: {
|
|
31
|
+
start: number;
|
|
32
|
+
end: number | null;
|
|
33
|
+
};
|
|
34
|
+
/** What the clip says, for `--placeholder` only: spread evenly over the clip as a free stand-in transcript. */
|
|
35
|
+
script: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** Where the music under the film comes from. `prompt` and `video` are paid (ElevenLabs Music, Video to Music). */
|
|
38
|
+
export type MusicSource = {
|
|
39
|
+
kind: "none";
|
|
40
|
+
} | {
|
|
41
|
+
kind: "file";
|
|
42
|
+
path: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "prompt";
|
|
45
|
+
prompt: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "video";
|
|
48
|
+
description: string;
|
|
49
|
+
tags: string[];
|
|
50
|
+
};
|
|
51
|
+
export interface FootageMusic {
|
|
52
|
+
source: MusicSource;
|
|
53
|
+
/** The music's volume while nobody speaks (0-1). */
|
|
54
|
+
volume: number;
|
|
55
|
+
/** The music's volume under speech (0-1). */
|
|
56
|
+
duckedVolume: number;
|
|
57
|
+
}
|
|
58
|
+
/** How the transcript turns into the cut (`buildEdl`). */
|
|
59
|
+
export interface CutOptions {
|
|
60
|
+
/** Words cut out wherever they stand, compared without case, punctuation and repeated letters. */
|
|
61
|
+
fillers: string[];
|
|
62
|
+
/** A silence between two words longer than this is cut (seconds). */
|
|
63
|
+
pauseSeconds: number;
|
|
64
|
+
/** Seconds kept before the first and after the last word of every kept run. */
|
|
65
|
+
padSeconds: number;
|
|
66
|
+
/** The cut's longest length in seconds; later segments are shortened or dropped. Null: no limit. */
|
|
67
|
+
maxSeconds: number | null;
|
|
68
|
+
}
|
|
69
|
+
/** Default transitions by kind of cut; a segment of the EDL may name its own. */
|
|
70
|
+
export interface FootageTransitions {
|
|
71
|
+
/** A cut inside one talking clip (a removed filler or pause). */
|
|
72
|
+
jump: CutTransition;
|
|
73
|
+
/** A cut from one clip to another. */
|
|
74
|
+
clip: CutTransition;
|
|
75
|
+
}
|
|
76
|
+
export interface FootageFilm {
|
|
77
|
+
id: string;
|
|
78
|
+
title: string;
|
|
79
|
+
format: VideoFormat;
|
|
80
|
+
/** ISO 639 code the clips speak (`pl`, `en`): the transcript's language and the default fillers. */
|
|
81
|
+
language: string;
|
|
82
|
+
clips: FootageClip[];
|
|
83
|
+
/** Clean the talking clips' voice (ElevenLabs Voice Isolator, paid) before transcribing them. */
|
|
84
|
+
isolateVoice: boolean;
|
|
85
|
+
cut: CutOptions;
|
|
86
|
+
transitions: FootageTransitions;
|
|
87
|
+
music: FootageMusic;
|
|
88
|
+
/** Word-by-word captions from the transcript. */
|
|
89
|
+
captions: boolean;
|
|
90
|
+
/** The closing card after the last segment; null: the film ends with its last segment. */
|
|
91
|
+
endCard: EndCard | null;
|
|
92
|
+
}
|
|
93
|
+
/** Filler words per language, written with repeated letters collapsed (`yyy` and `yyyy` are both `y`). */
|
|
94
|
+
export declare const DEFAULT_FILLERS: Record<string, string[]>;
|
|
95
|
+
/** The default fillers of a language; none for a language without a list. */
|
|
96
|
+
export declare function getDefaultFillers(language: string): string[];
|
|
97
|
+
export declare const DEFAULT_CUT: Omit<CutOptions, "fillers">;
|
|
98
|
+
export declare const DEFAULT_TRANSITIONS: FootageTransitions;
|
|
99
|
+
export declare const DEFAULT_MUSIC_VOLUME: {
|
|
100
|
+
readonly volume: 0.35;
|
|
101
|
+
readonly duckedVolume: 0.1;
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=film.d.ts.map
|
|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AE5D;AAED,eAAO,MAAM,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAA6D,CAAC;AAElH,eAAO,MAAM,mBAAmB,EAAE,kBAAmD,CAAC;AAEtF,eAAO,MAAM,oBAAoB;;;CAA+C,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A footage film: filmed clips (a person talking to camera, b-roll) cut by their transcript into a captioned
|
|
3
|
+
* vertical film. Built from `marketing.json` (`footage[]`) or passed to `renderFootageFilm` as it is.
|
|
4
|
+
*/
|
|
5
|
+
/** `talk`: someone speaks, so the cut follows the words. `broll`: pictures without speech, kept whole with a slow zoom. */
|
|
6
|
+
export const CLIP_ROLES = ["talk", "broll"];
|
|
7
|
+
/**
|
|
8
|
+
* How a clip whose aspect differs from the film's fills the frame: `crop` (scaled to cover, edges cut), `blur` (the
|
|
9
|
+
* whole picture over a blurred, enlarged copy of itself) or `auto` (crop when the aspects are within 15 %, else blur).
|
|
10
|
+
*/
|
|
11
|
+
export const CLIP_FITS = ["auto", "crop", "blur"];
|
|
12
|
+
/**
|
|
13
|
+
* How a segment of the cut starts: `cut` (hard), `fade` (a short cross-fade from the previous segment), `zoom` (a
|
|
14
|
+
* punch-in that hides a jump cut inside one talking clip) or `whoosh` (a hard cut with the whoosh sound).
|
|
15
|
+
*/
|
|
16
|
+
export const CUT_TRANSITIONS = ["cut", "fade", "zoom", "whoosh"];
|
|
17
|
+
/** Filler words per language, written with repeated letters collapsed (`yyy` and `yyyy` are both `y`). */
|
|
18
|
+
export const DEFAULT_FILLERS = {
|
|
19
|
+
pl: ["y", "e", "yhm", "yh", "ym", "em", "hm", "mhm", "eh", "uh"],
|
|
20
|
+
en: ["um", "uh", "uhm", "er", "erm", "hm", "mhm", "ah"],
|
|
21
|
+
};
|
|
22
|
+
/** The default fillers of a language; none for a language without a list. */
|
|
23
|
+
export function getDefaultFillers(language) {
|
|
24
|
+
return DEFAULT_FILLERS[language] ?? [];
|
|
25
|
+
}
|
|
26
|
+
export const DEFAULT_CUT = { pauseSeconds: 0.6, padSeconds: 0.12, maxSeconds: null };
|
|
27
|
+
export const DEFAULT_TRANSITIONS = { jump: "zoom", clip: "fade" };
|
|
28
|
+
export const DEFAULT_MUSIC_VOLUME = { volume: 0.35, duckedVolume: 0.1 };
|
|
29
|
+
//# sourceMappingURL=film.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"film.js","sourceRoot":"","sources":["../../src/footage/film.ts"],"names":[],"mappings":"AAGA;;;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;AAsE1E,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,MAAM,CAAC,MAAM,mBAAmB,GAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAEtF,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAW,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TimedWord } from "../voice/voiceover.js";
|
|
2
|
+
/**
|
|
3
|
+
* Music under the voice: loud between sentences, ducked while someone speaks. The envelope is a list of keyframes
|
|
4
|
+
* computed from the film's word times; ffmpeg applies it to the music file (`volumeExpression`), so the composition
|
|
5
|
+
* plays an already ducked track.
|
|
6
|
+
*/
|
|
7
|
+
export interface VolumeKeyframe {
|
|
8
|
+
t: number;
|
|
9
|
+
volume: number;
|
|
10
|
+
}
|
|
11
|
+
export interface DuckingOptions {
|
|
12
|
+
/** The music's volume between sentences and under speech. */
|
|
13
|
+
volume: number;
|
|
14
|
+
duckedVolume: number;
|
|
15
|
+
/** Seconds the music takes to go down before the first word, and to come back after the last. */
|
|
16
|
+
attack?: number;
|
|
17
|
+
release?: number;
|
|
18
|
+
/** Two words closer than this stay one stretch of speech. */
|
|
19
|
+
gap?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Stretches of speech: the words joined when less than `gap` seconds apart. */
|
|
22
|
+
export declare function getSpeechSpans(words: TimedWord[], gap: number): {
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
}[];
|
|
26
|
+
/**
|
|
27
|
+
* The music's volume over time as keyframes (linear between them): `volume`, down to `duckedVolume` by the first word
|
|
28
|
+
* of each stretch of speech, back up `release` seconds after its last word. Stretches too close for the music to
|
|
29
|
+
* come back up merge.
|
|
30
|
+
*/
|
|
31
|
+
export declare function duckingKeyframes(words: TimedWord[], options: DuckingOptions): VolumeKeyframe[];
|
|
32
|
+
/**
|
|
33
|
+
* An expression for ffmpeg's `volume` filter (`eval=frame`, time `t`): the keyframes as a sum of linear pieces, each
|
|
34
|
+
* switched on by its own time window, so a long film needs no nesting.
|
|
35
|
+
*/
|
|
36
|
+
export declare function volumeExpression(keyframes: VolumeKeyframe[]): string;
|
|
37
|
+
//# sourceMappingURL=music.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"music.d.ts","sourceRoot":"","sources":["../../src/footage/music.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAQhG;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE,CAsB9F;AAID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,MAAM,CAapE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const r3 = (value) => Math.round(value * 1000) / 1000 || 0;
|
|
2
|
+
/** Stretches of speech: the words joined when less than `gap` seconds apart. */
|
|
3
|
+
export function getSpeechSpans(words, gap) {
|
|
4
|
+
const spans = [];
|
|
5
|
+
for (const word of [...words].sort((a, b) => a.start - b.start)) {
|
|
6
|
+
const last = spans.at(-1);
|
|
7
|
+
if (last !== undefined && word.start - last.end < gap)
|
|
8
|
+
last.end = Math.max(last.end, word.end);
|
|
9
|
+
else
|
|
10
|
+
spans.push({ start: word.start, end: word.end });
|
|
11
|
+
}
|
|
12
|
+
return spans;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The music's volume over time as keyframes (linear between them): `volume`, down to `duckedVolume` by the first word
|
|
16
|
+
* of each stretch of speech, back up `release` seconds after its last word. Stretches too close for the music to
|
|
17
|
+
* come back up merge.
|
|
18
|
+
*/
|
|
19
|
+
export function duckingKeyframes(words, options) {
|
|
20
|
+
const attack = options.attack ?? 0.25;
|
|
21
|
+
const release = options.release ?? 0.5;
|
|
22
|
+
const spans = getSpeechSpans(words, Math.max(options.gap ?? 0.6, attack + release));
|
|
23
|
+
const keyframes = [];
|
|
24
|
+
const push = (t, volume) => {
|
|
25
|
+
const time = r3(Math.max(0, t));
|
|
26
|
+
const last = keyframes.at(-1);
|
|
27
|
+
if (last !== undefined && time <= last.t) {
|
|
28
|
+
last.volume = volume;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
keyframes.push({ t: time, volume });
|
|
32
|
+
};
|
|
33
|
+
if (spans.length === 0 || (spans[0]?.start ?? 0) - attack > 0)
|
|
34
|
+
push(0, options.volume);
|
|
35
|
+
for (const span of spans) {
|
|
36
|
+
push(span.start - attack, options.volume);
|
|
37
|
+
push(span.start, options.duckedVolume);
|
|
38
|
+
push(span.end, options.duckedVolume);
|
|
39
|
+
push(span.end + release, options.volume);
|
|
40
|
+
}
|
|
41
|
+
return keyframes;
|
|
42
|
+
}
|
|
43
|
+
const n = (value) => String(r3(value));
|
|
44
|
+
/**
|
|
45
|
+
* An expression for ffmpeg's `volume` filter (`eval=frame`, time `t`): the keyframes as a sum of linear pieces, each
|
|
46
|
+
* switched on by its own time window, so a long film needs no nesting.
|
|
47
|
+
*/
|
|
48
|
+
export function volumeExpression(keyframes) {
|
|
49
|
+
const first = keyframes[0];
|
|
50
|
+
const last = keyframes.at(-1);
|
|
51
|
+
if (first === undefined || last === undefined)
|
|
52
|
+
return "1";
|
|
53
|
+
const pieces = [`lt(t,${n(first.t)})*${n(first.volume)}`];
|
|
54
|
+
keyframes.slice(0, -1).forEach((from, index) => {
|
|
55
|
+
const to = keyframes[index + 1];
|
|
56
|
+
const slope = (to.volume - from.volume) / (to.t - from.t);
|
|
57
|
+
const value = slope === 0 ? n(from.volume) : `(${n(from.volume)}+${String(Math.round(slope * 1e6) / 1e6)}*(t-${n(from.t)}))`;
|
|
58
|
+
pieces.push(`gte(t,${n(from.t)})*lt(t,${n(to.t)})*${value}`);
|
|
59
|
+
});
|
|
60
|
+
pieces.push(`gte(t,${n(last.t)})*${n(last.volume)}`);
|
|
61
|
+
return pieces.join("+");
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=music.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"music.js","sourceRoot":"","sources":["../../src/footage/music.ts"],"names":[],"mappings":"AAwBA,MAAM,EAAE,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AAE3E,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAAC,KAAkB,EAAE,GAAW;IAC5D,MAAM,KAAK,GAAqC,EAAE,CAAC;IACnD,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,GA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AG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7H,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ClipFit, FootageClip } from "./film.js";
|
|
2
|
+
import { type FootageProbe, type HdrKind } from "./probe.js";
|
|
3
|
+
/**
|
|
4
|
+
* One intermediate format for every clip, so the composition can cut between them freely: the film's frame at
|
|
5
|
+
* 30 fps, upright (ffmpeg applies the stored rotation while decoding), SDR BT.709 (HDR tone-mapped), filled by a crop
|
|
6
|
+
* or a blurred copy, a keyframe every half second (the renderer seeks into each segment), and 48 kHz stereo AAC
|
|
7
|
+
* (silence when the clip has no sound), so the speech track can be cut from any clip alike.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FOOTAGE_FPS = 30;
|
|
10
|
+
export declare const FOOTAGE_SAMPLE_RATE = 48000;
|
|
11
|
+
export interface Frame {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
/** The fit `auto` resolves to for this picture in this frame. */
|
|
16
|
+
export declare function resolveFit(fit: ClipFit, probe: Pick<FootageProbe, "displayWidth" | "displayHeight">, frame: Frame): "crop" | "blur";
|
|
17
|
+
/**
|
|
18
|
+
* HDR to SDR BT.709 on the CPU: to linear light (zscale), Hable tone curve, back to BT.709. A Dolby Vision phone
|
|
19
|
+
* clip is read through its HLG base layer.
|
|
20
|
+
*/
|
|
21
|
+
export declare function toneMapFilter(hdr: HdrKind | null, transfer: string | null): string[];
|
|
22
|
+
/** The video filter graph from input 0's picture to `[v]`. */
|
|
23
|
+
export declare function buildVideoFilter(options: {
|
|
24
|
+
fit: "crop" | "blur";
|
|
25
|
+
frame: Frame;
|
|
26
|
+
hdr: HdrKind | null;
|
|
27
|
+
transfer: string | null;
|
|
28
|
+
}): string;
|
|
29
|
+
export interface NormalizeInput {
|
|
30
|
+
clip: FootageClip;
|
|
31
|
+
/** The local file (a URL's downloaded copy). */
|
|
32
|
+
file: string;
|
|
33
|
+
probe: FootageProbe;
|
|
34
|
+
frame: Frame;
|
|
35
|
+
output: string;
|
|
36
|
+
}
|
|
37
|
+
/** ffmpeg's arguments for one clip; pure, so the graph is tested without ffmpeg. */
|
|
38
|
+
export declare function buildNormalizeArgs(input: NormalizeInput): string[];
|
|
39
|
+
/** Runs ffmpeg for one clip; throws with the clip's id when it fails (a broken file is not an expected outcome here). */
|
|
40
|
+
export declare function normalizeFootage(input: NormalizeInput): void;
|
|
41
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/footage/normalize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,O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