@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
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Edl } from "./edl.js";
|
|
2
|
+
import type { ClipRole } from "./film.js";
|
|
3
|
+
/** What ffprobe says about a written film, reduced to what a platform checks. */
|
|
4
|
+
export interface FilmFacts {
|
|
5
|
+
bytes: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
durationSeconds: number;
|
|
9
|
+
video: {
|
|
10
|
+
codec: string;
|
|
11
|
+
profile: string | null;
|
|
12
|
+
pixelFormat: string | null;
|
|
13
|
+
};
|
|
14
|
+
/** Null for a film without sound. */
|
|
15
|
+
audio: {
|
|
16
|
+
codec: string;
|
|
17
|
+
sampleRate: number;
|
|
18
|
+
channels: number;
|
|
19
|
+
} | null;
|
|
20
|
+
}
|
|
21
|
+
/** ffprobe's JSON (`-show_streams -show_format -of json`) of a film read as its facts; an error names what is missing. */
|
|
22
|
+
export declare function readFilmFacts(json: unknown): {
|
|
23
|
+
ok: true;
|
|
24
|
+
facts: FilmFacts;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
error: string;
|
|
28
|
+
};
|
|
29
|
+
/** Runs ffprobe on a written film; an error names the file and the reason. Rejects only on abort. */
|
|
30
|
+
export declare function probeFilmFacts(path: string, options?: {
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
ok: true;
|
|
34
|
+
facts: FilmFacts;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
error: string;
|
|
38
|
+
}>;
|
|
39
|
+
/** True when the picture is already what platforms take: H.264 High, yuv420p. */
|
|
40
|
+
export declare function isPublishableVideo(video: FilmFacts["video"]): boolean;
|
|
41
|
+
/** True when the sound is already what platforms take: AAC at 48 kHz, stereo. */
|
|
42
|
+
export declare function isPublishableAudio(audio: NonNullable<FilmFacts["audio"]>): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The final pass: each stream that is already publishable is copied, the other re-encoded, and the `moov` box moved
|
|
45
|
+
* to the front. A film without sound keeps none.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildFinishArgs(input: string, facts: Pick<FilmFacts, "video" | "audio">, output: string): string[];
|
|
48
|
+
/** The types of an MP4's top-level boxes, in file order (`ftyp`, `moov`, `mdat`, …). */
|
|
49
|
+
export declare function readTopLevelBoxes(path: string): string[];
|
|
50
|
+
/** True when the `moov` box comes before the media (`mdat`), so a player can start before the whole file is in. */
|
|
51
|
+
export declare function isFastStart(boxes: string[]): boolean;
|
|
52
|
+
/** What keeps a finished film from being publishable; empty when nothing does. */
|
|
53
|
+
export declare function findFinishProblems(facts: FilmFacts, boxes: string[]): string[];
|
|
54
|
+
/** The default cover time: the middle of the first talking segment, or of the first segment when nobody talks. */
|
|
55
|
+
export declare function getDefaultCoverSeconds(edl: Edl, roles: Record<string, ClipRole>): number;
|
|
56
|
+
/** A cover time inside the film: at most just before its end. */
|
|
57
|
+
export declare function clampCoverSeconds(seconds: number, durationSeconds: number): number;
|
|
58
|
+
/** One frame of the finished film as a JPG. */
|
|
59
|
+
export declare function buildCoverArgs(film: string, seconds: number, output: string): string[];
|
|
60
|
+
/** The cover's path next to the film: its name with `.jpg`. */
|
|
61
|
+
export declare function getCoverPath(film: string): string;
|
|
62
|
+
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/footage/publish.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAiB1C,iFAAiF;AACjF,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC7E,qCAAqC;IACrC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACvE;AAkBD,0HAA0H;AAC1H,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAA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+CAA+C;AAC/C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEtF;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { closeSync, openSync, readSync, statSync } from "node:fs";
|
|
2
|
+
import { extname } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { getSegmentStarts } from "./edl.js";
|
|
5
|
+
import { FOOTAGE_SAMPLE_RATE } from "./normalize.js";
|
|
6
|
+
import { runProcess } from "./process.js";
|
|
7
|
+
/**
|
|
8
|
+
* The finished film as a platform or a scheduler takes it: H.264 High in yuv420p, AAC 48 kHz stereo, the `moov` box
|
|
9
|
+
* before the media (`+faststart`, so a streamed URL plays before it is whole), a cover frame, and the facts an app
|
|
10
|
+
* records (bytes, picture, real duration), all read from the written file.
|
|
11
|
+
*/
|
|
12
|
+
/** The audio bitrate of a re-encoded track. */
|
|
13
|
+
const AUDIO_BITRATE = "192k";
|
|
14
|
+
/** The quality of a re-encoded picture (x264's constant rate factor; 18 is visually lossless). */
|
|
15
|
+
const VIDEO_CRF = 18;
|
|
16
|
+
/** How far before the film's end the latest cover frame is taken, so a frame still exists there. */
|
|
17
|
+
const COVER_END_MARGIN = 0.1;
|
|
18
|
+
const streamSchema = z.looseObject({
|
|
19
|
+
codec_type: z.string().optional(),
|
|
20
|
+
codec_name: z.string().optional(),
|
|
21
|
+
profile: z.string().optional(),
|
|
22
|
+
pix_fmt: z.string().optional(),
|
|
23
|
+
width: z.number().optional(),
|
|
24
|
+
height: z.number().optional(),
|
|
25
|
+
sample_rate: z.string().optional(),
|
|
26
|
+
channels: z.number().optional(),
|
|
27
|
+
});
|
|
28
|
+
const factsSchema = z.looseObject({
|
|
29
|
+
streams: z.array(streamSchema).default([]),
|
|
30
|
+
format: z.looseObject({ duration: z.string().optional(), size: z.string().optional() }).optional(),
|
|
31
|
+
});
|
|
32
|
+
/** ffprobe's JSON (`-show_streams -show_format -of json`) of a film read as its facts; an error names what is missing. */
|
|
33
|
+
export function readFilmFacts(json) {
|
|
34
|
+
const parsed = factsSchema.safeParse(json);
|
|
35
|
+
if (!parsed.success)
|
|
36
|
+
return { ok: false, error: "ffprobe printed an unexpected shape" };
|
|
37
|
+
const { streams, format } = parsed.data;
|
|
38
|
+
const video = streams.find((stream) => stream.codec_type === "video");
|
|
39
|
+
if (video?.width === undefined || video.height === undefined)
|
|
40
|
+
return { ok: false, error: "no video stream" };
|
|
41
|
+
const durationSeconds = Number(format?.duration);
|
|
42
|
+
if (!Number.isFinite(durationSeconds) || durationSeconds <= 0)
|
|
43
|
+
return { ok: false, error: "no duration" };
|
|
44
|
+
const audio = streams.find((stream) => stream.codec_type === "audio");
|
|
45
|
+
return {
|
|
46
|
+
ok: true,
|
|
47
|
+
facts: {
|
|
48
|
+
bytes: Number(format?.size ?? 0),
|
|
49
|
+
width: video.width,
|
|
50
|
+
height: video.height,
|
|
51
|
+
durationSeconds,
|
|
52
|
+
video: { codec: video.codec_name ?? "unknown", profile: video.profile ?? null, pixelFormat: video.pix_fmt ?? null },
|
|
53
|
+
audio: audio === undefined ? null : { codec: audio.codec_name ?? "unknown", sampleRate: Number(audio.sample_rate ?? 0), channels: audio.channels ?? 0 },
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Runs ffprobe on a written film; an error names the file and the reason. Rejects only on abort. */
|
|
58
|
+
export async function probeFilmFacts(path, options = {}) {
|
|
59
|
+
const result = await runProcess({ command: "ffprobe", args: ["-v", "error", "-show_streams", "-show_format", "-of", "json", path], ...options });
|
|
60
|
+
if (result.kind === "not-started")
|
|
61
|
+
return { ok: false, error: `ffprobe did not start for ${path}: ${result.error}` };
|
|
62
|
+
if (result.code !== 0)
|
|
63
|
+
return { ok: false, error: `ffprobe cannot read ${path}: ${result.stderr.trim() || `code ${String(result.code)}`}` };
|
|
64
|
+
let json;
|
|
65
|
+
try {
|
|
66
|
+
json = JSON.parse(result.stdout);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return { ok: false, error: `ffprobe printed no JSON for ${path}: ${String(error)}` };
|
|
70
|
+
}
|
|
71
|
+
const read = readFilmFacts(json);
|
|
72
|
+
return read.ok ? read : { ok: false, error: `${path}: ${read.error}` };
|
|
73
|
+
}
|
|
74
|
+
/** True when the picture is already what platforms take: H.264 High, yuv420p. */
|
|
75
|
+
export function isPublishableVideo(video) {
|
|
76
|
+
return video.codec === "h264" && video.profile === "High" && video.pixelFormat === "yuv420p";
|
|
77
|
+
}
|
|
78
|
+
/** True when the sound is already what platforms take: AAC at 48 kHz, stereo. */
|
|
79
|
+
export function isPublishableAudio(audio) {
|
|
80
|
+
return audio.codec === "aac" && audio.sampleRate === FOOTAGE_SAMPLE_RATE && audio.channels === 2;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The final pass: each stream that is already publishable is copied, the other re-encoded, and the `moov` box moved
|
|
84
|
+
* to the front. A film without sound keeps none.
|
|
85
|
+
*/
|
|
86
|
+
export function buildFinishArgs(input, facts, output) {
|
|
87
|
+
const video = isPublishableVideo(facts.video)
|
|
88
|
+
? ["-c:v", "copy"]
|
|
89
|
+
: ["-c:v", "libx264", "-profile:v", "high", "-pix_fmt", "yuv420p", "-preset", "medium", "-crf", String(VIDEO_CRF)];
|
|
90
|
+
const audio = facts.audio === null
|
|
91
|
+
? []
|
|
92
|
+
: isPublishableAudio(facts.audio)
|
|
93
|
+
? ["-map", "0:a:0", "-c:a", "copy"]
|
|
94
|
+
: ["-map", "0:a:0", "-c:a", "aac", "-b:a", AUDIO_BITRATE, "-ar", String(FOOTAGE_SAMPLE_RATE), "-ac", "2"];
|
|
95
|
+
return ["-v", "error", "-y", "-i", input, "-map", "0:v:0", ...video, ...audio, "-movflags", "+faststart", output];
|
|
96
|
+
}
|
|
97
|
+
/** The types of an MP4's top-level boxes, in file order (`ftyp`, `moov`, `mdat`, …). */
|
|
98
|
+
export function readTopLevelBoxes(path) {
|
|
99
|
+
const size = statSync(path).size;
|
|
100
|
+
const fd = openSync(path, "r");
|
|
101
|
+
const header = Buffer.alloc(16);
|
|
102
|
+
const types = [];
|
|
103
|
+
try {
|
|
104
|
+
let offset = 0;
|
|
105
|
+
while (offset + 8 <= size) {
|
|
106
|
+
readSync(fd, header, 0, 16, offset);
|
|
107
|
+
let length = header.readUInt32BE(0);
|
|
108
|
+
types.push(header.toString("latin1", 4, 8));
|
|
109
|
+
// 1: a 64-bit length follows the type; 0: the box runs to the end of the file.
|
|
110
|
+
if (length === 1)
|
|
111
|
+
length = Number(header.readBigUInt64BE(8));
|
|
112
|
+
if (length === 0)
|
|
113
|
+
break;
|
|
114
|
+
if (length < 8)
|
|
115
|
+
throw new Error(`${path}: a box of ${length} bytes at ${offset} is not an MP4 box.`);
|
|
116
|
+
offset += length;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
closeSync(fd);
|
|
121
|
+
}
|
|
122
|
+
return types;
|
|
123
|
+
}
|
|
124
|
+
/** True when the `moov` box comes before the media (`mdat`), so a player can start before the whole file is in. */
|
|
125
|
+
export function isFastStart(boxes) {
|
|
126
|
+
const moov = boxes.indexOf("moov");
|
|
127
|
+
const mdat = boxes.indexOf("mdat");
|
|
128
|
+
return moov !== -1 && (mdat === -1 || moov < mdat);
|
|
129
|
+
}
|
|
130
|
+
/** What keeps a finished film from being publishable; empty when nothing does. */
|
|
131
|
+
export function findFinishProblems(facts, boxes) {
|
|
132
|
+
const problems = [];
|
|
133
|
+
const { video, audio } = facts;
|
|
134
|
+
if (!isPublishableVideo(video))
|
|
135
|
+
problems.push(`the picture is ${video.codec} ${video.profile ?? "-"} ${video.pixelFormat ?? "-"}, not h264 High yuv420p`);
|
|
136
|
+
if (audio !== null && !isPublishableAudio(audio))
|
|
137
|
+
problems.push(`the sound is ${audio.codec} ${audio.sampleRate} Hz ${audio.channels} channels, not aac 48000 Hz stereo`);
|
|
138
|
+
if (!isFastStart(boxes))
|
|
139
|
+
problems.push("the moov box is not before the media (no fast start)");
|
|
140
|
+
return problems;
|
|
141
|
+
}
|
|
142
|
+
/** The default cover time: the middle of the first talking segment, or of the first segment when nobody talks. */
|
|
143
|
+
export function getDefaultCoverSeconds(edl, roles) {
|
|
144
|
+
const starts = getSegmentStarts(edl);
|
|
145
|
+
const index = Math.max(0, edl.segments.findIndex((segment) => roles[segment.clip] === "talk"));
|
|
146
|
+
const segment = edl.segments[index];
|
|
147
|
+
if (segment === undefined)
|
|
148
|
+
return 0;
|
|
149
|
+
return Math.round(((starts[index] ?? 0) + (segment.end - segment.start) / 2) * 1000) / 1000;
|
|
150
|
+
}
|
|
151
|
+
/** A cover time inside the film: at most just before its end. */
|
|
152
|
+
export function clampCoverSeconds(seconds, durationSeconds) {
|
|
153
|
+
return Math.min(Math.max(0, seconds), Math.max(0, Math.round((durationSeconds - COVER_END_MARGIN) * 1000) / 1000));
|
|
154
|
+
}
|
|
155
|
+
/** One frame of the finished film as a JPG. */
|
|
156
|
+
export function buildCoverArgs(film, seconds, output) {
|
|
157
|
+
return ["-v", "error", "-y", "-ss", String(seconds), "-i", film, "-frames:v", "1", "-q:v", "2", output];
|
|
158
|
+
}
|
|
159
|
+
/** The cover's path next to the film: its name with `.jpg`. */
|
|
160
|
+
export function getCoverPath(film) {
|
|
161
|
+
const extension = extname(film);
|
|
162
|
+
return `${extension.length > 0 ? film.slice(0, -extension.length) : film}.jpg`;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/footage/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CA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AE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAC1G,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AACjF,CAAC"}
|
package/dist/footage/render.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Edl } from "./edl.js";
|
|
2
2
|
import { type VolumeKeyframe } from "./music.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The speech track: every segment's sound cut from its sound span (its own clip's, or `audio`'s: a J/L-cut or b-roll
|
|
5
|
+
* over speech) and joined in order; `audio.ownVolume` keeps the picture clip's own sound under it.
|
|
6
|
+
*/
|
|
4
7
|
export declare function buildSpeechArgs(edl: Edl, sources: Record<string, string>, output: string): string[];
|
|
5
8
|
/** The music track: looped to the film's length, ducked by the keyframes, faded in and out. */
|
|
6
9
|
export declare function buildMusicArgs(options: {
|
|
@@ -15,6 +18,4 @@ export declare function buildCutPreviewArgs(edl: Edl, clips: Record<string, stri
|
|
|
15
18
|
export declare function buildLastFrameArgs(edl: Edl, clips: Record<string, string>, output: string): string[];
|
|
16
19
|
/** Audio extracted from a normalized clip, for the providers and the speech track. */
|
|
17
20
|
export declare function buildAudioArgs(clip: string, output: string): string[];
|
|
18
|
-
/** Runs ffmpeg; throws naming the step (a failure here is a broken input or machine, not an expected outcome). */
|
|
19
|
-
export declare function runFfmpeg(step: string, args: string[]): void;
|
|
20
21
|
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/footage/render.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/footage/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAWnE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAgCnG;AAED,+FAA+F;AAC/F,wBAAgB,cAAc,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,cAAc,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,EAAE,CASjI;AAED,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAYrG;AAED,kGAAkG;AAClG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAOpG;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAErE"}
|
package/dist/footage/render.js
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getSoundSpan } from "./edl.js";
|
|
2
2
|
import { FOOTAGE_SAMPLE_RATE } from "./normalize.js";
|
|
3
3
|
import { volumeExpression } from "./music.js";
|
|
4
|
-
/** ffmpeg steps of the footage render: pure argument builders
|
|
4
|
+
/** ffmpeg steps of the footage render: pure argument builders, tested without ffmpeg (`runFfmpeg` in `process.ts` runs them). */
|
|
5
5
|
/** A short fade at every cut of the speech track, so a cut never clicks. */
|
|
6
6
|
const CUT_FADE_SECONDS = 0.02;
|
|
7
7
|
const MUSIC_FADE_IN = 1;
|
|
8
8
|
const MUSIC_FADE_OUT = 1.5;
|
|
9
9
|
const r3 = (value) => Math.round(value * 1000) / 1000 || 0;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* The speech track: every segment's sound cut from its sound span (its own clip's, or `audio`'s: a J/L-cut or b-roll
|
|
12
|
+
* over speech) and joined in order; `audio.ownVolume` keeps the picture clip's own sound under it.
|
|
13
|
+
*/
|
|
11
14
|
export function buildSpeechArgs(edl, sources, output) {
|
|
12
15
|
const inputs = [];
|
|
13
16
|
const parts = [];
|
|
14
|
-
|
|
15
|
-
const source = sources[
|
|
17
|
+
const getSource = (clip) => {
|
|
18
|
+
const source = sources[clip];
|
|
16
19
|
if (source === undefined)
|
|
17
|
-
throw new Error(`No audio for clip "${
|
|
18
|
-
|
|
20
|
+
throw new Error(`No audio for clip "${clip}" of the EDL.`);
|
|
21
|
+
return source;
|
|
22
|
+
};
|
|
23
|
+
const cut = (input, span, duration) => `[${input}:a]atrim=start=${span.start}:end=${span.end},asetpts=PTS-STARTPTS,aformat=sample_rates=${FOOTAGE_SAMPLE_RATE}:channel_layouts=stereo,apad=whole_dur=${duration}`;
|
|
24
|
+
edl.segments.forEach((segment, index) => {
|
|
25
|
+
const sound = getSoundSpan(segment);
|
|
19
26
|
const duration = r3(segment.end - segment.start);
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
const fades = `afade=t=in:d=${CUT_FADE_SECONDS},afade=t=out:st=${r3(Math.max(0, duration - CUT_FADE_SECONDS))}:d=${CUT_FADE_SECONDS}`;
|
|
28
|
+
const input = inputs.length / 2;
|
|
29
|
+
inputs.push("-i", getSource(sound.clip));
|
|
30
|
+
const own = segment.audio?.ownVolume ?? 0;
|
|
31
|
+
// A borrowed span may be a few milliseconds longer than the picture: it is cut to the picture's length.
|
|
32
|
+
const fit = segment.audio === undefined ? "" : `,atrim=end=${duration}`;
|
|
33
|
+
if (own <= 0) {
|
|
34
|
+
parts.push(`${cut(input, sound, duration)}${fit},${fades}[a${index}]`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const ownInput = inputs.length / 2;
|
|
38
|
+
inputs.push("-i", getSource(segment.clip));
|
|
39
|
+
parts.push(`${cut(input, sound, duration)},atrim=end=${duration}[s${index}]`);
|
|
40
|
+
parts.push(`${cut(ownInput, segment, duration)},atrim=end=${duration},volume=${own}[o${index}]`);
|
|
41
|
+
parts.push(`[s${index}][o${index}]amix=inputs=2:duration=first:normalize=0,${fades}[a${index}]`);
|
|
22
42
|
});
|
|
23
43
|
const joined = edl.segments.map((_, index) => `[a${index}]`).join("");
|
|
24
44
|
const graph = `${parts.join(";")};${joined}concat=n=${edl.segments.length}:v=0:a=1[speech]`;
|
|
@@ -65,12 +85,4 @@ export function buildLastFrameArgs(edl, clips, output) {
|
|
|
65
85
|
export function buildAudioArgs(clip, output) {
|
|
66
86
|
return ["-v", "error", "-y", "-i", clip, "-vn", "-c:a", "libmp3lame", "-q:a", "2", output];
|
|
67
87
|
}
|
|
68
|
-
/** Runs ffmpeg; throws naming the step (a failure here is a broken input or machine, not an expected outcome). */
|
|
69
|
-
export function runFfmpeg(step, args) {
|
|
70
|
-
const result = spawnSync("ffmpeg", args, { stdio: ["ignore", "inherit", "inherit"] });
|
|
71
|
-
if (result.error !== undefined)
|
|
72
|
-
throw new Error(`${step}: ffmpeg did not start (${result.error.message}).`);
|
|
73
|
-
if (result.status !== 0)
|
|
74
|
-
throw new Error(`${step}: ffmpeg ended with code ${String(result.status)} (signal ${result.signal ?? "-"}).`);
|
|
75
|
-
}
|
|
76
88
|
//# sourceMappingURL=render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/footage/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/footage/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAY,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAuB,MAAM,YAAY,CAAC;AAEnE,iIAAiI;AAEjI,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,EAAE,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AAE3E;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAQ,EAAE,OAA+B,EAAE,MAAc;IACvF,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE;QACzC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,eAAe,CAAC,CAAC;QACrF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,IAAoC,EAAE,QAAgB,EAAU,EAAE,CAC5F,IAAI,KAAK,kBAAkB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,8CAA8C,mBAAmB,0CAA0C,QAAQ,EAAE,CAAC;IAC7K,GAAG,CAAC,QAAQ,CAAC,OAAO,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EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACrJ,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,kBAAkB,CAAC,GAAQ,EAAE,KAA6B,EAAE,MAAc;IACxF,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,IAAI,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,IAAI,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,IAAI,eAAe,CAAC,CAAC;IACvF,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AACrG,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,MAAc;IACzD,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TimedWord } from "../voice/voiceover.js";
|
|
2
|
+
/**
|
|
3
|
+
* The transcript as sentences with stable ids (`s1`, `s2`… in film order), and suggestions of the sentences an editor
|
|
4
|
+
* usually drops: a retake (the same sentence said again later), a false start (a sentence begun and begun again) and a
|
|
5
|
+
* cut-off sentence. The kit only suggests, with a reason; the caller decides what `buildEdl` keeps.
|
|
6
|
+
*/
|
|
7
|
+
export interface Sentence {
|
|
8
|
+
/** `s<n>`, numbered across the film's talking clips in order. */
|
|
9
|
+
id: string;
|
|
10
|
+
/** The clip it is spoken in. */
|
|
11
|
+
clip: string;
|
|
12
|
+
/** Seconds in the trimmed clip. */
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
text: string;
|
|
16
|
+
words: TimedWord[];
|
|
17
|
+
/** It ends with `.`, `?`, `!` or `…`. */
|
|
18
|
+
isComplete: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type RetakeKind = "retake" | "false-start" | "cut-off";
|
|
21
|
+
export interface RetakeSuggestion {
|
|
22
|
+
/** The sentence to drop. */
|
|
23
|
+
sentence: string;
|
|
24
|
+
kind: RetakeKind;
|
|
25
|
+
/** The sentence that replaces it (the later, good take); absent for a cut-off sentence. */
|
|
26
|
+
of?: string;
|
|
27
|
+
reason: string;
|
|
28
|
+
}
|
|
29
|
+
/** One clip's words as sentences; `firstNumber` is the number of the first id. */
|
|
30
|
+
export declare function splitSentences(words: TimedWord[], clip: string, firstNumber?: number): Sentence[];
|
|
31
|
+
/** The sentences of every talking clip, numbered across the film in clip order. */
|
|
32
|
+
export declare function splitFilmSentences(clips: {
|
|
33
|
+
id: string;
|
|
34
|
+
role: string;
|
|
35
|
+
words: TimedWord[];
|
|
36
|
+
}[]): Sentence[];
|
|
37
|
+
/**
|
|
38
|
+
* Sentences an editor would likely drop, each with the reason. Within one clip, a sentence is compared with the next
|
|
39
|
+
* three: a `false-start` when its words begin a later sentence, a `retake` when 60 % or more of the longer one's words
|
|
40
|
+
* match in order (the later take is kept). Otherwise a sentence that ends in a dash or an ellipsis, or ends its clip
|
|
41
|
+
* without a full stop, is `cut-off`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function findRetakes(sentences: Sentence[]): RetakeSuggestion[];
|
|
44
|
+
//# sourceMappingURL=sentences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentences.d.ts","sourceRoot":"","sources":["../../src/footage/sentences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD;;;;GAIG;AAEH,MAAM,WAAW,QAAQ;IACvB,iEAAiE;IACjE,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,yCAAyC;IACzC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,2FAA2F;IAC3F,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAYD,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,SAAI,GAAG,QAAQ,EAAE,CA6B5F;AAED,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,EAAE,CAAA;CAAE,EAAE,GAAG,QAAQ,EAAE,CAOxG;AAqBD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,gBAAgB,EAAE,CAyBrE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { normalizeWord } from "./words.js";
|
|
2
|
+
/** A silence this long ends a sentence even without punctuation. */
|
|
3
|
+
const SENTENCE_PAUSE_SECONDS = 1;
|
|
4
|
+
/** How many later sentences a take is compared with. */
|
|
5
|
+
const RETAKE_WINDOW = 3;
|
|
6
|
+
/** The share of the longer sentence's words, in order, that makes two sentences one sentence said twice. */
|
|
7
|
+
const RETAKE_SIMILARITY = 0.6;
|
|
8
|
+
const ENDS_SENTENCE = /[.?!…]["'”’)\]]*$/u;
|
|
9
|
+
const ENDS_CUT_OFF = /(-|—|–|\.\.\.|…)["'”’)\]]*$/u;
|
|
10
|
+
/** One clip's words as sentences; `firstNumber` is the number of the first id. */
|
|
11
|
+
export function splitSentences(words, clip, firstNumber = 1) {
|
|
12
|
+
const sorted = [...words].sort((a, b) => a.start - b.start);
|
|
13
|
+
const groups = [];
|
|
14
|
+
let current = [];
|
|
15
|
+
sorted.forEach((word, index) => {
|
|
16
|
+
const previous = sorted[index - 1];
|
|
17
|
+
if (current.length > 0 && previous !== undefined && word.start - previous.end > SENTENCE_PAUSE_SECONDS) {
|
|
18
|
+
groups.push(current);
|
|
19
|
+
current = [];
|
|
20
|
+
}
|
|
21
|
+
current.push(word);
|
|
22
|
+
if (ENDS_SENTENCE.test(word.text.trim())) {
|
|
23
|
+
groups.push(current);
|
|
24
|
+
current = [];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (current.length > 0)
|
|
28
|
+
groups.push(current);
|
|
29
|
+
return groups.map((group, index) => {
|
|
30
|
+
const last = group[group.length - 1];
|
|
31
|
+
return {
|
|
32
|
+
id: `s${firstNumber + index}`,
|
|
33
|
+
clip,
|
|
34
|
+
start: group[0].start,
|
|
35
|
+
end: last.end,
|
|
36
|
+
text: group.map((word) => word.text.trim()).join(" "),
|
|
37
|
+
words: group,
|
|
38
|
+
isComplete: ENDS_SENTENCE.test(last.text.trim()) && !ENDS_CUT_OFF.test(last.text.trim()),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** The sentences of every talking clip, numbered across the film in clip order. */
|
|
43
|
+
export function splitFilmSentences(clips) {
|
|
44
|
+
const sentences = [];
|
|
45
|
+
for (const clip of clips) {
|
|
46
|
+
if (clip.role !== "talk")
|
|
47
|
+
continue;
|
|
48
|
+
sentences.push(...splitSentences(clip.words, clip.id, sentences.length + 1));
|
|
49
|
+
}
|
|
50
|
+
return sentences;
|
|
51
|
+
}
|
|
52
|
+
function getTokens(sentence) {
|
|
53
|
+
return sentence.words.map((word) => normalizeWord(word.text)).filter((token) => token.length > 0);
|
|
54
|
+
}
|
|
55
|
+
/** The length of the longest common subsequence of two token lists. */
|
|
56
|
+
function getCommonLength(a, b) {
|
|
57
|
+
let previous = new Array(b.length + 1).fill(0);
|
|
58
|
+
for (const token of a) {
|
|
59
|
+
const row = [0];
|
|
60
|
+
b.forEach((other, j) => row.push(token === other ? (previous[j] ?? 0) + 1 : Math.max(previous[j + 1] ?? 0, row[j] ?? 0)));
|
|
61
|
+
previous = row;
|
|
62
|
+
}
|
|
63
|
+
return previous[b.length] ?? 0;
|
|
64
|
+
}
|
|
65
|
+
function isPrefix(short, long) {
|
|
66
|
+
return short.length > 0 && short.length < long.length && short.every((token, index) => long[index] === token);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sentences an editor would likely drop, each with the reason. Within one clip, a sentence is compared with the next
|
|
70
|
+
* three: a `false-start` when its words begin a later sentence, a `retake` when 60 % or more of the longer one's words
|
|
71
|
+
* match in order (the later take is kept). Otherwise a sentence that ends in a dash or an ellipsis, or ends its clip
|
|
72
|
+
* without a full stop, is `cut-off`.
|
|
73
|
+
*/
|
|
74
|
+
export function findRetakes(sentences) {
|
|
75
|
+
const suggestions = [];
|
|
76
|
+
sentences.forEach((sentence, index) => {
|
|
77
|
+
const tokens = getTokens(sentence);
|
|
78
|
+
const later = sentences.slice(index + 1, index + 1 + RETAKE_WINDOW).filter((other) => other.clip === sentence.clip);
|
|
79
|
+
for (const other of later) {
|
|
80
|
+
const otherTokens = getTokens(other);
|
|
81
|
+
if (isPrefix(tokens, otherTokens)) {
|
|
82
|
+
suggestions.push({ sentence: sentence.id, kind: "false-start", of: other.id, reason: `${other.id} starts with the same words and finishes the sentence` });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const longest = Math.max(tokens.length, otherTokens.length);
|
|
86
|
+
const similarity = longest === 0 ? 0 : getCommonLength(tokens, otherTokens) / longest;
|
|
87
|
+
if (tokens.length > 0 && similarity >= RETAKE_SIMILARITY) {
|
|
88
|
+
suggestions.push({ sentence: sentence.id, kind: "retake", of: other.id, reason: `${other.id} says it again (${Math.round(similarity * 100)} % of the words); the later take is kept` });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const last = sentence.words.at(-1)?.text.trim() ?? "";
|
|
93
|
+
const next = sentences[index + 1];
|
|
94
|
+
const isLastOfClip = next === undefined || next.clip !== sentence.clip;
|
|
95
|
+
if (ENDS_CUT_OFF.test(last))
|
|
96
|
+
suggestions.push({ sentence: sentence.id, kind: "cut-off", reason: "it breaks off mid-sentence" });
|
|
97
|
+
else if (!sentence.isComplete && isLastOfClip)
|
|
98
|
+
suggestions.push({ sentence: sentence.id, kind: "cut-off", reason: "the clip ends before the sentence does" });
|
|
99
|
+
});
|
|
100
|
+
return suggestions;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=sentences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentences.js","sourceRoot":"","sources":["../../src/footage/sentences.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiC3C,oEAAoE;AACpE,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,wDAAwD;AACxD,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,4GAA4G;AAC5G,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,MAAM,aAAa,GAAG,oBAAoB,CAA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AI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAClC,MAAM,YAAY,GAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC;QACvE,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,WAAW,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAAC,CAAC;aAC3H,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,YAAY;YAAE,WAAW,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,wCAAwC,EAAE,CAAC,CAAC;IAChK,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machine check before a footage run, so a worker image without the HEVC decoder or `zscale` fails at start
|
|
3
|
+
* instead of inside the first HDR iPhone clip's normalize. Nothing here downloads anything.
|
|
4
|
+
*/
|
|
5
|
+
export interface FootageToolsOptions {
|
|
6
|
+
/** Check hyperframes and its browser too (a run that renders); true by default. */
|
|
7
|
+
needsRender?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Accept a machine without hyperframes' browser, which its first render downloads (a developer's machine); a
|
|
10
|
+
* worker image ships the browser, so the default is false.
|
|
11
|
+
*/
|
|
12
|
+
isBrowserDownloadAllowed?: boolean;
|
|
13
|
+
/** The environment the run sees (`HYPERFRAMES_BROWSER_PATH`, `PRODUCER_HEADLESS_SHELL_PATH`, `HOME`). */
|
|
14
|
+
env?: NodeJS.ProcessEnv;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/** What the footage blocks need from ffmpeg: decoders and filters, by the name ffmpeg lists them under. */
|
|
18
|
+
export declare const REQUIRED_DECODERS: readonly ["hevc", "h264"];
|
|
19
|
+
export declare const REQUIRED_FILTERS: readonly ["zscale", "tonemap"];
|
|
20
|
+
/** The names in `ffmpeg -decoders` or `-filters` output: the second column of each listing line. */
|
|
21
|
+
export declare function readFfmpegListing(output: string): Set<string>;
|
|
22
|
+
/**
|
|
23
|
+
* The browser hyperframes renders with, resolved as hyperframes 0.8 does: `PRODUCER_HEADLESS_SHELL_PATH`, then
|
|
24
|
+
* `HYPERFRAMES_BROWSER_PATH`, then its own and puppeteer's cache of chrome-headless-shell. A problem when none is there.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findBrowserProblem(env: NodeJS.ProcessEnv): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Checks the machine for a footage run: ffmpeg and ffprobe run, ffmpeg decodes HEVC and H.264 and has `zscale` and
|
|
29
|
+
* `tonemap` (HDR clips), and, for a render, hyperframes runs and has its browser. Returns every problem found; an
|
|
30
|
+
* empty list means the machine is ready.
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkFootageTools(options?: FootageToolsOptions): Promise<string[]>;
|
|
33
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/footage/tools.ts"],"names":[],"mappings":"AAOA;;;GAGG;AAEH,MAAM,WAAW,mBAAmB;IAClC,mFAAmF;IACnF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,yGAAyG;IACzG,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,2GAA2G;AAC3G,eAAO,MAAM,iBAAiB,2BAA4B,CAAC;AAC3D,eAAO,MAAM,gBAAgB,gCAAiC,CAAC;AAI/D,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAO7D;AA4BD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAUxE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA8B5F"}
|