@softure-ai/marketing-kit 0.6.0 → 0.7.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +64 -8
  3. package/dist/cli/footage.d.ts.map +1 -1
  4. package/dist/cli/footage.js +5 -2
  5. package/dist/cli/footage.js.map +1 -1
  6. package/dist/compose/compose.d.ts.map +1 -1
  7. package/dist/compose/compose.js +3 -3
  8. package/dist/compose/compose.js.map +1 -1
  9. package/dist/compose/timeline.d.ts +16 -0
  10. package/dist/compose/timeline.d.ts.map +1 -1
  11. package/dist/compose/timeline.js +17 -1
  12. package/dist/compose/timeline.js.map +1 -1
  13. package/dist/config/config.d.ts.map +1 -1
  14. package/dist/config/config.js +18 -2
  15. package/dist/config/config.js.map +1 -1
  16. package/dist/config/schema.d.ts +16 -0
  17. package/dist/config/schema.d.ts.map +1 -1
  18. package/dist/config/schema.js +50 -3
  19. package/dist/config/schema.js.map +1 -1
  20. package/dist/footage/captions.d.ts +5 -1
  21. package/dist/footage/captions.d.ts.map +1 -1
  22. package/dist/footage/captions.js +6 -2
  23. package/dist/footage/captions.js.map +1 -1
  24. package/dist/footage/compose.d.ts +13 -2
  25. package/dist/footage/compose.d.ts.map +1 -1
  26. package/dist/footage/compose.js +75 -23
  27. package/dist/footage/compose.js.map +1 -1
  28. package/dist/footage/cuts.d.ts +44 -0
  29. package/dist/footage/cuts.d.ts.map +1 -0
  30. package/dist/footage/cuts.js +83 -0
  31. package/dist/footage/cuts.js.map +1 -0
  32. package/dist/footage/draft.d.ts +17 -3
  33. package/dist/footage/draft.d.ts.map +1 -1
  34. package/dist/footage/draft.js +28 -14
  35. package/dist/footage/draft.js.map +1 -1
  36. package/dist/footage/edl.d.ts +2 -1
  37. package/dist/footage/edl.d.ts.map +1 -1
  38. package/dist/footage/edl.js +5 -2
  39. package/dist/footage/edl.js.map +1 -1
  40. package/dist/footage/film.d.ts +42 -3
  41. package/dist/footage/film.d.ts.map +1 -1
  42. package/dist/footage/film.js +7 -1
  43. package/dist/footage/film.js.map +1 -1
  44. package/dist/footage/loudness.d.ts +20 -3
  45. package/dist/footage/loudness.d.ts.map +1 -1
  46. package/dist/footage/loudness.js +36 -18
  47. package/dist/footage/loudness.js.map +1 -1
  48. package/dist/footage/music.d.ts +3 -0
  49. package/dist/footage/music.d.ts.map +1 -1
  50. package/dist/footage/music.js +5 -0
  51. package/dist/footage/music.js.map +1 -1
  52. package/dist/footage/normalize.d.ts +9 -0
  53. package/dist/footage/normalize.d.ts.map +1 -1
  54. package/dist/footage/normalize.js +8 -4
  55. package/dist/footage/normalize.js.map +1 -1
  56. package/dist/footage/picture.d.ts +42 -0
  57. package/dist/footage/picture.d.ts.map +1 -0
  58. package/dist/footage/picture.js +141 -0
  59. package/dist/footage/picture.js.map +1 -0
  60. package/dist/footage/pipeline.d.ts +46 -1
  61. package/dist/footage/pipeline.d.ts.map +1 -1
  62. package/dist/footage/pipeline.js +128 -19
  63. package/dist/footage/pipeline.js.map +1 -1
  64. package/dist/footage/publish.d.ts +4 -2
  65. package/dist/footage/publish.d.ts.map +1 -1
  66. package/dist/footage/publish.js +8 -5
  67. package/dist/footage/publish.js.map +1 -1
  68. package/dist/footage/render.d.ts +17 -2
  69. package/dist/footage/render.d.ts.map +1 -1
  70. package/dist/footage/render.js +62 -13
  71. package/dist/footage/render.js.map +1 -1
  72. package/dist/index.d.ts +8 -6
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +8 -6
  75. package/dist/index.js.map +1 -1
  76. package/docker/footage-worker.Dockerfile +1 -0
  77. package/package.json +1 -1
  78. package/schema/marketing.schema.json +105 -4
  79. package/src/cli/footage.ts +4 -2
  80. package/src/compose/compose.ts +13 -3
  81. package/src/compose/timeline.ts +27 -1
  82. package/src/config/config.ts +18 -2
  83. package/src/config/schema.ts +52 -3
  84. package/src/footage/captions.ts +6 -2
  85. package/src/footage/compose.ts +86 -23
  86. package/src/footage/cuts.ts +104 -0
  87. package/src/footage/draft.ts +43 -14
  88. package/src/footage/edl.ts +5 -2
  89. package/src/footage/film.ts +47 -4
  90. package/src/footage/loudness.ts +38 -16
  91. package/src/footage/music.ts +7 -0
  92. package/src/footage/normalize.ts +8 -4
  93. package/src/footage/picture.ts +179 -0
  94. package/src/footage/pipeline.ts +166 -22
  95. package/src/footage/publish.ts +8 -5
  96. package/src/footage/render.ts +72 -13
  97. package/src/index.ts +36 -2
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/footage/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhE;;;;;GAKG;AAEH,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAI1C,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAKnI;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,EAAE,CAYpF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,OAAO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EAAE,CAAA;CAAE,CAIjH;AAED,4HAA4H;AAC5H,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,EAAE,CAmDlE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3H"}
@@ -65,12 +65,16 @@ export function buildVideoFilter(options) {
65
65
  /** x264's presets, fastest first. */
66
66
  export const X264_PRESETS = ["ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow"];
67
67
  const DEFAULT_NORMALIZE_PRESET = "veryfast";
68
- /** The thread arguments: global filter threads (before the inputs) and encoder threads (before the output). */
69
- function getThreadArgs(threads) {
68
+ /**
69
+ * The thread arguments: global filter threads (before the inputs) and encoder threads (before the output; the same
70
+ * flag before an input sets that input's decoder threads). Throws, naming `option`, when `threads` is not a positive
71
+ * whole number.
72
+ */
73
+ export function getThreadArgs(threads, option) {
70
74
  if (threads === undefined)
71
75
  return { global: [], output: [] };
72
76
  if (!Number.isInteger(threads) || threads < 1)
73
- throw new Error(`normalize.threads must be a positive whole number, got ${threads}.`);
77
+ throw new Error(`${option} must be a positive whole number, got ${threads}.`);
74
78
  return { global: ["-filter_complex_threads", String(threads)], output: ["-threads", String(threads)] };
75
79
  }
76
80
  /** ffmpeg's arguments for one clip; pure, so the graph is tested without ffmpeg. Throws on an invalid `encoder.threads`. */
@@ -79,7 +83,7 @@ export function buildNormalizeArgs(input) {
79
83
  const duration = getTrimmedDuration(clip, probe);
80
84
  const fit = resolveFit(clip.fit, probe, frame);
81
85
  const seek = clip.trim.start > 0 ? ["-ss", String(clip.trim.start)] : [];
82
- const threads = getThreadArgs(input.encoder?.threads);
86
+ const threads = getThreadArgs(input.encoder?.threads, "normalize.threads");
83
87
  const silence = probe.hasAudio ? [] : ["-f", "lavfi", "-i", `anullsrc=r=${F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AAC,oBAAoB,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,IAAI,GAAG,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;AACxI,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { type Edl } from "./edl.js";
2
+ import { type FootageFilm } from "./film.js";
3
+ import { type NormalizeEncoder } from "./normalize.js";
4
+ /** The outgoing segment's tail under a cross-fade. */
5
+ export interface PictureFadeTail {
6
+ clip: string;
7
+ /** Seconds in the clip: where the outgoing segment ends. */
8
+ start: number;
9
+ frames: number;
10
+ /** The zoom the outgoing segment ends on, held through the fade. */
11
+ scale: number;
12
+ }
13
+ /** One segment's piece of the picture. */
14
+ export interface PicturePiece {
15
+ clip: string;
16
+ /** Seconds in the clip where the piece starts. */
17
+ start: number;
18
+ /** The piece's first film frame. */
19
+ frame: number;
20
+ frames: number;
21
+ /** For a `fade` cut, the outgoing tail the piece dissolves from; null for any other cut. */
22
+ fade: PictureFadeTail | null;
23
+ }
24
+ /** The picture's pieces, one per segment, covering the cut's frames without a gap. Throws on an EDL without segments. */
25
+ export declare function planFootagePicture(film: Pick<FootageFilm, "edit">, edl: Edl): PicturePiece[];
26
+ /** The number of frames the picture has: the cut's length in film frames. */
27
+ export declare function getPictureFrames(pieces: readonly PicturePiece[]): number;
28
+ export interface PicturePieceArgsInput {
29
+ piece: PicturePiece;
30
+ /** The normalized clips by id. */
31
+ clips: Record<string, string>;
32
+ output: string;
33
+ /** The intermediate clips' encoder (`RenderFootageOptions.normalize`): its preset and threads encode the piece too. */
34
+ encoder?: NormalizeEncoder;
35
+ }
36
+ /** One piece's ffmpeg arguments: its clip (and a fade's outgoing tail), exactly `frames` frames, H.264 without sound. */
37
+ export declare function buildPicturePieceArgs(input: PicturePieceArgsInput): string[];
38
+ /** The concat demuxer's list: one `file` line per piece, quotes escaped as the demuxer reads them. */
39
+ export declare function buildPictureList(files: readonly string[]): string;
40
+ /** Joins the pieces by stream copy (they share one encoder's settings) into the picture, fast start. */
41
+ export declare function buildPictureConcatArgs(list: string, output: string): string[];
42
+ //# sourceMappingURL=picture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"picture.d.ts","sourceRoot":"","sources":["../../src/footage/picture.ts"],"names":[],"mappings":"AACA,OAAO,EAAoC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAuBnF,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0CAA0C;AAC1C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,4FAA4F;IAC5F,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;CAC9B;AAOD,yHAAyH;AACzH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,YAAY,EAAE,CAsB5F;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAExE;AAuBD,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,YAAY,CAAC;IACpB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,uHAAuH;IACvH,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,yHAAyH;AACzH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAsD5E;AAED,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEjE;AAED,wGAAwG;AACxG,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7E"}
@@ -0,0 +1,141 @@
1
+ import { getSegmentScales } from "./compose.js";
2
+ import { getEdlDuration, getSegmentStarts } from "./edl.js";
3
+ import { getFootageEdit } from "./film.js";
4
+ import { FOOTAGE_FPS, getThreadArgs } from "./normalize.js";
5
+ /**
6
+ * The cut's picture in film time, which the render's composition plays as one `<video>`: one short ffmpeg per segment
7
+ * (run one after the other, so one decoder at a time) and a stream-copy join. hyperframes then extracts the whole
8
+ * film's frames with one ffmpeg, and its Chrome holds one video instead of one per segment (issue #1030: the
9
+ * extraction peak falls from about 1 GB to 0.2 GB, the capture's from 1.7 GB to 1.1 GB on a 45 s 1080x1920 film).
10
+ *
11
+ * Every piece starts on a film frame and runs to the next segment's frame, so rounding never adds up along the cut.
12
+ * A cross-fade is drawn into the incoming piece: the outgoing segment's tail, held at the zoom it ends on, dissolves
13
+ * into the incoming clip (`xfade`), as the per-segment composition plays it. Zoom cuts and Ken Burns stay tweens on
14
+ * the composition's video.
15
+ */
16
+ /** The point a zoom keeps still, as the composition's `transform-origin: 50% 42%`. */
17
+ const ZOOM_ORIGIN = { x: 0.5, y: 0.42 };
18
+ /** How far a segment marked `kenburns` zooms when the film's `kenBurnsPercent` is 0, as in the composition. */
19
+ const HAND_KEN_BURNS_PERCENT = 4;
20
+ const PICTURE_CRF = 18;
21
+ const DEFAULT_PICTURE_PRESET = "veryfast";
22
+ const r3 = (value) => Math.round(value * 1000) / 1000 || 0;
23
+ /** The film frame a film second falls on. */
24
+ function toFrame(seconds) {
25
+ return Math.round(seconds * FOOTAGE_FPS);
26
+ }
27
+ /** The picture's pieces, one per segment, covering the cut's frames without a gap. Throws on an EDL without segments. */
28
+ export function planFootagePicture(film, edl) {
29
+ if (edl.segments.length === 0)
30
+ throw new Error("The EDL has no segments.");
31
+ const edit = getFootageEdit(film);
32
+ const kenBurnsScale = 1 + (edit.kenBurnsPercent > 0 ? edit.kenBurnsPercent : HAND_KEN_BURNS_PERCENT) / 100;
33
+ const scales = getSegmentScales(edl, edit.zoomPercent);
34
+ const starts = getSegmentStarts(edl);
35
+ const lastFrame = toFrame(getEdlDuration(edl));
36
+ return edl.segments.map((segment, index) => {
37
+ const frame = toFrame(starts[index]);
38
+ const nextStart = starts[index + 1];
39
+ const frames = Math.max(1, (nextStart === undefined ? lastFrame : toFrame(nextStart)) - frame);
40
+ const previous = edl.segments[index - 1];
41
+ const fadeFrames = segment.transition === "fade" ? Math.min(frames, edit.fadeFrames) : 0;
42
+ let fade = null;
43
+ if (previous !== undefined && fadeFrames > 0) {
44
+ const previousScale = scales[index - 1];
45
+ // The outgoing segment's Ken Burns tween ends at its end; its tail holds the zoom it reached.
46
+ const scale = previous.motion === "kenburns" ? Math.round(previousScale * kenBurnsScale * 10000) / 10000 : previousScale;
47
+ fade = { clip: previous.clip, start: r3(previous.end), frames: fadeFrames, scale };
48
+ }
49
+ return { clip: segment.clip, start: r3(segment.start), frame, frames, fade };
50
+ });
51
+ }
52
+ /** The number of frames the picture has: the cut's length in film frames. */
53
+ export function getPictureFrames(pieces) {
54
+ return pieces.reduce((sum, piece) => sum + piece.frames, 0);
55
+ }
56
+ /** Filters that bring a stream to the film's rate and pixel format and exactly `frames` long (a short clip holds its last frame). */
57
+ function fitStream(frames) {
58
+ const seconds = r3(frames / FOOTAGE_FPS);
59
+ return [
60
+ "setpts=PTS-STARTPTS",
61
+ `fps=${FOOTAGE_FPS}`,
62
+ "format=yuv420p",
63
+ "setsar=1",
64
+ `tpad=stop_mode=clone:stop_duration=${seconds}`,
65
+ `trim=end_frame=${frames}`,
66
+ "setpts=PTS-STARTPTS",
67
+ `settb=1/${FOOTAGE_FPS}`,
68
+ ];
69
+ }
70
+ /** A crop to `scale` about the zoom origin and back to the clip's size; nothing at scale 1. */
71
+ function zoomFilters(scale) {
72
+ if (scale === 1)
73
+ return [];
74
+ return [`crop=iw/${scale}:ih/${scale}:(iw-iw/${scale})*${ZOOM_ORIGIN.x}:(ih-ih/${scale})*${ZOOM_ORIGIN.y}`, `scale=iw*${scale}:ih*${scale}`];
75
+ }
76
+ /** One piece's ffmpeg arguments: its clip (and a fade's outgoing tail), exactly `frames` frames, H.264 without sound. */
77
+ export function buildPicturePieceArgs(input) {
78
+ const { piece, clips } = input;
79
+ const getClip = (id) => {
80
+ const file = clips[id];
81
+ if (file === undefined)
82
+ throw new Error(`No file for clip "${id}" of the EDL.`);
83
+ return file;
84
+ };
85
+ const threads = getThreadArgs(input.encoder?.threads, "normalize.threads");
86
+ const seconds = (frames) => String(r3(frames / FOOTAGE_FPS + 1 / FOOTAGE_FPS));
87
+ const inputs = [...threads.output, "-ss", String(piece.start), "-t", seconds(piece.frames), "-i", getClip(piece.clip)];
88
+ let graph = `[0:v]${fitStream(piece.frames).join(",")}[picture]`;
89
+ if (piece.fade !== null) {
90
+ const { fade } = piece;
91
+ inputs.push(...threads.output, "-ss", String(fade.start), "-t", seconds(fade.frames), "-i", getClip(fade.clip));
92
+ const tail = [...zoomFilters(fade.scale), ...fitStream(fade.frames)];
93
+ graph = [
94
+ `[0:v]${fitStream(piece.frames).join(",")}[incoming]`,
95
+ `[1:v]${tail.join(",")}[outgoing]`,
96
+ // xfade's output is the outgoing tail plus the incoming piece minus the fade: the piece's own length.
97
+ `[outgoing][incoming]xfade=transition=fade:duration=${r3(fade.frames / FOOTAGE_FPS)}:offset=0,trim=end_frame=${piece.frames}[picture]`,
98
+ ].join(";");
99
+ }
100
+ return [
101
+ "-v",
102
+ "error",
103
+ "-y",
104
+ ...threads.global,
105
+ ...inputs,
106
+ "-filter_complex",
107
+ graph,
108
+ "-map",
109
+ "[picture]",
110
+ "-an",
111
+ "-frames:v",
112
+ String(piece.frames),
113
+ "-c:v",
114
+ "libx264",
115
+ "-preset",
116
+ input.encoder?.preset ?? DEFAULT_PICTURE_PRESET,
117
+ "-crf",
118
+ String(PICTURE_CRF),
119
+ "-g",
120
+ String(FOOTAGE_FPS / 2),
121
+ "-pix_fmt",
122
+ "yuv420p",
123
+ "-color_primaries",
124
+ "bt709",
125
+ "-color_trc",
126
+ "bt709",
127
+ "-colorspace",
128
+ "bt709",
129
+ ...threads.output,
130
+ input.output,
131
+ ];
132
+ }
133
+ /** The concat demuxer's list: one `file` line per piece, quotes escaped as the demuxer reads them. */
134
+ export function buildPictureList(files) {
135
+ return `${files.map((file) => `file '${file.replace(/'/g, "'\\''")}'`).join("\n")}\n`;
136
+ }
137
+ /** Joins the pieces by stream copy (they share one encoder's settings) into the picture, fast start. */
138
+ export function buildPictureConcatArgs(list, output) {
139
+ return ["-v", "error", "-y", "-f", "concat", "-safe", "0", "-i", list, "-c", "copy", "-movflags", "+faststart", output];
140
+ }
141
+ //# sourceMappingURL=picture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"picture.js","sourceRoot":"","sources":["../../src/footage/picture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAY,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,cAAc,EAAoB,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAyB,MAAM,gBAAgB,CAAC;AAEnF;;;;;;;;;;GAUG;AAEH,sFAAsF;AACtF,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAW,CAAC;AACjD,+GAA+G;AAC/G,MAAM,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QACjB,KAAK;QACL,MAAM;QACN,WAAW;QACX,KAAK;QACL,WAAW;QACX,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;QACpB,MAAM;QACN,SAAS;QACT,SAAS;QACT,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,sBAAsB;QAC/C,MAAM;QACN,MAAM,CAAC,WAAW,CAAC;QACnB,IAAI;QACJ,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC;QACvB,UAAU;QACV,SAAS;QACT,kBAAkB;QAClB,OAAO;QACP,YAAY;QACZ,OAAO;QACP,aAAa;QACb,OAAO;QACP,GAAG,OAAO,CAAC,MAAM;QACjB,KAAK,CAAC,MAAM;KACb,CAAC;AACJ,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,gBAAgB,CAAC,KAAwB;IACvD,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACxF,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,MAAc;IACjE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AAC1H,CAAC"}
@@ -6,6 +6,7 @@ import { type TtsResult } from "../voice/provider.js";
6
6
  import type { TimedWord } from "../voice/voiceover.js";
7
7
  import { type FreeBytesReader } from "./disk.js";
8
8
  import { type Edl } from "./edl.js";
9
+ import { type CutMeasure } from "./cuts.js";
9
10
  import { type FootageClip, type FootageFilm } from "./film.js";
10
11
  import { type Frame, type NormalizeEncoder } from "./normalize.js";
11
12
  import { type FootageProbe } from "./probe.js";
@@ -80,10 +81,32 @@ export declare function getMusicPaidStep(film: FootageFilm, options: Pick<Footag
80
81
  export declare function transcribeFootage(film: FootageFilm, clips: PreparedClip[], options: FootageRunOptions): Promise<FootageResult<TranscribeOutcome>>;
81
82
  /** The talking clips' sentences with their ids (`s1`…), as `buildEdl` names them, for choosing what to keep. */
82
83
  export declare function getFootageSentences(clips: PreparedClip[], words: Record<string, TimedWord[]>): Sentence[];
83
- /** The cut from the transcripts, written to the EDL file (replacing what is there); `keepSentences` keeps only those sentences. */
84
+ /**
85
+ * The cut from the transcripts, written to the EDL file (replacing what is there); `keepSentences` keeps only those
86
+ * sentences. Sync, so it never looks at the frames: with `transitions.jump: "auto"` the jump cuts stay plain cuts, and
87
+ * `cutFootageFilm` is the step that chooses them.
88
+ */
84
89
  export declare function cutFootage(film: FootageFilm, clips: PreparedClip[], words: Record<string, TimedWord[]>, edlPath: string, options?: {
85
90
  keepSentences?: readonly string[];
86
91
  }): Edl;
92
+ export interface CutFootageFilmOptions {
93
+ /** The sentence ids to keep; absent keeps all. */
94
+ keepSentences?: readonly string[];
95
+ signal?: AbortSignal;
96
+ }
97
+ /** The file next to the EDL that records what the auto transitions measured. */
98
+ export declare const CUTS_FILE = "cuts.json";
99
+ /**
100
+ * The cut as `cutFootage` builds it, with `transitions.jump: "auto"` resolved from the frames of the normalized clips
101
+ * (`chooseCutTransitions`): each jump cut gets `zoom` or `fade`, and what it measured is answered and written to
102
+ * `cuts.json` next to the EDL, so an app or an agent sees why. Otherwise the same as `cutFootage`, and `cuts` is empty.
103
+ */
104
+ export declare function cutFootageFilm(film: FootageFilm, clips: PreparedClip[], words: Record<string, TimedWord[]>, edlPath: string, options?: CutFootageFilmOptions): Promise<{
105
+ edl: Edl;
106
+ cuts: CutMeasure[];
107
+ }>;
108
+ /** One line per auto-chosen cut, for a log: `s4: zoom (difference 0.031)`. */
109
+ export declare function describeCutMeasures(cuts: CutMeasure[]): string[];
87
110
  /** The EDL file as written by `cutFootage` or edited by hand, checked against the clips. */
88
111
  export declare function readEdlFile(film: FootageFilm, clips: PreparedClip[], edlPath: string): FootageResult<Edl>;
89
112
  export interface RenderFootageOptions extends FootageRunOptions {
@@ -102,6 +125,16 @@ export interface RenderFootageOptions extends FootageRunOptions {
102
125
  tempDir?: string;
103
126
  /** Reads a folder's free bytes for the disk check; injected in tests. */
104
127
  readFreeBytes?: FreeBytesReader;
128
+ /**
129
+ * hyperframes' capture workers (`--workers`), each a Chrome of its own; by default hyperframes' choice (one in its
130
+ * low-memory profile). A positive whole number.
131
+ */
132
+ workers?: number;
133
+ /**
134
+ * hyperframes' low-memory profile (`--low-memory-mode`: one worker, screenshot capture): true forces it on, false
135
+ * off; by default hyperframes turns it on by itself on a machine (or cgroup) of 8 GB or less.
136
+ */
137
+ lowMemory?: boolean;
105
138
  }
106
139
  export type RenderedFootage = {
107
140
  kind: "dry-run";
@@ -130,8 +163,20 @@ export interface FinishedFootage {
130
163
  /** The cover JPG, or null when the film has none. */
131
164
  cover: string | null;
132
165
  }
166
+ /**
167
+ * The final pass over hyperframes' render: the mix normalized to `film.mixLoudness` (measured on the render, one
168
+ * linear gain; the picture still copied), publishable codecs and fast start (stream copy where the render already
169
+ * matches), checked with ffprobe, then the cover and the file's facts. Exported for tests only.
170
+ */
171
+ export declare function finishFootage(film: Pick<FootageFilm, "mixLoudness" | "cover">, input: {
172
+ renderFile: string;
173
+ seconds: number;
174
+ coverAt: number;
175
+ }, options: Pick<RenderFootageOptions, "log" | "signal" | "output" | "onProgress">): Promise<FootageResult<FinishedFootage>>;
133
176
  /** hyperframes' progress lines carry a percentage (`… 42%`); the last one on a line counts. */
134
177
  export declare function readRenderPercent(line: string): number | null;
178
+ /** hyperframes' render arguments: the quality, the output and the memory settings the caller set. Throws on invalid `workers`. */
179
+ export declare function getHyperframesRenderArgs(options: Pick<RenderFootageOptions, "quality" | "workers" | "lowMemory">, output: string): string[];
135
180
  export interface RenderFootageFilmOptions extends RenderFootageOptions {
136
181
  /** Build the EDL again even when the build folder holds one (by default a present EDL, maybe edited by hand, is used). */
137
182
  isRecut?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/footage/pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAuD,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACtG,OAAO,EAA8C,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,EAAkB,KAAK,WAAW,EAAE,KAAK,WAAW,EAAoB,MAAM,WAAW,CAAC;AAIjG,OAAO,EAAoB,KAAK,KAAK,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAmD,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAahG,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAanE,OAAO,EAAkC,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAqC,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGnL,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAyBvC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE;QAAE,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;QAA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AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,OAAO,CAAC,EAChD,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC/D,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAC,GAC9E,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAwCzC;AAED,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D;AAED,kIAAkI;AAClI,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ3I;AA+ED,MAAM,WAAW,wBAAyB,SAAQ,oBAAoB;IACpE,0HAA0H;IAC1H,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gHAAgH;IAChH,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAuBrI"}
@@ -10,20 +10,22 @@ import { readCachedTranscript, writeCacheFile, writeTranscript } from "./cache.j
10
10
  import { composeFootage, END_CARD_SECONDS, getFootageFilmSeconds } from "./compose.js";
11
11
  import { findMissingCaptionGlyphs, getFootageCaptionLayout } from "./captions.js";
12
12
  import { findLowDiskProblems, getFreeBytes, getRenderTempDir } from "./disk.js";
13
- import { buildEdl, readEdl, remapWords, validateEdl } from "./edl.js";
13
+ import { buildEdl, getEdlDuration, readEdl, remapWords, validateEdl } from "./edl.js";
14
14
  import { makePlaceholderTranscript } from "./fake.js";
15
- import { getFootageEdit } from "./film.js";
15
+ import { chooseCutTransitions } from "./cuts.js";
16
+ import { DEFAULT_AUTO_THRESHOLD, getFootageEdit } from "./film.js";
16
17
  import { getFilmKeyTerms } from "./keyterms.js";
17
- import { DEFAULT_LOUDNESS, normalizeLoudness } from "./loudness.js";
18
- import { duckingKeyframes } from "./music.js";
19
- import { normalizeFootage } from "./normalize.js";
18
+ import { DEFAULT_LOUDNESS, getLoudnessFilter, measureLoudness, normalizeLoudness } from "./loudness.js";
19
+ import { duckingKeyframes, getDuckingOptions } from "./music.js";
20
+ import { FOOTAGE_FPS, normalizeFootage } from "./normalize.js";
21
+ import { buildPictureConcatArgs, buildPictureList, buildPicturePieceArgs, getPictureFrames, planFootagePicture } from "./picture.js";
20
22
  import { describeProbe, getTrimmedDuration, probeFootage } from "./probe.js";
21
23
  import { getClipCacheKey, getDownloadPath, getEdlPath, getIsolatedCache, getPromptMusicCache, getTranscriptCache, getVideoMusicCache, isUrl, } from "./paid.js";
22
24
  import { runFfmpeg, runProcess } from "./process.js";
23
25
  import { splitFilmSentences } from "./sentences.js";
24
26
  import { buildCoverArgs, buildFinishArgs, clampCoverSeconds, findFinishProblems, getCoverPath, getDefaultCoverSeconds, isPublishableAudio, isPublishableVideo, probeFilmFacts, readTopLevelBoxes, } from "./publish.js";
25
27
  import { describePaidSteps, toPaidAudio } from "./providers.js";
26
- import { buildAudioArgs, buildCutPreviewArgs, buildLastFrameArgs, buildMusicArgs, buildSpeechArgs } from "./render.js";
28
+ import { buildAudioArgs, buildCutPreviewArgs, buildLastFrameArgs, buildMusicArgs, buildSpeechArgs, getSpeechCutOptions } from "./render.js";
27
29
  export { getEdlPath } from "./paid.js";
28
30
  /**
29
31
  * The footage film end to end, as standalone steps (`prepareFootage` → `transcribeFootage` → `cutFootage` →
@@ -282,13 +284,53 @@ export async function transcribeFootage(film, clips, options) {
282
284
  export function getFootageSentences(clips, words) {
283
285
  return splitFilmSentences(clips.map((clip) => ({ id: clip.clip.id, role: clip.clip.role, words: words[clip.clip.id] ?? [] })));
284
286
  }
285
- /** The cut from the transcripts, written to the EDL file (replacing what is there); `keepSentences` keeps only those sentences. */
286
- export function cutFootage(film, clips, words, edlPath, options = {}) {
287
- const edl = buildEdl(film.id, clips.map((clip) => ({ id: clip.clip.id, role: clip.clip.role, duration: clip.duration, words: words[clip.clip.id] ?? [] })), film.cut, film.transitions, { isKenBurns: getFootageEdit(film).kenBurnsPercent > 0, ...(options.keepSentences === undefined ? {} : { keepSentences: options.keepSentences }) });
287
+ function buildFilmEdl(film, clips, words, keepSentences) {
288
+ return buildEdl(film.id, clips.map((clip) => ({ id: clip.clip.id, role: clip.clip.role, duration: clip.duration, words: words[clip.clip.id] ?? [] })), film.cut, film.transitions, { isKenBurns: getFootageEdit(film).kenBurnsPercent > 0, ...(keepSentences === undefined ? {} : { keepSentences }) });
289
+ }
290
+ function writeEdl(edl, edlPath) {
288
291
  mkdirSync(dirname(edlPath), { recursive: true });
289
292
  writeFileSync(edlPath, `${JSON.stringify(edl, null, 2)}\n`);
293
+ }
294
+ /**
295
+ * The cut from the transcripts, written to the EDL file (replacing what is there); `keepSentences` keeps only those
296
+ * sentences. Sync, so it never looks at the frames: with `transitions.jump: "auto"` the jump cuts stay plain cuts, and
297
+ * `cutFootageFilm` is the step that chooses them.
298
+ */
299
+ export function cutFootage(film, clips, words, edlPath, options = {}) {
300
+ const edl = buildFilmEdl(film, clips, words, options.keepSentences);
301
+ writeEdl(edl, edlPath);
290
302
  return edl;
291
303
  }
304
+ /** The file next to the EDL that records what the auto transitions measured. */
305
+ export const CUTS_FILE = "cuts.json";
306
+ /**
307
+ * The cut as `cutFootage` builds it, with `transitions.jump: "auto"` resolved from the frames of the normalized clips
308
+ * (`chooseCutTransitions`): each jump cut gets `zoom` or `fade`, and what it measured is answered and written to
309
+ * `cuts.json` next to the EDL, so an app or an agent sees why. Otherwise the same as `cutFootage`, and `cuts` is empty.
310
+ */
311
+ export async function cutFootageFilm(film, clips, words, edlPath, options = {}) {
312
+ let edl = buildFilmEdl(film, clips, words, options.keepSentences);
313
+ let cuts = [];
314
+ const cutsPath = join(dirname(edlPath), CUTS_FILE);
315
+ rmSync(cutsPath, { force: true });
316
+ if (film.transitions.jump === "auto") {
317
+ const chosen = await chooseCutTransitions(edl, Object.fromEntries(clips.map((clip) => [clip.clip.id, clip.file])), {
318
+ workDir: join(dirname(edlPath), "cut-frames"),
319
+ ...(film.transitions.autoThreshold === undefined ? {} : { threshold: film.transitions.autoThreshold }),
320
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
321
+ });
322
+ edl = chosen.edl;
323
+ cuts = chosen.cuts;
324
+ mkdirSync(dirname(cutsPath), { recursive: true });
325
+ writeFileSync(cutsPath, `${JSON.stringify({ threshold: film.transitions.autoThreshold ?? DEFAULT_AUTO_THRESHOLD, cuts }, null, 2)}\n`);
326
+ }
327
+ writeEdl(edl, edlPath);
328
+ return { edl, cuts };
329
+ }
330
+ /** One line per auto-chosen cut, for a log: `s4: zoom (difference 0.031)`. */
331
+ export function describeCutMeasures(cuts) {
332
+ return cuts.map((cut) => `${cut.segment}: ${cut.transition} (difference ${cut.difference.toFixed(3)})`);
333
+ }
292
334
  /** The EDL file as written by `cutFootage` or edited by hand, checked against the clips. */
293
335
  export function readEdlFile(film, clips, edlPath) {
294
336
  let json;
@@ -419,7 +461,7 @@ export async function renderFootage(film, clips, transcript, edl, options) {
419
461
  const rawSpeechFile = loudness === null ? speechFile : join(assetsDir, "speech.raw.mp3");
420
462
  const ffmpegTrack = (label, output, args) => (onSeconds) => runFfmpeg(label, args(), { ...aborting, output, onSeconds });
421
463
  const tracks = [
422
- { item: "speech", seconds, run: ffmpegTrack("The speech track", rawSpeechFile, () => buildSpeechArgs(edl, transcript.speech, rawSpeechFile)) },
464
+ { item: "speech", seconds, run: ffmpegTrack("The speech track", rawSpeechFile, () => buildSpeechArgs(edl, transcript.speech, rawSpeechFile, getSpeechCutOptions(getFootageEdit(film)))) },
423
465
  ];
424
466
  if (loudness !== null) {
425
467
  tracks.push({
@@ -434,13 +476,21 @@ export async function renderFootage(film, clips, transcript, edl, options) {
434
476
  });
435
477
  }
436
478
  if (musicFile !== null) {
437
- const keyframes = duckingKeyframes(words, { volume: film.music.volume, duckedVolume: film.music.duckedVolume });
479
+ const keyframes = duckingKeyframes(words, getDuckingOptions(film.music));
438
480
  const output = join(assetsDir, "music.mp3");
439
481
  tracks.push({ item: "music", seconds, run: ffmpegTrack("The music track", output, () => buildMusicArgs({ input: musicFile, seconds, keyframes, output })) });
440
482
  }
441
483
  // A single frame: counted as a moment of work so the stage's bar still ends at its total.
442
484
  const lastFrame = join(assetsDir, "last.jpg");
443
485
  tracks.push({ item: "last frame", seconds: 0.1, run: ffmpegTrack("The end card's backdrop", lastFrame, () => buildLastFrameArgs(edl, clipFiles, lastFrame)) });
486
+ // The cut's picture in film time, one segment after the other: the composition plays it as one <video> (#1030).
487
+ const pictureFile = join(assetsDir, "picture.mp4");
488
+ const pictureSeconds = getEdlDuration(edl);
489
+ tracks.push({
490
+ item: "picture",
491
+ seconds: pictureSeconds,
492
+ run: (onSeconds) => buildPicture({ film, edl, clips: clipFiles, output: pictureFile, ...(options.normalize === undefined ? {} : { encoder: options.normalize }), ...aborting, onSeconds }),
493
+ });
444
494
  const assetProgress = createStageProgress(options.onProgress, "assets", tracks);
445
495
  for (const [index, track] of tracks.entries()) {
446
496
  assetProgress(index, 0);
@@ -482,6 +532,7 @@ export async function renderFootage(film, clips, transcript, edl, options) {
482
532
  fonts,
483
533
  assets: {
484
534
  clips: Object.fromEntries(clips.map((clip) => [clip.clip.id, `clips/${clip.clip.id}.mp4`])),
535
+ picture: "assets/picture.mp4",
485
536
  speech: "assets/speech.mp3",
486
537
  music: musicAsset,
487
538
  lastFrame: "assets/last.jpg",
@@ -505,10 +556,11 @@ export async function renderFootage(film, clips, transcript, edl, options) {
505
556
  return ok({ kind: "rendered", output: options.output, seconds, edlPath: getEdlPath(buildDir, options.isPlaceholder), ...finished.value });
506
557
  }
507
558
  /**
508
- * The final pass over hyperframes' render: publishable codecs and fast start (stream copy where the render already
509
- * matches), checked with ffprobe, then the cover and the file's facts.
559
+ * The final pass over hyperframes' render: the mix normalized to `film.mixLoudness` (measured on the render, one
560
+ * linear gain; the picture still copied), publishable codecs and fast start (stream copy where the render already
561
+ * matches), checked with ffprobe, then the cover and the file's facts. Exported for tests only.
510
562
  */
511
- async function finishFootage(film, input, options) {
563
+ export async function finishFootage(film, input, options) {
512
564
  const { log, signal, output } = options;
513
565
  const aborting = signal === undefined ? {} : { signal };
514
566
  const progress = createStageProgress(options.onProgress, "finish", [{ item: "film", seconds: input.seconds }]);
@@ -516,8 +568,22 @@ async function finishFootage(film, input, options) {
516
568
  const rendered = await probeFilmFacts(input.renderFile, aborting);
517
569
  if (!rendered.ok)
518
570
  return err(`the rendered film: ${rendered.error}`);
519
- const isCopied = isPublishableVideo(rendered.facts.video) && (rendered.facts.audio === null || isPublishableAudio(rendered.facts.audio));
520
- await runFfmpeg("The film's final pass", buildFinishArgs(input.renderFile, rendered.facts, output), { ...aborting, output, onSeconds: (done) => progress(0, done) });
571
+ const mixLoudness = film.mixLoudness === undefined ? DEFAULT_LOUDNESS : film.mixLoudness;
572
+ let audioFilter;
573
+ if (mixLoudness !== null && rendered.facts.audio !== null) {
574
+ const measured = await measureLoudness(input.renderFile, mixLoudness, { label: "the film's mix", ...aborting });
575
+ if (measured.kind === "silent") {
576
+ log("loudness: the film's mix is silent, left as it is.");
577
+ }
578
+ else {
579
+ audioFilter = getLoudnessFilter(measured.measurement, mixLoudness);
580
+ log(`loudness: the film's mix measured ${measured.measurement.inputI.toFixed(1)} LUFS, normalized to ${mixLoudness.target} LUFS (true peak ${mixLoudness.truePeak} dBTP).`);
581
+ }
582
+ }
583
+ const isVideoCopied = isPublishableVideo(rendered.facts.video);
584
+ const isAudioCopied = audioFilter === undefined && (rendered.facts.audio === null || isPublishableAudio(rendered.facts.audio));
585
+ const finishArgs = buildFinishArgs(input.renderFile, rendered.facts, output, audioFilter === undefined ? {} : { audioFilter });
586
+ await runFfmpeg("The film's final pass", finishArgs, { ...aborting, output, onSeconds: (done) => progress(0, done) });
521
587
  rmSync(input.renderFile, { force: true });
522
588
  const finished = await probeFilmFacts(output, aborting);
523
589
  if (!finished.ok)
@@ -527,7 +593,8 @@ async function finishFootage(film, input, options) {
527
593
  return err(`the finished film ${output} is not publishable: ${problems.join("; ")}.`);
528
594
  progress(0, input.seconds);
529
595
  const { bytes, width, height, durationSeconds } = finished.facts;
530
- log(`finish: ${isCopied ? "streams copied" : "re-encoded"} to H.264 High, AAC 48 kHz stereo, fast start; ${width}×${height}, ${durationSeconds.toFixed(2)} s, ${bytes} bytes.`);
596
+ const streams = isVideoCopied && isAudioCopied ? "streams copied" : isVideoCopied ? "picture copied, sound re-encoded" : "re-encoded";
597
+ log(`finish: ${streams} to H.264 High, AAC 48 kHz stereo, fast start; ${width}×${height}, ${durationSeconds.toFixed(2)} s, ${bytes} bytes.`);
531
598
  let cover = null;
532
599
  if (film.cover !== null) {
533
600
  cover = getCoverPath(output);
@@ -548,6 +615,42 @@ export function readRenderPercent(line) {
548
615
  const percent = Number(last);
549
616
  return percent >= 0 && percent <= 100 ? percent : null;
550
617
  }
618
+ /** hyperframes' render arguments: the quality, the output and the memory settings the caller set. Throws on invalid `workers`. */
619
+ export function getHyperframesRenderArgs(options, output) {
620
+ const args = ["render", "--quality", options.quality];
621
+ if (options.workers !== undefined) {
622
+ if (!Number.isInteger(options.workers) || options.workers < 1)
623
+ throw new Error(`workers must be a positive whole number, got ${options.workers}.`);
624
+ args.push("--workers", String(options.workers));
625
+ }
626
+ if (options.lowMemory !== undefined)
627
+ args.push(options.lowMemory ? "--low-memory-mode" : "--no-low-memory-mode");
628
+ return [...args, "-o", output];
629
+ }
630
+ /** Renders the picture piece by piece (one ffmpeg at a time) and joins the pieces; the pieces are removed after the join. */
631
+ async function buildPicture(input) {
632
+ const pieces = planFootagePicture(input.film, input.edl);
633
+ const dir = join(dirname(input.output), "picture");
634
+ rmSync(dir, { recursive: true, force: true });
635
+ mkdirSync(dir, { recursive: true });
636
+ const aborting = input.signal === undefined ? {} : { signal: input.signal };
637
+ const files = [];
638
+ for (const [index, piece] of pieces.entries()) {
639
+ const file = join(dir, `${String(index).padStart(3, "0")}.mp4`);
640
+ const done = piece.frame / FOOTAGE_FPS;
641
+ await runFfmpeg(`The picture of segment ${index + 1}`, buildPicturePieceArgs({ piece, clips: input.clips, output: file, ...(input.encoder === undefined ? {} : { encoder: input.encoder }) }), {
642
+ ...aborting,
643
+ output: file,
644
+ onSeconds: (seconds) => input.onSeconds(done + seconds),
645
+ });
646
+ files.push(file);
647
+ }
648
+ const list = join(dir, "pieces.txt");
649
+ writeFileSync(list, buildPictureList(files));
650
+ await runFfmpeg("The picture's join", buildPictureConcatArgs(list, input.output), { ...aborting, output: input.output });
651
+ rmSync(dir, { recursive: true, force: true });
652
+ input.onSeconds(getPictureFrames(pieces) / FOOTAGE_FPS);
653
+ }
551
654
  /** The hyperframes render as a child process: its lines go to the log (progress every 10 %), its percentages to `onProgress`. */
552
655
  async function runHyperframesRender(options, output, seconds) {
553
656
  const progress = createStageProgress(options.onProgress, "render", [{ item: "film", seconds }]);
@@ -577,7 +680,7 @@ async function runHyperframesRender(options, output, seconds) {
577
680
  }
578
681
  const result = await runProcess({
579
682
  command: process.execPath,
580
- args: [getHyperframesBin(), "render", "--quality", options.quality, "-o", output],
683
+ args: [getHyperframesBin(), ...getHyperframesRenderArgs(options, output)],
581
684
  cwd: options.buildDir,
582
685
  env,
583
686
  ...(options.signal === undefined ? {} : { signal: options.signal }),
@@ -615,8 +718,14 @@ export async function renderFootageFilm(film, options) {
615
718
  options.log(`cut: ${edlPath} (${edl.segments.length} segments), as it is; softure-marketing footage --step=cut builds it again.`);
616
719
  }
617
720
  else {
618
- edl = cutFootage(film, clips.value, transcript.value.words, edlPath, options.keepSentences === undefined ? {} : { keepSentences: options.keepSentences });
721
+ const cut = await cutFootageFilm(film, clips.value, transcript.value.words, edlPath, {
722
+ ...(options.keepSentences === undefined ? {} : { keepSentences: options.keepSentences }),
723
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
724
+ });
725
+ edl = cut.edl;
619
726
  options.log(`cut: ${edl.segments.length} segments written to ${edlPath}.`);
727
+ for (const line of describeCutMeasures(cut.cuts))
728
+ options.log(` auto transition ${line}`);
620
729
  }
621
730
  return renderFootage(film, clips.value, transcript.value, edl, options);
622
731
  }