@softure-ai/marketing-kit 0.9.2 → 0.10.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 +24 -0
- package/dist/config/actions-schema.d.ts +14 -14
- package/dist/config/schema.d.ts +68 -68
- package/dist/config/shot-steps.d.ts +16 -16
- package/dist/footage/draft.d.ts +1 -1
- package/dist/footage/draft.d.ts.map +1 -1
- package/dist/footage/draft.js +7 -3
- package/dist/footage/draft.js.map +1 -1
- package/dist/footage/ffmpeg-command.d.ts +31 -0
- package/dist/footage/ffmpeg-command.d.ts.map +1 -0
- package/dist/footage/ffmpeg-command.js +60 -0
- package/dist/footage/ffmpeg-command.js.map +1 -0
- package/dist/footage/ffmpeg-failure.d.ts +36 -0
- package/dist/footage/ffmpeg-failure.d.ts.map +1 -0
- package/dist/footage/ffmpeg-failure.js +75 -0
- package/dist/footage/ffmpeg-failure.js.map +1 -0
- package/dist/footage/pipeline.d.ts +12 -1
- package/dist/footage/pipeline.d.ts.map +1 -1
- package/dist/footage/pipeline.js +30 -6
- package/dist/footage/pipeline.js.map +1 -1
- package/dist/footage/process.d.ts +19 -1
- package/dist/footage/process.d.ts.map +1 -1
- package/dist/footage/process.js +57 -6
- package/dist/footage/process.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/footage/draft.ts +9 -4
- package/src/footage/ffmpeg-command.ts +78 -0
- package/src/footage/ffmpeg-failure.ts +89 -0
- package/src/footage/pipeline.ts +44 -6
- package/src/footage/process.ts +66 -6
- package/src/index.ts +13 -1
package/dist/index.js
CHANGED
|
@@ -57,7 +57,9 @@ export { chooseFootageDraftFont, readFontFamilyName } from "./footage/draft-font
|
|
|
57
57
|
export { buildPictureConcatArgs, buildPictureList, buildPicturePieceArgs, getPictureFrames, planFootagePicture, } from "./footage/picture.js";
|
|
58
58
|
export { DEFAULT_LOUDNESS, buildLoudnessArgs, buildLoudnessMeasureArgs, getLoudnessFilter, isSilent, measureLoudness, normalizeLoudness, readLoudnessMeasurement, } from "./footage/loudness.js";
|
|
59
59
|
export { buildCoverArgs, buildFinishArgs, clampCoverSeconds, findFinishProblems, getCoverPath, getDefaultCoverSeconds, isFastStart, isPublishableAudio, isPublishableVideo, PUBLISHABLE_H264_PROFILES, probeFilmFacts, readFilmFacts, readTopLevelBoxes, } from "./footage/publish.js";
|
|
60
|
-
export { readFfmpegProgressSeconds, runFfmpeg, runProcess } from "./footage/process.js";
|
|
60
|
+
export { readFfmpegProgressSeconds, runFfmpeg, runProcess, withFfmpegFailureReporting, } from "./footage/process.js";
|
|
61
|
+
export { FFMPEG_FAILURE_STDERR_LINES, formatFfmpegCommand, splitFilterGraph } from "./footage/ffmpeg-command.js";
|
|
62
|
+
export { buildFfmpegFailureScript, FFMPEG_FAILURE_FILES, writeFfmpegFailure } from "./footage/ffmpeg-failure.js";
|
|
61
63
|
export { estimateFootageFilm, findCachedStep, getDownloadPath, } from "./footage/paid.js";
|
|
62
64
|
export { RENDER_MIN_FREE_BYTES, findLowDiskProblems, getFreeBytes, getRenderTempDir } from "./footage/disk.js";
|
|
63
65
|
export { DRAFT_FILTERS, REQUIRED_DECODERS, REQUIRED_FILTERS, checkFootageTools, findBrowserProblem, readFfmpegListing } from "./footage/tools.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,oGAAoG;AACpG,uGAAuG;AACvG,wGAAwG;AACxG,wHAAwH;AACxH,wEAAwE;AACxE,qEAAqE;AACrE,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,eAAe,GAKhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,YAAY,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AAC9B,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,gBAAgB,EAAsB,MAAM,6BAA6B,CAAC;AACrI,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,kBAAkB,EAA2B,MAAM,6BAA6B,CAAC;AAC1I,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,eAAe,GAKhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,YAAY,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AACrI,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAA4B,MAAM,oBAAoB,CAAC;AAC5K,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAYlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,iBAAiB,GAGlB,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/marketing-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "SOFTURE AI marketing kit: a CLI that turns a project's real app into a vertical film (cached voiceover, frame-by-frame recording, HTML composition, hyperframes render) plus per-platform post copy and OG images.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/footage/draft.ts
CHANGED
|
@@ -13,8 +13,8 @@ import { getEdlDuration, getSegmentStarts, remapWords, type Edl } from "./edl.js
|
|
|
13
13
|
import { getFootageEdit, type FootageFilm } from "./film.js";
|
|
14
14
|
import { duckingKeyframes, getDuckingOptions } from "./music.js";
|
|
15
15
|
import { FOOTAGE_FPS, getThreadArgs, type Frame } from "./normalize.js";
|
|
16
|
-
import { findFootageMusic, getFrame, type FootageBrand, type FootageResult, type FootageRunOptions, type PreparedClip, type TranscribeOutcome } from "./pipeline.js";
|
|
17
|
-
import { runFfmpeg } from "./process.js";
|
|
16
|
+
import { findFootageMusic, getFfmpegReporting, getFrame, type FootageBrand, type FootageResult, type FootageRunOptions, type PreparedClip, type TranscribeOutcome } from "./pipeline.js";
|
|
17
|
+
import { runFfmpeg, withFfmpegFailureReporting } from "./process.js";
|
|
18
18
|
import { buildMusicArgs, buildSpeechArgs, getSpeechCutOptions } from "./render.js";
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -394,7 +394,7 @@ export function buildFootageDraftArgs(input: FootageDraftArgsInput): string[] {
|
|
|
394
394
|
];
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
export interface RenderFootageDraftOptions extends Pick<FootageRunOptions, "buildDir" | "log" | "signal" | "onProgress">, Partial<Pick<FootageRunOptions, "cacheDir" | "providers">> {
|
|
397
|
+
export interface RenderFootageDraftOptions extends Pick<FootageRunOptions, "buildDir" | "log" | "signal" | "onProgress" | "onFfmpegFailure">, Partial<Pick<FootageRunOptions, "cacheDir" | "providers">> {
|
|
398
398
|
/** The draft MP4. */
|
|
399
399
|
output: string;
|
|
400
400
|
/** The draft's width; default 540 (540×960 for a 9:16 film). */
|
|
@@ -458,7 +458,12 @@ async function findDraftMusic(film: FootageFilm, edl: Edl, clips: PreparedClip[]
|
|
|
458
458
|
* and its font in `<buildDir>/draft/`, then one ffmpeg run (`buildFootageDraftArgs`). Spends nothing: no provider is
|
|
459
459
|
* called; takes the same clips, transcript and EDL as `renderFootage`.
|
|
460
460
|
*/
|
|
461
|
-
export
|
|
461
|
+
export function renderFootageDraft(film: FootageFilm, clips: PreparedClip[], transcript: Extract<TranscribeOutcome, { kind: "ready" }>, edl: Edl, options: RenderFootageDraftOptions): Promise<FootageResult<FootageDraft>> {
|
|
462
|
+
return withFfmpegFailureReporting(getFfmpegReporting(options), () => runRenderFootageDraft(film, clips, transcript, edl, options));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** The body of `renderFootageDraft`, inside its ffmpeg failure reporting. */
|
|
466
|
+
async function runRenderFootageDraft(
|
|
462
467
|
film: FootageFilm,
|
|
463
468
|
clips: PreparedClip[],
|
|
464
469
|
transcript: Extract<TranscribeOutcome, { kind: "ready" }>,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
|
|
3
|
+
/** What a failed ffmpeg step ran and printed, enough for a person to run it again (`writeFfmpegFailure`). */
|
|
4
|
+
export interface FfmpegFailure {
|
|
5
|
+
/** The step's name, as the thrown error starts. */
|
|
6
|
+
step: string;
|
|
7
|
+
/** Exactly the arguments ffmpeg was spawned with, `-progress` included. */
|
|
8
|
+
args: string[];
|
|
9
|
+
/** The folder ffmpeg ran in (the process's own when the step set none). */
|
|
10
|
+
cwd: string;
|
|
11
|
+
/** The exit code; null when ffmpeg did not start or was killed by a signal. */
|
|
12
|
+
code: number | null;
|
|
13
|
+
signal: string | null;
|
|
14
|
+
/** The whole stderr, line by line (its last `FFMPEG_FAILURE_STDERR_LINES` lines on a very long run). */
|
|
15
|
+
stderr: string[];
|
|
16
|
+
/** Every `-i` input: files resolved against `cwd`, `lavfi` sources as they are. */
|
|
17
|
+
inputs: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** How many stderr lines a failure keeps at most (the last ones). */
|
|
21
|
+
export const FFMPEG_FAILURE_STDERR_LINES = 2000;
|
|
22
|
+
|
|
23
|
+
/** Every `-i` input of an ffmpeg command: files resolved against `cwd`; a `-f lavfi` source is not a file, kept as it is. */
|
|
24
|
+
export function findFfmpegInputs(args: readonly string[], cwd: string): string[] {
|
|
25
|
+
const inputs: string[] = [];
|
|
26
|
+
let format: string | null = null;
|
|
27
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
28
|
+
const arg = args[index];
|
|
29
|
+
const value = args[index + 1];
|
|
30
|
+
if (arg === "-f" && value !== undefined) format = value;
|
|
31
|
+
if (arg !== "-i" || value === undefined) continue;
|
|
32
|
+
inputs.push(format === "lavfi" ? value : resolve(cwd, value));
|
|
33
|
+
format = null;
|
|
34
|
+
}
|
|
35
|
+
return inputs;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const SAFE_SHELL_ARGUMENT = /^[\w@%+=:,./-]+$/;
|
|
39
|
+
|
|
40
|
+
/** One argument for a POSIX shell: as it is when it needs no quoting, otherwise in single quotes. */
|
|
41
|
+
export function quoteShellArgument(value: string): string {
|
|
42
|
+
if (SAFE_SHELL_ARGUMENT.test(value)) return value;
|
|
43
|
+
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The command as one shell line: `ffmpeg` and every argument, quoted where needed. */
|
|
47
|
+
export function formatFfmpegCommand(args: readonly string[]): string {
|
|
48
|
+
return ["ffmpeg", ...args.map(quoteShellArgument)].join(" ");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A filter graph's chains, split at each top-level `;`: a `;` escaped with `\` or inside single quotes (a captions
|
|
53
|
+
* path, a drawtext string) stays in its chain. Joined with `;` they give the graph back. ffmpeg skips whitespace
|
|
54
|
+
* between chains, so a graph file with one chain per line reads as the graph.
|
|
55
|
+
*/
|
|
56
|
+
export function splitFilterGraph(graph: string): string[] {
|
|
57
|
+
const chains: string[] = [];
|
|
58
|
+
let chain = "";
|
|
59
|
+
let isQuoted = false;
|
|
60
|
+
for (let index = 0; index < graph.length; index += 1) {
|
|
61
|
+
const char = graph[index] ?? "";
|
|
62
|
+
// Inside single quotes every character is literal, a backslash too.
|
|
63
|
+
if (char === "\\" && !isQuoted && index + 1 < graph.length) {
|
|
64
|
+
chain += char + (graph[index + 1] ?? "");
|
|
65
|
+
index += 1;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (char === "'") isQuoted = !isQuoted;
|
|
69
|
+
if (char === ";" && !isQuoted) {
|
|
70
|
+
chains.push(chain);
|
|
71
|
+
chain = "";
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
chain += char;
|
|
75
|
+
}
|
|
76
|
+
chains.push(chain);
|
|
77
|
+
return chains;
|
|
78
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { isAbsolute, join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { quoteShellArgument, splitFilterGraph, type FfmpegFailure } from "./ffmpeg-command.js";
|
|
5
|
+
import { runFfprobe } from "./probe.js";
|
|
6
|
+
|
|
7
|
+
/** The files `writeFfmpegFailure` writes, by name. */
|
|
8
|
+
export const FFMPEG_FAILURE_FILES = { command: "command.sh", filterGraph: "filtergraph.txt", stderr: "stderr.log", inputs: "inputs.json" } as const;
|
|
9
|
+
|
|
10
|
+
/** One input's ffprobe facts (`ffprobe -show_format -show_streams` JSON), or why there are none. */
|
|
11
|
+
export type FfmpegFailureInput =
|
|
12
|
+
| { input: string; kind: "probed"; json: unknown }
|
|
13
|
+
| { input: string; kind: "probe-failed"; error: string }
|
|
14
|
+
| { input: string; kind: "lavfi" };
|
|
15
|
+
|
|
16
|
+
/** The command's `-filter_complex` graph; null when it has none. */
|
|
17
|
+
function findFilterGraph(args: readonly string[]): string | null {
|
|
18
|
+
const at = args.indexOf("-filter_complex");
|
|
19
|
+
return at === -1 ? null : (args[at + 1] ?? null);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `command.sh` for a failure: runs the same ffmpeg in the same folder. A `-filter_complex` graph is read from
|
|
24
|
+
* `filtergraph.txt` next to the script, with `-/filter_complex` on ffmpeg 7.1 and later and `-filter_complex_script`
|
|
25
|
+
* before it (the script asks `ffmpeg -version`).
|
|
26
|
+
*/
|
|
27
|
+
export function buildFfmpegFailureScript(failure: FfmpegFailure): string {
|
|
28
|
+
const at = failure.args.indexOf("-filter_complex");
|
|
29
|
+
const hasGraph = findFilterGraph(failure.args) !== null;
|
|
30
|
+
const words = failure.args.map((arg, index) => {
|
|
31
|
+
if (hasGraph && index === at) return '"$graph_option"';
|
|
32
|
+
if (hasGraph && index === at + 1) return `"$here/${FFMPEG_FAILURE_FILES.filterGraph}"`;
|
|
33
|
+
return quoteShellArgument(arg);
|
|
34
|
+
});
|
|
35
|
+
const lines = [
|
|
36
|
+
"#!/bin/sh",
|
|
37
|
+
`# ${failure.step}: ffmpeg ended with code ${String(failure.code)} (signal ${failure.signal ?? "-"}).`,
|
|
38
|
+
"# Runs the same ffmpeg command in the folder it ran in. stderr.log holds what it printed, inputs.json its inputs.",
|
|
39
|
+
'here=$(cd "$(dirname "$0")" && pwd)',
|
|
40
|
+
`cd ${quoteShellArgument(failure.cwd)} || exit 1`,
|
|
41
|
+
];
|
|
42
|
+
if (hasGraph) {
|
|
43
|
+
lines.push(
|
|
44
|
+
"# ffmpeg 7.1 and later read a filter graph file with -/filter_complex, earlier versions with -filter_complex_script.",
|
|
45
|
+
"graph_option=-/filter_complex",
|
|
46
|
+
"case \"$(ffmpeg -version 2>/dev/null | sed -n '1s/^ffmpeg version n\\{0,1\\}\\([0-9][0-9]*\\.[0-9][0-9]*\\).*/\\1/p')\" in",
|
|
47
|
+
" [0-6].* | 7.0) graph_option=-filter_complex_script ;;",
|
|
48
|
+
"esac",
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
lines.push(`exec ffmpeg ${words.join(" ")}`, "");
|
|
52
|
+
return lines.join("\n");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** ffprobe's facts of every input; a `lavfi` source is not a file and is not probed. */
|
|
56
|
+
async function probeInputs(failure: FfmpegFailure, signal: AbortSignal | undefined): Promise<FfmpegFailureInput[]> {
|
|
57
|
+
const probed: FfmpegFailureInput[] = [];
|
|
58
|
+
for (const input of failure.inputs) {
|
|
59
|
+
// Files are resolved to absolute paths; a lavfi source (`anullsrc=...`) is kept as it is.
|
|
60
|
+
if (!isAbsolute(input)) {
|
|
61
|
+
probed.push({ input, kind: "lavfi" });
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const result = await runFfprobe(input, signal === undefined ? {} : { signal });
|
|
65
|
+
probed.push(result.ok ? { input, kind: "probed", json: result.json } : { input, kind: "probe-failed", error: result.error });
|
|
66
|
+
}
|
|
67
|
+
return probed;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Writes a failed ffmpeg step to `dir` for a person to run again: `command.sh` (the command, run from the folder it
|
|
72
|
+
* ran in), `filtergraph.txt` (its `-filter_complex` graph, one chain per line; only when it has one), `stderr.log`
|
|
73
|
+
* (the whole stderr) and `inputs.json` (ffprobe's facts of every input). Answers the paths written.
|
|
74
|
+
*/
|
|
75
|
+
export async function writeFfmpegFailure(dir: string, failure: FfmpegFailure, options: { signal?: AbortSignal } = {}): Promise<string[]> {
|
|
76
|
+
await mkdir(dir, { recursive: true });
|
|
77
|
+
const written: string[] = [];
|
|
78
|
+
const write = async (name: string, content: string, mode?: number): Promise<void> => {
|
|
79
|
+
const path = join(dir, name);
|
|
80
|
+
await writeFile(path, content, mode === undefined ? {} : { mode });
|
|
81
|
+
written.push(path);
|
|
82
|
+
};
|
|
83
|
+
await write(FFMPEG_FAILURE_FILES.command, buildFfmpegFailureScript(failure), 0o755);
|
|
84
|
+
const graph = findFilterGraph(failure.args);
|
|
85
|
+
if (graph !== null) await write(FFMPEG_FAILURE_FILES.filterGraph, `${splitFilterGraph(graph).join(";\n")}\n`);
|
|
86
|
+
await write(FFMPEG_FAILURE_FILES.stderr, failure.stderr.map((line) => `${line}\n`).join(""));
|
|
87
|
+
await write(FFMPEG_FAILURE_FILES.inputs, `${JSON.stringify(await probeInputs(failure, options.signal), null, 2)}\n`);
|
|
88
|
+
return written;
|
|
89
|
+
}
|
package/src/footage/pipeline.ts
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
isUrl,
|
|
37
37
|
type CacheEntry,
|
|
38
38
|
} from "./paid.js";
|
|
39
|
-
import { runFfmpeg, runProcess } from "./process.js";
|
|
39
|
+
import { runFfmpeg, runProcess, withFfmpegFailureReporting, type FfmpegFailureHook, type FfmpegFailureReporting } from "./process.js";
|
|
40
40
|
import { splitFilmSentences, type Sentence } from "./sentences.js";
|
|
41
41
|
import {
|
|
42
42
|
buildCoverArgs,
|
|
@@ -110,6 +110,12 @@ export interface FootageRunOptions {
|
|
|
110
110
|
* the normalize stamp, so changing it does not normalize clips already made again.
|
|
111
111
|
*/
|
|
112
112
|
normalize?: NormalizeEncoder;
|
|
113
|
+
/**
|
|
114
|
+
* Called when an ffmpeg step fails, before the run throws, with exactly what ran: the arguments, the folder, the
|
|
115
|
+
* whole stderr and the inputs (`FfmpegFailure`). A promise is awaited, so `writeFfmpegFailure` can keep it for a
|
|
116
|
+
* person to run again. Every failure also gets one `log` line with the step and its full command.
|
|
117
|
+
*/
|
|
118
|
+
onFfmpegFailure?: FfmpegFailureHook;
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
export interface PreparedClip {
|
|
@@ -155,6 +161,11 @@ function createStageProgress(
|
|
|
155
161
|
};
|
|
156
162
|
}
|
|
157
163
|
|
|
164
|
+
/** The ffmpeg failure reporting of a footage entry point: its `log` and its `onFfmpegFailure`. */
|
|
165
|
+
export function getFfmpegReporting(options: Pick<FootageRunOptions, "log" | "onFfmpegFailure">): FfmpegFailureReporting {
|
|
166
|
+
return { log: options.log, ...(options.onFfmpegFailure === undefined ? {} : { onFailure: options.onFfmpegFailure }) };
|
|
167
|
+
}
|
|
168
|
+
|
|
158
169
|
/** Rejects with the signal's reason once the run was aborted (before a paid call, which the provider may not stop). */
|
|
159
170
|
function throwIfAborted(signal: AbortSignal | undefined): void {
|
|
160
171
|
signal?.throwIfAborted();
|
|
@@ -186,7 +197,12 @@ function getNormalizeStamp(clip: FootageClip, source: string, frame: Frame): str
|
|
|
186
197
|
}
|
|
187
198
|
|
|
188
199
|
/** Downloads URL clips, probes every clip (all problems at once) and a local music file, normalizes each clip that changed. */
|
|
189
|
-
export
|
|
200
|
+
export function prepareFootage(film: FootageFilm, options: Pick<FootageRunOptions, "buildDir" | "log" | "fetch" | "signal" | "onProgress" | "normalize" | "onFfmpegFailure">): Promise<FootageResult<PreparedClip[]>> {
|
|
201
|
+
return withFfmpegFailureReporting(getFfmpegReporting(options), () => runPrepareFootage(film, options));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** The body of `prepareFootage`, inside its ffmpeg failure reporting. */
|
|
205
|
+
async function runPrepareFootage(
|
|
190
206
|
film: FootageFilm,
|
|
191
207
|
options: Pick<FootageRunOptions, "buildDir" | "log" | "fetch" | "signal" | "onProgress" | "normalize">,
|
|
192
208
|
): Promise<FootageResult<PreparedClip[]>> {
|
|
@@ -275,7 +291,12 @@ export function getMusicPaidStep(film: FootageFilm, options: Pick<FootageRunOpti
|
|
|
275
291
|
* voice cleaned first when the film isolates it. Without `isCommit`, a cache miss returns the dry run: every paid
|
|
276
292
|
* call the film still needs, music included, with its length.
|
|
277
293
|
*/
|
|
278
|
-
export
|
|
294
|
+
export function transcribeFootage(film: FootageFilm, clips: PreparedClip[], options: FootageRunOptions): Promise<FootageResult<TranscribeOutcome>> {
|
|
295
|
+
return withFfmpegFailureReporting(getFfmpegReporting(options), () => runTranscribeFootage(film, clips, options));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** The body of `transcribeFootage`, inside its ffmpeg failure reporting. */
|
|
299
|
+
async function runTranscribeFootage(film: FootageFilm, clips: PreparedClip[], options: FootageRunOptions): Promise<FootageResult<TranscribeOutcome>> {
|
|
279
300
|
const { buildDir, providers, log, signal } = options;
|
|
280
301
|
if (options.isPlaceholder) return ok(transcribePlaceholder(film, clips, buildDir));
|
|
281
302
|
const keyTerms = getFilmKeyTerms(film);
|
|
@@ -402,6 +423,8 @@ export interface CutFootageFilmOptions {
|
|
|
402
423
|
/** The sentence ids to keep; absent keeps all. */
|
|
403
424
|
keepSentences?: readonly string[];
|
|
404
425
|
signal?: AbortSignal;
|
|
426
|
+
/** Called when a cut frame's ffmpeg step fails, before the cut throws (`FootageRunOptions.onFfmpegFailure`). */
|
|
427
|
+
onFfmpegFailure?: FfmpegFailureHook;
|
|
405
428
|
}
|
|
406
429
|
|
|
407
430
|
/** The file next to the EDL that records what the auto transitions measured. */
|
|
@@ -412,7 +435,12 @@ export const CUTS_FILE = "cuts.json";
|
|
|
412
435
|
* (`chooseCutTransitions`): each jump cut gets `zoom` or `fade`, and what it measured is answered and written to
|
|
413
436
|
* `cuts.json` next to the EDL, so an app or an agent sees why. Otherwise the same as `cutFootage`, and `cuts` is empty.
|
|
414
437
|
*/
|
|
415
|
-
export
|
|
438
|
+
export function cutFootageFilm(film: FootageFilm, clips: PreparedClip[], words: Record<string, TimedWord[]>, edlPath: string, options: CutFootageFilmOptions = {}): Promise<{ edl: Edl; cuts: CutMeasure[] }> {
|
|
439
|
+
return withFfmpegFailureReporting(options.onFfmpegFailure === undefined ? {} : { onFailure: options.onFfmpegFailure }, () => runCutFootageFilm(film, clips, words, edlPath, options));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** The body of `cutFootageFilm`, inside its ffmpeg failure reporting. */
|
|
443
|
+
async function runCutFootageFilm(
|
|
416
444
|
film: FootageFilm,
|
|
417
445
|
clips: PreparedClip[],
|
|
418
446
|
words: Record<string, TimedWord[]>,
|
|
@@ -601,7 +629,12 @@ export type RenderedFootage = { kind: "dry-run"; steps: PaidStep[] } | ({ kind:
|
|
|
601
629
|
* hyperframes, final pass, cover. First of all it checks that hyperframes' temp folder and the build folder have the
|
|
602
630
|
* 1 GiB free hyperframes requires, so a full disk ends the run with a sentence before anything is bought or built.
|
|
603
631
|
*/
|
|
604
|
-
export
|
|
632
|
+
export function renderFootage(film: FootageFilm, clips: PreparedClip[], transcript: Extract<TranscribeOutcome, { kind: "ready" }>, edl: Edl, options: RenderFootageOptions): Promise<FootageResult<RenderedFootage>> {
|
|
633
|
+
return withFfmpegFailureReporting(getFfmpegReporting(options), () => runRenderFootage(film, clips, transcript, edl, options));
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/** The body of `renderFootage`, inside its ffmpeg failure reporting. */
|
|
637
|
+
async function runRenderFootage(
|
|
605
638
|
film: FootageFilm,
|
|
606
639
|
clips: PreparedClip[],
|
|
607
640
|
transcript: Extract<TranscribeOutcome, { kind: "ready" }>,
|
|
@@ -902,7 +935,12 @@ export interface RenderFootageFilmOptions extends RenderFootageOptions {
|
|
|
902
935
|
* The whole footage film from a `FootageFilm` object, no `marketing.json` needed: prepare, transcribe (or the dry
|
|
903
936
|
* run), cut (reusing an EDL already in the build folder unless `isRecut`), render.
|
|
904
937
|
*/
|
|
905
|
-
export
|
|
938
|
+
export function renderFootageFilm(film: FootageFilm, options: RenderFootageFilmOptions): Promise<FootageResult<RenderedFootage>> {
|
|
939
|
+
return withFfmpegFailureReporting(getFfmpegReporting(options), () => runRenderFootageFilm(film, options));
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/** The body of `renderFootageFilm`, inside its ffmpeg failure reporting. */
|
|
943
|
+
async function runRenderFootageFilm(film: FootageFilm, options: RenderFootageFilmOptions): Promise<FootageResult<RenderedFootage>> {
|
|
906
944
|
const clips = await prepareFootage(film, options);
|
|
907
945
|
if (!clips.ok) return clips;
|
|
908
946
|
const transcript = await transcribeFootage(film, clips.value, options);
|
package/src/footage/process.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1
2
|
import { spawn } from "node:child_process";
|
|
2
3
|
import { rmSync } from "node:fs";
|
|
3
4
|
|
|
5
|
+
import { FFMPEG_FAILURE_STDERR_LINES, findFfmpegInputs, formatFfmpegCommand, type FfmpegFailure } from "./ffmpeg-command.js";
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* Child processes of the footage blocks (ffmpeg, ffprobe, hyperframes), run without blocking the event loop, so a jobs
|
|
6
9
|
* worker keeps its lease heartbeat during a long normalize or render. An abort kills the child, removes the partial
|
|
@@ -103,6 +106,28 @@ export function readFfmpegProgressSeconds(line: string): number | null {
|
|
|
103
106
|
return match === null ? null : Number(match[1]) / 1_000_000;
|
|
104
107
|
}
|
|
105
108
|
|
|
109
|
+
/** Called with a failed ffmpeg step before it throws; a promise is awaited, so the app can write the failure out. */
|
|
110
|
+
export type FfmpegFailureHook = (failure: FfmpegFailure) => void | Promise<void>;
|
|
111
|
+
|
|
112
|
+
export interface FfmpegFailureReporting {
|
|
113
|
+
onFailure?: FfmpegFailureHook;
|
|
114
|
+
/** Gets one line naming the failed step and its full command. */
|
|
115
|
+
log?: (line: string) => void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const failureReporting = new AsyncLocalStorage<FfmpegFailureReporting>();
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Runs `run` with `onFailure` and `log` set for every ffmpeg step inside it, however deep (the footage entry points
|
|
122
|
+
* wrap their body in it). A value it does not set keeps the one of an enclosing call.
|
|
123
|
+
*/
|
|
124
|
+
export function withFfmpegFailureReporting<T>(reporting: FfmpegFailureReporting, run: () => Promise<T>): Promise<T> {
|
|
125
|
+
const outer = failureReporting.getStore();
|
|
126
|
+
const onFailure = reporting.onFailure ?? outer?.onFailure;
|
|
127
|
+
const log = reporting.log ?? outer?.log;
|
|
128
|
+
return failureReporting.run({ ...(onFailure === undefined ? {} : { onFailure }), ...(log === undefined ? {} : { log }) }, run);
|
|
129
|
+
}
|
|
130
|
+
|
|
106
131
|
export interface FfmpegRunOptions {
|
|
107
132
|
signal?: AbortSignal;
|
|
108
133
|
/** The file the run writes, removed on abort. */
|
|
@@ -111,14 +136,38 @@ export interface FfmpegRunOptions {
|
|
|
111
136
|
onSeconds?: (seconds: number) => void;
|
|
112
137
|
/** The folder ffmpeg runs in, so relative names in the arguments and the filter graph resolve there. */
|
|
113
138
|
cwd?: string;
|
|
139
|
+
/** Called when the run fails, before it throws; by default the one `withFfmpegFailureReporting` set. */
|
|
140
|
+
onFailure?: FfmpegFailureHook;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Logs the failure and hands it to the hook; an error of the hook itself is logged, never thrown over ffmpeg's. */
|
|
144
|
+
async function reportFfmpegFailure(failure: FfmpegFailure, onFailure: FfmpegFailureHook | undefined): Promise<void> {
|
|
145
|
+
const reporting = failureReporting.getStore();
|
|
146
|
+
const log = reporting?.log;
|
|
147
|
+
log?.(`ffmpeg failed: ${failure.step}, in ${failure.cwd}: ${formatFfmpegCommand(failure.args)}`);
|
|
148
|
+
const hook = onFailure ?? reporting?.onFailure;
|
|
149
|
+
if (hook === undefined) return;
|
|
150
|
+
try {
|
|
151
|
+
await hook(failure);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
const message = `ffmpeg failed: the failure hook of "${failure.step}" threw: ${error instanceof Error ? error.message : String(error)}`;
|
|
154
|
+
if (log === undefined) console.error(message);
|
|
155
|
+
else log(message);
|
|
156
|
+
}
|
|
114
157
|
}
|
|
115
158
|
|
|
116
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Runs ffmpeg with its progress on stdout; throws naming the step when it fails (a broken input or machine), after
|
|
161
|
+
* handing the whole failure (`FfmpegFailure`) to `onFailure` and one line with the command to the reporting `log`.
|
|
162
|
+
*/
|
|
117
163
|
export async function runFfmpeg(step: string, args: string[], options: FfmpegRunOptions = {}): Promise<void> {
|
|
118
164
|
const errors: string[] = [];
|
|
165
|
+
const stderr: string[] = [];
|
|
166
|
+
const spawned = ["-progress", "pipe:1", "-nostats", ...args];
|
|
167
|
+
const cwd = options.cwd ?? process.cwd();
|
|
119
168
|
const outcome = await runProcess({
|
|
120
169
|
command: "ffmpeg",
|
|
121
|
-
args:
|
|
170
|
+
args: spawned,
|
|
122
171
|
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
123
172
|
...(options.cwd === undefined ? {} : { cwd: options.cwd }),
|
|
124
173
|
removeOnAbort: options.output === undefined ? [] : [options.output],
|
|
@@ -127,12 +176,23 @@ export async function runFfmpeg(step: string, args: string[], options: FfmpegRun
|
|
|
127
176
|
if (seconds !== null) options.onSeconds?.(seconds);
|
|
128
177
|
},
|
|
129
178
|
onStderrLine: (line) => {
|
|
179
|
+
stderr.push(line);
|
|
180
|
+
if (stderr.length > FFMPEG_FAILURE_STDERR_LINES) stderr.shift();
|
|
130
181
|
if (line.trim().length > 0) errors.push(line);
|
|
131
182
|
},
|
|
132
183
|
});
|
|
184
|
+
if (outcome.kind === "exited" && outcome.code === 0) return;
|
|
185
|
+
const failure: FfmpegFailure = {
|
|
186
|
+
step,
|
|
187
|
+
args: spawned,
|
|
188
|
+
cwd,
|
|
189
|
+
code: outcome.kind === "exited" ? outcome.code : null,
|
|
190
|
+
signal: outcome.kind === "exited" ? outcome.signal : null,
|
|
191
|
+
stderr: outcome.kind === "exited" ? stderr : [outcome.error],
|
|
192
|
+
inputs: findFfmpegInputs(spawned, cwd),
|
|
193
|
+
};
|
|
194
|
+
await reportFfmpegFailure(failure, options.onFailure);
|
|
133
195
|
if (outcome.kind === "not-started") throw new Error(`${step}: ffmpeg did not start (${outcome.error}).`);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
throw new Error(`${step}: ffmpeg ended with code ${String(outcome.code)} (signal ${outcome.signal ?? "-"})${detail.length > 0 ? `: ${detail}` : ""}.`);
|
|
137
|
-
}
|
|
196
|
+
const detail = errors.slice(-5).join(" | ");
|
|
197
|
+
throw new Error(`${step}: ffmpeg ended with code ${String(outcome.code)} (signal ${outcome.signal ?? "-"})${detail.length > 0 ? `: ${detail}` : ""}.`);
|
|
138
198
|
}
|
package/src/index.ts
CHANGED
|
@@ -397,7 +397,19 @@ export {
|
|
|
397
397
|
readTopLevelBoxes,
|
|
398
398
|
type FilmFacts,
|
|
399
399
|
} from "./footage/publish.js";
|
|
400
|
-
export {
|
|
400
|
+
export {
|
|
401
|
+
readFfmpegProgressSeconds,
|
|
402
|
+
runFfmpeg,
|
|
403
|
+
runProcess,
|
|
404
|
+
withFfmpegFailureReporting,
|
|
405
|
+
type FfmpegFailureHook,
|
|
406
|
+
type FfmpegFailureReporting,
|
|
407
|
+
type FfmpegRunOptions,
|
|
408
|
+
type ProcessOptions,
|
|
409
|
+
type ProcessOutcome,
|
|
410
|
+
} from "./footage/process.js";
|
|
411
|
+
export { FFMPEG_FAILURE_STDERR_LINES, formatFfmpegCommand, splitFilterGraph, type FfmpegFailure } from "./footage/ffmpeg-command.js";
|
|
412
|
+
export { buildFfmpegFailureScript, FFMPEG_FAILURE_FILES, writeFfmpegFailure, type FfmpegFailureInput } from "./footage/ffmpeg-failure.js";
|
|
401
413
|
export {
|
|
402
414
|
estimateFootageFilm,
|
|
403
415
|
findCachedStep,
|