@margoengine/headless 0.0.0-stage → 0.1.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.
@@ -0,0 +1,320 @@
1
+ import { t as e } from "./crc32-Cc3b8qnn.js";
2
+ import { n as t, r as n, t as r } from "./errors-CDgOgzCd.js";
3
+ //#region src/compare.ts
4
+ function i(e, n) {
5
+ for (let { width: r, height: i, data: a } of [e, n]) if (a?.length !== r * i * 4) throw t("Frame data does not match its size", "headless");
6
+ if (e.width !== n.width || e.height !== n.height) throw t("Images must be one size to compare", "headless");
7
+ }
8
+ function a(e, n, r = {}) {
9
+ let { threshold: a = 2, image: s = !1, mask: c = !1, clusters: l } = r;
10
+ if (i(e, n), !(a >= 0 && a <= 255)) throw t("Invalid threshold", "headless");
11
+ if (l !== void 0 && !(l >= 0 && l < Infinity)) throw t("Invalid clusters; pass a gap in pixels, 0 or more", "headless");
12
+ let { width: u, height: d } = e, f = e.data, p = n.data, m = u * d, h = s ? new Uint8Array(m * 4) : void 0, g = c || l !== void 0 ? new Uint8Array(m) : void 0, _ = 0, v = 0, y = 0, b = u, x = d, S = -1, C = -1;
13
+ for (let e = 0; e < f.length; e += 4) {
14
+ let t = f[e + 3], n = p[e + 3], r = Math.abs(t - n);
15
+ for (let i = 0; i < 3; i++) {
16
+ let a = Math.abs(f[e + i] * t - p[e + i] * n) / 255;
17
+ a > r && (r = a);
18
+ }
19
+ y += r, r > v && (v = r);
20
+ let i = r > a;
21
+ if (i) {
22
+ _++;
23
+ let t = e >> 2, n = t % u, r = (t - n) / u;
24
+ n < b && (b = n), n > S && (S = n), r < x && (x = r), C = r, g && (g[t] = 1);
25
+ }
26
+ if (h) {
27
+ if (i) h.set([
28
+ 255,
29
+ 0,
30
+ 0,
31
+ 255
32
+ ], e);
33
+ else {
34
+ for (let t = 0; t < 3; t++) h[e + t] = 191 + f[e + t] / 4;
35
+ h[e + 3] = 255;
36
+ }
37
+ }
38
+ }
39
+ return {
40
+ different: _,
41
+ total: m,
42
+ ratio: _ / m,
43
+ largest: v,
44
+ mean: y / m,
45
+ box: _ ? {
46
+ x: b,
47
+ y: x,
48
+ width: S - b + 1,
49
+ height: C - x + 1
50
+ } : null,
51
+ ...h ? { image: {
52
+ width: u,
53
+ height: d,
54
+ data: h
55
+ } } : {},
56
+ ...c ? { mask: g } : {},
57
+ ...l === void 0 ? {} : { clusters: o(g, u, d, l) }
58
+ };
59
+ }
60
+ function o(e, t, n, r) {
61
+ let i = new Int32Array(e.length), a = [0], o = (e) => {
62
+ for (; a[e] !== e;) e = a[e] = a[a[e]];
63
+ return e;
64
+ }, s = (e, t) => {
65
+ e = o(e), t = o(t), e !== t && (a[Math.max(e, t)] = Math.min(e, t));
66
+ };
67
+ for (let r = 0; r < n; r++) for (let n = 0; n < t; n++) {
68
+ let o = r * t + n;
69
+ if (!e[o]) continue;
70
+ let c = 0, l = [
71
+ n > 0 ? o - 1 : -1,
72
+ r > 0 && n > 0 ? o - t - 1 : -1,
73
+ r > 0 ? o - t : -1
74
+ ];
75
+ r > 0 && n < t - 1 && l.push(o - t + 1);
76
+ for (let e of l) e >= 0 && i[e] && (c ? s(c, i[e]) : c = i[e]);
77
+ c || a.push(c = a.length), i[o] = c;
78
+ }
79
+ let c = /* @__PURE__ */ new Map();
80
+ for (let e = 0; e < i.length; e++) {
81
+ if (!i[e]) continue;
82
+ let n = o(i[e]), r = e % t, a = (e - r) / t, s = c.get(n);
83
+ s ? (r < s[0] && (s[0] = r), r > s[2] && (s[2] = r), s[3] = a) : c.set(n, [
84
+ r,
85
+ a,
86
+ r,
87
+ a
88
+ ]);
89
+ }
90
+ let l = [...c.values()];
91
+ for (let e = !0; e;) {
92
+ e = !1;
93
+ for (let t = 0; t < l.length; t++) for (let n = t + 1; n < l.length; n++) {
94
+ let i = l[t], a = l[n];
95
+ Math.max(a[0] - i[2], i[0] - a[2], a[1] - i[3], i[1] - a[3]) - 1 > r || (l[t] = [
96
+ Math.min(i[0], a[0]),
97
+ Math.min(i[1], a[1]),
98
+ Math.max(i[2], a[2]),
99
+ Math.max(i[3], a[3])
100
+ ], l.splice(n--, 1), e = !0);
101
+ }
102
+ }
103
+ return l.sort((e, t) => e[1] - t[1] || e[0] - t[0]).map(([e, t, n, r]) => ({
104
+ x: e,
105
+ y: t,
106
+ width: n - e + 1,
107
+ height: r - t + 1
108
+ }));
109
+ }
110
+ function s({ width: e, height: t, data: n }) {
111
+ let r = new Float64Array(e * t);
112
+ for (let e = 0; e < r.length; e++) {
113
+ let t = e * 4;
114
+ r[e] = (.2126 * n[t] + .7152 * n[t + 1] + .0722 * n[t + 2]) * n[t + 3] / 255;
115
+ }
116
+ return r;
117
+ }
118
+ function c(e, t, n, r) {
119
+ let i = r.length, a = t - i + 1, o = n - i + 1, s = new Float64Array(a * n), c = new Float64Array(a * o);
120
+ for (let o = 0; o < n; o++) for (let n = 0; n < a; n++) {
121
+ let c = 0;
122
+ for (let a = 0; a < i; a++) c += e[o * t + n + a] * r[a];
123
+ s[o * a + n] = c;
124
+ }
125
+ for (let e = 0; e < o; e++) for (let t = 0; t < a; t++) {
126
+ let n = 0;
127
+ for (let o = 0; o < i; o++) n += s[(e + o) * a + t] * r[o];
128
+ c[e * a + t] = n;
129
+ }
130
+ return c;
131
+ }
132
+ var l = (.01 * 255) ** 2, u = (.03 * 255) ** 2;
133
+ function d(e, n, r = {}) {
134
+ let { window: a = 11, sigma: o = 1.5, map: d = !1 } = r;
135
+ if (i(e, n), !Number.isInteger(a) || a < 1 || a % 2 == 0) throw t("Invalid SSIM window", "headless");
136
+ if (!(o > 0) || !Number.isFinite(o)) throw t("Invalid SSIM sigma", "headless");
137
+ let { width: f, height: p } = e, m = Math.min(f, p), h = Math.min(a, m % 2 ? m : m - 1) || 1, g = new Float64Array(h), _ = (h - 1) / 2, v = 0;
138
+ for (let e = 0; e < h; e++) v += g[e] = Math.exp(-((e - _) ** 2) / (2 * o * o));
139
+ for (let e = 0; e < h; e++) g[e] /= v;
140
+ let y = s(e), b = s(n), x = (e, t) => e.map((e, n) => e * t[n]), S = (e) => c(e, f, p, g), C = S(y), w = S(b), T = S(x(y, y)), E = S(x(b, b)), D = S(x(y, b)), O = new Float32Array(C.length), k = 0;
141
+ for (let e = 0; e < C.length; e++) {
142
+ let t = C[e], n = w[e], r = T[e] - t * t, i = E[e] - n * n, a = D[e] - t * n, o = (2 * t * n + l) * (2 * a + u) / ((t * t + n * n + l) * (r + i + u));
143
+ O[e] = o, k += o;
144
+ }
145
+ return {
146
+ score: k / C.length,
147
+ ...d ? { map: {
148
+ width: f - h + 1,
149
+ height: p - h + 1,
150
+ data: O
151
+ } } : {}
152
+ };
153
+ }
154
+ var f = [
155
+ 137,
156
+ 80,
157
+ 78,
158
+ 71,
159
+ 13,
160
+ 10,
161
+ 26,
162
+ 10
163
+ ], p = {
164
+ 0: 1,
165
+ 2: 3,
166
+ 3: 1,
167
+ 4: 2,
168
+ 6: 4
169
+ }, m = {
170
+ 0: [
171
+ 1,
172
+ 2,
173
+ 4,
174
+ 8,
175
+ 16
176
+ ],
177
+ 2: [8, 16],
178
+ 3: [
179
+ 1,
180
+ 2,
181
+ 4,
182
+ 8
183
+ ],
184
+ 4: [8, 16],
185
+ 6: [8, 16]
186
+ }, h = [
187
+ [
188
+ 0,
189
+ 0,
190
+ 8,
191
+ 8
192
+ ],
193
+ [
194
+ 4,
195
+ 0,
196
+ 8,
197
+ 8
198
+ ],
199
+ [
200
+ 0,
201
+ 4,
202
+ 4,
203
+ 8
204
+ ],
205
+ [
206
+ 2,
207
+ 0,
208
+ 4,
209
+ 4
210
+ ],
211
+ [
212
+ 0,
213
+ 2,
214
+ 2,
215
+ 4
216
+ ],
217
+ [
218
+ 1,
219
+ 0,
220
+ 2,
221
+ 2
222
+ ],
223
+ [
224
+ 0,
225
+ 1,
226
+ 1,
227
+ 2
228
+ ]
229
+ ], g = () => r("failed", "Not a PNG file this reader can use", "headless");
230
+ function _(e, t, n, r) {
231
+ let i = new Uint8Array(t * n);
232
+ for (let a = 0; a < n; a++) {
233
+ let n = e[a * (t + 1)], o = a * (t + 1) + 1, s = a * t;
234
+ for (let c = 0; c < t; c++) {
235
+ let l = c >= r ? i[s + c - r] : 0, u = a ? i[s - t + c] : 0, d = a && c >= r ? i[s - t + c - r] : 0, f = 0;
236
+ if (n === 1) f = l;
237
+ else if (n === 2) f = u;
238
+ else if (n === 3) f = l + u >> 1;
239
+ else if (n === 4) {
240
+ let e = l + u - d, t = Math.abs(e - l), n = Math.abs(e - u), r = Math.abs(e - d);
241
+ f = t <= n && t <= r ? l : n <= r ? u : d;
242
+ } else if (n !== 0) throw g();
243
+ i[s + c] = e[o + c] + f;
244
+ }
245
+ }
246
+ return i;
247
+ }
248
+ async function v(t) {
249
+ if (!(t instanceof Uint8Array)) throw n("decodePNG needs PNG file bytes", "headless");
250
+ if (t.length < 33 || f.some((e, n) => t[n] !== e)) throw g();
251
+ let r = new DataView(t.buffer, t.byteOffset, t.byteLength);
252
+ if (r.getUint32(8) !== 13 || String.fromCharCode(...t.subarray(12, 16)) !== "IHDR") throw g();
253
+ let i = r.getUint32(16), a = r.getUint32(20), o = t[24], s = t[25], c = p[s];
254
+ if (!c || !m[s].includes(o) || !i || !a || t[28] > 1) throw g();
255
+ let l = t[28] === 1, u = [], d, v;
256
+ for (let n = 8; n + 12 <= t.length;) {
257
+ let i = r.getUint32(n), a = String.fromCharCode(...t.subarray(n + 4, n + 8)), o = t.subarray(n + 8, n + 8 + i);
258
+ if (n + 12 + i > t.length || r.getUint32(n + 8 + i) !== e(t.subarray(n + 4, n + 8 + i))) throw g();
259
+ if (a === "IDAT") u.push(o);
260
+ else if (a === "PLTE") d = o;
261
+ else if (a === "tRNS") v = o;
262
+ else if (a === "IEND") break;
263
+ n += i + 12;
264
+ }
265
+ if (!u.length) throw g();
266
+ let y = new Blob(u).stream().pipeThrough(new DecompressionStream("deflate")), b = new Uint8Array(await new Response(y).arrayBuffer()), x = c * o, S = new Uint8Array(i * a * 4), C = 2 ** Math.min(o, 8) - 1, w = 255 / C, T = (e) => v.length > e * 2 + 1 ? v[e * 2] << 8 | v[e * 2 + 1] : -1, E = 0, D = (e, t, n, r, a, l) => {
267
+ let u = Math.ceil(e * x / 8);
268
+ if (b.length < E + (u + 1) * t) throw g();
269
+ let f = _(b.subarray(E), u, t, Math.max(1, x >> 3)), p = (e, t) => {
270
+ let n = e * u;
271
+ if (o === 16) return f[n + t * 2];
272
+ if (o === 8) return f[n + t];
273
+ let r = t * o;
274
+ return f[n + (r >> 3)] >> 8 - o - (r & 7) & C;
275
+ }, m = (e, t) => o === 16 ? f[e * u + t * 2] << 8 | f[e * u + t * 2 + 1] : p(e, t);
276
+ E += (u + 1) * t;
277
+ for (let o = 0; o < t; o++) for (let t = 0; t < e; t++) {
278
+ let e = ((r + o * l) * i + n + t * a) * 4;
279
+ if (s === 3) {
280
+ let n = p(o, t);
281
+ if (!d || n * 3 + 2 >= d.length) throw g();
282
+ S.set(d.subarray(n * 3, n * 3 + 3), e), S[e + 3] = v?.[n] ?? 255;
283
+ } else if (s === 0 || s === 4) S.fill(Math.round(p(o, t * c) * w), e, e + 3), S[e + 3] = s === 4 ? Math.round(p(o, t * 2 + 1) * w) : v && m(o, t) === T(0) ? 0 : 255;
284
+ else {
285
+ for (let n = 0; n < 3; n++) S[e + n] = Math.round(p(o, t * c + n) * w);
286
+ S[e + 3] = s === 6 ? Math.round(p(o, t * 4 + 3) * w) : v && [
287
+ 0,
288
+ 1,
289
+ 2
290
+ ].every((e) => m(o, t * 3 + e) === T(e)) ? 0 : 255;
291
+ }
292
+ }
293
+ };
294
+ if (!l) D(i, a, 0, 0, 1, 1);
295
+ else for (let [e, t, n, r] of h) {
296
+ let o = Math.ceil((i - e) / n), s = Math.ceil((a - t) / r);
297
+ o > 0 && s > 0 && D(o, s, e, t, n, r);
298
+ }
299
+ return {
300
+ width: i,
301
+ height: a,
302
+ data: S
303
+ };
304
+ }
305
+ var y = (e) => e instanceof Uint8Array ? v(e) : e;
306
+ async function b(e, n, { threshold: r, maxRatio: i = .001, minSSIM: o = .99 } = {}) {
307
+ if (!(i >= 0 && i <= 1) || !(o >= -1 && o <= 1)) throw t("Invalid compare limits", "headless");
308
+ let [s, c] = await Promise.all([y(e), y(n)]), l = a(s, c, {
309
+ threshold: r,
310
+ image: !0
311
+ }), { score: u } = d(s, c);
312
+ return {
313
+ ...l,
314
+ image: l.image,
315
+ ssim: u,
316
+ pass: l.ratio <= i && u >= o
317
+ };
318
+ }
319
+ //#endregion
320
+ export { b as compareImages, v as decodePNG, a as pixelDiff, d as ssim };
@@ -0,0 +1,23 @@
1
+ //#region ../shared/crc32.js
2
+ var e;
3
+ function t() {
4
+ e = /* @__PURE__ */ new Int32Array(2048);
5
+ for (let t = 0; t < 256; t++) {
6
+ let n = t;
7
+ for (let e = 0; e < 8; e++) n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
8
+ e[t] = n;
9
+ }
10
+ for (let t = 0; t < 256; t++) for (let n = 1; n < 8; n++) {
11
+ let r = e[(n - 1) * 256 + t];
12
+ e[n * 256 + t] = r >>> 8 ^ e[r & 255];
13
+ }
14
+ return e;
15
+ }
16
+ function n(n, r = 0) {
17
+ let i = e ?? t(), a = n.length, o = a - (a & 7), s = ~r, c = 0;
18
+ for (; c < o; c += 8) s ^= n[c] | n[c + 1] << 8 | n[c + 2] << 16 | n[c + 3] << 24, s = i[1792 + (s & 255)] ^ i[1536 + (s >>> 8 & 255)] ^ i[1280 + (s >>> 16 & 255)] ^ i[1024 + (s >>> 24)] ^ i[768 + n[c + 4]] ^ i[512 + n[c + 5]] ^ i[256 + n[c + 6]] ^ i[n[c + 7]];
19
+ for (; c < a; c++) s = i[(s ^ n[c]) & 255] ^ s >>> 8;
20
+ return ~s >>> 0;
21
+ }
22
+ //#endregion
23
+ export { n as t };
@@ -0,0 +1,7 @@
1
+ //#region ../shared/errors.js
2
+ var e = (e, t) => Object.assign(Error(t), {
3
+ name: "MargoError",
4
+ code: e
5
+ }), t = (e, t) => `${e}; see https://margoengine.com/errors#${t}`, n = (n, r, i = n) => e(n, t(r, i)), r = (e, n) => TypeError(t(e, n)), i = (e, n) => RangeError(t(e, n));
6
+ //#endregion
7
+ export { i as n, r, n as t };
@@ -0,0 +1,15 @@
1
+ //#region src/ffmpeg-colour.ts
2
+ var e = (e) => `scale=out_color_matrix=bt709:out_range=tv:out_chroma_loc=left,format=${e},setparams=color_primaries=bt709:color_trc=iec61966-2-1:colorspace=bt709:range=tv:chroma_location=left`, t = [
3
+ "-colorspace",
4
+ "bt709",
5
+ "-color_primaries",
6
+ "bt709",
7
+ "-color_trc",
8
+ "iec61966-2-1",
9
+ "-color_range",
10
+ "tv",
11
+ "-chroma_sample_location",
12
+ "left"
13
+ ];
14
+ //#endregion
15
+ export { e as n, t };
@@ -0,0 +1,4 @@
1
+ /** The filter that turns RGB(A) frames into `format` with the engine's matrix, range, chroma siting and tags. */
2
+ export declare const colourFilter: (format: string) => string;
3
+ /** The output options that tag the stream as the filter made it. */
4
+ export declare const COLOUR_TAGS: readonly string[];
@@ -0,0 +1,129 @@
1
+ /** An H.264 encoder: `'x264'` (software, libx264) or a hardware one: `'nvenc'` (NVIDIA), `'amf'` (AMD), `'qsv'` (Intel). */
2
+ export type FFmpegEncoder = 'x264' | 'nvenc' | 'amf' | 'qsv';
3
+ /** Options of {@link encoderArguments}. */
4
+ export interface EncoderOptions {
5
+ /** Constant quality from 1 to 51, lower is better: x264's CRF, NVENC's CQ, AMF's QP, QSV's global quality. Default 20. */
6
+ quality?: number;
7
+ /**
8
+ * x264's speed preset (`'ultrafast'` to `'placebo'`; x264's own default is `'medium'`), or NVENC's (`'p1'` to `'p7'`;
9
+ * default `'p5'`). AMF and QSV take none. Default: the encoder's.
10
+ */
11
+ preset?: string;
12
+ }
13
+ /**
14
+ * The H.264 colour tags the engine writes (ITU-T H.273): BT.709 primaries (1) and matrix (1), the sRGB transfer (13) of
15
+ * a rendered frame, TV range and chroma on the left column (chroma_sample_loc_type 0), as an `h264_metadata` bitstream
16
+ * filter, which rewrites the VUI of any H.264 stream, encoded or copied.
17
+ */
18
+ export declare const H264_COLOUR_TAGS = "h264_metadata=colour_primaries=1:transfer_characteristics=13:matrix_coefficients=1:video_full_range_flag=0:chroma_sample_loc_type=0";
19
+ /**
20
+ * The output arguments of an H.264 MP4 from RGBA frames with `encoder`: the same BT.709, TV range, sRGB transfer and
21
+ * left chroma as encodeWithFFmpeg's default, the stream's VUI rewritten by {@link H264_COLOUR_TAGS} whatever the encoder
22
+ * writes, and `+faststart`. Pass them as encodeWithFFmpeg's `args`.
23
+ */
24
+ export declare function encoderArguments(encoder?: FFmpegEncoder, { quality, preset }?: EncoderOptions): string[];
25
+ /** Options shared by the file tools. */
26
+ export interface FFmpegFileOptions {
27
+ /** The program, or the program and its first arguments. Default `'ffmpeg'` on the `PATH`. */
28
+ ffmpeg?: string | readonly string[];
29
+ /** Stops ffmpeg; the promise rejects with the signal's reason and the output is not written. */
30
+ signal?: AbortSignal;
31
+ }
32
+ /** One sample of a video track, in decode order. */
33
+ export interface VideoSample {
34
+ /** Presentation time in seconds, after the edit list. */
35
+ time: number;
36
+ /** A sync sample (a key frame a decoder can start from). */
37
+ key: boolean;
38
+ }
39
+ /** What {@link readVideoTrack} gives back. */
40
+ export interface VideoTrack {
41
+ /** The sample entry's four-character code: `'avc1'` or `'avc3'` for H.264, `'hvc1'`, `'av01'` and so on. */
42
+ codec: string;
43
+ /** Ticks per second of the track's media timescale. */
44
+ timescale: number;
45
+ /** The H.264 decoder configuration (the sample entry's `avcC` box body), or undefined for other codecs. */
46
+ avcConfig?: Uint8Array;
47
+ /** Every sample, from the `moov` sample tables and any movie fragments, in decode order. */
48
+ samples: VideoSample[];
49
+ }
50
+ /**
51
+ * The first video track of an MP4 or MOV file (ISO/IEC 14496-12): its codec, timescale, H.264 configuration and every
52
+ * sample's presentation time and key flag, from the sample tables (`stts`, `ctts`, `stss`) and movie fragments (`trex`,
53
+ * `tfhd`, `tfdt`, `trun`), with the edit list's start applied. Reads box headers, `moov` and each `moof`, never `mdat`.
54
+ * Rejects with code `'unsupported'` when the file has no video track.
55
+ */
56
+ export declare function readVideoTrack(path: string): Promise<VideoTrack>;
57
+ /**
58
+ * The MP4 track timescale ffmpeg's muxer gives an encode at `fps` frames a second (the rate doubled until it reaches
59
+ * 10,000: 15,360 at 30 and 60 fps, 12,288 at 24), so a copied span written at it joins engine chunks with every frame
60
+ * on a whole tick. Whole frame rates only.
61
+ */
62
+ export declare function mp4Timescale(fps: number): number;
63
+ /** The span {@link checkSpan} and {@link copySpan} take. */
64
+ export interface SpanOptions {
65
+ /** Seconds into the file where the span starts: a key frame's presentation time. */
66
+ start: number;
67
+ /** Frames the span holds. */
68
+ frames: number;
69
+ /** The frame rate the span must hold: frame k at start + k / fps. */
70
+ fps: number;
71
+ /** Ticks per second of the file the span is written to. Default {@link mp4Timescale}(fps). */
72
+ timescale?: number;
73
+ }
74
+ /** Why a span cannot be stream copied, or ok. */
75
+ export type SpanCheck = {
76
+ ok: true;
77
+ reason?: undefined;
78
+ } | {
79
+ ok: false;
80
+ reason: string;
81
+ };
82
+ /**
83
+ * Whether `frames` frames from `start` of an MP4 or MOV file can be cut by stream copy into a file whose frames sit at
84
+ * start + k / fps: H.264; a key frame within half a tick of `start` (ticks of `timescale`); the next `frames` samples
85
+ * in decode order are exactly the frames k = 0 to frames - 1, each within half a tick of its step, so no frame is
86
+ * missing and none is decoded after the next key frame as an open GOP's leading frames are.
87
+ */
88
+ export declare function checkSpan(path: string, options: SpanOptions): Promise<SpanCheck>;
89
+ /** Options of {@link copySpan}. */
90
+ export interface CopySpanOptions extends SpanOptions, FFmpegFileOptions {
91
+ }
92
+ /**
93
+ * Cuts `frames` frames from `start` of an H.264 MP4 or MOV recording into `output` by stream copy (no decode, no
94
+ * encode): the picture alone, its VUI rewritten to the engine's colour tags ({@link H264_COLOUR_TAGS}), at `timescale`
95
+ * (default the engine chunks' {@link mp4Timescale}), with `+faststart`, so it joins engine chunks with
96
+ * {@link joinVideos}. Rejects with code `'unsupported'` and {@link checkSpan}'s reason when the span cannot be copied.
97
+ */
98
+ export declare function copySpan(input: string, output: string, options: CopySpanOptions): Promise<void>;
99
+ /** Options of {@link joinVideos}. */
100
+ export interface JoinOptions extends FFmpegFileOptions {
101
+ /**
102
+ * `'auto'` (default) writes `avc3` when the files' H.264 parameter sets differ, since `avc1` keeps one set in its
103
+ * sample entry and a join then carries each file's own sets in band (ISO/IEC 14496-15), and `avc1` when they agree;
104
+ * or force either.
105
+ */
106
+ sampleEntry?: 'auto' | 'avc1' | 'avc3';
107
+ }
108
+ /**
109
+ * Joins video files end to end by stream copy, without encoding again (ffmpeg's concat demuxer), into `output` with
110
+ * `+faststart`. The files must share codec, size and frame rate, as chunks of one render do. Resolves the sample
111
+ * entry written for H.264 MP4 or MOV inputs (`'avc1'` or `'avc3'`), else undefined.
112
+ */
113
+ export declare function joinVideos(inputs: readonly string[], output: string, options?: JoinOptions): Promise<'avc1' | 'avc3' | undefined>;
114
+ /** Options of {@link addSound}. */
115
+ export interface AddSoundOptions extends FFmpegFileOptions {
116
+ /** Audio codec: `'aac'` (default for MP4 and MOV), `'opus'` (default for WebM), or `'copy'` to keep the sound's own. */
117
+ codec?: 'aac' | 'opus' | 'copy';
118
+ /** Bits per second when encoding. Default 192000. */
119
+ bitrate?: number;
120
+ /** Seconds of picture before the sound starts. Default 0. */
121
+ offset?: number;
122
+ /** End the file with the shorter of picture and sound. Default false: the file keeps both lengths. */
123
+ shortest?: boolean;
124
+ }
125
+ /**
126
+ * Lays the sound file `sound` (WAV, FLAC, MP3, AAC or any file ffmpeg reads; its first audio stream) under the video
127
+ * `video` without encoding the picture again (`-c:v copy`), into `output`. Any sound the video had is replaced.
128
+ */
129
+ export declare function addSound(video: string, sound: string, output: string, options?: AddSoundOptions): Promise<void>;