@softure-ai/marketing-kit 0.6.0 → 0.8.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 (107) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +90 -11
  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 +27 -7
  53. package/dist/footage/normalize.d.ts.map +1 -1
  54. package/dist/footage/normalize.js +39 -19
  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 +55 -1
  61. package/dist/footage/pipeline.d.ts.map +1 -1
  62. package/dist/footage/pipeline.js +136 -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/footage/tonemap-lut.d.ts +45 -0
  73. package/dist/footage/tonemap-lut.d.ts.map +1 -0
  74. package/dist/footage/tonemap-lut.js +100 -0
  75. package/dist/footage/tonemap-lut.js.map +1 -0
  76. package/dist/footage/tools.d.ts +4 -4
  77. package/dist/footage/tools.d.ts.map +1 -1
  78. package/dist/footage/tools.js +4 -4
  79. package/dist/footage/tools.js.map +1 -1
  80. package/dist/index.d.ts +9 -6
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +9 -6
  83. package/dist/index.js.map +1 -1
  84. package/docker/footage-worker.Dockerfile +1 -0
  85. package/package.json +1 -1
  86. package/schema/marketing.schema.json +105 -4
  87. package/src/cli/footage.ts +4 -2
  88. package/src/compose/compose.ts +13 -3
  89. package/src/compose/timeline.ts +27 -1
  90. package/src/config/config.ts +18 -2
  91. package/src/config/schema.ts +52 -3
  92. package/src/footage/captions.ts +6 -2
  93. package/src/footage/compose.ts +86 -23
  94. package/src/footage/cuts.ts +104 -0
  95. package/src/footage/draft.ts +43 -14
  96. package/src/footage/edl.ts +5 -2
  97. package/src/footage/film.ts +47 -4
  98. package/src/footage/loudness.ts +38 -16
  99. package/src/footage/music.ts +7 -0
  100. package/src/footage/normalize.ts +47 -22
  101. package/src/footage/picture.ts +179 -0
  102. package/src/footage/pipeline.ts +179 -22
  103. package/src/footage/publish.ts +8 -5
  104. package/src/footage/render.ts +72 -13
  105. package/src/footage/tonemap-lut.ts +109 -0
  106. package/src/footage/tools.ts +4 -4
  107. package/src/index.ts +37 -2
@@ -18,9 +18,9 @@ const measurementSchema = z.looseObject({
18
18
  function getLoudnormFilter(target) {
19
19
  return `loudnorm=I=${target.target}:TP=${target.truePeak}:LRA=${LOUDNESS_RANGE}`;
20
20
  }
21
- /** The first pass: decodes the track, prints the measurement on stderr, writes nothing. */
21
+ /** The first pass: decodes the sound only (a film's picture is skipped), prints the measurement on stderr, writes nothing. */
22
22
  export function buildLoudnessMeasureArgs(input, target) {
23
- return ["-hide_banner", "-nostats", "-i", input, "-af", `${getLoudnormFilter(target)}:print_format=json`, "-f", "null", "-"];
23
+ return ["-hide_banner", "-nostats", "-i", input, "-vn", "-af", `${getLoudnormFilter(target)}:print_format=json`, "-f", "null", "-"];
24
24
  }
25
25
  /** The measurement from the first pass's stderr (its last JSON block); null when there is none or it is incomplete. */
26
26
  export function readLoudnessMeasurement(stderr) {
@@ -42,8 +42,13 @@ export function readLoudnessMeasurement(stderr) {
42
42
  if (!parsed.success)
43
43
  return null;
44
44
  const value = parsed.data;
45
- // `-inf` (silence) reads as -Infinity, which `isSilent` tells apart.
46
- const read = (text) => (text.trim() === "-inf" ? -Infinity : Number(text));
45
+ // Silence prints `-inf` loudness and an `inf` offset; both read as infinities, which `isSilent` tells apart.
46
+ const read = (text) => {
47
+ const trimmed = text.trim();
48
+ if (trimmed === "-inf")
49
+ return -Infinity;
50
+ return trimmed === "inf" || trimmed === "+inf" ? Infinity : Number(trimmed);
51
+ };
47
52
  const measurement = {
48
53
  inputI: read(value.input_i),
49
54
  inputTp: read(value.input_tp),
@@ -57,11 +62,10 @@ export function readLoudnessMeasurement(stderr) {
57
62
  export function isSilent(measurement) {
58
63
  return !Number.isFinite(measurement.inputI) || measurement.inputI < SILENCE_LUFS || !Number.isFinite(measurement.inputThresh);
59
64
  }
60
- /** The second pass: one linear gain from the measurement, resampled back to the film's rate (`loudnorm` runs at 192 kHz). */
61
- export function buildLoudnessArgs(options) {
62
- const { measurement } = options;
65
+ /** The second pass's filter: one linear gain from the measurement, resampled back to the film's rate (`loudnorm` runs at 192 kHz). */
66
+ export function getLoudnessFilter(measurement, target) {
63
67
  const filter = [
64
- getLoudnormFilter(options.target),
68
+ getLoudnormFilter(target),
65
69
  `measured_I=${measurement.inputI}`,
66
70
  `measured_TP=${measurement.inputTp}`,
67
71
  `measured_LRA=${measurement.inputLra}`,
@@ -69,6 +73,10 @@ export function buildLoudnessArgs(options) {
69
73
  `offset=${measurement.targetOffset}`,
70
74
  "linear=true",
71
75
  ].join(":");
76
+ return `${filter},aresample=${FOOTAGE_SAMPLE_RATE}`;
77
+ }
78
+ /** The speech track's second pass, written as an mp3 at the film's rate. */
79
+ export function buildLoudnessArgs(options) {
72
80
  return [
73
81
  "-v",
74
82
  "error",
@@ -76,7 +84,7 @@ export function buildLoudnessArgs(options) {
76
84
  "-i",
77
85
  options.input,
78
86
  "-af",
79
- `${filter},aresample=${FOOTAGE_SAMPLE_RATE}`,
87
+ getLoudnessFilter(options.measurement, options.target),
80
88
  "-ar",
81
89
  String(FOOTAGE_SAMPLE_RATE),
82
90
  "-c:a",
@@ -87,23 +95,33 @@ export function buildLoudnessArgs(options) {
87
95
  ];
88
96
  }
89
97
  /**
90
- * Measures `input` and writes it normalized to `output`; a silent track is copied as it is. Throws naming the step
91
- * when ffmpeg fails, rejects with the signal's reason on abort.
98
+ * The first pass over `input`: its measurement, or silent when no gain can bring it to the target. Throws naming
99
+ * `label` (what is measured) when ffmpeg fails, rejects with the signal's reason on abort.
92
100
  */
93
- export async function normalizeLoudness(input, output, target, options = {}) {
94
- const signal = options.signal === undefined ? {} : { signal: options.signal };
95
- const measured = await runProcess({ command: "ffmpeg", args: buildLoudnessMeasureArgs(input, target), ...signal });
101
+ export async function measureLoudness(input, target, options) {
102
+ const step = `Measuring ${options.label}'s loudness`;
103
+ const measured = await runProcess({ command: "ffmpeg", args: buildLoudnessMeasureArgs(input, target), ...(options.signal === undefined ? {} : { signal: options.signal }) });
96
104
  if (measured.kind === "not-started")
97
- throw new Error(`Measuring the speech track's loudness: ffmpeg did not start (${measured.error}).`);
105
+ throw new Error(`${step}: ffmpeg did not start (${measured.error}).`);
98
106
  if (measured.code !== 0)
99
- throw new Error(`Measuring the speech track's loudness: ffmpeg ended with code ${String(measured.code)}: ${measured.stderr.trim().split("\n").slice(-3).join(" | ")}.`);
107
+ throw new Error(`${step}: ffmpeg ended with code ${String(measured.code)}: ${measured.stderr.trim().split("\n").slice(-3).join(" | ")}.`);
100
108
  const measurement = readLoudnessMeasurement(measured.stderr);
101
109
  if (measurement === null)
102
- throw new Error(`Measuring the speech track's loudness: ffmpeg printed no loudnorm measurement for ${input}.`);
103
- if (isSilent(measurement)) {
110
+ throw new Error(`${step}: ffmpeg printed no loudnorm measurement for ${input}.`);
111
+ return isSilent(measurement) ? { kind: "silent" } : { kind: "measured", measurement };
112
+ }
113
+ /**
114
+ * Measures `input` and writes it normalized to `output`; a silent track is copied as it is. Throws naming the step
115
+ * when ffmpeg fails, rejects with the signal's reason on abort.
116
+ */
117
+ export async function normalizeLoudness(input, output, target, options = {}) {
118
+ const signal = options.signal === undefined ? {} : { signal: options.signal };
119
+ const measured = await measureLoudness(input, target, { label: "the speech track", ...signal });
120
+ if (measured.kind === "silent") {
104
121
  copyFileSync(input, output);
105
122
  return { kind: "silent" };
106
123
  }
124
+ const { measurement } = measured;
107
125
  await runFfmpeg("Normalizing the speech track's loudness", buildLoudnessArgs({ input, measurement, target, output }), {
108
126
  ...signal,
109
127
  output,
@@ -1 +1 @@
1
- {"version":3,"file":"loudness.js","sourceRoot":"","sources":["../../src/footage/loudness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAerD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAmB,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;AAE9E,+GAA+G;AAC/G,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,sEAAsE;AACtE,MAAM,YAAY,GAAG,CAAC,EAAE,CAAC;AAWzB,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;CAC1B,CAAC,CAAC;AAEH,SAAS,iBAAiB,CAAC,MAAsB;IAC/C,OAAO,cAAc,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,QAAQ,QAAQ,cAAc,EAAE,CAAC;AACnF,CAAC;AAED,2FAA2F;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,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAChG,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC/B,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC5B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;IACD,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IACjC,MAAM,SAAS,CAAC,yCAAyC,EAAE,iBAAiB,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE;QACpH,GAAG,MAAM;QACT,MAAM;QACN,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;KAC7E,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC;AAC9D,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { TimedWord } from "../voice/voiceover.js";
2
+ import type { FootageMusic } from "./film.js";
2
3
  /**
3
4
  * Music under the voice: loud between sentences, ducked while someone speaks. The envelope is a list of keyframes
4
5
  * computed from the film's word times; ffmpeg applies it to the music file (`volumeExpression`), so the composition
@@ -18,6 +19,8 @@ export interface DuckingOptions {
18
19
  /** Two words closer than this stay one stretch of speech. */
19
20
  gap?: number;
20
21
  }
22
+ /** A film's music settings as ducking options: its volumes, and its attack and release when it sets them. */
23
+ export declare function getDuckingOptions(music: Pick<FootageMusic, "volume" | "duckedVolume" | "attack" | "release">): DuckingOptions;
21
24
  /** Stretches of speech: the words joined when less than `gap` seconds apart. */
22
25
  export declare function getSpeechSpans(words: TimedWord[], gap: number): {
23
26
  start: number;
@@ -1 +1 @@
1
- {"version":3,"file":"music.d.ts","sourceRoot":"","sources":["../../src/footage/music.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAQhG;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE,CAsB9F;AAID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,MAAM,CAapE"}
1
+ {"version":3,"file":"music.d.ts","sourceRoot":"","sources":["../../src/footage/music.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,6GAA6G;AAC7G,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC,GAAG,cAAc,CAG7H;AAID,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAQhG;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE,CAsB9F;AAID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,MAAM,CAapE"}
@@ -1,3 +1,8 @@
1
+ /** A film's music settings as ducking options: its volumes, and its attack and release when it sets them. */
2
+ export function getDuckingOptions(music) {
3
+ const { volume, duckedVolume, attack, release } = music;
4
+ return { volume, duckedVolume, ...(attack === undefined ? {} : { attack }), ...(release === undefined ? {} : { release }) };
5
+ }
1
6
  const r3 = (value) => Math.round(value * 1000) / 1000 || 0;
2
7
  /** Stretches of speech: the words joined when less than `gap` seconds apart. */
3
8
  export function getSpeechSpans(words, gap) {
@@ -1 +1 @@
1
- {"version":3,"file":"music.js","sourceRoot":"","sources":["../../src/footage/music.ts"],"names":[],"mappings":"AAwBA,MAAM,EAAE,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AAE3E,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAAC,KAAkB,EAA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AC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7H,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC"}
@@ -16,22 +16,26 @@ export interface Frame {
16
16
  /** The fit `auto` resolves to for this picture in this frame. */
17
17
  export declare function resolveFit(fit: ClipFit, probe: Pick<FootageProbe, "displayWidth" | "displayHeight">, frame: Frame): "crop" | "blur";
18
18
  /**
19
- * HDR to SDR BT.709 on the CPU: to linear light (zscale), Hable tone curve, back to BT.709. A Dolby Vision phone
20
- * clip is read through its HLG base layer.
19
+ * HDR to SDR BT.709 on the CPU. A Dolby Vision phone clip is read through its HLG base layer. With `lut` (the file
20
+ * name of the transfer's tone map LUT, `ensureToneMapLut`, in the folder ffmpeg runs in): to 16-bit R'G'B', the LUT
21
+ * to linear BT.709 light, the BT.709 transfer and matrix, about half the cost; colours outside BT.709 are clipped per
22
+ * RGB channel. Without it: to linear light (zscale), the Hable curve in float, back to BT.709, the same curve the LUT
23
+ * is made from; colours outside BT.709 are clamped in YUV.
21
24
  */
22
- export declare function toneMapFilter(hdr: HdrKind | null, transfer: string | null): string[];
25
+ export declare function toneMapFilter(hdr: HdrKind | null, transfer: string | null, lut?: string): string[];
23
26
  /**
24
27
  * The video filter graph from input 0's picture to `[v]`. Every stage runs on as little as it can: frames are
25
28
  * dropped to 30 fps first, then the picture is scaled to the frame (crop: covered and cropped to it; blur: fitted
26
- * inside it), and only then tone-mapped, so the float stages of an HDR clip work on frame-sized pictures instead of
29
+ * inside it), and only then tone-mapped, so the tone map of an HDR clip works on frame-sized pictures instead of
27
30
  * the source's (a 4K phone clip has 4x the pixels of a 1080x1920 frame). The blur's background is made from the
28
- * fitted picture.
31
+ * fitted picture. `toneMapLut` as in `toneMapFilter`.
29
32
  */
30
33
  export declare function buildVideoFilter(options: {
31
34
  fit: "crop" | "blur";
32
35
  frame: Frame;
33
36
  hdr: HdrKind | null;
34
37
  transfer: string | null;
38
+ toneMapLut?: string;
35
39
  }): string;
36
40
  /** x264's presets, fastest first. */
37
41
  export declare const X264_PRESETS: readonly ["ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow"];
@@ -53,12 +57,28 @@ export interface NormalizeInput {
53
57
  frame: Frame;
54
58
  output: string;
55
59
  encoder?: NormalizeEncoder;
60
+ /**
61
+ * The tone map LUT's file name for an HDR clip, resolved in the folder ffmpeg runs in (`toneMapFilter`). Without it
62
+ * `buildNormalizeArgs` uses the float chain; `normalizeFootage` makes the LUT next to the output and uses it.
63
+ */
64
+ toneMapLut?: string;
56
65
  }
66
+ /**
67
+ * The thread arguments: global filter threads (before the inputs) and encoder threads (before the output; the same
68
+ * flag before an input sets that input's decoder threads). Throws, naming `option`, when `threads` is not a positive
69
+ * whole number.
70
+ */
71
+ export declare function getThreadArgs(threads: number | undefined, option: string): {
72
+ global: string[];
73
+ output: string[];
74
+ };
57
75
  /** ffmpeg's arguments for one clip; pure, so the graph is tested without ffmpeg. Throws on an invalid `encoder.threads`. */
58
76
  export declare function buildNormalizeArgs(input: NormalizeInput): string[];
59
77
  /**
60
78
  * Runs ffmpeg for one clip without blocking; throws with the clip's id when it fails (a broken file is not an expected
61
- * outcome here). An abort removes the partial output and rejects with the signal's reason.
79
+ * outcome here). An HDR clip without `toneMapLut` gets its transfer's LUT made once in the output's folder, and ffmpeg
80
+ * runs there so the graph names the LUT without a path. An abort removes the partial output and rejects with the
81
+ * signal's reason.
62
82
  */
63
- export declare function normalizeFootage(input: NormalizeInput, options?: Omit<FfmpegRunOptions, "output">): Promise<void>;
83
+ export declare function normalizeFootage(input: NormalizeInput, options?: Omit<FfmpegRunOptions, "output" | "cwd">): Promise<void>;
64
84
  //# sourceMappingURL=normalize.d.ts.map
@@ -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,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAiBtI;AAED,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;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAIjH;AAED,4HAA4H;AAC5H,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,EAAE,CAmDlE;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,KAAK,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYnI"}
@@ -1,5 +1,7 @@
1
+ import { dirname, resolve } from "node:path";
1
2
  import { getTrimmedDuration } from "./probe.js";
2
3
  import { runFfmpeg } from "./process.js";
4
+ import { ensureToneMapLut, getToneMapTransfer, HABLE_STAGES } from "./tonemap-lut.js";
3
5
  /**
4
6
  * One intermediate format for every clip, so the composition can cut between them freely: the film's frame at
5
7
  * 30 fps, upright (ffmpeg applies the stored rotation while decoding), SDR BT.709 (HDR tone-mapped), filled by a crop
@@ -18,20 +20,22 @@ export function resolveFit(fit, probe, frame) {
18
20
  const frameAspect = frame.width / frame.height;
19
21
  return Math.abs(clipAspect - frameAspect) / frameAspect <= CROP_ASPECT_TOLERANCE ? "crop" : "blur";
20
22
  }
21
- const TRANSFER_INPUT = { pq: "smpte2084", hlg: "arib-std-b67", "dolby-vision": "arib-std-b67" };
22
23
  /**
23
- * HDR to SDR BT.709 on the CPU: to linear light (zscale), Hable tone curve, back to BT.709. A Dolby Vision phone
24
- * clip is read through its HLG base layer.
24
+ * HDR to SDR BT.709 on the CPU. A Dolby Vision phone clip is read through its HLG base layer. With `lut` (the file
25
+ * name of the transfer's tone map LUT, `ensureToneMapLut`, in the folder ffmpeg runs in): to 16-bit R'G'B', the LUT
26
+ * to linear BT.709 light, the BT.709 transfer and matrix, about half the cost; colours outside BT.709 are clipped per
27
+ * RGB channel. Without it: to linear light (zscale), the Hable curve in float, back to BT.709, the same curve the LUT
28
+ * is made from; colours outside BT.709 are clamped in YUV.
25
29
  */
26
- export function toneMapFilter(hdr, transfer) {
30
+ export function toneMapFilter(hdr, transfer, lut) {
27
31
  if (hdr === null)
28
32
  return [];
29
- const input = transfer === "smpte2084" || transfer === "arib-std-b67" ? transfer : TRANSFER_INPUT[hdr];
33
+ if (lut !== undefined) {
34
+ return ["zscale=min=bt2020nc:m=gbr:r=full", "format=gbrp16le", `lut3d=file=${lut}:interp=tetrahedral`, "zscale=tin=linear:pin=bt709:t=bt709:p=bt709:m=bt709:r=tv", "format=yuv420p"];
35
+ }
30
36
  return [
31
- `zscale=tin=${input}:pin=bt2020:min=bt2020nc:t=linear:npl=100`,
32
- "format=gbrpf32le",
33
- "zscale=p=bt709",
34
- "tonemap=tonemap=hable:desat=0",
37
+ `zscale=tin=${getToneMapTransfer(hdr, transfer)}:pin=bt2020:min=bt2020nc:t=linear:npl=100`,
38
+ ...HABLE_STAGES,
35
39
  "zscale=t=bt709:m=bt709:r=tv",
36
40
  // Back to 8-bit before scaling: the blur fill on float frames crashed ffmpeg 6.1.
37
41
  "format=yuv420p",
@@ -40,13 +44,13 @@ export function toneMapFilter(hdr, transfer) {
40
44
  /**
41
45
  * The video filter graph from input 0's picture to `[v]`. Every stage runs on as little as it can: frames are
42
46
  * dropped to 30 fps first, then the picture is scaled to the frame (crop: covered and cropped to it; blur: fitted
43
- * inside it), and only then tone-mapped, so the float stages of an HDR clip work on frame-sized pictures instead of
47
+ * inside it), and only then tone-mapped, so the tone map of an HDR clip works on frame-sized pictures instead of
44
48
  * the source's (a 4K phone clip has 4x the pixels of a 1080x1920 frame). The blur's background is made from the
45
- * fitted picture.
49
+ * fitted picture. `toneMapLut` as in `toneMapFilter`.
46
50
  */
47
51
  export function buildVideoFilter(options) {
48
52
  const { width, height } = options.frame;
49
- const toneMap = toneMapFilter(options.hdr, options.transfer);
53
+ const toneMap = toneMapFilter(options.hdr, options.transfer, options.toneMapLut);
50
54
  const tail = "setsar=1,format=yuv420p";
51
55
  if (options.fit === "crop") {
52
56
  const cover = `scale=${width}:${height}:force_original_aspect_ratio=increase,crop=${width}:${height}`;
@@ -65,12 +69,16 @@ export function buildVideoFilter(options) {
65
69
  /** x264's presets, fastest first. */
66
70
  export const X264_PRESETS = ["ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow"];
67
71
  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) {
72
+ /**
73
+ * The thread arguments: global filter threads (before the inputs) and encoder threads (before the output; the same
74
+ * flag before an input sets that input's decoder threads). Throws, naming `option`, when `threads` is not a positive
75
+ * whole number.
76
+ */
77
+ export function getThreadArgs(threads, option) {
70
78
  if (threads === undefined)
71
79
  return { global: [], output: [] };
72
80
  if (!Number.isInteger(threads) || threads < 1)
73
- throw new Error(`normalize.threads must be a positive whole number, got ${threads}.`);
81
+ throw new Error(`${option} must be a positive whole number, got ${threads}.`);
74
82
  return { global: ["-filter_complex_threads", String(threads)], output: ["-threads", String(threads)] };
75
83
  }
76
84
  /** ffmpeg's arguments for one clip; pure, so the graph is tested without ffmpeg. Throws on an invalid `encoder.threads`. */
@@ -79,7 +87,7 @@ export function buildNormalizeArgs(input) {
79
87
  const duration = getTrimmedDuration(clip, probe);
80
88
  const fit = resolveFit(clip.fit, probe, frame);
81
89
  const seek = clip.trim.start > 0 ? ["-ss", String(clip.trim.start)] : [];
82
- const threads = getThreadArgs(input.encoder?.threads);
90
+ const threads = getThreadArgs(input.encoder?.threads, "normalize.threads");
83
91
  const silence = probe.hasAudio ? [] : ["-f", "lavfi", "-i", `anullsrc=r=${FOOTAGE_SAMPLE_RATE}:cl=stereo`];
84
92
  return [
85
93
  "-v",
@@ -93,7 +101,7 @@ export function buildNormalizeArgs(input) {
93
101
  "-t",
94
102
  duration.toFixed(3),
95
103
  "-filter_complex",
96
- buildVideoFilter({ fit, frame, hdr: probe.hdr, transfer: probe.colorTransfer }),
104
+ buildVideoFilter({ fit, frame, hdr: probe.hdr, transfer: probe.colorTransfer, ...(input.toneMapLut === undefined ? {} : { toneMapLut: input.toneMapLut }) }),
97
105
  "-map",
98
106
  "[v]",
99
107
  "-map",
@@ -128,9 +136,21 @@ export function buildNormalizeArgs(input) {
128
136
  }
129
137
  /**
130
138
  * Runs ffmpeg for one clip without blocking; throws with the clip's id when it fails (a broken file is not an expected
131
- * outcome here). An abort removes the partial output and rejects with the signal's reason.
139
+ * outcome here). An HDR clip without `toneMapLut` gets its transfer's LUT made once in the output's folder, and ffmpeg
140
+ * runs there so the graph names the LUT without a path. An abort removes the partial output and rejects with the
141
+ * signal's reason.
132
142
  */
133
143
  export async function normalizeFootage(input, options = {}) {
134
- await runFfmpeg(`Normalizing clip ${input.clip.id} (${input.file})`, buildNormalizeArgs(input), { ...options, output: input.output });
144
+ const step = `Normalizing clip ${input.clip.id} (${input.file})`;
145
+ const output = resolve(input.output);
146
+ const { hdr, colorTransfer } = input.probe;
147
+ if (hdr === null || input.toneMapLut !== undefined) {
148
+ await runFfmpeg(step, buildNormalizeArgs(input), { ...options, output });
149
+ return;
150
+ }
151
+ const dir = dirname(output);
152
+ const toneMapLut = await ensureToneMapLut(getToneMapTransfer(hdr, colorTransfer), dir, options.signal === undefined ? {} : { signal: options.signal });
153
+ const args = buildNormalizeArgs({ ...input, file: resolve(input.file), output, toneMapLut });
154
+ await runFfmpeg(step, args, { ...options, output, cwd: dir });
135
155
  }
136
156
  //# sourceMappingURL=normalize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/footage/normalize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAmC,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,SAAS,EAAyB,MAAM,cAAc,CAAC;AAEhE;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAC9B,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAC1C,qGAAqG;AACrG,MAAM,qBAA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M,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;IAC3C,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACnD,MAAM,SAAS,CAAC,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACzE,OAAO;IACT,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACvJ,MAAM,IAAI,GAAG,kBAAkB,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7F,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AAChE,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,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAE1C,MAAM,EAAE,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AAwB3E,6CAA6C;AAC7C,SAAS,OAAO,CAAC,OAAe;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED,yHAAyH;AACzH,MAAM,UAAU,kBAAkB,CAAC,IAA+B,EAAE,GAAQ;IAC1E,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,cAAc,CAAC,IAA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