@kolkrabbi/design-editor 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -26
- package/dist/{BufferResource-CKQMSOM4.js → BufferResource-BfLgK37S.js} +42 -34
- package/dist/{CanvasPool-ilDNHrRx.js → CanvasPool-YNSF8hsR.js} +9 -9
- package/dist/CanvasRenderer-Bl0rlqNq.js +2 -0
- package/dist/{browserAll-CJ593myQ.js → FederatedEventTarget-BJgROaRQ.js} +119 -127
- package/dist/FilterSystem-BUrPNXx-.js +1323 -0
- package/dist/{Geometry-D3fkwmax.js → Geometry-C5s5KpWq.js} +492 -411
- package/dist/{OrbitControls-CE3qSrHQ.js → OrbitControls-Cql8Rn2i.js} +1944 -1914
- package/dist/{RenderTargetSystem-umK0aqrs.js → RenderTargetSystem-oFwWv5IW.js} +1107 -612
- package/dist/WebGLRenderer-CXxpVIx3.js +2 -0
- package/dist/WebGPURenderer-BwLEUYBa.js +2 -0
- package/dist/browserAll-CAzdTUbR.js +6 -0
- package/dist/canvasUtils-BoNfkAod.js +168 -0
- package/dist/{rolldown-runtime-B0aSnxlc.js → chunk-3b4jIN3o.js} +4 -11
- package/dist/design-editor.css +2 -2
- package/dist/design-editor.js +7675 -8478
- package/dist/{getTextureBatchBindGroup-ChWkOJ3t.js → getTextureBatchBindGroup-CNWhZRbV.js} +5 -5
- package/dist/{host-6EhdLf5-.js → host-CVR9RL_W.js} +8 -6
- package/dist/{host-DPFYZP9I.js → host-be1CWhN1.js} +4 -2
- package/dist/init-jApIMi04.js +4 -0
- package/dist/{phase-D3rwI6OO.js → phase-t_DhU5Nm.js} +2 -2
- package/dist/pipeline-CMpuPUaX.js +11995 -0
- package/dist/{src-zDOFeQWX.js → src-QwKcYKfv.js} +747 -746
- package/dist/webworkerAll-DEZhpG90.js +2 -0
- package/package.json +32 -26
- package/LICENSE +0 -21
- package/dist/CanvasRenderer-CDbc3nH9.js +0 -3396
- package/dist/WebGLRenderer-DVKPZbKc.js +0 -2145
- package/dist/WebGPURenderer-DHSBocAL.js +0 -1656
- package/dist/canvasUtils-CXoNqK7T.js +0 -168
- package/dist/defaultFilter.vert-C9efGgir.js +0 -888
- package/dist/init-4Y6mtayI.js +0 -441
- package/dist/pipeline-DfTD40M-.js +0 -4825
- package/dist/webworkerAll-wTH3MKcZ.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./chunk-3b4jIN3o.js";
|
|
2
2
|
import { t as e } from "./design-editor.js";
|
|
3
|
-
//#region node_modules/.pnpm/mediabunny@1.
|
|
3
|
+
//#region ../../node_modules/.pnpm/mediabunny@1.55.6/node_modules/mediabunny/dist/modules/src/misc.js
|
|
4
4
|
function t(e) {
|
|
5
5
|
if (!e) throw Error("Assertion failed.");
|
|
6
6
|
}
|
|
@@ -37,7 +37,7 @@ var n = (e) => {
|
|
|
37
37
|
bt470bg: 5,
|
|
38
38
|
smpte170m: 6,
|
|
39
39
|
"bt2020-ncl": 9
|
|
40
|
-
}, f = (e) =>
|
|
40
|
+
}, f = (e) => !e || e.primaries == null && e.transfer == null && e.matrix == null && e.fullRange == null, p = (e) => e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || ArrayBuffer.isView(e), m = class {
|
|
41
41
|
constructor() {
|
|
42
42
|
this.currentPromise = Promise.resolve(), this.pending = 0;
|
|
43
43
|
}
|
|
@@ -68,22 +68,17 @@ var n = (e) => {
|
|
|
68
68
|
};
|
|
69
69
|
}, _ = (e) => {
|
|
70
70
|
throw Error(`Unexpected value: ${e}`);
|
|
71
|
-
},
|
|
71
|
+
}, v = (e, t, n) => {
|
|
72
72
|
let r = e.getUint8(t), i = e.getUint8(t + 1), a = e.getUint8(t + 2);
|
|
73
73
|
return n ? r | i << 8 | a << 16 : r << 16 | i << 8 | a;
|
|
74
|
-
},
|
|
74
|
+
}, y = (e, t, n) => Math.max(t, Math.min(n, e)), b = (e, t, n) => e + (t - e) * n, x = (e, t) => Math.round(e / t) * t, S = (e, t) => Math.round(e * t) / t, C = (e, t) => Math.floor(e * t) / t, ee = /^[a-z]{3}$/, te = (e) => ee.test(e), w = 1e6 * (1 + 2 ** -52), ne = class {
|
|
75
75
|
constructor() {
|
|
76
76
|
this.currentPromise = Promise.resolve();
|
|
77
77
|
}
|
|
78
78
|
call(e) {
|
|
79
79
|
return this.currentPromise = this.currentPromise.then(e);
|
|
80
80
|
}
|
|
81
|
-
},
|
|
82
|
-
if (E !== null) return E;
|
|
83
|
-
if (typeof navigator > "u") return null;
|
|
84
|
-
let e = /\bChrome\/(\d+)/.exec(navigator.userAgent);
|
|
85
|
-
return e ? E = Number(e[1]) : null;
|
|
86
|
-
}, se = function* (e) {
|
|
81
|
+
}, re = null, ie = () => re === null ? re = typeof navigator < "u" && navigator.userAgent?.includes("Firefox") : re, T = null, ae = () => T === null ? T = !!(typeof navigator < "u" && (navigator.vendor?.includes("Google Inc") || /Chrome/.test(navigator.userAgent))) : T, oe = (e) => globalThis.isSecureContext !== void 0 && !globalThis.isSecureContext ? `${e} is not available in this environment; this may be because this page is running in an insecure context. Try serving your page over HTTPS or use localhost.` : `${e} is not available in this environment.`, se = (/* #__PURE__ */ (async () => {})()).constructor, E = (e) => e instanceof se || e instanceof Promise ? !0 : typeof e?.then == "function", ce = function* (e) {
|
|
87
82
|
for (let t in e) {
|
|
88
83
|
let n = e[t];
|
|
89
84
|
n !== void 0 && (yield {
|
|
@@ -91,7 +86,7 @@ var n = (e) => {
|
|
|
91
86
|
value: n
|
|
92
87
|
});
|
|
93
88
|
}
|
|
94
|
-
},
|
|
89
|
+
}, le = (e) => {
|
|
95
90
|
switch (e.toLowerCase()) {
|
|
96
91
|
case "image/jpeg":
|
|
97
92
|
case "image/jpg": return ".jpg";
|
|
@@ -106,20 +101,20 @@ var n = (e) => {
|
|
|
106
101
|
case "image/vnd.microsoft.icon": return ".ico";
|
|
107
102
|
default: return null;
|
|
108
103
|
}
|
|
109
|
-
},
|
|
104
|
+
}, ue = (e, t) => {
|
|
110
105
|
if (e.length !== t.length) return !1;
|
|
111
106
|
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
112
107
|
return !0;
|
|
113
|
-
},
|
|
108
|
+
}, de = () => {
|
|
114
109
|
Symbol.dispose ??= Symbol("Symbol.dispose");
|
|
115
|
-
},
|
|
110
|
+
}, fe = (e) => typeof e == "number" && !Number.isNaN(e), pe = (e, t) => {
|
|
116
111
|
let n = -1, r = Infinity;
|
|
117
112
|
for (let i = 0; i < e.length; i++) {
|
|
118
113
|
let a = t(e[i]);
|
|
119
114
|
a < r && (r = a, n = i);
|
|
120
115
|
}
|
|
121
116
|
return n;
|
|
122
|
-
},
|
|
117
|
+
}, me = (e) => {
|
|
123
118
|
t(Number.isInteger(e.num)), t(Number.isInteger(e.den)), t(e.den !== 0);
|
|
124
119
|
let n = Math.abs(e.num), r = Math.abs(e.den);
|
|
125
120
|
for (; r !== 0;) {
|
|
@@ -137,7 +132,7 @@ var n = (e) => {
|
|
|
137
132
|
if (!Number.isInteger(e.top) || e.top < 0) throw TypeError(`${t}.top must be a non-negative integer.`);
|
|
138
133
|
if (!Number.isInteger(e.width) || e.width < 0) throw TypeError(`${t}.width must be a non-negative integer.`);
|
|
139
134
|
if (!Number.isInteger(e.height) || e.height < 0) throw TypeError(`${t}.height must be a non-negative integer.`);
|
|
140
|
-
},
|
|
135
|
+
}, he = (e) => new Promise((t) => setTimeout(t, e)), ge = (e) => Array.isArray(e) ? e : [e], O = class {
|
|
141
136
|
constructor() {
|
|
142
137
|
this._listeners = /* @__PURE__ */ new Map();
|
|
143
138
|
}
|
|
@@ -162,7 +157,7 @@ var n = (e) => {
|
|
|
162
157
|
e.once && r.delete(e);
|
|
163
158
|
}
|
|
164
159
|
}
|
|
165
|
-
},
|
|
160
|
+
}, _e = (e) => typeof e == "object" && !!e && Object.getPrototypeOf(e) === Object.prototype && Object.values(e).every((e) => typeof e == "string"), k;
|
|
166
161
|
(function(e) {
|
|
167
162
|
e[e.Silent = 0] = "Silent", e[e.Errors = 1] = "Errors", e[e.Warnings = 2] = "Warnings", e[e.Info = 3] = "Info";
|
|
168
163
|
})(k ||= {});
|
|
@@ -193,20 +188,20 @@ var A = class e {
|
|
|
193
188
|
};
|
|
194
189
|
A._level = k.Info, A._emitterInstance = null;
|
|
195
190
|
//#endregion
|
|
196
|
-
//#region node_modules/.pnpm/mediabunny@1.
|
|
197
|
-
var
|
|
191
|
+
//#region ../../node_modules/.pnpm/mediabunny@1.55.6/node_modules/mediabunny/dist/modules/src/metadata.js
|
|
192
|
+
var ve = class {
|
|
198
193
|
constructor(e, t) {
|
|
199
194
|
if (this.data = e, this.mimeType = t, !(e instanceof Uint8Array)) throw TypeError("data must be a Uint8Array.");
|
|
200
195
|
if (typeof t != "string") throw TypeError("mimeType must be a string.");
|
|
201
196
|
}
|
|
202
|
-
},
|
|
197
|
+
}, ye = class {
|
|
203
198
|
constructor(e, t, n, r) {
|
|
204
199
|
if (this.data = e, this.mimeType = t, this.name = n, this.description = r, !(e instanceof Uint8Array)) throw TypeError("data must be a Uint8Array.");
|
|
205
200
|
if (t !== void 0 && typeof t != "string") throw TypeError("mimeType, when provided, must be a string.");
|
|
206
201
|
if (n !== void 0 && typeof n != "string") throw TypeError("name, when provided, must be a string.");
|
|
207
202
|
if (r !== void 0 && typeof r != "string") throw TypeError("description, when provided, must be a string.");
|
|
208
203
|
}
|
|
209
|
-
},
|
|
204
|
+
}, be = (e) => {
|
|
210
205
|
if (!e || typeof e != "object") throw TypeError("tags must be an object.");
|
|
211
206
|
if (e.title !== void 0 && typeof e.title != "string") throw TypeError("tags.title, when provided, must be a string.");
|
|
212
207
|
if (e.description !== void 0 && typeof e.description != "string") throw TypeError("tags.description, when provided, must be a string.");
|
|
@@ -236,9 +231,9 @@ var ge = class {
|
|
|
236
231
|
if (e.comment !== void 0 && typeof e.comment != "string") throw TypeError("tags.comment, when provided, must be a string.");
|
|
237
232
|
if (e.raw !== void 0) {
|
|
238
233
|
if (!e.raw || typeof e.raw != "object") throw TypeError("tags.raw, when provided, must be an object.");
|
|
239
|
-
for (let t of Object.values(e.raw)) if (t !== null && typeof t != "string" && !(t instanceof Uint8Array) && !(t instanceof
|
|
234
|
+
for (let t of Object.values(e.raw)) if (t !== null && typeof t != "string" && !(t instanceof Uint8Array) && !(t instanceof ve) && !(t instanceof ye) && !_e(t)) throw TypeError("Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, Record<string, string>, or null.");
|
|
240
235
|
}
|
|
241
|
-
},
|
|
236
|
+
}, xe = (e) => {
|
|
242
237
|
if (!e || typeof e != "object") throw TypeError("disposition must be an object.");
|
|
243
238
|
if (e.default !== void 0 && typeof e.default != "boolean") throw TypeError("disposition.default must be a boolean.");
|
|
244
239
|
if (e.primary !== void 0 && typeof e.primary != "boolean") throw TypeError("disposition.primary must be a boolean.");
|
|
@@ -287,7 +282,7 @@ var ge = class {
|
|
|
287
282
|
let t = new e(this.bytes);
|
|
288
283
|
return t.pos = this.pos, t;
|
|
289
284
|
}
|
|
290
|
-
},
|
|
285
|
+
}, Se = [
|
|
291
286
|
96e3,
|
|
292
287
|
88200,
|
|
293
288
|
64e3,
|
|
@@ -301,7 +296,7 @@ var ge = class {
|
|
|
301
296
|
11025,
|
|
302
297
|
8e3,
|
|
303
298
|
7350
|
|
304
|
-
],
|
|
299
|
+
], Ce = [
|
|
305
300
|
-1,
|
|
306
301
|
1,
|
|
307
302
|
2,
|
|
@@ -310,23 +305,196 @@ var ge = class {
|
|
|
310
305
|
5,
|
|
311
306
|
6,
|
|
312
307
|
8
|
|
313
|
-
],
|
|
314
|
-
let t =
|
|
315
|
-
|
|
316
|
-
let
|
|
317
|
-
|
|
318
|
-
let
|
|
319
|
-
e.objectType
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
},
|
|
308
|
+
], we = (e) => {
|
|
309
|
+
let t = e.objectType === 5 || e.objectType === 29, n = e.objectType === 29, r = t ? e.outputSampleRate / 2 : e.outputSampleRate, i = n ? 1 : e.outputNumberOfChannels, a = Ce.indexOf(i);
|
|
310
|
+
if (a === -1) throw TypeError(`Unsupported number of channels: ${e.outputNumberOfChannels}`);
|
|
311
|
+
let o = 16;
|
|
312
|
+
e.objectType >= 32 && (o += 6), De(r) === 15 && (o += 24), t && (o += 9, De(e.outputSampleRate) === 15 && (o += 24));
|
|
313
|
+
let s = Math.ceil(o / 8), c = new Uint8Array(s), l = new j(c);
|
|
314
|
+
return Te(l, e.objectType), Ee(l, r), l.writeBits(4, a), t && (Ee(l, e.outputSampleRate), Te(l, 2)), l.writeBits(3, 0), c;
|
|
315
|
+
}, Te = (e, t) => {
|
|
316
|
+
t < 32 ? e.writeBits(5, t) : (e.writeBits(5, 31), e.writeBits(6, t - 32));
|
|
317
|
+
}, Ee = (e, t) => {
|
|
318
|
+
let n = De(t);
|
|
319
|
+
e.writeBits(4, n), n === 15 && e.writeBits(24, t);
|
|
320
|
+
}, De = (e) => {
|
|
321
|
+
let t = Se.indexOf(e);
|
|
322
|
+
return t === -1 ? 15 : t;
|
|
323
|
+
}, M;
|
|
324
|
+
(function(e) {
|
|
325
|
+
e[e.NON_IDR_SLICE = 1] = "NON_IDR_SLICE", e[e.SLICE_DPA = 2] = "SLICE_DPA", e[e.SLICE_DPB = 3] = "SLICE_DPB", e[e.SLICE_DPC = 4] = "SLICE_DPC", e[e.IDR = 5] = "IDR", e[e.SEI = 6] = "SEI", e[e.SPS = 7] = "SPS", e[e.PPS = 8] = "PPS", e[e.AUD = 9] = "AUD", e[e.SPS_EXT = 13] = "SPS_EXT";
|
|
326
|
+
})(M ||= {});
|
|
327
|
+
var Oe;
|
|
328
|
+
(function(e) {
|
|
329
|
+
e[e.RASL_N = 8] = "RASL_N", e[e.RASL_R = 9] = "RASL_R", e[e.BLA_W_LP = 16] = "BLA_W_LP", e[e.RSV_IRAP_VCL23 = 23] = "RSV_IRAP_VCL23", e[e.VPS_NUT = 32] = "VPS_NUT", e[e.SPS_NUT = 33] = "SPS_NUT", e[e.PPS_NUT = 34] = "PPS_NUT", e[e.AUD_NUT = 35] = "AUD_NUT", e[e.PREFIX_SEI_NUT = 39] = "PREFIX_SEI_NUT", e[e.SUFFIX_SEI_NUT = 40] = "SUFFIX_SEI_NUT";
|
|
330
|
+
})(Oe ||= {});
|
|
331
|
+
var ke = function* (e) {
|
|
332
|
+
let t = 0, n = -1;
|
|
333
|
+
for (; t < e.length - 2;) {
|
|
334
|
+
let r = e.indexOf(0, t);
|
|
335
|
+
if (r === -1 || r >= e.length - 2) break;
|
|
336
|
+
t = r;
|
|
337
|
+
let i = 0;
|
|
338
|
+
if (t + 3 < e.length && e[t + 1] === 0 && e[t + 2] === 0 && e[t + 3] === 1 ? i = 4 : e[t + 1] === 0 && e[t + 2] === 1 && (i = 3), i === 0) {
|
|
339
|
+
t++;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
n !== -1 && t > n && (yield {
|
|
343
|
+
offset: n,
|
|
344
|
+
length: t - n
|
|
345
|
+
}), n = t + i, t = n;
|
|
346
|
+
}
|
|
347
|
+
n !== -1 && n < e.length && (yield {
|
|
348
|
+
offset: n,
|
|
349
|
+
length: e.length - n
|
|
350
|
+
});
|
|
351
|
+
}, Ae = function* (e, n) {
|
|
352
|
+
let r = 0, i = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
353
|
+
for (; r + n <= e.length;) {
|
|
354
|
+
let e;
|
|
355
|
+
n === 1 ? e = i.getUint8(r) : n === 2 ? e = i.getUint16(r, !1) : n === 3 ? e = v(i, r, !1) : (t(n === 4), e = i.getUint32(r, !1)), r += n, yield {
|
|
356
|
+
offset: r,
|
|
357
|
+
length: e
|
|
358
|
+
}, r += e;
|
|
359
|
+
}
|
|
360
|
+
}, je = (e, t) => t.description ? Ae(e, (o(t.description)[4] & 3) + 1) : ke(e), Me = (e) => e & 31, Ne = (e) => {
|
|
361
|
+
let t = [], n = e.length;
|
|
362
|
+
for (let r = 0; r < n; r++) r + 2 < n && e[r] === 0 && e[r + 1] === 0 && e[r + 2] === 3 ? (t.push(0, 0), r += 2) : t.push(e[r]);
|
|
363
|
+
return new Uint8Array(t);
|
|
364
|
+
};
|
|
365
|
+
new Uint8Array([
|
|
366
|
+
0,
|
|
367
|
+
0,
|
|
368
|
+
0,
|
|
369
|
+
1
|
|
370
|
+
]);
|
|
371
|
+
var Pe = (e, t) => t.description ? Ae(e, (o(t.description)[21] & 3) + 1) : ke(e), Fe = (e) => e >> 1 & 63, Ie;
|
|
372
|
+
(function(e) {
|
|
373
|
+
e[e.audAllowed = 0] = "audAllowed", e[e.beforeFirstVcl = 1] = "beforeFirstVcl", e[e.afterFirstVcl = 2] = "afterFirstVcl", e[e.eoBitstreamAllowed = 3] = "eoBitstreamAllowed", e[e.noMoreDataAllowed = 4] = "noMoreDataAllowed";
|
|
374
|
+
})(Ie ||= {});
|
|
375
|
+
var Le = function* (e) {
|
|
376
|
+
let n = new j(e), r = () => {
|
|
377
|
+
let e = 0;
|
|
378
|
+
for (let t = 0; t < 8; t++) {
|
|
379
|
+
let r = n.readAlignedByte();
|
|
380
|
+
if (e += (r & 127) * 2 ** (t * 7), !(r & 128)) break;
|
|
381
|
+
if (t === 7 && r & 128) return null;
|
|
382
|
+
}
|
|
383
|
+
return e > 2 ** 32 - 1 ? null : e;
|
|
384
|
+
};
|
|
385
|
+
for (; n.getBitsLeft() >= 8;) {
|
|
386
|
+
n.skipBits(1);
|
|
387
|
+
let i = n.readBits(4), a = n.readBits(1), o = n.readBits(1);
|
|
388
|
+
n.skipBits(1), a && n.skipBits(8);
|
|
389
|
+
let s;
|
|
390
|
+
if (o) {
|
|
391
|
+
let e = r();
|
|
392
|
+
if (e === null) return;
|
|
393
|
+
s = e;
|
|
394
|
+
} else s = Math.floor(n.getBitsLeft() / 8);
|
|
395
|
+
t(n.pos % 8 == 0), yield {
|
|
396
|
+
type: i,
|
|
397
|
+
data: e.subarray(n.pos / 8, n.pos / 8 + s)
|
|
398
|
+
}, n.skipBits(s * 8);
|
|
399
|
+
}
|
|
400
|
+
}, Re = (e) => {
|
|
401
|
+
let t = s(e), n = t.getUint8(9), r = t.getUint16(10, !0), i = t.getUint32(12, !0), a = t.getInt16(16, !0), o = t.getUint8(18), c = null;
|
|
402
|
+
return o && (c = e.subarray(19, 21 + n)), {
|
|
403
|
+
outputChannelCount: n,
|
|
404
|
+
preSkip: r,
|
|
405
|
+
inputSampleRate: i,
|
|
406
|
+
outputGain: a,
|
|
407
|
+
channelMappingFamily: o,
|
|
408
|
+
channelMappingTable: c
|
|
409
|
+
};
|
|
410
|
+
}, ze = (e, n, r) => {
|
|
411
|
+
switch (e) {
|
|
412
|
+
case "avc":
|
|
413
|
+
for (let e of je(r, n)) {
|
|
414
|
+
let t = r[e.offset], n = Me(t);
|
|
415
|
+
if (n >= M.NON_IDR_SLICE && n <= M.SLICE_DPC) return "delta";
|
|
416
|
+
if (n === M.IDR) return "key";
|
|
417
|
+
if (n === M.SEI && !ae()) {
|
|
418
|
+
let t = Ne(r.subarray(e.offset, e.offset + e.length)), n = 1;
|
|
419
|
+
do {
|
|
420
|
+
let e = 0;
|
|
421
|
+
for (;;) {
|
|
422
|
+
let r = t[n++];
|
|
423
|
+
if (r === void 0 || (e += r, r < 255)) break;
|
|
424
|
+
}
|
|
425
|
+
let r = 0;
|
|
426
|
+
for (;;) {
|
|
427
|
+
let e = t[n++];
|
|
428
|
+
if (e === void 0 || (r += e, e < 255)) break;
|
|
429
|
+
}
|
|
430
|
+
if (e === 6) {
|
|
431
|
+
let e = new j(t);
|
|
432
|
+
e.pos = 8 * n;
|
|
433
|
+
let r = i(e), a = e.readBits(1);
|
|
434
|
+
if (r === 0 && a === 1) return "key";
|
|
435
|
+
}
|
|
436
|
+
n += r;
|
|
437
|
+
} while (n < t.length - 1);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return "delta";
|
|
441
|
+
case "hevc":
|
|
442
|
+
for (let e of Pe(r, n)) {
|
|
443
|
+
let t = Fe(r[e.offset]);
|
|
444
|
+
if (t < Oe.BLA_W_LP) return "delta";
|
|
445
|
+
if (t <= Oe.RSV_IRAP_VCL23) return "key";
|
|
446
|
+
}
|
|
447
|
+
return "delta";
|
|
448
|
+
case "vp8": return r[0] & 1 ? "delta" : "key";
|
|
449
|
+
case "vp9": {
|
|
450
|
+
let e = new j(r);
|
|
451
|
+
if (e.readBits(2) !== 2) return null;
|
|
452
|
+
let t = e.readBits(1);
|
|
453
|
+
return (e.readBits(1) << 1) + t === 3 && e.skipBits(1), e.readBits(1) ? null : e.readBits(1) === 0 ? "key" : "delta";
|
|
454
|
+
}
|
|
455
|
+
case "av1": {
|
|
456
|
+
let e = !1;
|
|
457
|
+
for (let { type: t, data: n } of Le(r)) if (t === 1) {
|
|
458
|
+
let t = new j(n);
|
|
459
|
+
t.skipBits(4), e = !!t.readBits(1);
|
|
460
|
+
} else if (t === 3 || t === 6 || t === 7) {
|
|
461
|
+
if (e) return "key";
|
|
462
|
+
let t = new j(n);
|
|
463
|
+
return t.readBits(1) ? null : t.readBits(2) === 0 ? "key" : "delta";
|
|
464
|
+
}
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
case "prores": return "key";
|
|
468
|
+
default: _(e), t(!1);
|
|
469
|
+
}
|
|
470
|
+
}, Be;
|
|
471
|
+
(function(e) {
|
|
472
|
+
e[e.STREAMINFO = 0] = "STREAMINFO", e[e.VORBIS_COMMENT = 4] = "VORBIS_COMMENT", e[e.PICTURE = 6] = "PICTURE";
|
|
473
|
+
})(Be ||= {}), new Uint8Array([
|
|
474
|
+
5,
|
|
475
|
+
4,
|
|
476
|
+
65,
|
|
477
|
+
67,
|
|
478
|
+
45,
|
|
479
|
+
51
|
|
480
|
+
]), new Uint8Array([
|
|
481
|
+
5,
|
|
482
|
+
4,
|
|
483
|
+
69,
|
|
484
|
+
65,
|
|
485
|
+
67,
|
|
486
|
+
51
|
|
487
|
+
]);
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region ../../node_modules/.pnpm/mediabunny@1.55.6/node_modules/mediabunny/dist/modules/src/codec.js
|
|
490
|
+
var N = [
|
|
323
491
|
"avc",
|
|
324
492
|
"hevc",
|
|
325
493
|
"vp9",
|
|
326
494
|
"av1",
|
|
327
495
|
"vp8",
|
|
328
496
|
"prores"
|
|
329
|
-
],
|
|
497
|
+
], P = [
|
|
330
498
|
"pcm-s16",
|
|
331
499
|
"pcm-s16be",
|
|
332
500
|
"pcm-s24",
|
|
@@ -341,15 +509,16 @@ var ge = class {
|
|
|
341
509
|
"pcm-s8",
|
|
342
510
|
"ulaw",
|
|
343
511
|
"alaw"
|
|
344
|
-
],
|
|
512
|
+
], Ve = [
|
|
345
513
|
"aac",
|
|
346
514
|
"opus",
|
|
347
515
|
"mp3",
|
|
348
516
|
"vorbis",
|
|
349
517
|
"flac",
|
|
350
518
|
"ac3",
|
|
351
|
-
"eac3"
|
|
352
|
-
|
|
519
|
+
"eac3",
|
|
520
|
+
"dts"
|
|
521
|
+
], F = [...Ve, ...P], I = ["webvtt"], He = [
|
|
353
522
|
{
|
|
354
523
|
maxMacroblocks: 99,
|
|
355
524
|
maxBitrate: 64e3,
|
|
@@ -464,7 +633,7 @@ var ge = class {
|
|
|
464
633
|
maxDpbMbs: 696320,
|
|
465
634
|
level: 62
|
|
466
635
|
}
|
|
467
|
-
],
|
|
636
|
+
], Ue = [
|
|
468
637
|
{
|
|
469
638
|
maxPictureSize: 36864,
|
|
470
639
|
maxBitrate: 128e3,
|
|
@@ -591,7 +760,7 @@ var ge = class {
|
|
|
591
760
|
tier: "H",
|
|
592
761
|
level: 186
|
|
593
762
|
}
|
|
594
|
-
],
|
|
763
|
+
], We = [
|
|
595
764
|
{
|
|
596
765
|
maxPictureSize: 36864,
|
|
597
766
|
maxBitrate: 2e5,
|
|
@@ -662,7 +831,7 @@ var ge = class {
|
|
|
662
831
|
maxBitrate: 48e7,
|
|
663
832
|
level: 62
|
|
664
833
|
}
|
|
665
|
-
],
|
|
834
|
+
], Ge = [
|
|
666
835
|
{
|
|
667
836
|
maxPictureSize: 147456,
|
|
668
837
|
maxBitrate: 15e5,
|
|
@@ -807,14 +976,19 @@ var ge = class {
|
|
|
807
976
|
tier: "H",
|
|
808
977
|
level: 19
|
|
809
978
|
}
|
|
810
|
-
],
|
|
979
|
+
], L = [
|
|
811
980
|
"ap4x",
|
|
812
981
|
"ap4h",
|
|
813
982
|
"apch",
|
|
814
983
|
"apcn",
|
|
815
984
|
"apcs",
|
|
816
985
|
"apco"
|
|
817
|
-
],
|
|
986
|
+
], R = [
|
|
987
|
+
"dtsc",
|
|
988
|
+
"dtsh",
|
|
989
|
+
"dtsl",
|
|
990
|
+
"dtse"
|
|
991
|
+
], Ke = [
|
|
818
992
|
{
|
|
819
993
|
fourCc: "apco",
|
|
820
994
|
bitrate: 45e6,
|
|
@@ -845,34 +1019,30 @@ var ge = class {
|
|
|
845
1019
|
bitrate: 5e8,
|
|
846
1020
|
alpha: !0
|
|
847
1021
|
}
|
|
848
|
-
],
|
|
1022
|
+
], qe = (e, t, n, i, a) => {
|
|
849
1023
|
if (e === "avc") {
|
|
850
|
-
let e = Math.ceil(t / 16) * Math.ceil(n / 16), a =
|
|
1024
|
+
let e = Math.ceil(t / 16) * Math.ceil(n / 16), a = He.find((t) => e <= t.maxMacroblocks && i <= t.maxBitrate) ?? r(He), o = a ? a.level : 0;
|
|
851
1025
|
return `avc1.${"64".padStart(2, "0")}00${o.toString(16).padStart(2, "0")}`;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
let e = t * n, a = Te.find((t) => e <= t.maxPictureSize && i <= t.maxBitrate) ?? r(Te);
|
|
1026
|
+
} else if (e === "hevc") {
|
|
1027
|
+
let e = t * n, a = Ue.find((t) => e <= t.maxPictureSize && i <= t.maxBitrate) ?? r(Ue);
|
|
855
1028
|
return `hev1.1.6.${a.tier}${a.level}.B0`;
|
|
856
|
-
}
|
|
857
|
-
if (e === "
|
|
858
|
-
if (e === "vp9") {
|
|
1029
|
+
} else if (e === "vp8") return "vp8";
|
|
1030
|
+
else if (e === "vp9") {
|
|
859
1031
|
let e = t * n;
|
|
860
|
-
return `vp09.00.${(
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
let e = t * n, a = De.find((t) => e <= t.maxPictureSize && i <= t.maxBitrate) ?? r(De);
|
|
1032
|
+
return `vp09.00.${(We.find((t) => e <= t.maxPictureSize && i <= t.maxBitrate) ?? r(We)).level.toString().padStart(2, "0")}.08`;
|
|
1033
|
+
} else if (e === "av1") {
|
|
1034
|
+
let e = t * n, a = Ge.find((t) => e <= t.maxPictureSize && i <= t.maxBitrate) ?? r(Ge);
|
|
864
1035
|
return `av01.0.${a.level.toString().padStart(2, "0")}${a.tier}.08`;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
let e = (t * n / 2073600) ** .95, r = Oe.filter((e) => e.alpha === a), o = r[0].fourCc, s = Infinity;
|
|
1036
|
+
} else if (e === "prores") {
|
|
1037
|
+
let e = (t * n / (1920 * 1080)) ** .95, r = Ke.filter((e) => e.alpha === a), o = r[0].fourCc, s = Infinity;
|
|
868
1038
|
for (let { fourCc: t, bitrate: n } of r) {
|
|
869
1039
|
let r = Math.abs(n * e - i);
|
|
870
1040
|
r < s && (s = r, o = t);
|
|
871
1041
|
}
|
|
872
1042
|
return o;
|
|
873
|
-
}
|
|
874
|
-
throw
|
|
875
|
-
},
|
|
1043
|
+
} else _(e);
|
|
1044
|
+
throw TypeError(`Unhandled codec '${String(e)}'.`);
|
|
1045
|
+
}, Je = (e) => {
|
|
876
1046
|
let t = e.split(".");
|
|
877
1047
|
return [
|
|
878
1048
|
1,
|
|
@@ -888,16 +1058,16 @@ var ge = class {
|
|
|
888
1058
|
1,
|
|
889
1059
|
t[4] ? Number(t[4]) : 1
|
|
890
1060
|
];
|
|
891
|
-
},
|
|
892
|
-
let t = e.split("."), n = Number(t[1]), r = t[2], i = Number(r.slice(0, -1)), a = (n << 5) + i, o = +(r.slice(-1) === "H"), s = Number(t[3]) === 8 ? 0 : 1,
|
|
1061
|
+
}, Ye = (e) => {
|
|
1062
|
+
let t = e.split("."), n = Number(t[1]), r = t[2], i = Number(r.slice(0, -1)), a = (n << 5) + i, o = +(r.slice(-1) === "H"), s = Number(t[3]), c = s === 8 ? 0 : 1, l = +(s === 12), u = t[4] ? Number(t[4]) : 0, d = t[5] ? Number(t[5][0]) : 1, f = t[5] ? Number(t[5][1]) : 1, p = t[5] ? Number(t[5][2]) : 0;
|
|
893
1063
|
return [
|
|
894
1064
|
129,
|
|
895
1065
|
a,
|
|
896
|
-
(o << 7) + (
|
|
1066
|
+
(o << 7) + (c << 6) + (l << 5) + (u << 4) + (d << 3) + (f << 2) + p,
|
|
897
1067
|
0
|
|
898
1068
|
];
|
|
899
|
-
},
|
|
900
|
-
if (t(
|
|
1069
|
+
}, Xe = 48e3, Ze = /^pcm-([usf])(\d+)(be)?$/, Qe = (e) => {
|
|
1070
|
+
if (t(P.includes(e)), e === "ulaw") return {
|
|
901
1071
|
dataType: "ulaw",
|
|
902
1072
|
sampleSize: 1,
|
|
903
1073
|
littleEndian: !0,
|
|
@@ -909,7 +1079,7 @@ var ge = class {
|
|
|
909
1079
|
littleEndian: !0,
|
|
910
1080
|
silentValue: 213
|
|
911
1081
|
};
|
|
912
|
-
let n =
|
|
1082
|
+
let n = Ze.exec(e);
|
|
913
1083
|
t(n);
|
|
914
1084
|
let r;
|
|
915
1085
|
r = n[1] === "u" ? "unsigned" : n[1] === "s" ? "signed" : "float";
|
|
@@ -918,9 +1088,9 @@ var ge = class {
|
|
|
918
1088
|
dataType: r,
|
|
919
1089
|
sampleSize: i,
|
|
920
1090
|
littleEndian: a,
|
|
921
|
-
silentValue: e === "pcm-u8" ?
|
|
1091
|
+
silentValue: e === "pcm-u8" ? 2 ** 7 : 0
|
|
922
1092
|
};
|
|
923
|
-
},
|
|
1093
|
+
}, z = (e) => e.startsWith("avc1") || e.startsWith("avc3") ? "avc" : e.startsWith("hev1") || e.startsWith("hvc1") ? "hevc" : e === "vp8" ? "vp8" : e.startsWith("vp09") ? "vp9" : e.startsWith("av01") ? "av1" : L.includes(e) ? "prores" : e === "mp3" || e === "mp4a.69" || e === "mp4a.6B" || e === "mp4a.6b" || e === "mp4a.40.34" ? "mp3" : e.startsWith("mp4a.40.") || e === "mp4a.67" ? "aac" : e === "opus" ? "opus" : e === "vorbis" ? "vorbis" : e === "flac" ? "flac" : e === "ac-3" || e === "ac3" ? "ac3" : e === "ec-3" || e === "eac3" ? "eac3" : R.includes(e) ? "dts" : e === "ulaw" ? "ulaw" : e === "alaw" ? "alaw" : Ze.test(e) ? e : e === "webvtt" ? "webvtt" : null, $e = (e) => e === "avc" ? { avc: { format: "avc" } } : e === "hevc" ? { hevc: { format: "hevc" } } : {}, et = [
|
|
924
1094
|
"avc1",
|
|
925
1095
|
"avc3",
|
|
926
1096
|
"hev1",
|
|
@@ -928,14 +1098,14 @@ var ge = class {
|
|
|
928
1098
|
"vp8",
|
|
929
1099
|
"vp09",
|
|
930
1100
|
"av01",
|
|
931
|
-
...
|
|
932
|
-
],
|
|
1101
|
+
...L
|
|
1102
|
+
], tt = /^(avc1|avc3)\.[0-9a-fA-F]{6}$/, nt = /^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/, rt = /^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/, it = /^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/, at = (e, t) => {
|
|
933
1103
|
if (!e) throw TypeError("Video chunk metadata must be provided.");
|
|
934
1104
|
if (typeof e != "object") throw TypeError("Video chunk metadata must be an object.");
|
|
935
1105
|
if (!e.decoderConfig) throw TypeError("Video chunk metadata must include a decoder configuration.");
|
|
936
1106
|
if (typeof e.decoderConfig != "object") throw TypeError("Video chunk metadata decoder configuration must be an object.");
|
|
937
1107
|
if (typeof e.decoderConfig.codec != "string") throw TypeError("Video chunk metadata decoder configuration must specify a codec string.");
|
|
938
|
-
if (!
|
|
1108
|
+
if (!et.some((t) => e.decoderConfig.codec.startsWith(t))) throw TypeError("Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the Mediabunny Codec Registry.");
|
|
939
1109
|
if (!Number.isInteger(e.decoderConfig.codedWidth) || e.decoderConfig.codedWidth <= 0) throw TypeError("Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).");
|
|
940
1110
|
if (!Number.isInteger(e.decoderConfig.codedHeight) || e.decoderConfig.codedHeight <= 0) throw TypeError("Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).");
|
|
941
1111
|
if (e.decoderConfig.displayAspectWidth !== void 0 && (!Number.isInteger(e.decoderConfig.displayAspectWidth) || e.decoderConfig.displayAspectWidth <= 0)) throw TypeError("Video chunk metadata decoder configuration displayAspectWidth, when defined, must be a positive integer.");
|
|
@@ -954,18 +1124,18 @@ var ge = class {
|
|
|
954
1124
|
if (t.fullRange != null && typeof t.fullRange != "boolean") throw TypeError("Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.");
|
|
955
1125
|
}
|
|
956
1126
|
if (e.decoderConfig.codec.startsWith("avc1") || e.decoderConfig.codec.startsWith("avc3")) {
|
|
957
|
-
if (!
|
|
1127
|
+
if (!tt.test(e.decoderConfig.codec)) throw TypeError("Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.");
|
|
958
1128
|
} else if (e.decoderConfig.codec.startsWith("hev1") || e.decoderConfig.codec.startsWith("hvc1")) {
|
|
959
|
-
if (!
|
|
1129
|
+
if (!nt.test(e.decoderConfig.codec)) throw TypeError("Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.");
|
|
960
1130
|
} else if (e.decoderConfig.codec.startsWith("vp8")) {
|
|
961
1131
|
if (e.decoderConfig.codec !== "vp8") throw TypeError("Video chunk metadata decoder configuration codec string for VP8 must be \"vp8\".");
|
|
962
1132
|
} else if (e.decoderConfig.codec.startsWith("vp09")) {
|
|
963
|
-
if (!
|
|
1133
|
+
if (!rt.test(e.decoderConfig.codec)) throw TypeError("Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section \"Codecs Parameter String\" of https://www.webmproject.org/vp9/mp4/.");
|
|
964
1134
|
} else if (e.decoderConfig.codec.startsWith("av01")) {
|
|
965
|
-
if (!
|
|
966
|
-
} else if (
|
|
967
|
-
if (t !== null &&
|
|
968
|
-
},
|
|
1135
|
+
if (!it.test(e.decoderConfig.codec)) throw TypeError("Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section \"Codecs Parameter String\" of https://aomediacodec.github.io/av1-isobmff/.");
|
|
1136
|
+
} else if (L.some((t) => e.decoderConfig.codec.startsWith(t)) && !L.some((t) => e.decoderConfig.codec === t)) throw TypeError(`Video chunk metadata decoder configuration codec string for ProRes must be one of the valid ProRes four-character codes: ${L.join(", ")}.`);
|
|
1137
|
+
if (t !== null && z(e.decoderConfig.codec) !== t) throw TypeError(`Video chunk metadata decoder configuration codec string '${e.decoderConfig.codec}' does not fit to the track codec '${t}'.`);
|
|
1138
|
+
}, ot = [
|
|
969
1139
|
"mp4a",
|
|
970
1140
|
"mp3",
|
|
971
1141
|
"opus",
|
|
@@ -975,14 +1145,15 @@ var ge = class {
|
|
|
975
1145
|
"alaw",
|
|
976
1146
|
"pcm",
|
|
977
1147
|
"ac-3",
|
|
978
|
-
"ec-3"
|
|
979
|
-
|
|
1148
|
+
"ec-3",
|
|
1149
|
+
"dts"
|
|
1150
|
+
], st = (e, t) => {
|
|
980
1151
|
if (!e) throw TypeError("Audio chunk metadata must be provided.");
|
|
981
1152
|
if (typeof e != "object") throw TypeError("Audio chunk metadata must be an object.");
|
|
982
1153
|
if (!e.decoderConfig) throw TypeError("Audio chunk metadata must include a decoder configuration.");
|
|
983
1154
|
if (typeof e.decoderConfig != "object") throw TypeError("Audio chunk metadata decoder configuration must be an object.");
|
|
984
1155
|
if (typeof e.decoderConfig.codec != "string") throw TypeError("Audio chunk metadata decoder configuration must specify a codec string.");
|
|
985
|
-
if (!
|
|
1156
|
+
if (!ot.some((t) => e.decoderConfig.codec.startsWith(t))) throw TypeError("Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the Mediabunny Codec Registry.");
|
|
986
1157
|
if (!Number.isInteger(e.decoderConfig.sampleRate) || e.decoderConfig.sampleRate <= 0) throw TypeError("Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).");
|
|
987
1158
|
if (!Number.isInteger(e.decoderConfig.numberOfChannels) || e.decoderConfig.numberOfChannels <= 0) throw TypeError("Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).");
|
|
988
1159
|
if (e.decoderConfig.description !== void 0 && !p(e.decoderConfig.description)) throw TypeError("Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");
|
|
@@ -1010,184 +1181,19 @@ var ge = class {
|
|
|
1010
1181
|
if (e.decoderConfig.codec !== "ac-3") throw TypeError("Audio chunk metadata decoder configuration codec string for AC-3 must be \"ac-3\".");
|
|
1011
1182
|
} else if (e.decoderConfig.codec.startsWith("ec-3") || e.decoderConfig.codec.startsWith("eac3")) {
|
|
1012
1183
|
if (e.decoderConfig.codec !== "ec-3") throw TypeError("Audio chunk metadata decoder configuration codec string for EC-3 must be \"ec-3\".");
|
|
1013
|
-
} else if (
|
|
1014
|
-
|
|
1015
|
-
}
|
|
1184
|
+
} else if (e.decoderConfig.codec.startsWith("dts")) {
|
|
1185
|
+
if (!R.includes(e.decoderConfig.codec)) throw TypeError(`Audio chunk metadata decoder configuration codec string for DTS must be one of the following four-character codes: ${R.join(", ")}.`);
|
|
1186
|
+
} else if ((e.decoderConfig.codec.startsWith("pcm") || e.decoderConfig.codec.startsWith("ulaw") || e.decoderConfig.codec.startsWith("alaw")) && !P.includes(e.decoderConfig.codec)) throw TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${P.join(", ")}).`);
|
|
1187
|
+
if (t !== null && z(e.decoderConfig.codec) !== t) throw TypeError(`Audio chunk metadata decoder configuration codec string '${e.decoderConfig.codec}' does not fit to the track codec '${t}'.`);
|
|
1188
|
+
}, ct = (e) => {
|
|
1016
1189
|
if (!e) throw TypeError("Subtitle metadata must be provided.");
|
|
1017
1190
|
if (typeof e != "object") throw TypeError("Subtitle metadata must be an object.");
|
|
1018
1191
|
if (!e.config) throw TypeError("Subtitle metadata must include a config object.");
|
|
1019
1192
|
if (typeof e.config != "object") throw TypeError("Subtitle metadata config must be an object.");
|
|
1020
1193
|
if (typeof e.config.description != "string") throw TypeError("Subtitle metadata config description must be a string.");
|
|
1021
|
-
},
|
|
1022
|
-
(function(e) {
|
|
1023
|
-
e[e.NON_IDR_SLICE = 1] = "NON_IDR_SLICE", e[e.SLICE_DPA = 2] = "SLICE_DPA", e[e.SLICE_DPB = 3] = "SLICE_DPB", e[e.SLICE_DPC = 4] = "SLICE_DPC", e[e.IDR = 5] = "IDR", e[e.SEI = 6] = "SEI", e[e.SPS = 7] = "SPS", e[e.PPS = 8] = "PPS", e[e.AUD = 9] = "AUD", e[e.SPS_EXT = 13] = "SPS_EXT";
|
|
1024
|
-
})(R ||= {});
|
|
1025
|
-
var Ge;
|
|
1026
|
-
(function(e) {
|
|
1027
|
-
e[e.RASL_N = 8] = "RASL_N", e[e.RASL_R = 9] = "RASL_R", e[e.BLA_W_LP = 16] = "BLA_W_LP", e[e.RSV_IRAP_VCL23 = 23] = "RSV_IRAP_VCL23", e[e.VPS_NUT = 32] = "VPS_NUT", e[e.SPS_NUT = 33] = "SPS_NUT", e[e.PPS_NUT = 34] = "PPS_NUT", e[e.AUD_NUT = 35] = "AUD_NUT", e[e.PREFIX_SEI_NUT = 39] = "PREFIX_SEI_NUT", e[e.SUFFIX_SEI_NUT = 40] = "SUFFIX_SEI_NUT";
|
|
1028
|
-
})(Ge ||= {});
|
|
1029
|
-
var Ke = function* (e) {
|
|
1030
|
-
let t = 0, n = -1;
|
|
1031
|
-
for (; t < e.length - 2;) {
|
|
1032
|
-
let r = e.indexOf(0, t);
|
|
1033
|
-
if (r === -1 || r >= e.length - 2) break;
|
|
1034
|
-
t = r;
|
|
1035
|
-
let i = 0;
|
|
1036
|
-
if (t + 3 < e.length && e[t + 1] === 0 && e[t + 2] === 0 && e[t + 3] === 1 ? i = 4 : e[t + 1] === 0 && e[t + 2] === 1 && (i = 3), i === 0) {
|
|
1037
|
-
t++;
|
|
1038
|
-
continue;
|
|
1039
|
-
}
|
|
1040
|
-
n !== -1 && t > n && (yield {
|
|
1041
|
-
offset: n,
|
|
1042
|
-
length: t - n
|
|
1043
|
-
}), n = t + i, t = n;
|
|
1044
|
-
}
|
|
1045
|
-
n !== -1 && n < e.length && (yield {
|
|
1046
|
-
offset: n,
|
|
1047
|
-
length: e.length - n
|
|
1048
|
-
});
|
|
1049
|
-
}, qe = function* (e, n) {
|
|
1050
|
-
let r = 0, i = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1051
|
-
for (; r + n <= e.length;) {
|
|
1052
|
-
let e;
|
|
1053
|
-
n === 1 ? e = i.getUint8(r) : n === 2 ? e = i.getUint16(r, !1) : n === 3 ? e = ee(i, r, !1) : (t(n === 4), e = i.getUint32(r, !1)), r += n, yield {
|
|
1054
|
-
offset: r,
|
|
1055
|
-
length: e
|
|
1056
|
-
}, r += e;
|
|
1057
|
-
}
|
|
1058
|
-
}, Je = (e, t) => t.description ? qe(e, (o(t.description)[4] & 3) + 1) : Ke(e), Ye = (e) => e & 31, Xe = (e) => {
|
|
1059
|
-
let t = [], n = e.length;
|
|
1060
|
-
for (let r = 0; r < n; r++) r + 2 < n && e[r] === 0 && e[r + 1] === 0 && e[r + 2] === 3 ? (t.push(0, 0), r += 2) : t.push(e[r]);
|
|
1061
|
-
return new Uint8Array(t);
|
|
1062
|
-
};
|
|
1063
|
-
new Uint8Array([
|
|
1064
|
-
0,
|
|
1065
|
-
0,
|
|
1066
|
-
0,
|
|
1067
|
-
1
|
|
1068
|
-
]);
|
|
1069
|
-
var Ze = (e, t) => t.description ? qe(e, (o(t.description)[21] & 3) + 1) : Ke(e), Qe = (e) => e >> 1 & 63, $e;
|
|
1070
|
-
(function(e) {
|
|
1071
|
-
e[e.audAllowed = 0] = "audAllowed", e[e.beforeFirstVcl = 1] = "beforeFirstVcl", e[e.afterFirstVcl = 2] = "afterFirstVcl", e[e.eoBitstreamAllowed = 3] = "eoBitstreamAllowed", e[e.noMoreDataAllowed = 4] = "noMoreDataAllowed";
|
|
1072
|
-
})($e ||= {});
|
|
1073
|
-
var et = function* (e) {
|
|
1074
|
-
let n = new j(e), r = () => {
|
|
1075
|
-
let e = 0;
|
|
1076
|
-
for (let t = 0; t < 8; t++) {
|
|
1077
|
-
let r = n.readAlignedByte();
|
|
1078
|
-
if (e |= (r & 127) << t * 7, !(r & 128)) break;
|
|
1079
|
-
if (t === 7 && r & 128) return null;
|
|
1080
|
-
}
|
|
1081
|
-
return e >= 2 ** 32 - 1 ? null : e;
|
|
1082
|
-
};
|
|
1083
|
-
for (; n.getBitsLeft() >= 8;) {
|
|
1084
|
-
n.skipBits(1);
|
|
1085
|
-
let i = n.readBits(4), a = n.readBits(1), o = n.readBits(1);
|
|
1086
|
-
n.skipBits(1), a && n.skipBits(8);
|
|
1087
|
-
let s;
|
|
1088
|
-
if (o) {
|
|
1089
|
-
let e = r();
|
|
1090
|
-
if (e === null) return;
|
|
1091
|
-
s = e;
|
|
1092
|
-
} else s = Math.floor(n.getBitsLeft() / 8);
|
|
1093
|
-
t(n.pos % 8 == 0), yield {
|
|
1094
|
-
type: i,
|
|
1095
|
-
data: e.subarray(n.pos / 8, n.pos / 8 + s)
|
|
1096
|
-
}, n.skipBits(s * 8);
|
|
1097
|
-
}
|
|
1098
|
-
}, tt = (e) => {
|
|
1099
|
-
let t = s(e), n = t.getUint8(9), r = t.getUint16(10, !0), i = t.getUint32(12, !0), a = t.getInt16(16, !0), o = t.getUint8(18), c = null;
|
|
1100
|
-
return o && (c = e.subarray(19, 21 + n)), {
|
|
1101
|
-
outputChannelCount: n,
|
|
1102
|
-
preSkip: r,
|
|
1103
|
-
inputSampleRate: i,
|
|
1104
|
-
outputGain: a,
|
|
1105
|
-
channelMappingFamily: o,
|
|
1106
|
-
channelMappingTable: c
|
|
1107
|
-
};
|
|
1108
|
-
}, nt = (e, n, r) => {
|
|
1109
|
-
switch (e) {
|
|
1110
|
-
case "avc":
|
|
1111
|
-
for (let e of Je(r, n)) {
|
|
1112
|
-
let t = r[e.offset], n = Ye(t);
|
|
1113
|
-
if (n >= R.NON_IDR_SLICE && n <= R.SLICE_DPC) return "delta";
|
|
1114
|
-
if (n === R.IDR) return "key";
|
|
1115
|
-
if (n === R.SEI && (!ae() || oe() >= 144)) {
|
|
1116
|
-
let t = Xe(r.subarray(e.offset, e.offset + e.length)), n = 1;
|
|
1117
|
-
do {
|
|
1118
|
-
let e = 0;
|
|
1119
|
-
for (;;) {
|
|
1120
|
-
let r = t[n++];
|
|
1121
|
-
if (r === void 0 || (e += r, r < 255)) break;
|
|
1122
|
-
}
|
|
1123
|
-
let r = 0;
|
|
1124
|
-
for (;;) {
|
|
1125
|
-
let e = t[n++];
|
|
1126
|
-
if (e === void 0 || (r += e, e < 255)) break;
|
|
1127
|
-
}
|
|
1128
|
-
if (e === 6) {
|
|
1129
|
-
let e = new j(t);
|
|
1130
|
-
e.pos = 8 * n;
|
|
1131
|
-
let r = i(e), a = e.readBits(1);
|
|
1132
|
-
if (r === 0 && a === 1) return "key";
|
|
1133
|
-
}
|
|
1134
|
-
n += r;
|
|
1135
|
-
} while (n < t.length - 1);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
return "delta";
|
|
1139
|
-
case "hevc":
|
|
1140
|
-
for (let e of Ze(r, n)) {
|
|
1141
|
-
let t = Qe(r[e.offset]);
|
|
1142
|
-
if (t < Ge.BLA_W_LP) return "delta";
|
|
1143
|
-
if (t <= Ge.RSV_IRAP_VCL23) return "key";
|
|
1144
|
-
}
|
|
1145
|
-
return "delta";
|
|
1146
|
-
case "vp8": return r[0] & 1 ? "delta" : "key";
|
|
1147
|
-
case "vp9": {
|
|
1148
|
-
let e = new j(r);
|
|
1149
|
-
if (e.readBits(2) !== 2) return null;
|
|
1150
|
-
let t = e.readBits(1);
|
|
1151
|
-
return (e.readBits(1) << 1) + t === 3 && e.skipBits(1), e.readBits(1) ? null : e.readBits(1) === 0 ? "key" : "delta";
|
|
1152
|
-
}
|
|
1153
|
-
case "av1": {
|
|
1154
|
-
let e = !1;
|
|
1155
|
-
for (let { type: t, data: n } of et(r)) if (t === 1) {
|
|
1156
|
-
let t = new j(n);
|
|
1157
|
-
t.skipBits(4), e = !!t.readBits(1);
|
|
1158
|
-
} else if (t === 3 || t === 6 || t === 7) {
|
|
1159
|
-
if (e) return "key";
|
|
1160
|
-
let t = new j(n);
|
|
1161
|
-
return t.readBits(1) ? null : t.readBits(2) === 0 ? "key" : "delta";
|
|
1162
|
-
}
|
|
1163
|
-
return null;
|
|
1164
|
-
}
|
|
1165
|
-
case "prores": return "key";
|
|
1166
|
-
default: _(e), t(!1);
|
|
1167
|
-
}
|
|
1168
|
-
}, rt;
|
|
1169
|
-
(function(e) {
|
|
1170
|
-
e[e.STREAMINFO = 0] = "STREAMINFO", e[e.VORBIS_COMMENT = 4] = "VORBIS_COMMENT", e[e.PICTURE = 6] = "PICTURE";
|
|
1171
|
-
})(rt ||= {}), new Uint8Array([
|
|
1172
|
-
5,
|
|
1173
|
-
4,
|
|
1174
|
-
65,
|
|
1175
|
-
67,
|
|
1176
|
-
45,
|
|
1177
|
-
51
|
|
1178
|
-
]), new Uint8Array([
|
|
1179
|
-
5,
|
|
1180
|
-
4,
|
|
1181
|
-
69,
|
|
1182
|
-
65,
|
|
1183
|
-
67,
|
|
1184
|
-
51
|
|
1185
|
-
]);
|
|
1186
|
-
//#endregion
|
|
1187
|
-
//#region node_modules/.pnpm/mediabunny@1.54.0/node_modules/mediabunny/dist/modules/src/packet.js
|
|
1188
|
-
var it = /* #__PURE__ */ new Uint8Array(), z = class e {
|
|
1194
|
+
}, lt = /* #__PURE__ */ new Uint8Array(), B = class e {
|
|
1189
1195
|
constructor(e, t, n, r, i = -1, a, o) {
|
|
1190
|
-
if (this.data = e, this.type = t, this.timestamp = n, this.duration = r, this.sequenceNumber = i, e ===
|
|
1196
|
+
if (this.data = e, this.type = t, this.timestamp = n, this.duration = r, this.sequenceNumber = i, e === lt && a === void 0) throw Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");
|
|
1191
1197
|
if (a === void 0 && (a = e.byteLength), !(e instanceof Uint8Array)) throw TypeError("data must be a Uint8Array.");
|
|
1192
1198
|
if (t !== "key" && t !== "delta") throw TypeError("type must be either \"key\" or \"delta\".");
|
|
1193
1199
|
if (!Number.isFinite(n)) throw TypeError("timestamp must be a number.");
|
|
@@ -1200,17 +1206,17 @@ var it = /* #__PURE__ */ new Uint8Array(), z = class e {
|
|
|
1200
1206
|
this.byteLength = a, this.sideData = o ?? {}, this.sideData.alpha && this.sideData.alphaByteLength === void 0 && (this.sideData.alphaByteLength = this.sideData.alpha.byteLength);
|
|
1201
1207
|
}
|
|
1202
1208
|
get isMetadataOnly() {
|
|
1203
|
-
return this.data ===
|
|
1209
|
+
return this.data === lt;
|
|
1204
1210
|
}
|
|
1205
1211
|
get microsecondTimestamp() {
|
|
1206
|
-
return Math.trunc(
|
|
1212
|
+
return Math.trunc(w * this.timestamp);
|
|
1207
1213
|
}
|
|
1208
1214
|
get microsecondDuration() {
|
|
1209
|
-
return Math.trunc(
|
|
1215
|
+
return Math.trunc(w * this.duration);
|
|
1210
1216
|
}
|
|
1211
1217
|
toEncodedVideoChunk() {
|
|
1212
1218
|
if (this.isMetadataOnly) throw TypeError("Metadata-only packets cannot be converted to a video chunk.");
|
|
1213
|
-
if (typeof EncodedVideoChunk > "u") throw Error("
|
|
1219
|
+
if (typeof EncodedVideoChunk > "u") throw Error("EncodedVideoChunk is not available in this environment.");
|
|
1214
1220
|
return new EncodedVideoChunk({
|
|
1215
1221
|
data: this.data,
|
|
1216
1222
|
type: this.type,
|
|
@@ -1221,7 +1227,7 @@ var it = /* #__PURE__ */ new Uint8Array(), z = class e {
|
|
|
1221
1227
|
alphaToEncodedVideoChunk(e = this.type) {
|
|
1222
1228
|
if (!this.sideData.alpha) throw TypeError("This packet does not contain alpha side data.");
|
|
1223
1229
|
if (this.isMetadataOnly) throw TypeError("Metadata-only packets cannot be converted to a video chunk.");
|
|
1224
|
-
if (typeof EncodedVideoChunk > "u") throw Error("
|
|
1230
|
+
if (typeof EncodedVideoChunk > "u") throw Error("EncodedVideoChunk is not available in this environment.");
|
|
1225
1231
|
return new EncodedVideoChunk({
|
|
1226
1232
|
data: this.sideData.alpha,
|
|
1227
1233
|
type: e,
|
|
@@ -1231,7 +1237,7 @@ var it = /* #__PURE__ */ new Uint8Array(), z = class e {
|
|
|
1231
1237
|
}
|
|
1232
1238
|
toEncodedAudioChunk() {
|
|
1233
1239
|
if (this.isMetadataOnly) throw TypeError("Metadata-only packets cannot be converted to an audio chunk.");
|
|
1234
|
-
if (typeof EncodedAudioChunk > "u") throw Error("
|
|
1240
|
+
if (typeof EncodedAudioChunk > "u") throw Error("EncodedAudioChunk is not available in this environment.");
|
|
1235
1241
|
return new EncodedAudioChunk({
|
|
1236
1242
|
data: this.data,
|
|
1237
1243
|
type: this.type,
|
|
@@ -1254,38 +1260,38 @@ var it = /* #__PURE__ */ new Uint8Array(), z = class e {
|
|
|
1254
1260
|
if (t?.sideData !== void 0 && (typeof t.sideData != "object" || t.sideData === null)) throw TypeError("options.sideData, when provided, must be an object.");
|
|
1255
1261
|
return new e(t?.data ?? this.data, t?.type ?? this.type, t?.timestamp ?? this.timestamp, t?.duration ?? this.duration, t?.sequenceNumber ?? this.sequenceNumber, this.byteLength, t?.sideData ?? this.sideData);
|
|
1256
1262
|
}
|
|
1257
|
-
},
|
|
1263
|
+
}, V = class {
|
|
1258
1264
|
constructor(e) {
|
|
1259
1265
|
this.value = e;
|
|
1260
1266
|
}
|
|
1261
|
-
},
|
|
1267
|
+
}, H = class {
|
|
1262
1268
|
constructor(e) {
|
|
1263
1269
|
this.value = e;
|
|
1264
1270
|
}
|
|
1265
|
-
},
|
|
1271
|
+
}, ut = class {
|
|
1266
1272
|
constructor(e) {
|
|
1267
1273
|
this.value = e;
|
|
1268
1274
|
}
|
|
1269
|
-
},
|
|
1275
|
+
}, U = class {
|
|
1270
1276
|
constructor(e) {
|
|
1271
1277
|
this.value = e;
|
|
1272
1278
|
}
|
|
1273
|
-
},
|
|
1279
|
+
}, W;
|
|
1274
1280
|
(function(e) {
|
|
1275
1281
|
e[e.EBML = 440786851] = "EBML", e[e.EBMLVersion = 17030] = "EBMLVersion", e[e.EBMLReadVersion = 17143] = "EBMLReadVersion", e[e.EBMLMaxIDLength = 17138] = "EBMLMaxIDLength", e[e.EBMLMaxSizeLength = 17139] = "EBMLMaxSizeLength", e[e.DocType = 17026] = "DocType", e[e.DocTypeVersion = 17031] = "DocTypeVersion", e[e.DocTypeReadVersion = 17029] = "DocTypeReadVersion", e[e.Void = 236] = "Void", e[e.Segment = 408125543] = "Segment", e[e.SeekHead = 290298740] = "SeekHead", e[e.Seek = 19899] = "Seek", e[e.SeekID = 21419] = "SeekID", e[e.SeekPosition = 21420] = "SeekPosition", e[e.Duration = 17545] = "Duration", e[e.Info = 357149030] = "Info", e[e.TimestampScale = 2807729] = "TimestampScale", e[e.MuxingApp = 19840] = "MuxingApp", e[e.WritingApp = 22337] = "WritingApp", e[e.Tracks = 374648427] = "Tracks", e[e.TrackEntry = 174] = "TrackEntry", e[e.TrackNumber = 215] = "TrackNumber", e[e.TrackUID = 29637] = "TrackUID", e[e.TrackType = 131] = "TrackType", e[e.FlagEnabled = 185] = "FlagEnabled", e[e.FlagDefault = 136] = "FlagDefault", e[e.FlagForced = 21930] = "FlagForced", e[e.FlagOriginal = 21934] = "FlagOriginal", e[e.FlagHearingImpaired = 21931] = "FlagHearingImpaired", e[e.FlagVisualImpaired = 21932] = "FlagVisualImpaired", e[e.FlagCommentary = 21935] = "FlagCommentary", e[e.FlagLacing = 156] = "FlagLacing", e[e.Name = 21358] = "Name", e[e.Language = 2274716] = "Language", e[e.LanguageBCP47 = 2274717] = "LanguageBCP47", e[e.CodecID = 134] = "CodecID", e[e.CodecPrivate = 25506] = "CodecPrivate", e[e.CodecDelay = 22186] = "CodecDelay", e[e.SeekPreRoll = 22203] = "SeekPreRoll", e[e.DefaultDuration = 2352003] = "DefaultDuration", e[e.Video = 224] = "Video", e[e.PixelWidth = 176] = "PixelWidth", e[e.PixelHeight = 186] = "PixelHeight", e[e.DisplayWidth = 21680] = "DisplayWidth", e[e.DisplayHeight = 21690] = "DisplayHeight", e[e.DisplayUnit = 21682] = "DisplayUnit", e[e.AlphaMode = 21440] = "AlphaMode", e[e.Audio = 225] = "Audio", e[e.SamplingFrequency = 181] = "SamplingFrequency", e[e.Channels = 159] = "Channels", e[e.BitDepth = 25188] = "BitDepth", e[e.SimpleBlock = 163] = "SimpleBlock", e[e.BlockGroup = 160] = "BlockGroup", e[e.Block = 161] = "Block", e[e.BlockAdditions = 30113] = "BlockAdditions", e[e.BlockMore = 166] = "BlockMore", e[e.BlockAdditional = 165] = "BlockAdditional", e[e.BlockAddID = 238] = "BlockAddID", e[e.BlockDuration = 155] = "BlockDuration", e[e.ReferenceBlock = 251] = "ReferenceBlock", e[e.Cluster = 524531317] = "Cluster", e[e.Timestamp = 231] = "Timestamp", e[e.Cues = 475249515] = "Cues", e[e.CuePoint = 187] = "CuePoint", e[e.CueTime = 179] = "CueTime", e[e.CueTrackPositions = 183] = "CueTrackPositions", e[e.CueTrack = 247] = "CueTrack", e[e.CueClusterPosition = 241] = "CueClusterPosition", e[e.Colour = 21936] = "Colour", e[e.MatrixCoefficients = 21937] = "MatrixCoefficients", e[e.TransferCharacteristics = 21946] = "TransferCharacteristics", e[e.Primaries = 21947] = "Primaries", e[e.Range = 21945] = "Range", e[e.Projection = 30320] = "Projection", e[e.ProjectionType = 30321] = "ProjectionType", e[e.ProjectionPoseRoll = 30325] = "ProjectionPoseRoll", e[e.Attachments = 423732329] = "Attachments", e[e.AttachedFile = 24999] = "AttachedFile", e[e.FileDescription = 18046] = "FileDescription", e[e.FileName = 18030] = "FileName", e[e.FileMediaType = 18016] = "FileMediaType", e[e.FileData = 18012] = "FileData", e[e.FileUID = 18094] = "FileUID", e[e.Chapters = 272869232] = "Chapters", e[e.Tags = 307544935] = "Tags", e[e.Tag = 29555] = "Tag", e[e.Targets = 25536] = "Targets", e[e.TargetTypeValue = 26826] = "TargetTypeValue", e[e.TargetType = 25546] = "TargetType", e[e.TagTrackUID = 25541] = "TagTrackUID", e[e.TagEditionUID = 25545] = "TagEditionUID", e[e.TagChapterUID = 25540] = "TagChapterUID", e[e.TagAttachmentUID = 25542] = "TagAttachmentUID", e[e.SimpleTag = 26568] = "SimpleTag", e[e.TagName = 17827] = "TagName", e[e.TagLanguage = 17530] = "TagLanguage", e[e.TagString = 17543] = "TagString", e[e.TagBinary = 17541] = "TagBinary", e[e.ContentEncodings = 28032] = "ContentEncodings", e[e.ContentEncoding = 25152] = "ContentEncoding", e[e.ContentEncodingOrder = 20529] = "ContentEncodingOrder", e[e.ContentEncodingScope = 20530] = "ContentEncodingScope", e[e.ContentCompression = 20532] = "ContentCompression", e[e.ContentCompAlgo = 16980] = "ContentCompAlgo", e[e.ContentCompSettings = 16981] = "ContentCompSettings", e[e.ContentEncryption = 20533] = "ContentEncryption";
|
|
1276
|
-
})(
|
|
1277
|
-
var
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1282
|
+
})(W ||= {});
|
|
1283
|
+
var dt = [W.EBML, W.Segment], ft = [
|
|
1284
|
+
W.SeekHead,
|
|
1285
|
+
W.Info,
|
|
1286
|
+
W.Cluster,
|
|
1287
|
+
W.Tracks,
|
|
1288
|
+
W.Cues,
|
|
1289
|
+
W.Attachments,
|
|
1290
|
+
W.Chapters,
|
|
1291
|
+
W.Tags
|
|
1286
1292
|
];
|
|
1287
|
-
[...
|
|
1288
|
-
var
|
|
1293
|
+
[...dt, ...ft];
|
|
1294
|
+
var pt = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4 : e < 2 ** 40 ? 5 : 6, mt = (e) => e < 1n << 8n ? 1 : e < 1n << 16n ? 2 : e < 1n << 24n ? 3 : e < 1n << 32n ? 4 : e < 1n << 40n ? 5 : e < 1n << 48n ? 6 : e < 1n << 56n ? 7 : 8, ht = (e) => e >= -64 && e < 64 ? 1 : e >= -8192 && e < 8192 ? 2 : e >= -1048576 && e < 1 << 20 ? 3 : e >= -134217728 && e < 1 << 27 ? 4 : e >= -(2 ** 34) && e < 2 ** 34 ? 5 : 6, gt = (e) => {
|
|
1289
1295
|
if (e < 127) return 1;
|
|
1290
1296
|
if (e < 16383) return 2;
|
|
1291
1297
|
if (e < (1 << 21) - 1) return 3;
|
|
@@ -1293,9 +1299,9 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1293
1299
|
if (e < 2 ** 35 - 1) return 5;
|
|
1294
1300
|
if (e < 2 ** 42 - 1) return 6;
|
|
1295
1301
|
throw Error("EBML varint size not supported " + e);
|
|
1296
|
-
},
|
|
1302
|
+
}, _t = class {
|
|
1297
1303
|
constructor(e) {
|
|
1298
|
-
this.writer = e, this.helper =
|
|
1304
|
+
this.writer = e, this.helper = new Uint8Array(8), this.helperView = new DataView(this.helper.buffer), this.offsets = /* @__PURE__ */ new WeakMap(), this.dataOffsets = /* @__PURE__ */ new WeakMap();
|
|
1299
1305
|
}
|
|
1300
1306
|
writeByte(e) {
|
|
1301
1307
|
this.helperView.setUint8(0, e), this.writer.write(this.helper.subarray(0, 1));
|
|
@@ -1306,7 +1312,7 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1306
1312
|
writeFloat64(e) {
|
|
1307
1313
|
this.helperView.setFloat64(0, e, !1), this.writer.write(this.helper);
|
|
1308
1314
|
}
|
|
1309
|
-
writeUnsignedInt(e, t =
|
|
1315
|
+
writeUnsignedInt(e, t = pt(e)) {
|
|
1310
1316
|
let n = 0;
|
|
1311
1317
|
switch (t) {
|
|
1312
1318
|
case 6: this.helperView.setUint8(n++, e / 2 ** 40 | 0);
|
|
@@ -1321,15 +1327,15 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1321
1327
|
}
|
|
1322
1328
|
this.writer.write(this.helper.subarray(0, n));
|
|
1323
1329
|
}
|
|
1324
|
-
writeUnsignedBigInt(e, t =
|
|
1330
|
+
writeUnsignedBigInt(e, t = mt(e)) {
|
|
1325
1331
|
let n = 0;
|
|
1326
1332
|
for (let r = t - 1; r >= 0; r--) this.helperView.setUint8(n++, Number(e >> BigInt(r * 8) & 255n));
|
|
1327
1333
|
this.writer.write(this.helper.subarray(0, n));
|
|
1328
1334
|
}
|
|
1329
|
-
writeSignedInt(e, t =
|
|
1335
|
+
writeSignedInt(e, t = ht(e)) {
|
|
1330
1336
|
e < 0 && (e += 2 ** (t * 8)), this.writeUnsignedInt(e, t);
|
|
1331
1337
|
}
|
|
1332
|
-
writeVarInt(e, t =
|
|
1338
|
+
writeVarInt(e, t = gt(e)) {
|
|
1333
1339
|
let n = 0;
|
|
1334
1340
|
switch (t) {
|
|
1335
1341
|
case 1:
|
|
@@ -1358,37 +1364,35 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1358
1364
|
this.writer.write(new Uint8Array(e.split("").map((e) => e.charCodeAt(0))));
|
|
1359
1365
|
}
|
|
1360
1366
|
writeEBML(e) {
|
|
1361
|
-
if (e !== null)
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
}
|
|
1391
|
-
}, ht = {
|
|
1367
|
+
if (e !== null) if (e instanceof Uint8Array) this.writer.write(e);
|
|
1368
|
+
else if (Array.isArray(e)) for (let t of e) this.writeEBML(t);
|
|
1369
|
+
else if (this.offsets.set(e, this.writer.getPos()), this.writeUnsignedInt(e.id), Array.isArray(e.data)) {
|
|
1370
|
+
let t = this.writer.getPos(), n = e.size === -1 ? 1 : e.size ?? 4;
|
|
1371
|
+
e.size === -1 ? this.writeByte(255) : this.writer.seek(this.writer.getPos() + n);
|
|
1372
|
+
let r = this.writer.getPos();
|
|
1373
|
+
if (this.dataOffsets.set(e, r), this.writeEBML(e.data), e.size !== -1) {
|
|
1374
|
+
let e = this.writer.getPos() - r, i = this.writer.getPos();
|
|
1375
|
+
this.writer.seek(t), this.writeVarInt(e, n), this.writer.seek(i);
|
|
1376
|
+
}
|
|
1377
|
+
} else if (typeof e.data == "number") {
|
|
1378
|
+
let t = e.size ?? pt(e.data);
|
|
1379
|
+
this.writeVarInt(t), this.writeUnsignedInt(e.data, t);
|
|
1380
|
+
} else if (typeof e.data == "bigint") {
|
|
1381
|
+
let t = e.size ?? mt(e.data);
|
|
1382
|
+
this.writeVarInt(t), this.writeUnsignedBigInt(e.data, t);
|
|
1383
|
+
} else if (typeof e.data == "string") this.writeVarInt(e.data.length), this.writeAsciiString(e.data);
|
|
1384
|
+
else if (e.data instanceof Uint8Array) this.writeVarInt(e.data.byteLength, e.size), this.writer.write(e.data);
|
|
1385
|
+
else if (e.data instanceof V) this.writeVarInt(4), this.writeFloat32(e.data.value);
|
|
1386
|
+
else if (e.data instanceof H) this.writeVarInt(8), this.writeFloat64(e.data.value);
|
|
1387
|
+
else if (e.data instanceof ut) {
|
|
1388
|
+
let t = e.size ?? ht(e.data.value);
|
|
1389
|
+
this.writeVarInt(t), this.writeSignedInt(e.data.value, t);
|
|
1390
|
+
} else if (e.data instanceof U) {
|
|
1391
|
+
let t = c.encode(e.data.value);
|
|
1392
|
+
this.writeVarInt(t.length), this.writer.write(t);
|
|
1393
|
+
} else _(e.data);
|
|
1394
|
+
}
|
|
1395
|
+
}, vt = {
|
|
1392
1396
|
avc: "V_MPEG4/ISO/AVC",
|
|
1393
1397
|
hevc: "V_MPEGH/ISO/HEVC",
|
|
1394
1398
|
vp8: "V_VP8",
|
|
@@ -1402,6 +1406,7 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1402
1406
|
flac: "A_FLAC",
|
|
1403
1407
|
ac3: "A_AC3",
|
|
1404
1408
|
eac3: "A_EAC3",
|
|
1409
|
+
dts: "A_DTS",
|
|
1405
1410
|
"pcm-u8": "A_PCM/INT/LIT",
|
|
1406
1411
|
"pcm-s16": "A_PCM/INT/LIT",
|
|
1407
1412
|
"pcm-s16be": "A_PCM/INT/BIG",
|
|
@@ -1412,15 +1417,15 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1412
1417
|
"pcm-f32": "A_PCM/FLOAT/IEEE",
|
|
1413
1418
|
"pcm-f64": "A_PCM/FLOAT/IEEE",
|
|
1414
1419
|
webvtt: "S_TEXT/WEBVTT"
|
|
1415
|
-
},
|
|
1420
|
+
}, yt = (e) => {
|
|
1416
1421
|
let t = (e.hasVideo ? "video/" : e.hasAudio ? "audio/" : "application/") + (e.isWebM ? "webm" : "x-matroska");
|
|
1417
1422
|
if (e.codecStrings.length > 0) {
|
|
1418
1423
|
let n = [...new Set(e.codecStrings.filter(Boolean))];
|
|
1419
1424
|
t += `; codecs="${n.join(", ")}"`;
|
|
1420
1425
|
}
|
|
1421
1426
|
return t;
|
|
1422
|
-
},
|
|
1423
|
-
let t = e.filePos, n = new j(
|
|
1427
|
+
}, bt = (e) => {
|
|
1428
|
+
let t = e.filePos, n = new j(Qt(e, 9));
|
|
1424
1429
|
if (n.readBits(12) !== 4095 || (n.skipBits(1), n.readBits(2) !== 0)) return null;
|
|
1425
1430
|
let r = n.readBits(1), i = n.readBits(2) + 1, a = n.readBits(4);
|
|
1426
1431
|
if (a === 15) return null;
|
|
@@ -1442,7 +1447,7 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1442
1447
|
crcCheck: l,
|
|
1443
1448
|
startPos: t
|
|
1444
1449
|
};
|
|
1445
|
-
},
|
|
1450
|
+
}, xt = function(e, t, n) {
|
|
1446
1451
|
if (t != null) {
|
|
1447
1452
|
if (typeof t != "object" && typeof t != "function") throw TypeError("Object expected.");
|
|
1448
1453
|
var r, i;
|
|
@@ -1468,7 +1473,7 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1468
1473
|
});
|
|
1469
1474
|
} else n && e.stack.push({ async: !0 });
|
|
1470
1475
|
return t;
|
|
1471
|
-
},
|
|
1476
|
+
}, St = (function(e) {
|
|
1472
1477
|
return function(t) {
|
|
1473
1478
|
function n(n) {
|
|
1474
1479
|
t.error = t.hasError ? new e(n, t.error, "An error was suppressed during disposal.") : n, t.hasError = !0;
|
|
@@ -1495,17 +1500,17 @@ var ut = (e) => e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 2 ** 32 ? 4
|
|
|
1495
1500
|
var r = Error(n);
|
|
1496
1501
|
return r.name = "SuppressedError", r.error = e, r.suppressed = t, r;
|
|
1497
1502
|
});
|
|
1498
|
-
|
|
1499
|
-
var
|
|
1500
|
-
typeof FinalizationRegistry < "u" && (
|
|
1503
|
+
de();
|
|
1504
|
+
var Ct = -Infinity, wt = -Infinity, G = null;
|
|
1505
|
+
typeof FinalizationRegistry < "u" && (G = new FinalizationRegistry((e) => {
|
|
1501
1506
|
let t = performance.now();
|
|
1502
|
-
e.type === "video" ? (t -
|
|
1507
|
+
e.type === "video" ? (t - Ct >= 1e3 && (A._error("A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them."), Ct = t), typeof VideoFrame < "u" && e.data instanceof VideoFrame && e.data.close()) : (t - wt >= 1e3 && (A._error("An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them."), wt = t), typeof AudioData < "u" && e.data instanceof AudioData && e.data.close());
|
|
1503
1508
|
}));
|
|
1504
|
-
var
|
|
1509
|
+
var K = class {
|
|
1505
1510
|
constructor() {
|
|
1506
1511
|
this._referenceCount = 0, this._lastAllocationBuffer = null;
|
|
1507
1512
|
}
|
|
1508
|
-
},
|
|
1513
|
+
}, Tt = [
|
|
1509
1514
|
"I420",
|
|
1510
1515
|
"I420P10",
|
|
1511
1516
|
"I420P12",
|
|
@@ -1529,7 +1534,7 @@ var U = class {
|
|
|
1529
1534
|
"RGBX",
|
|
1530
1535
|
"BGRA",
|
|
1531
1536
|
"BGRX"
|
|
1532
|
-
],
|
|
1537
|
+
], Et = new Set(Tt), q = class e {
|
|
1533
1538
|
get codedWidth() {
|
|
1534
1539
|
return this.visibleRect.width;
|
|
1535
1540
|
}
|
|
@@ -1543,10 +1548,10 @@ var U = class {
|
|
|
1543
1548
|
return this.rotation % 180 == 0 ? this.squarePixelHeight : this.squarePixelWidth;
|
|
1544
1549
|
}
|
|
1545
1550
|
get microsecondTimestamp() {
|
|
1546
|
-
return Math.trunc(
|
|
1551
|
+
return Math.trunc(w * this.timestamp);
|
|
1547
1552
|
}
|
|
1548
1553
|
get microsecondDuration() {
|
|
1549
|
-
return Math.trunc(
|
|
1554
|
+
return Math.trunc(w * this.duration);
|
|
1550
1555
|
}
|
|
1551
1556
|
get hasAlpha() {
|
|
1552
1557
|
return this.format && this.format.includes("A");
|
|
@@ -1554,7 +1559,7 @@ var U = class {
|
|
|
1554
1559
|
constructor(t, n) {
|
|
1555
1560
|
if (this._closed = !1, t instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && t instanceof SharedArrayBuffer || ArrayBuffer.isView(t)) {
|
|
1556
1561
|
if (!n || typeof n != "object") throw TypeError("init must be an object.");
|
|
1557
|
-
if (n.format === void 0 || !
|
|
1562
|
+
if (n.format === void 0 || !Et.has(n.format)) throw TypeError("init.format must be one of: " + Tt.join(", "));
|
|
1558
1563
|
if (!Number.isInteger(n.codedWidth) || n.codedWidth <= 0) throw TypeError("init.codedWidth must be a positive integer.");
|
|
1559
1564
|
if (!Number.isInteger(n.codedHeight) || n.codedHeight <= 0) throw TypeError("init.codedHeight must be a positive integer.");
|
|
1560
1565
|
if (n.rotation !== void 0 && ![
|
|
@@ -1577,7 +1582,7 @@ var U = class {
|
|
|
1577
1582
|
if (n.displayHeight !== void 0 && (!Number.isInteger(n.displayHeight) || n.displayHeight <= 0)) throw TypeError("init.displayHeight, when provided, must be a positive integer.");
|
|
1578
1583
|
if (n.displayWidth !== void 0 != (n.displayHeight !== void 0)) throw TypeError("init.displayWidth and init.displayHeight must be either both provided or both omitted.");
|
|
1579
1584
|
this.format = n.format, this.rotation = n.rotation ?? 0, this.timestamp = n.timestamp, this.duration = n.duration ?? 0;
|
|
1580
|
-
let e = n.layout ??
|
|
1585
|
+
let e = n.layout ?? Ft(n.format, n.codedWidth, n.codedHeight), r = n.colorSpace ?? null;
|
|
1581
1586
|
r === null && (r = this.format === "RGBA" || this.format === "RGBX" || this.format === "BGRA" || this.format === "BGRX" ? {
|
|
1582
1587
|
primaries: "bt709",
|
|
1583
1588
|
transfer: "iec61966-2-1",
|
|
@@ -1593,7 +1598,7 @@ var U = class {
|
|
|
1593
1598
|
top: n.visibleRect?.top ?? 0,
|
|
1594
1599
|
width: n.visibleRect?.width ?? n.codedWidth,
|
|
1595
1600
|
height: n.visibleRect?.height ?? n.codedHeight
|
|
1596
|
-
}, n.displayWidth === void 0 ? (this.squarePixelWidth = this.visibleRect.width, this.squarePixelHeight = this.visibleRect.height) : (this.squarePixelWidth = this.rotation % 180 == 0 ? n.displayWidth : n.displayHeight, this.squarePixelHeight = this.rotation % 180 == 0 ? n.displayHeight : n.displayWidth), this._data = n._doNotCopy ? o(t) : o(t).slice(), this._layout = e, this.colorSpace = new
|
|
1601
|
+
}, n.displayWidth === void 0 ? (this.squarePixelWidth = this.visibleRect.width, this.squarePixelHeight = this.visibleRect.height) : (this.squarePixelWidth = this.rotation % 180 == 0 ? n.displayWidth : n.displayHeight, this.squarePixelHeight = this.rotation % 180 == 0 ? n.displayHeight : n.displayWidth), this._data = n._doNotCopy ? o(t) : o(t).slice(), this._layout = e, this.colorSpace = new jt(r);
|
|
1597
1602
|
} else if (typeof VideoFrame < "u" && t instanceof VideoFrame) {
|
|
1598
1603
|
if (n?.rotation !== void 0 && ![
|
|
1599
1604
|
0,
|
|
@@ -1608,7 +1613,7 @@ var U = class {
|
|
|
1608
1613
|
top: t.visibleRect?.y ?? 0,
|
|
1609
1614
|
width: t.visibleRect?.width ?? t.codedWidth,
|
|
1610
1615
|
height: t.visibleRect?.height ?? t.codedHeight
|
|
1611
|
-
}, this.rotation = n?.rotation ?? 0, this.squarePixelWidth = t.displayWidth, this.squarePixelHeight = t.displayHeight, this.timestamp = n?.timestamp ?? t.timestamp / 1e6, this.duration = n?.duration ?? (t.duration ?? 0) / 1e6, this.colorSpace = new
|
|
1616
|
+
}, this.rotation = n?.rotation ?? 0, this.squarePixelWidth = t.displayWidth, this.squarePixelHeight = t.displayHeight, this.timestamp = n?.timestamp ?? t.timestamp / 1e6, this.duration = n?.duration ?? (t.duration ?? 0) / 1e6, this.colorSpace = new jt(t.colorSpace);
|
|
1612
1617
|
} else if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof SVGImageElement < "u" && t instanceof SVGImageElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap || typeof HTMLVideoElement < "u" && t instanceof HTMLVideoElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof OffscreenCanvas < "u" && t instanceof OffscreenCanvas) {
|
|
1613
1618
|
if (!n || typeof n != "object") throw TypeError("init must be an object.");
|
|
1614
1619
|
if (n.rotation !== void 0 && ![
|
|
@@ -1620,8 +1625,8 @@ var U = class {
|
|
|
1620
1625
|
if (!Number.isFinite(n.timestamp)) throw TypeError("init.timestamp must be a number.");
|
|
1621
1626
|
if (n.duration !== void 0 && (!Number.isFinite(n.duration) || n.duration < 0)) throw TypeError("init.duration, when provided, must be a non-negative number.");
|
|
1622
1627
|
if (n.visibleRect !== void 0 && D(n.visibleRect, "init.visibleRect"), typeof VideoFrame < "u") return new e(new VideoFrame(t, {
|
|
1623
|
-
timestamp: Math.trunc(n.timestamp *
|
|
1624
|
-
duration: Math.trunc((n.duration ?? 0) *
|
|
1628
|
+
timestamp: Math.trunc(n.timestamp * w),
|
|
1629
|
+
duration: Math.trunc((n.duration ?? 0) * w) || void 0,
|
|
1625
1630
|
visibleRect: n.visibleRect && {
|
|
1626
1631
|
x: n.visibleRect.left,
|
|
1627
1632
|
y: n.visibleRect.top,
|
|
@@ -1646,13 +1651,13 @@ var U = class {
|
|
|
1646
1651
|
top: 0,
|
|
1647
1652
|
width: a.width,
|
|
1648
1653
|
height: a.height
|
|
1649
|
-
}, this.squarePixelWidth = a.width, this.squarePixelHeight = a.height, this.rotation = n.rotation ?? 0, this.timestamp = n.timestamp, this.duration = n.duration ?? 0, this.colorSpace = new
|
|
1654
|
+
}, this.squarePixelWidth = a.width, this.squarePixelHeight = a.height, this.rotation = n.rotation ?? 0, this.timestamp = n.timestamp, this.duration = n.duration ?? 0, this.colorSpace = new jt({
|
|
1650
1655
|
matrix: "rgb",
|
|
1651
1656
|
primaries: "bt709",
|
|
1652
1657
|
transfer: "iec61966-2-1",
|
|
1653
1658
|
fullRange: !0
|
|
1654
1659
|
});
|
|
1655
|
-
} else if (t instanceof
|
|
1660
|
+
} else if (t instanceof K) {
|
|
1656
1661
|
if (!n || typeof n != "object") throw TypeError("init must be an object.");
|
|
1657
1662
|
if (n.rotation !== void 0 && ![
|
|
1658
1663
|
0,
|
|
@@ -1662,7 +1667,7 @@ var U = class {
|
|
|
1662
1667
|
].includes(n.rotation)) throw TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");
|
|
1663
1668
|
if (!Number.isFinite(n.timestamp)) throw TypeError("init.timestamp must be a number.");
|
|
1664
1669
|
if (n.duration !== void 0 && (!Number.isFinite(n.duration) || n.duration < 0)) throw TypeError("init.duration, when provided, must be a non-negative number.");
|
|
1665
|
-
if (this._data = t, t._referenceCount++, this.format = t.getFormat(), this.format !== null && !
|
|
1670
|
+
if (this._data = t, t._referenceCount++, this.format = t.getFormat(), this.format !== null && !Tt.includes(this.format)) throw TypeError("getFormat() must return a VideoSamplePixelFormat or null.");
|
|
1666
1671
|
if (this.visibleRect = {
|
|
1667
1672
|
left: 0,
|
|
1668
1673
|
top: 0,
|
|
@@ -1674,22 +1679,22 @@ var U = class {
|
|
|
1674
1679
|
if (this.squarePixelHeight = t.getSquarePixelHeight(), !Number.isInteger(this.squarePixelHeight) || this.squarePixelHeight <= 0) throw TypeError("getSquarePixelHeight() must return a positive integer.");
|
|
1675
1680
|
this.rotation = n.rotation ?? 0, this.timestamp = n.timestamp, this.duration = n.duration ?? 0, this.colorSpace = t.getColorSpace();
|
|
1676
1681
|
} else throw TypeError("Invalid data type: Must be a BufferSource, CanvasImageSource, or VideoSampleResource.");
|
|
1677
|
-
this.encodeOptions = n?.encodeOptions ?? {}, this.pixelAspectRatio =
|
|
1682
|
+
this.encodeOptions = n?.encodeOptions ?? {}, this.pixelAspectRatio = me({
|
|
1678
1683
|
num: this.squarePixelWidth * this.codedHeight,
|
|
1679
1684
|
den: this.squarePixelHeight * this.codedWidth
|
|
1680
|
-
}),
|
|
1685
|
+
}), G?.register(this, {
|
|
1681
1686
|
type: "video",
|
|
1682
1687
|
data: this._data
|
|
1683
1688
|
}, this);
|
|
1684
1689
|
}
|
|
1685
1690
|
clone() {
|
|
1686
1691
|
if (this._closed) throw Error("VideoSample is closed.");
|
|
1687
|
-
return t(this._data !== null), this._data instanceof
|
|
1692
|
+
return t(this._data !== null), this._data instanceof K ? new e(this._data, {
|
|
1688
1693
|
timestamp: this.timestamp,
|
|
1689
1694
|
duration: this.duration,
|
|
1690
1695
|
rotation: this.rotation,
|
|
1691
1696
|
encodeOptions: this.encodeOptions
|
|
1692
|
-
}) :
|
|
1697
|
+
}) : Y(this._data) ? new e(this._data.clone(), {
|
|
1693
1698
|
timestamp: this.timestamp,
|
|
1694
1699
|
duration: this.duration,
|
|
1695
1700
|
rotation: this.rotation,
|
|
@@ -1723,18 +1728,18 @@ var U = class {
|
|
|
1723
1728
|
});
|
|
1724
1729
|
}
|
|
1725
1730
|
close() {
|
|
1726
|
-
this._closed ||= (
|
|
1731
|
+
this._closed ||= (G?.unregister(this), this._data instanceof K ? (this._data._referenceCount--, this._data._referenceCount === 0 && this._data.close()) : Y(this._data) ? this._data.close() : this._data = null, !0);
|
|
1727
1732
|
}
|
|
1728
1733
|
allocationSize(e = {}) {
|
|
1729
|
-
if (
|
|
1734
|
+
if (Pt(e), this._closed) throw Error("VideoSample is closed.");
|
|
1730
1735
|
if ((e.format ?? this.format) == null) throw Error("Cannot get allocation size when format is null.");
|
|
1731
|
-
return
|
|
1736
|
+
return Y(this._data) ? this._data.allocationSize(e) : It(this, e).allocationSize;
|
|
1732
1737
|
}
|
|
1733
1738
|
async copyTo(n, r = {}) {
|
|
1734
1739
|
if (!p(n)) throw TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");
|
|
1735
|
-
if (
|
|
1740
|
+
if (Pt(r), this._closed) throw Error("VideoSample is closed.");
|
|
1736
1741
|
if ((r.format ?? this.format) == null) throw Error("Cannot copy video sample data when format is null.");
|
|
1737
|
-
if (t(this._data !== null),
|
|
1742
|
+
if (t(this._data !== null), Y(this._data)) return this._data.copyTo(n, r);
|
|
1738
1743
|
if (r.format && ![
|
|
1739
1744
|
"RGBA",
|
|
1740
1745
|
"RGBX",
|
|
@@ -1745,46 +1750,44 @@ var U = class {
|
|
|
1745
1750
|
"RGBX",
|
|
1746
1751
|
"BGRA",
|
|
1747
1752
|
"BGRX"
|
|
1748
|
-
].includes(r.format)) {
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
yt(t);
|
|
1773
|
-
}
|
|
1774
|
-
} else {
|
|
1775
|
-
if (typeof VideoFrame > "u") throw Error("For this sample, converting from a non-RGB to an RGB format requires VideoFrame to be defined.");
|
|
1776
|
-
let e = this.toVideoFrame(), t = await e.copyTo(n, r);
|
|
1777
|
-
return e.close(), t;
|
|
1753
|
+
].includes(r.format)) if (this._data instanceof K) {
|
|
1754
|
+
let t = {
|
|
1755
|
+
stack: [],
|
|
1756
|
+
error: void 0,
|
|
1757
|
+
hasError: !1
|
|
1758
|
+
};
|
|
1759
|
+
try {
|
|
1760
|
+
let i = xt(t, await this._data.toRgbSample({
|
|
1761
|
+
timestamp: this.timestamp,
|
|
1762
|
+
duration: this.duration,
|
|
1763
|
+
rotation: this.rotation
|
|
1764
|
+
}, r.colorSpace ?? "srgb"), !1);
|
|
1765
|
+
if (!(i instanceof e)) throw TypeError("toRgbSample() must return a VideoSample.");
|
|
1766
|
+
if (![
|
|
1767
|
+
"RGBA",
|
|
1768
|
+
"RGBX",
|
|
1769
|
+
"BGRA",
|
|
1770
|
+
"BGRX"
|
|
1771
|
+
].includes(i.format)) throw Error(`Sample returned by toRgbSample was expected to have an RGB format, got '${i.format}' instead.`);
|
|
1772
|
+
return await i.copyTo(n, r);
|
|
1773
|
+
} catch (e) {
|
|
1774
|
+
t.error = e, t.hasError = !0;
|
|
1775
|
+
} finally {
|
|
1776
|
+
St(t);
|
|
1778
1777
|
}
|
|
1778
|
+
} else {
|
|
1779
|
+
if (typeof VideoFrame > "u") throw Error("For this sample, converting from a non-RGB to an RGB format requires VideoFrame to be defined.");
|
|
1780
|
+
let e = this.toVideoFrame(), t = await e.copyTo(n, r);
|
|
1781
|
+
return e.close(), t;
|
|
1779
1782
|
}
|
|
1780
|
-
let i =
|
|
1783
|
+
let i = It(this, r);
|
|
1781
1784
|
t(this.format);
|
|
1782
1785
|
let a = o(n);
|
|
1783
1786
|
if (a.byteLength < i.allocationSize) throw TypeError(`Destination buffer too small. Required: ${i.allocationSize}, Available: ${a.byteLength}`);
|
|
1784
1787
|
let s = X(this.format), c;
|
|
1785
|
-
if (this._data instanceof
|
|
1788
|
+
if (this._data instanceof K) {
|
|
1786
1789
|
let e = this._data.getDataPlanes();
|
|
1787
|
-
if (e
|
|
1790
|
+
if (E(e) && (e = await e), !Array.isArray(e) || e.some((e) => !(e.data instanceof Uint8Array) || !Number.isInteger(e.stride) || e.stride < 0)) throw TypeError("getDataPlanes() must return an array of objects with a Uint8Array \"data\" property and a non-negative integer \"stride\" property.");
|
|
1788
1791
|
c = e;
|
|
1789
1792
|
} else if (this._data instanceof Uint8Array) t(this._layout), t(this._layout.length === s.length), c = this._layout.map((e, t) => {
|
|
1790
1793
|
let n = Math.ceil(this.codedHeight / s[t].heightDivisor);
|
|
@@ -1820,8 +1823,8 @@ var U = class {
|
|
|
1820
1823
|
let e = this.format.startsWith("RGB") !== r.format.startsWith("RGB"), t = this.format.includes("X") && r.format.includes("A");
|
|
1821
1824
|
if (e || t) for (let n = 0; n < i.allocationSize; n += 4) {
|
|
1822
1825
|
if (e) {
|
|
1823
|
-
let e = a[n]
|
|
1824
|
-
a[n] =
|
|
1826
|
+
let e = a[n];
|
|
1827
|
+
a[n] = a[n + 2], a[n + 2] = e;
|
|
1825
1828
|
}
|
|
1826
1829
|
t && (a[n + 3] = 255);
|
|
1827
1830
|
}
|
|
@@ -1830,10 +1833,10 @@ var U = class {
|
|
|
1830
1833
|
}
|
|
1831
1834
|
toVideoFrame() {
|
|
1832
1835
|
if (this._closed) throw Error("VideoSample is closed.");
|
|
1833
|
-
if (t(this._data !== null), this._data instanceof
|
|
1836
|
+
if (t(this._data !== null), this._data instanceof K) {
|
|
1834
1837
|
if (this.format === null) throw Error("Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if format is null.");
|
|
1835
1838
|
let e = this._data.getDataPlanes();
|
|
1836
|
-
if (e
|
|
1839
|
+
if (E(e)) throw Error("Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if getDataPlanes() returns a promise.");
|
|
1837
1840
|
let t = e.reduce((e, t) => e + t.data.byteLength, 0), n = new Uint8Array(t), r = 0, i = [];
|
|
1838
1841
|
for (let t of e) n.set(t.data, r), i.push(r), r += t.data.byteLength;
|
|
1839
1842
|
return new VideoFrame(n, {
|
|
@@ -1851,11 +1854,11 @@ var U = class {
|
|
|
1851
1854
|
displayWidth: this.squarePixelWidth,
|
|
1852
1855
|
displayHeight: this.squarePixelHeight
|
|
1853
1856
|
});
|
|
1854
|
-
}
|
|
1855
|
-
return J(this._data) ? new VideoFrame(this._data, {
|
|
1857
|
+
} else if (Y(this._data)) return new VideoFrame(this._data, {
|
|
1856
1858
|
timestamp: this.microsecondTimestamp,
|
|
1857
1859
|
duration: this.microsecondDuration || void 0
|
|
1858
|
-
})
|
|
1860
|
+
});
|
|
1861
|
+
else if (this._data instanceof Uint8Array) return t(this._layout), new VideoFrame(this._data, {
|
|
1859
1862
|
format: this.format,
|
|
1860
1863
|
codedWidth: this.codedWidth,
|
|
1861
1864
|
codedHeight: this.codedHeight,
|
|
@@ -1866,7 +1869,8 @@ var U = class {
|
|
|
1866
1869
|
visibleRect: this.visibleRect,
|
|
1867
1870
|
displayWidth: this.squarePixelWidth,
|
|
1868
1871
|
displayHeight: this.squarePixelHeight
|
|
1869
|
-
})
|
|
1872
|
+
});
|
|
1873
|
+
else return new VideoFrame(this._data, {
|
|
1870
1874
|
timestamp: this.microsecondTimestamp,
|
|
1871
1875
|
duration: this.microsecondDuration || void 0
|
|
1872
1876
|
});
|
|
@@ -1886,10 +1890,10 @@ var U = class {
|
|
|
1886
1890
|
({sx: l, sy: u, sWidth: d, sHeight: f} = this._rotateSourceRegion(l, u, d, f, this.rotation));
|
|
1887
1891
|
let _ = this.toCanvasImageSource();
|
|
1888
1892
|
e.save();
|
|
1889
|
-
let
|
|
1890
|
-
e.translate(
|
|
1891
|
-
let
|
|
1892
|
-
e.scale(1 /
|
|
1893
|
+
let v = p + h / 2, y = m + g / 2;
|
|
1894
|
+
e.translate(v, y), e.rotate(this.rotation * Math.PI / 180);
|
|
1895
|
+
let b = this.rotation % 180 == 0 ? 1 : h / g;
|
|
1896
|
+
e.scale(1 / b, b), e.drawImage(_, l, u, d, f, -h / 2, -g / 2, h, g), e.restore();
|
|
1893
1897
|
}
|
|
1894
1898
|
drawWithFit(e, t) {
|
|
1895
1899
|
if (!(typeof CanvasRenderingContext2D < "u" && e instanceof CanvasRenderingContext2D || typeof OffscreenCanvasRenderingContext2D < "u" && e instanceof OffscreenCanvasRenderingContext2D)) throw TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");
|
|
@@ -1905,9 +1909,9 @@ var U = class {
|
|
|
1905
1909
|
180,
|
|
1906
1910
|
270
|
|
1907
1911
|
].includes(t.rotation)) throw TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");
|
|
1908
|
-
t.crop !== void 0 &&
|
|
1912
|
+
t.crop !== void 0 && Nt(t.crop, "options.");
|
|
1909
1913
|
let n = e.canvas.width, r = e.canvas.height, i = t.rotation ?? this.rotation, [a, o] = i % 180 == 0 ? [this.squarePixelWidth, this.squarePixelHeight] : [this.squarePixelHeight, this.squarePixelWidth], s = t.crop;
|
|
1910
|
-
s &&=
|
|
1914
|
+
s &&= Mt(s, a, o);
|
|
1911
1915
|
let c, l, u, d, { sx: f, sy: p, sWidth: m, sHeight: h } = this._rotateSourceRegion(t.crop?.left ?? 0, t.crop?.top ?? 0, t.crop?.width ?? a, t.crop?.height ?? o, i);
|
|
1912
1916
|
if (t.fit === "fill") c = 0, l = 0, u = n, d = r;
|
|
1913
1917
|
else {
|
|
@@ -1939,7 +1943,7 @@ var U = class {
|
|
|
1939
1943
|
_drawWithFitAndMipmapping(e, t, n) {
|
|
1940
1944
|
let r = e.width, i = e.height, [a, o] = n.rotation % 180 == 0 ? [this.squarePixelWidth, this.squarePixelHeight] : [this.squarePixelHeight, this.squarePixelWidth], s = n.crop ? n.crop.width : a, c = n.crop ? n.crop.height : o, l = 0;
|
|
1941
1945
|
2 * r < s && 2 * i < c && (l = Math.floor(Math.log2(Math.min(s / r, c / i))));
|
|
1942
|
-
let u = r * 2 ** l, d = i * 2 ** l, { canvas: f, context: p, isNew: m } = l > 0 ?
|
|
1946
|
+
let u = r * 2 ** l, d = i * 2 ** l, { canvas: f, context: p, isNew: m } = l > 0 ? At(u, d) : {
|
|
1943
1947
|
canvas: e,
|
|
1944
1948
|
context: t,
|
|
1945
1949
|
isNew: n.targetIsFresh
|
|
@@ -1957,11 +1961,10 @@ var U = class {
|
|
|
1957
1961
|
}
|
|
1958
1962
|
toCanvasImageSource() {
|
|
1959
1963
|
if (this._closed) throw Error("VideoSample is closed.");
|
|
1960
|
-
if (t(this._data !== null), this._data instanceof
|
|
1964
|
+
if (t(this._data !== null), this._data instanceof K || this._data instanceof Uint8Array) {
|
|
1961
1965
|
let e = this.toVideoFrame();
|
|
1962
1966
|
return queueMicrotask(() => e.close()), e;
|
|
1963
|
-
}
|
|
1964
|
-
return this._data;
|
|
1967
|
+
} else return this._data;
|
|
1965
1968
|
}
|
|
1966
1969
|
async transform(t) {
|
|
1967
1970
|
if (!t || typeof t != "object") throw TypeError("options must be an object.");
|
|
@@ -1980,11 +1983,11 @@ var U = class {
|
|
|
1980
1983
|
180,
|
|
1981
1984
|
270
|
|
1982
1985
|
].includes(t.rotate)) throw TypeError("options.rotate, when provided, must be 0, 90, 180 or 270.");
|
|
1983
|
-
if (t.crop !== void 0 &&
|
|
1986
|
+
if (t.crop !== void 0 && Nt(t.crop, "options."), t.alpha !== void 0 && !["keep", "discard"].includes(t.alpha)) throw TypeError("options.alpha, when provided, must be 'keep' or 'discard'.");
|
|
1984
1987
|
let r = n(this.rotation + (t.rotate ?? 0)), [i, a] = r % 180 == 0 ? [this.squarePixelWidth, this.squarePixelHeight] : [this.squarePixelHeight, this.squarePixelWidth], o = t.crop;
|
|
1985
|
-
o &&=
|
|
1988
|
+
o &&= Mt(o, i, a);
|
|
1986
1989
|
let s = o ? o.width : i, c = o ? o.height : a, l = s / c, u, d;
|
|
1987
|
-
t.width !== void 0 && t.height === void 0 ? (u = t.width, d = u / l) : t.width === void 0 && t.height !== void 0 ? (d = t.height, u = d * l) : t.width !== void 0 && t.height !== void 0 ? (u = t.width, d = t.height) : (u = s, d = c), u =
|
|
1990
|
+
t.width !== void 0 && t.height === void 0 ? (u = t.width, d = u / l) : t.width === void 0 && t.height !== void 0 ? (d = t.height, u = d * l) : t.width !== void 0 && t.height !== void 0 ? (u = t.width, d = t.height) : (u = s, d = c), u = x(u, t.roundDimensionsTo ?? 1), d = x(d, t.roundDimensionsTo ?? 1);
|
|
1988
1991
|
let f = {
|
|
1989
1992
|
width: u,
|
|
1990
1993
|
height: d,
|
|
@@ -1998,11 +2001,11 @@ var U = class {
|
|
|
1998
2001
|
},
|
|
1999
2002
|
alpha: t.alpha ?? "keep"
|
|
2000
2003
|
};
|
|
2001
|
-
for (let e of
|
|
2004
|
+
for (let e of Dt) {
|
|
2002
2005
|
let t = e(this, f);
|
|
2003
|
-
if (t
|
|
2006
|
+
if (E(t) && (t = await t), t !== null) return t;
|
|
2004
2007
|
}
|
|
2005
|
-
let { canvas: p, context: m, isNew: h } =
|
|
2008
|
+
let { canvas: p, context: m, isNew: h } = At(f.width, f.height);
|
|
2006
2009
|
return this._drawWithFitAndMipmapping(p, m, {
|
|
2007
2010
|
fit: f.fit,
|
|
2008
2011
|
rotation: f.rotation,
|
|
@@ -2039,8 +2042,8 @@ var U = class {
|
|
|
2039
2042
|
[Symbol.dispose]() {
|
|
2040
2043
|
this.close();
|
|
2041
2044
|
}
|
|
2042
|
-
},
|
|
2043
|
-
for (let n of
|
|
2045
|
+
}, Dt = [], Ot = 3, J = [], kt = 0, At = (e, t) => {
|
|
2046
|
+
for (let n of J) if (n.canvas.width === e && n.canvas.height === t) return n.age = kt++, {
|
|
2044
2047
|
canvas: n.canvas,
|
|
2045
2048
|
context: n.context,
|
|
2046
2049
|
isNew: !1
|
|
@@ -2056,16 +2059,16 @@ var U = class {
|
|
|
2056
2059
|
willReadFrequently: !1
|
|
2057
2060
|
});
|
|
2058
2061
|
if (!r) throw Error("The '2d' canvas context is required to transform VideoSamples. Register a custom transformer using registerVideoSampleTransformer to work around this limitation.");
|
|
2059
|
-
return
|
|
2062
|
+
return J.length >= Ot && J.splice(pe(J, (e) => e.age), 1), J.push({
|
|
2060
2063
|
canvas: n,
|
|
2061
2064
|
context: r,
|
|
2062
|
-
age:
|
|
2065
|
+
age: kt++
|
|
2063
2066
|
}), {
|
|
2064
2067
|
canvas: n,
|
|
2065
2068
|
context: r,
|
|
2066
2069
|
isNew: !0
|
|
2067
2070
|
};
|
|
2068
|
-
},
|
|
2071
|
+
}, jt = class {
|
|
2069
2072
|
constructor(e) {
|
|
2070
2073
|
if (e !== void 0) {
|
|
2071
2074
|
if (!e || typeof e != "object") throw TypeError("init.colorSpace, when provided, must be an object.");
|
|
@@ -2087,7 +2090,7 @@ var U = class {
|
|
|
2087
2090
|
fullRange: this.fullRange
|
|
2088
2091
|
};
|
|
2089
2092
|
}
|
|
2090
|
-
},
|
|
2093
|
+
}, Y = (e) => typeof VideoFrame < "u" && e instanceof VideoFrame, Mt = (e, n, r) => {
|
|
2091
2094
|
let i = Math.min(e.left, n), a = Math.min(e.top, r), o = Math.min(e.width, n - i), s = Math.min(e.height, r - a);
|
|
2092
2095
|
return t(o >= 0), t(s >= 0), {
|
|
2093
2096
|
left: i,
|
|
@@ -2095,13 +2098,13 @@ var U = class {
|
|
|
2095
2098
|
width: o,
|
|
2096
2099
|
height: s
|
|
2097
2100
|
};
|
|
2098
|
-
},
|
|
2101
|
+
}, Nt = (e, t) => {
|
|
2099
2102
|
if (!e || typeof e != "object") throw TypeError(t + "crop, when provided, must be an object.");
|
|
2100
2103
|
if (!Number.isInteger(e.left) || e.left < 0) throw TypeError(t + "crop.left must be a non-negative integer.");
|
|
2101
2104
|
if (!Number.isInteger(e.top) || e.top < 0) throw TypeError(t + "crop.top must be a non-negative integer.");
|
|
2102
2105
|
if (!Number.isInteger(e.width) || e.width < 0) throw TypeError(t + "crop.width must be a non-negative integer.");
|
|
2103
2106
|
if (!Number.isInteger(e.height) || e.height < 0) throw TypeError(t + "crop.height must be a non-negative integer.");
|
|
2104
|
-
},
|
|
2107
|
+
}, Pt = (e) => {
|
|
2105
2108
|
if (!e || typeof e != "object") throw TypeError("options must be an object.");
|
|
2106
2109
|
if (e.colorSpace !== void 0 && !["display-p3", "srgb"].includes(e.colorSpace)) throw TypeError("options.colorSpace, when provided, must be 'display-p3' or 'srgb'.");
|
|
2107
2110
|
if (e.format !== void 0 && typeof e.format != "string") throw TypeError("options.format, when provided, must be a string.");
|
|
@@ -2120,7 +2123,7 @@ var U = class {
|
|
|
2120
2123
|
if (e.rect.width !== void 0 && (!Number.isInteger(e.rect.width) || e.rect.width < 0)) throw TypeError("options.rect.width, when provided, must be a non-negative integer.");
|
|
2121
2124
|
if (e.rect.height !== void 0 && (!Number.isInteger(e.rect.height) || e.rect.height < 0)) throw TypeError("options.rect.height, when provided, must be a non-negative integer.");
|
|
2122
2125
|
}
|
|
2123
|
-
},
|
|
2126
|
+
}, Ft = (e, t, n) => {
|
|
2124
2127
|
let r = X(e), i = [], a = 0;
|
|
2125
2128
|
for (let e of r) {
|
|
2126
2129
|
let r = Math.ceil(t / e.widthDivisor), o = Math.ceil(n / e.heightDivisor), s = r * e.sampleBytes, c = s * o;
|
|
@@ -2193,13 +2196,13 @@ var U = class {
|
|
|
2193
2196
|
}];
|
|
2194
2197
|
default: _(e), t(!1);
|
|
2195
2198
|
}
|
|
2196
|
-
},
|
|
2199
|
+
}, It = (e, t) => {
|
|
2197
2200
|
let n = {
|
|
2198
2201
|
left: 0,
|
|
2199
2202
|
top: 0,
|
|
2200
2203
|
width: e.codedWidth,
|
|
2201
2204
|
height: e.codedHeight
|
|
2202
|
-
}, r = t.rect, i =
|
|
2205
|
+
}, r = t.rect, i = Lt(n, r, e.codedWidth, e.codedHeight, e.format), a = t.layout, o;
|
|
2203
2206
|
if (!t.format || t.format === e.format) o = e.format;
|
|
2204
2207
|
else if ([
|
|
2205
2208
|
"RGBA",
|
|
@@ -2208,8 +2211,8 @@ var U = class {
|
|
|
2208
2211
|
"BGRX"
|
|
2209
2212
|
].includes(t.format)) o = t.format;
|
|
2210
2213
|
else throw Error("NotSupportedError: Invalid destination format.");
|
|
2211
|
-
return
|
|
2212
|
-
},
|
|
2214
|
+
return zt(i, o, a);
|
|
2215
|
+
}, Lt = (e, t, n, r, i) => {
|
|
2213
2216
|
let a = { ...e };
|
|
2214
2217
|
if (t !== void 0) {
|
|
2215
2218
|
if (t.width === 0 || t.height === 0) throw TypeError("visibleRect dimensions cannot be zero.");
|
|
@@ -2217,9 +2220,9 @@ var U = class {
|
|
|
2217
2220
|
if ((t.y || 0) + (t.height || 0) > r) throw TypeError("visibleRect exceeds codedHeight.");
|
|
2218
2221
|
a.x = t.x || 0, a.y = t.y || 0, a.width = t.width || 0, a.height = t.height || 0;
|
|
2219
2222
|
}
|
|
2220
|
-
if (!
|
|
2223
|
+
if (!Rt(i, a)) throw TypeError("visibleRect alignment is invalid for the format.");
|
|
2221
2224
|
return a;
|
|
2222
|
-
},
|
|
2225
|
+
}, Rt = (e, t) => {
|
|
2223
2226
|
if (e === null) return !0;
|
|
2224
2227
|
let n = X(e);
|
|
2225
2228
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -2227,7 +2230,7 @@ var U = class {
|
|
|
2227
2230
|
if ((t.x || 0) % i !== 0 || (t.y || 0) % a !== 0) return !1;
|
|
2228
2231
|
}
|
|
2229
2232
|
return !0;
|
|
2230
|
-
},
|
|
2233
|
+
}, zt = (e, t, n) => {
|
|
2231
2234
|
let r = X(t), i = r.length;
|
|
2232
2235
|
if (n !== void 0 && n.length !== i) throw TypeError(`Layout must have ${i} planes.`);
|
|
2233
2236
|
let a = 0, o = [], s = [];
|
|
@@ -2258,9 +2261,9 @@ var U = class {
|
|
|
2258
2261
|
allocationSize: a,
|
|
2259
2262
|
computedLayouts: o
|
|
2260
2263
|
};
|
|
2261
|
-
},
|
|
2264
|
+
}, Bt = (e) => {
|
|
2262
2265
|
if (!e || typeof e != "object") throw TypeError("Encoding config must be an object.");
|
|
2263
|
-
if (!
|
|
2266
|
+
if (!N.includes(e.codec)) throw TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${N.join(", ")}.`);
|
|
2264
2267
|
let t = e.bitrate;
|
|
2265
2268
|
if (e.quality === void 0 && t === void 0) throw TypeError("config.quality must be provided.");
|
|
2266
2269
|
if (e.quality !== void 0 && t !== void 0) throw TypeError("config.quality and config.bitrate cannot both be provided.");
|
|
@@ -2299,22 +2302,22 @@ var U = class {
|
|
|
2299
2302
|
180,
|
|
2300
2303
|
270
|
|
2301
2304
|
].includes(e.transform.rotate)) throw TypeError("config.transform.rotate, when provided, must be 0, 90, 180 or 270.");
|
|
2302
|
-
if (e.transform.crop !== void 0 &&
|
|
2305
|
+
if (e.transform.crop !== void 0 && Nt(e.transform.crop, "config.transform."), e.transform.process !== void 0 && typeof e.transform.process != "function") throw TypeError("config.transform.process, when provided, must be a function.");
|
|
2303
2306
|
if (e.transform.frameRate !== void 0 && (!Number.isFinite(e.transform.frameRate) || e.transform.frameRate <= 0)) throw TypeError("config.transform.frameRate, when provided, must be a finite positive number.");
|
|
2304
2307
|
if (e.transform.force !== void 0 && typeof e.transform.force != "boolean") throw TypeError("config.transform.force, when provided, must be a boolean.");
|
|
2305
2308
|
}
|
|
2306
2309
|
if (e.onEncodedPacket !== void 0 && typeof e.onEncodedPacket != "function") throw TypeError("config.onEncodedPacket, when provided, must be a function.");
|
|
2307
2310
|
if (e.onEncoderConfig !== void 0 && typeof e.onEncoderConfig != "function") throw TypeError("config.onEncoderConfig, when provided, must be a function.");
|
|
2308
2311
|
if (e.onEncodedSample !== void 0 && typeof e.onEncodedSample != "function") throw TypeError("config.onEncodedSample, when provided, must be a function.");
|
|
2309
|
-
|
|
2310
|
-
},
|
|
2312
|
+
Vt(e.codec, e);
|
|
2313
|
+
}, Vt = (e, t) => {
|
|
2311
2314
|
if (!t || typeof t != "object") throw TypeError("Encoding options must be an object.");
|
|
2312
2315
|
if (t.alpha !== void 0 && !["discard", "keep"].includes(t.alpha)) throw TypeError("options.alpha, when provided, must be 'discard' or 'keep'.");
|
|
2313
2316
|
let n = t.bitrateMode;
|
|
2314
2317
|
if (n !== void 0 && !["constant", "variable"].includes(n)) throw TypeError("bitrateMode, when provided, must be 'constant' or 'variable'.");
|
|
2315
2318
|
if (t.latencyMode !== void 0 && !["quality", "realtime"].includes(t.latencyMode)) throw TypeError("latencyMode, when provided, must be 'quality' or 'realtime'.");
|
|
2316
2319
|
if (t.fullCodecString !== void 0 && typeof t.fullCodecString != "string") throw TypeError("fullCodecString, when provided, must be a string.");
|
|
2317
|
-
if (t.fullCodecString !== void 0 &&
|
|
2320
|
+
if (t.fullCodecString !== void 0 && z(t.fullCodecString) !== e) throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);
|
|
2318
2321
|
if (t.hardwareAcceleration !== void 0 && ![
|
|
2319
2322
|
"no-preference",
|
|
2320
2323
|
"prefer-hardware",
|
|
@@ -2322,9 +2325,9 @@ var U = class {
|
|
|
2322
2325
|
].includes(t.hardwareAcceleration)) throw TypeError("hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.");
|
|
2323
2326
|
if (t.scalabilityMode !== void 0 && typeof t.scalabilityMode != "string") throw TypeError("scalabilityMode, when provided, must be a string.");
|
|
2324
2327
|
if (t.contentHint !== void 0 && typeof t.contentHint != "string") throw TypeError("contentHint, when provided, must be a string.");
|
|
2325
|
-
},
|
|
2328
|
+
}, Ht = (e) => {
|
|
2326
2329
|
let n = e.bitrateMode, r = e.quality._toVideoRateControl(e.codec, e.width, e.height, n), i = (t, n, r) => ({
|
|
2327
|
-
codec: e.fullCodecString ??
|
|
2330
|
+
codec: e.fullCodecString ?? qe(e.codec, e.width, e.height, r, e.alpha === "keep"),
|
|
2328
2331
|
width: e.width,
|
|
2329
2332
|
height: e.height,
|
|
2330
2333
|
displayWidth: e.squarePixelWidth,
|
|
@@ -2337,7 +2340,7 @@ var U = class {
|
|
|
2337
2340
|
hardwareAcceleration: e.hardwareAcceleration,
|
|
2338
2341
|
scalabilityMode: e.scalabilityMode,
|
|
2339
2342
|
contentHint: e.contentHint,
|
|
2340
|
-
|
|
2343
|
+
...$e(e.codec)
|
|
2341
2344
|
}), a = [];
|
|
2342
2345
|
return r.quantizer !== null && a.push({
|
|
2343
2346
|
config: i(void 0, "quantizer", r.bitrate),
|
|
@@ -2351,10 +2354,10 @@ var U = class {
|
|
|
2351
2354
|
if ((typeof e == "number" || typeof e == "string") && (e = { quality: e }), !e || typeof e != "object") throw TypeError("options must be an object.");
|
|
2352
2355
|
if (e.bitrateMode !== void 0 && !["constant", "variable"].includes(e.bitrateMode)) throw TypeError("options.bitrateMode, when provided, must be 'constant' or 'variable'.");
|
|
2353
2356
|
if ("quality" in e) {
|
|
2354
|
-
if (typeof e.quality == "string" ? !(e.quality in
|
|
2357
|
+
if (typeof e.quality == "string" ? !(e.quality in Ut) : typeof e.quality != "number" || Number.isNaN(e.quality)) throw TypeError("options.quality must be a number, or one of 'very-low', 'low', 'medium', 'high' or 'very-high'.");
|
|
2355
2358
|
if (e.preferBitrate !== void 0 && typeof e.preferBitrate != "boolean") throw TypeError("options.preferBitrate, when provided, must be a boolean.");
|
|
2356
2359
|
if ("bitrate" in e || "quantizer" in e) throw TypeError("options.quality cannot be combined with options.bitrate or options.quantizer.");
|
|
2357
|
-
this._quality = typeof e.quality == "string" ?
|
|
2360
|
+
this._quality = typeof e.quality == "string" ? Ut[e.quality] : e.quality, this._preferBitrate = e.preferBitrate ?? !1, this._bitrate = void 0, this._quantizer = void 0;
|
|
2358
2361
|
} else {
|
|
2359
2362
|
if (e.bitrate !== void 0 && (!Number.isInteger(e.bitrate) || e.bitrate <= 0)) throw TypeError("options.bitrate, when provided, must be a positive integer.");
|
|
2360
2363
|
if (e.quantizer !== void 0 && (!Number.isInteger(e.quantizer) || e.quantizer < 0)) throw TypeError("options.quantizer, when provided, must be a non-negative integer.");
|
|
@@ -2365,19 +2368,18 @@ var U = class {
|
|
|
2365
2368
|
this._bitrateMode = e.bitrateMode;
|
|
2366
2369
|
}
|
|
2367
2370
|
_toVideoRateControl(e, n, r, i) {
|
|
2368
|
-
let a =
|
|
2369
|
-
if (this._quantizer !== void 0) {
|
|
2370
|
-
if (
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
} else this._bitrate === void 0 && a && !this._preferBitrate && (t(this._quality !== void 0), o = v(Math.round(y(a.worst, a.best, this._quality)), a.min, a.max));
|
|
2371
|
+
let a = Wt[e], o = null, s = this._bitrateMode ?? i ?? "variable";
|
|
2372
|
+
if (this._quantizer !== void 0) if (!a) {
|
|
2373
|
+
if (this._bitrate === void 0) throw Error(`Codec '${e}' does not support quantizer-based encoding. Provide a bitrate in the Quality to define a fallback.`);
|
|
2374
|
+
} else if (this._quantizer < a.min || this._quantizer > a.max) {
|
|
2375
|
+
if (this._bitrate === void 0) throw Error(`Quantizer ${this._quantizer} is out of range for codec '${e}'; must be between ${a.min} and ${a.max}.`);
|
|
2376
|
+
} else o = this._quantizer, this._bitrate === void 0 && (s = "quantizer");
|
|
2377
|
+
else this._bitrate === void 0 && a && !this._preferBitrate && (t(this._quality !== void 0), o = y(Math.round(b(a.worst, a.best, this._quality)), a.min, a.max));
|
|
2376
2378
|
let c;
|
|
2377
2379
|
if (this._bitrate !== void 0) c = this._bitrate;
|
|
2378
2380
|
else {
|
|
2379
2381
|
let i = this._quality;
|
|
2380
|
-
i === void 0 && (t(o !== null && a), i =
|
|
2382
|
+
i === void 0 && (t(o !== null && a), i = y((o - a.worst) / (a.best - a.worst), 0, 1)), c = Kt(e, n, r, Gt(i));
|
|
2381
2383
|
}
|
|
2382
2384
|
return {
|
|
2383
2385
|
quantizer: o,
|
|
@@ -2386,19 +2388,20 @@ var U = class {
|
|
|
2386
2388
|
};
|
|
2387
2389
|
}
|
|
2388
2390
|
_toVideoBitrate(e, n, r) {
|
|
2389
|
-
return this._bitrate === void 0 ? (t(this._quality !== void 0),
|
|
2391
|
+
return this._bitrate === void 0 ? (t(this._quality !== void 0), Kt(e, n, r, Gt(this._quality))) : this._bitrate;
|
|
2390
2392
|
}
|
|
2391
2393
|
_toAudioBitrate(e) {
|
|
2392
|
-
if (
|
|
2394
|
+
if (P.includes(e) || e === "flac") return;
|
|
2393
2395
|
if (this._bitrate !== void 0) return this._bitrate;
|
|
2394
2396
|
if (this._quality === void 0) throw Error("This Quality defines neither a quality level nor a bitrate and therefore cannot be used for audio encoding.");
|
|
2395
|
-
let t =
|
|
2397
|
+
let t = Gt(this._quality), n = {
|
|
2396
2398
|
aac: 128e3,
|
|
2397
2399
|
opus: 64e3,
|
|
2398
2400
|
mp3: 16e4,
|
|
2399
2401
|
vorbis: 64e3,
|
|
2400
2402
|
ac3: 384e3,
|
|
2401
|
-
eac3: 192e3
|
|
2403
|
+
eac3: 192e3,
|
|
2404
|
+
dts: 768e3
|
|
2402
2405
|
}[e];
|
|
2403
2406
|
if (!n) throw Error(`Unhandled codec: ${e}`);
|
|
2404
2407
|
let r = n * t;
|
|
@@ -2426,13 +2429,13 @@ var U = class {
|
|
|
2426
2429
|
32e4
|
|
2427
2430
|
].reduce((e, t) => Math.abs(t - r) < Math.abs(e - r) ? t : e)), Math.round(r / 1e3) * 1e3;
|
|
2428
2431
|
}
|
|
2429
|
-
},
|
|
2432
|
+
}, Ut = {
|
|
2430
2433
|
"very-low": 0,
|
|
2431
2434
|
low: .25,
|
|
2432
2435
|
medium: .5,
|
|
2433
2436
|
high: .75,
|
|
2434
2437
|
"very-high": 1
|
|
2435
|
-
},
|
|
2438
|
+
}, Wt = {
|
|
2436
2439
|
avc: {
|
|
2437
2440
|
min: 0,
|
|
2438
2441
|
max: 51,
|
|
@@ -2457,7 +2460,7 @@ var U = class {
|
|
|
2457
2460
|
worst: 208,
|
|
2458
2461
|
best: 80
|
|
2459
2462
|
}
|
|
2460
|
-
},
|
|
2463
|
+
}, Gt = (e) => .3 * Math.exp(2.5538 * e), Kt = (e, t, n, r) => {
|
|
2461
2464
|
let i = t * n, a = 3e6, o = a * (i / 2073600) ** .95 * {
|
|
2462
2465
|
avc: 1,
|
|
2463
2466
|
hevc: .6,
|
|
@@ -2467,16 +2470,16 @@ var U = class {
|
|
|
2467
2470
|
prores: 22e7 / a
|
|
2468
2471
|
}[e] * r;
|
|
2469
2472
|
return Math.ceil(o / 1e3) * 1e3;
|
|
2470
|
-
},
|
|
2473
|
+
}, qt = (e, n) => {
|
|
2471
2474
|
if (e === "avc") return { avc: { quantizer: n } };
|
|
2472
2475
|
if (e === "hevc") return { hevc: { quantizer: n } };
|
|
2473
2476
|
if (e === "vp9") return { vp9: { quantizer: n } };
|
|
2474
2477
|
if (e === "av1") return { av1: { quantizer: n } };
|
|
2475
2478
|
t(!1);
|
|
2476
|
-
},
|
|
2479
|
+
}, Jt = (e, t) => {
|
|
2477
2480
|
if (e !== void 0) return e;
|
|
2478
2481
|
if (t !== void 0) return t instanceof Z ? t : new Z({ bitrate: t });
|
|
2479
|
-
},
|
|
2482
|
+
}, Yt = [], Xt = class e {
|
|
2480
2483
|
constructor(e, t, n, r, i) {
|
|
2481
2484
|
this.bytes = e, this.view = t, this.offset = n, this.start = r, this.end = i, this.bufferPos = r - n;
|
|
2482
2485
|
}
|
|
@@ -2502,13 +2505,13 @@ var U = class {
|
|
|
2502
2505
|
if (t < this.start || t + n > this.end) throw RangeError("Slicing outside of original slice.");
|
|
2503
2506
|
return new e(this.bytes, this.view, this.offset, t, t + n);
|
|
2504
2507
|
}
|
|
2505
|
-
},
|
|
2508
|
+
}, Zt = (e, t) => {
|
|
2506
2509
|
if (e.filePos < e.start || e.filePos + t > e.end) throw RangeError(`Tried reading [${e.filePos}, ${e.filePos + t}), but slice is [${e.start}, ${e.end}). This is likely an internal error, please report it alongside the file that caused it.`);
|
|
2507
|
-
},
|
|
2508
|
-
|
|
2510
|
+
}, Qt = (e, t) => {
|
|
2511
|
+
Zt(e, t);
|
|
2509
2512
|
let n = e.bytes.subarray(e.bufferPos, e.bufferPos + t);
|
|
2510
2513
|
return e.bufferPos += t, n;
|
|
2511
|
-
},
|
|
2514
|
+
}, $t = class {
|
|
2512
2515
|
constructor(e) {
|
|
2513
2516
|
this.mutex = new m(), this.trackTimestampInfo = /* @__PURE__ */ new WeakMap(), this.output = e;
|
|
2514
2517
|
}
|
|
@@ -2527,16 +2530,16 @@ var U = class {
|
|
|
2527
2530
|
}, this.trackTimestampInfo.set(e, r);
|
|
2528
2531
|
}
|
|
2529
2532
|
}
|
|
2530
|
-
},
|
|
2531
|
-
let t =
|
|
2533
|
+
}, en = /<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g, tn = /(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})/, nn = (e) => {
|
|
2534
|
+
let t = tn.exec(e);
|
|
2532
2535
|
if (!t) throw Error("Expected match.");
|
|
2533
|
-
return
|
|
2534
|
-
},
|
|
2535
|
-
let t = Math.floor(e /
|
|
2536
|
+
return 3600 * 1e3 * Number(t[1] || "0") + 60 * 1e3 * Number(t[2]) + 1e3 * Number(t[3]) + Number(t[4]);
|
|
2537
|
+
}, rn = (e) => {
|
|
2538
|
+
let t = Math.floor(e / (3600 * 1e3)), n = Math.floor(e % (3600 * 1e3) / (60 * 1e3)), r = Math.floor(e % (60 * 1e3) / 1e3), i = e % 1e3;
|
|
2536
2539
|
return t.toString().padStart(2, "0") + ":" + n.toString().padStart(2, "0") + ":" + r.toString().padStart(2, "0") + "." + i.toString().padStart(3, "0");
|
|
2537
2540
|
};
|
|
2538
2541
|
e();
|
|
2539
|
-
var
|
|
2542
|
+
var an = class {
|
|
2540
2543
|
constructor(e, t) {
|
|
2541
2544
|
if (this.finalized = !1, this.started = !1, this.pos = 0, this.trackedWrites = null, this.trackedStart = -1, this.trackedEnd = -1, e._writerAcquired) throw Error("Can't have multiple Writers for the same Target.");
|
|
2542
2545
|
this.target = e, e._setMonotonicity(t), e._writerAcquired = !0;
|
|
@@ -2575,7 +2578,7 @@ var Qt = class {
|
|
|
2575
2578
|
this.trackedWrites.set(e, t - this.trackedStart), this.trackedEnd = Math.max(this.trackedEnd, t + e.byteLength);
|
|
2576
2579
|
}
|
|
2577
2580
|
startTrackingWrites() {
|
|
2578
|
-
this.trackedWrites =
|
|
2581
|
+
this.trackedWrites = new Uint8Array(2 ** 10), this.trackedStart = this.getPos(), this.trackedEnd = this.trackedStart;
|
|
2579
2582
|
}
|
|
2580
2583
|
stopTrackingWrites() {
|
|
2581
2584
|
if (!this.trackedWrites) throw Error("Internal error: Can't get tracked writes since nothing was tracked.");
|
|
@@ -2601,25 +2604,25 @@ var Qt = class {
|
|
|
2601
2604
|
}
|
|
2602
2605
|
slice(e) {
|
|
2603
2606
|
if (!Number.isInteger(e) || e < 0) throw TypeError("offset must be a non-negative integer.");
|
|
2604
|
-
return new
|
|
2607
|
+
return new ln(this, e);
|
|
2605
2608
|
}
|
|
2606
|
-
},
|
|
2609
|
+
}, on = 2 ** 16, sn = 2 ** 32, cn = class extends Q {
|
|
2607
2610
|
constructor(e = {}) {
|
|
2608
2611
|
if (super(), this.buffer = null, this._maxPos = 0, !e || typeof e != "object") throw TypeError("BufferTarget options, when provided, must be an object.");
|
|
2609
2612
|
if (e.onFinalize !== void 0 && typeof e.onFinalize != "function") throw TypeError("options.onFinalize, when provided, must be a function.");
|
|
2610
2613
|
if (this._options = e, this._supportsResize = "resize" in /* @__PURE__ */ new ArrayBuffer(0), this._supportsResize) try {
|
|
2611
|
-
this._buffer = new ArrayBuffer(
|
|
2614
|
+
this._buffer = new ArrayBuffer(on, { maxByteLength: sn });
|
|
2612
2615
|
} catch {
|
|
2613
|
-
this._buffer = new ArrayBuffer(
|
|
2616
|
+
this._buffer = new ArrayBuffer(on), this._supportsResize = !1;
|
|
2614
2617
|
}
|
|
2615
|
-
else this._buffer = new ArrayBuffer(
|
|
2618
|
+
else this._buffer = new ArrayBuffer(on);
|
|
2616
2619
|
this._bytes = new Uint8Array(this._buffer);
|
|
2617
2620
|
}
|
|
2618
2621
|
_ensureSize(e) {
|
|
2619
2622
|
let t = this._buffer.byteLength;
|
|
2620
2623
|
for (; t < e;) t *= 2;
|
|
2621
2624
|
if (t !== this._buffer.byteLength) {
|
|
2622
|
-
if (t >
|
|
2625
|
+
if (t > sn) throw Error(`ArrayBuffer exceeded maximum size of ${sn} bytes. Please consider using another target.`);
|
|
2623
2626
|
if (this._supportsResize) this._buffer.resize(t);
|
|
2624
2627
|
else {
|
|
2625
2628
|
let e = new ArrayBuffer(t), n = new Uint8Array(e);
|
|
@@ -2639,7 +2642,7 @@ var Qt = class {
|
|
|
2639
2642
|
_getSlice(e, t) {
|
|
2640
2643
|
return this._bytes.slice(e, t);
|
|
2641
2644
|
}
|
|
2642
|
-
},
|
|
2645
|
+
}, ln = class extends Q {
|
|
2643
2646
|
constructor(e, t) {
|
|
2644
2647
|
super(), this._baseTarget = e, this._offset = t;
|
|
2645
2648
|
}
|
|
@@ -2657,56 +2660,56 @@ var Qt = class {
|
|
|
2657
2660
|
_setMonotonicity(e) {
|
|
2658
2661
|
super._setMonotonicity(e), this._baseTarget._setMonotonicity(e);
|
|
2659
2662
|
}
|
|
2660
|
-
},
|
|
2663
|
+
}, un = class {
|
|
2661
2664
|
constructor(e, t) {
|
|
2662
2665
|
if (this.rootPath = e, this.getTarget = t, typeof e != "string") throw TypeError("rootPath must be a string.");
|
|
2663
2666
|
if (typeof t != "function") throw TypeError("getTarget must be a function.");
|
|
2664
2667
|
}
|
|
2665
|
-
},
|
|
2668
|
+
}, dn = -(2 ** 15), fn = 2 ** 15 - 1, pn = "Mediabunny", mn = 6, hn = 5, gn = {
|
|
2666
2669
|
video: 1,
|
|
2667
2670
|
audio: 2,
|
|
2668
2671
|
subtitle: 17
|
|
2669
|
-
},
|
|
2672
|
+
}, _n = class extends $t {
|
|
2670
2673
|
constructor(e, t) {
|
|
2671
2674
|
super(e), this.trackDatas = [], this.allTracksKnown = g(), this.segment = null, this.segmentInfo = null, this.seekHead = null, this.tracksElement = null, this.tagsElement = null, this.attachmentsElement = null, this.segmentDuration = null, this.cues = null, this.currentCluster = null, this.currentClusterStartMsTimestamp = null, this.currentClusterMaxMsTimestamp = null, this.trackDatasInCurrentCluster = /* @__PURE__ */ new Map(), this.startTimestamp = Infinity, this.endTimestamp = -Infinity, this.format = t;
|
|
2672
2675
|
}
|
|
2673
2676
|
async start() {
|
|
2674
2677
|
let e = await this.mutex.acquire();
|
|
2675
|
-
this.writer = await this.output._getRootWriter(!!this.format._options.appendOnly), this.ebmlWriter = new
|
|
2678
|
+
this.writer = await this.output._getRootWriter(!!this.format._options.appendOnly), this.ebmlWriter = new _t(this.writer), this.writeEBMLHeader(), this.createSegmentInfo(), this.createCues(), await this.writer.flush();
|
|
2676
2679
|
for (let e of this.output.tracks) e.isVideoTrack() && e.metadata.decoderConfig ? this.getVideoTrackData(e, e.metadata.primingPacket ?? null, { decoderConfig: e.metadata.decoderConfig }) : e.isAudioTrack() && e.metadata.decoderConfig && this.getAudioTrackData(e, e.metadata.primingPacket ?? null, { decoderConfig: e.metadata.decoderConfig });
|
|
2677
2680
|
e();
|
|
2678
2681
|
}
|
|
2679
2682
|
writeEBMLHeader() {
|
|
2680
2683
|
this.format._options.onEbmlHeader && this.writer.startTrackingWrites();
|
|
2681
2684
|
let e = {
|
|
2682
|
-
id:
|
|
2685
|
+
id: W.EBML,
|
|
2683
2686
|
data: [
|
|
2684
2687
|
{
|
|
2685
|
-
id:
|
|
2688
|
+
id: W.EBMLVersion,
|
|
2686
2689
|
data: 1
|
|
2687
2690
|
},
|
|
2688
2691
|
{
|
|
2689
|
-
id:
|
|
2692
|
+
id: W.EBMLReadVersion,
|
|
2690
2693
|
data: 1
|
|
2691
2694
|
},
|
|
2692
2695
|
{
|
|
2693
|
-
id:
|
|
2696
|
+
id: W.EBMLMaxIDLength,
|
|
2694
2697
|
data: 4
|
|
2695
2698
|
},
|
|
2696
2699
|
{
|
|
2697
|
-
id:
|
|
2700
|
+
id: W.EBMLMaxSizeLength,
|
|
2698
2701
|
data: 8
|
|
2699
2702
|
},
|
|
2700
2703
|
{
|
|
2701
|
-
id:
|
|
2702
|
-
data: this.format instanceof
|
|
2704
|
+
id: W.DocType,
|
|
2705
|
+
data: this.format instanceof Mn ? "webm" : "matroska"
|
|
2703
2706
|
},
|
|
2704
2707
|
{
|
|
2705
|
-
id:
|
|
2708
|
+
id: W.DocTypeVersion,
|
|
2706
2709
|
data: 2
|
|
2707
2710
|
},
|
|
2708
2711
|
{
|
|
2709
|
-
id:
|
|
2712
|
+
id: W.DocTypeReadVersion,
|
|
2710
2713
|
data: 2
|
|
2711
2714
|
}
|
|
2712
2715
|
]
|
|
@@ -2744,59 +2747,59 @@ var Qt = class {
|
|
|
2744
2747
|
195,
|
|
2745
2748
|
103
|
|
2746
2749
|
]), o = {
|
|
2747
|
-
id:
|
|
2750
|
+
id: W.SeekHead,
|
|
2748
2751
|
data: [
|
|
2749
2752
|
{
|
|
2750
|
-
id:
|
|
2753
|
+
id: W.Seek,
|
|
2751
2754
|
data: [{
|
|
2752
|
-
id:
|
|
2755
|
+
id: W.SeekID,
|
|
2753
2756
|
data: t
|
|
2754
2757
|
}, {
|
|
2755
|
-
id:
|
|
2758
|
+
id: W.SeekPosition,
|
|
2756
2759
|
size: 5,
|
|
2757
2760
|
data: e ? this.ebmlWriter.offsets.get(this.cues) - this.segmentDataOffset : 0
|
|
2758
2761
|
}]
|
|
2759
2762
|
},
|
|
2760
2763
|
{
|
|
2761
|
-
id:
|
|
2764
|
+
id: W.Seek,
|
|
2762
2765
|
data: [{
|
|
2763
|
-
id:
|
|
2766
|
+
id: W.SeekID,
|
|
2764
2767
|
data: n
|
|
2765
2768
|
}, {
|
|
2766
|
-
id:
|
|
2769
|
+
id: W.SeekPosition,
|
|
2767
2770
|
size: 5,
|
|
2768
2771
|
data: e ? this.ebmlWriter.offsets.get(this.segmentInfo) - this.segmentDataOffset : 0
|
|
2769
2772
|
}]
|
|
2770
2773
|
},
|
|
2771
2774
|
{
|
|
2772
|
-
id:
|
|
2775
|
+
id: W.Seek,
|
|
2773
2776
|
data: [{
|
|
2774
|
-
id:
|
|
2777
|
+
id: W.SeekID,
|
|
2775
2778
|
data: r
|
|
2776
2779
|
}, {
|
|
2777
|
-
id:
|
|
2780
|
+
id: W.SeekPosition,
|
|
2778
2781
|
size: 5,
|
|
2779
2782
|
data: e ? this.ebmlWriter.offsets.get(this.tracksElement) - this.segmentDataOffset : 0
|
|
2780
2783
|
}]
|
|
2781
2784
|
},
|
|
2782
2785
|
this.attachmentsElement ? {
|
|
2783
|
-
id:
|
|
2786
|
+
id: W.Seek,
|
|
2784
2787
|
data: [{
|
|
2785
|
-
id:
|
|
2788
|
+
id: W.SeekID,
|
|
2786
2789
|
data: i
|
|
2787
2790
|
}, {
|
|
2788
|
-
id:
|
|
2791
|
+
id: W.SeekPosition,
|
|
2789
2792
|
size: 5,
|
|
2790
2793
|
data: e ? this.ebmlWriter.offsets.get(this.attachmentsElement) - this.segmentDataOffset : 0
|
|
2791
2794
|
}]
|
|
2792
2795
|
} : null,
|
|
2793
2796
|
this.tagsElement ? {
|
|
2794
|
-
id:
|
|
2797
|
+
id: W.Seek,
|
|
2795
2798
|
data: [{
|
|
2796
|
-
id:
|
|
2799
|
+
id: W.SeekID,
|
|
2797
2800
|
data: a
|
|
2798
2801
|
}, {
|
|
2799
|
-
id:
|
|
2802
|
+
id: W.SeekPosition,
|
|
2800
2803
|
size: 5,
|
|
2801
2804
|
data: e ? this.ebmlWriter.offsets.get(this.tagsElement) - this.segmentDataOffset : 0
|
|
2802
2805
|
}]
|
|
@@ -2807,24 +2810,24 @@ var Qt = class {
|
|
|
2807
2810
|
}
|
|
2808
2811
|
createSegmentInfo() {
|
|
2809
2812
|
let e = {
|
|
2810
|
-
id:
|
|
2811
|
-
data: new
|
|
2813
|
+
id: W.Duration,
|
|
2814
|
+
data: new H(0)
|
|
2812
2815
|
};
|
|
2813
2816
|
this.segmentDuration = e;
|
|
2814
2817
|
let t = {
|
|
2815
|
-
id:
|
|
2818
|
+
id: W.Info,
|
|
2816
2819
|
data: [
|
|
2817
2820
|
{
|
|
2818
|
-
id:
|
|
2821
|
+
id: W.TimestampScale,
|
|
2819
2822
|
data: 1e6
|
|
2820
2823
|
},
|
|
2821
2824
|
{
|
|
2822
|
-
id:
|
|
2823
|
-
data:
|
|
2825
|
+
id: W.MuxingApp,
|
|
2826
|
+
data: pn
|
|
2824
2827
|
},
|
|
2825
2828
|
{
|
|
2826
|
-
id:
|
|
2827
|
-
data:
|
|
2829
|
+
id: W.WritingApp,
|
|
2830
|
+
data: pn
|
|
2828
2831
|
},
|
|
2829
2832
|
this.format._options.appendOnly ? null : e
|
|
2830
2833
|
]
|
|
@@ -2833,88 +2836,88 @@ var Qt = class {
|
|
|
2833
2836
|
}
|
|
2834
2837
|
createTracks() {
|
|
2835
2838
|
let e = {
|
|
2836
|
-
id:
|
|
2839
|
+
id: W.Tracks,
|
|
2837
2840
|
data: []
|
|
2838
2841
|
};
|
|
2839
2842
|
this.tracksElement = e;
|
|
2840
2843
|
for (let n of this.trackDatas) {
|
|
2841
|
-
let r =
|
|
2842
|
-
t(r);
|
|
2844
|
+
let r = vt[n.track.source._codec];
|
|
2845
|
+
t(r), n.type === "audio" && n.track.source._codec === "dts" && (n.info.decoderConfig.codec === "dtse" ? r = "A_DTS/EXPRESS" : n.info.decoderConfig.codec === "dtsl" && (r = "A_DTS/LOSSLESS"));
|
|
2843
2846
|
let i = 0;
|
|
2844
2847
|
if (n.type === "audio" && n.track.source._codec === "opus") {
|
|
2845
|
-
i =
|
|
2848
|
+
i = 1e6 * 80;
|
|
2846
2849
|
let e = n.info.decoderConfig.description;
|
|
2847
2850
|
if (e) {
|
|
2848
|
-
let t =
|
|
2849
|
-
i = Math.round(1e9 * (t.preSkip /
|
|
2851
|
+
let t = Re(o(e));
|
|
2852
|
+
i = Math.round(1e9 * (t.preSkip / Xe));
|
|
2850
2853
|
}
|
|
2851
2854
|
}
|
|
2852
2855
|
e.data.push({
|
|
2853
|
-
id:
|
|
2856
|
+
id: W.TrackEntry,
|
|
2854
2857
|
data: [
|
|
2855
2858
|
{
|
|
2856
|
-
id:
|
|
2859
|
+
id: W.TrackNumber,
|
|
2857
2860
|
data: n.track.id
|
|
2858
2861
|
},
|
|
2859
2862
|
{
|
|
2860
|
-
id:
|
|
2863
|
+
id: W.TrackUID,
|
|
2861
2864
|
data: n.track.id
|
|
2862
2865
|
},
|
|
2863
2866
|
{
|
|
2864
|
-
id:
|
|
2865
|
-
data:
|
|
2867
|
+
id: W.TrackType,
|
|
2868
|
+
data: gn[n.type]
|
|
2866
2869
|
},
|
|
2867
2870
|
n.track.metadata.disposition?.default === !1 ? {
|
|
2868
|
-
id:
|
|
2871
|
+
id: W.FlagDefault,
|
|
2869
2872
|
data: 0
|
|
2870
2873
|
} : null,
|
|
2871
2874
|
n.track.metadata.disposition?.forced ? {
|
|
2872
|
-
id:
|
|
2875
|
+
id: W.FlagForced,
|
|
2873
2876
|
data: 1
|
|
2874
2877
|
} : null,
|
|
2875
2878
|
n.track.metadata.disposition?.hearingImpaired ? {
|
|
2876
|
-
id:
|
|
2879
|
+
id: W.FlagHearingImpaired,
|
|
2877
2880
|
data: 1
|
|
2878
2881
|
} : null,
|
|
2879
2882
|
n.track.metadata.disposition?.visuallyImpaired ? {
|
|
2880
|
-
id:
|
|
2883
|
+
id: W.FlagVisualImpaired,
|
|
2881
2884
|
data: 1
|
|
2882
2885
|
} : null,
|
|
2883
2886
|
n.track.metadata.disposition?.original ? {
|
|
2884
|
-
id:
|
|
2887
|
+
id: W.FlagOriginal,
|
|
2885
2888
|
data: 1
|
|
2886
2889
|
} : null,
|
|
2887
2890
|
n.track.metadata.disposition?.commentary ? {
|
|
2888
|
-
id:
|
|
2891
|
+
id: W.FlagCommentary,
|
|
2889
2892
|
data: 1
|
|
2890
2893
|
} : null,
|
|
2891
2894
|
{
|
|
2892
|
-
id:
|
|
2895
|
+
id: W.FlagLacing,
|
|
2893
2896
|
data: 0
|
|
2894
2897
|
},
|
|
2895
2898
|
{
|
|
2896
|
-
id:
|
|
2899
|
+
id: W.Language,
|
|
2897
2900
|
data: n.track.metadata.languageCode ?? "und"
|
|
2898
2901
|
},
|
|
2899
2902
|
{
|
|
2900
|
-
id:
|
|
2903
|
+
id: W.CodecID,
|
|
2901
2904
|
data: r
|
|
2902
2905
|
},
|
|
2903
2906
|
n.codecPrivate ? {
|
|
2904
|
-
id:
|
|
2907
|
+
id: W.CodecPrivate,
|
|
2905
2908
|
data: o(n.codecPrivate)
|
|
2906
2909
|
} : null,
|
|
2907
2910
|
{
|
|
2908
|
-
id:
|
|
2911
|
+
id: W.CodecDelay,
|
|
2909
2912
|
data: 0
|
|
2910
2913
|
},
|
|
2911
2914
|
{
|
|
2912
|
-
id:
|
|
2915
|
+
id: W.SeekPreRoll,
|
|
2913
2916
|
data: i
|
|
2914
2917
|
},
|
|
2915
2918
|
n.track.metadata.name === void 0 ? null : {
|
|
2916
|
-
id:
|
|
2917
|
-
data: new
|
|
2919
|
+
id: W.Name,
|
|
2920
|
+
data: new U(n.track.metadata.name)
|
|
2918
2921
|
},
|
|
2919
2922
|
n.type === "video" ? this.videoSpecificTrackInfo(n) : null,
|
|
2920
2923
|
n.type === "audio" ? this.audioSpecificTrackInfo(n) : null,
|
|
@@ -2925,64 +2928,64 @@ var Qt = class {
|
|
|
2925
2928
|
}
|
|
2926
2929
|
videoSpecificTrackInfo(e) {
|
|
2927
2930
|
let { frameRate: t, rotation: r } = e.track.metadata, i = [t ? {
|
|
2928
|
-
id:
|
|
2931
|
+
id: W.DefaultDuration,
|
|
2929
2932
|
data: 1e9 / t
|
|
2930
2933
|
} : null], a = r ? n(-r) : 0, o = !!e.info.aspectRatio && e.info.aspectRatio.num * e.info.height !== e.info.aspectRatio.den * e.info.width, s = e.info.decoderConfig.colorSpace, c = {
|
|
2931
|
-
id:
|
|
2934
|
+
id: W.Video,
|
|
2932
2935
|
data: [
|
|
2933
2936
|
{
|
|
2934
|
-
id:
|
|
2937
|
+
id: W.PixelWidth,
|
|
2935
2938
|
data: e.info.width
|
|
2936
2939
|
},
|
|
2937
2940
|
{
|
|
2938
|
-
id:
|
|
2941
|
+
id: W.PixelHeight,
|
|
2939
2942
|
data: e.info.height
|
|
2940
2943
|
},
|
|
2941
2944
|
o ? {
|
|
2942
|
-
id:
|
|
2945
|
+
id: W.DisplayWidth,
|
|
2943
2946
|
data: e.info.aspectRatio.num
|
|
2944
2947
|
} : null,
|
|
2945
2948
|
o ? {
|
|
2946
|
-
id:
|
|
2949
|
+
id: W.DisplayHeight,
|
|
2947
2950
|
data: e.info.aspectRatio.den
|
|
2948
2951
|
} : null,
|
|
2949
2952
|
o ? {
|
|
2950
|
-
id:
|
|
2953
|
+
id: W.DisplayUnit,
|
|
2951
2954
|
data: 3
|
|
2952
2955
|
} : null,
|
|
2953
2956
|
e.info.alphaMode ? {
|
|
2954
|
-
id:
|
|
2957
|
+
id: W.AlphaMode,
|
|
2955
2958
|
data: 1
|
|
2956
2959
|
} : null,
|
|
2957
|
-
f(s) ? {
|
|
2958
|
-
id:
|
|
2960
|
+
f(s) ? null : {
|
|
2961
|
+
id: W.Colour,
|
|
2959
2962
|
data: [
|
|
2960
2963
|
{
|
|
2961
|
-
id:
|
|
2962
|
-
data: d[s.matrix]
|
|
2964
|
+
id: W.MatrixCoefficients,
|
|
2965
|
+
data: s?.matrix == null ? 2 : d[s.matrix]
|
|
2963
2966
|
},
|
|
2964
2967
|
{
|
|
2965
|
-
id:
|
|
2966
|
-
data: u[s.transfer]
|
|
2968
|
+
id: W.TransferCharacteristics,
|
|
2969
|
+
data: s?.transfer == null ? 2 : u[s.transfer]
|
|
2967
2970
|
},
|
|
2968
2971
|
{
|
|
2969
|
-
id:
|
|
2970
|
-
data: l[s.primaries]
|
|
2972
|
+
id: W.Primaries,
|
|
2973
|
+
data: s?.primaries == null ? 2 : l[s.primaries]
|
|
2971
2974
|
},
|
|
2972
2975
|
{
|
|
2973
|
-
id:
|
|
2974
|
-
data: s.fullRange ? 2 : 1
|
|
2976
|
+
id: W.Range,
|
|
2977
|
+
data: s?.fullRange == null ? 0 : s.fullRange ? 2 : 1
|
|
2975
2978
|
}
|
|
2976
2979
|
]
|
|
2977
|
-
}
|
|
2980
|
+
},
|
|
2978
2981
|
a ? {
|
|
2979
|
-
id:
|
|
2982
|
+
id: W.Projection,
|
|
2980
2983
|
data: [{
|
|
2981
|
-
id:
|
|
2984
|
+
id: W.ProjectionType,
|
|
2982
2985
|
data: 0
|
|
2983
2986
|
}, {
|
|
2984
|
-
id:
|
|
2985
|
-
data: new
|
|
2987
|
+
id: W.ProjectionPoseRoll,
|
|
2988
|
+
data: new V((a + 180) % 360 - 180)
|
|
2986
2989
|
}]
|
|
2987
2990
|
} : null
|
|
2988
2991
|
]
|
|
@@ -2990,20 +2993,20 @@ var Qt = class {
|
|
|
2990
2993
|
return i.push(c), i;
|
|
2991
2994
|
}
|
|
2992
2995
|
audioSpecificTrackInfo(e) {
|
|
2993
|
-
let t =
|
|
2996
|
+
let t = P.includes(e.track.source._codec) ? Qe(e.track.source._codec) : null;
|
|
2994
2997
|
return [{
|
|
2995
|
-
id:
|
|
2998
|
+
id: W.Audio,
|
|
2996
2999
|
data: [
|
|
2997
3000
|
{
|
|
2998
|
-
id:
|
|
2999
|
-
data: new
|
|
3001
|
+
id: W.SamplingFrequency,
|
|
3002
|
+
data: new V(e.info.sampleRate)
|
|
3000
3003
|
},
|
|
3001
3004
|
{
|
|
3002
|
-
id:
|
|
3005
|
+
id: W.Channels,
|
|
3003
3006
|
data: e.info.numberOfChannels
|
|
3004
3007
|
},
|
|
3005
3008
|
t ? {
|
|
3006
|
-
id:
|
|
3009
|
+
id: W.BitDepth,
|
|
3007
3010
|
data: 8 * t.sampleSize
|
|
3008
3011
|
} : null
|
|
3009
3012
|
]
|
|
@@ -3015,20 +3018,20 @@ var Qt = class {
|
|
|
3015
3018
|
maybeCreateTags() {
|
|
3016
3019
|
let e = [], t = (t, n) => {
|
|
3017
3020
|
e.push({
|
|
3018
|
-
id:
|
|
3021
|
+
id: W.SimpleTag,
|
|
3019
3022
|
data: [{
|
|
3020
|
-
id:
|
|
3021
|
-
data: new
|
|
3023
|
+
id: W.TagName,
|
|
3024
|
+
data: new U(t)
|
|
3022
3025
|
}, typeof n == "string" ? {
|
|
3023
|
-
id:
|
|
3024
|
-
data: new
|
|
3026
|
+
id: W.TagString,
|
|
3027
|
+
data: new U(n)
|
|
3025
3028
|
} : {
|
|
3026
|
-
id:
|
|
3029
|
+
id: W.TagBinary,
|
|
3027
3030
|
data: n
|
|
3028
3031
|
}]
|
|
3029
3032
|
});
|
|
3030
3033
|
}, n = this.output._metadataTags, r = /* @__PURE__ */ new Set();
|
|
3031
|
-
for (let { key: e, value: i } of
|
|
3034
|
+
for (let { key: e, value: i } of ce(n)) switch (e) {
|
|
3032
3035
|
case "title":
|
|
3033
3036
|
t("TITLE", i), r.add("TITLE");
|
|
3034
3037
|
break;
|
|
@@ -3073,16 +3076,16 @@ var Qt = class {
|
|
|
3073
3076
|
i == null || r.has(e) || (typeof i == "string" || i instanceof Uint8Array) && t(e, i);
|
|
3074
3077
|
}
|
|
3075
3078
|
e.length !== 0 && (this.tagsElement = {
|
|
3076
|
-
id:
|
|
3079
|
+
id: W.Tags,
|
|
3077
3080
|
data: [{
|
|
3078
|
-
id:
|
|
3081
|
+
id: W.Tag,
|
|
3079
3082
|
data: [{
|
|
3080
|
-
id:
|
|
3083
|
+
id: W.Targets,
|
|
3081
3084
|
data: [{
|
|
3082
|
-
id:
|
|
3085
|
+
id: W.TargetTypeValue,
|
|
3083
3086
|
data: 50
|
|
3084
3087
|
}, {
|
|
3085
|
-
id:
|
|
3088
|
+
id: W.TargetType,
|
|
3086
3089
|
data: "MOVIE"
|
|
3087
3090
|
}]
|
|
3088
3091
|
}, ...e]
|
|
@@ -3093,7 +3096,7 @@ var Qt = class {
|
|
|
3093
3096
|
let e = this.output._metadataTags, t = [], n = /* @__PURE__ */ new Set(), r = e.images ?? [];
|
|
3094
3097
|
for (let e of r) {
|
|
3095
3098
|
let r = e.name;
|
|
3096
|
-
r === void 0 && (r = (e.kind === "coverFront" ? "cover" : e.kind === "coverBack" ? "back" : "image") + (
|
|
3099
|
+
r === void 0 && (r = (e.kind === "coverFront" ? "cover" : e.kind === "coverBack" ? "back" : "image") + (le(e.mimeType) ?? ""));
|
|
3097
3100
|
let i;
|
|
3098
3101
|
for (;;) {
|
|
3099
3102
|
i = 0n;
|
|
@@ -3101,66 +3104,66 @@ var Qt = class {
|
|
|
3101
3104
|
if (i !== 0n && !n.has(i)) break;
|
|
3102
3105
|
}
|
|
3103
3106
|
n.add(i), t.push({
|
|
3104
|
-
id:
|
|
3107
|
+
id: W.AttachedFile,
|
|
3105
3108
|
data: [
|
|
3106
3109
|
e.description === void 0 ? null : {
|
|
3107
|
-
id:
|
|
3108
|
-
data: new
|
|
3110
|
+
id: W.FileDescription,
|
|
3111
|
+
data: new U(e.description)
|
|
3109
3112
|
},
|
|
3110
3113
|
{
|
|
3111
|
-
id:
|
|
3112
|
-
data: new
|
|
3114
|
+
id: W.FileName,
|
|
3115
|
+
data: new U(r)
|
|
3113
3116
|
},
|
|
3114
3117
|
{
|
|
3115
|
-
id:
|
|
3118
|
+
id: W.FileMediaType,
|
|
3116
3119
|
data: e.mimeType
|
|
3117
3120
|
},
|
|
3118
3121
|
{
|
|
3119
|
-
id:
|
|
3122
|
+
id: W.FileData,
|
|
3120
3123
|
data: e.data
|
|
3121
3124
|
},
|
|
3122
3125
|
{
|
|
3123
|
-
id:
|
|
3126
|
+
id: W.FileUID,
|
|
3124
3127
|
data: i
|
|
3125
3128
|
}
|
|
3126
3129
|
]
|
|
3127
3130
|
});
|
|
3128
3131
|
}
|
|
3129
|
-
for (let [n, i] of Object.entries(e.raw ?? {})) i instanceof
|
|
3130
|
-
id:
|
|
3132
|
+
for (let [n, i] of Object.entries(e.raw ?? {})) i instanceof ye && /^\d+$/.test(n) && (r.find((e) => e.mimeType === i.mimeType && ue(e.data, i.data)) || t.push({
|
|
3133
|
+
id: W.AttachedFile,
|
|
3131
3134
|
data: [
|
|
3132
3135
|
i.description === void 0 ? null : {
|
|
3133
|
-
id:
|
|
3134
|
-
data: new
|
|
3136
|
+
id: W.FileDescription,
|
|
3137
|
+
data: new U(i.description)
|
|
3135
3138
|
},
|
|
3136
3139
|
{
|
|
3137
|
-
id:
|
|
3138
|
-
data: new
|
|
3140
|
+
id: W.FileName,
|
|
3141
|
+
data: new U(i.name ?? "")
|
|
3139
3142
|
},
|
|
3140
3143
|
{
|
|
3141
|
-
id:
|
|
3144
|
+
id: W.FileMediaType,
|
|
3142
3145
|
data: i.mimeType ?? ""
|
|
3143
3146
|
},
|
|
3144
3147
|
{
|
|
3145
|
-
id:
|
|
3148
|
+
id: W.FileData,
|
|
3146
3149
|
data: i.data
|
|
3147
3150
|
},
|
|
3148
3151
|
{
|
|
3149
|
-
id:
|
|
3152
|
+
id: W.FileUID,
|
|
3150
3153
|
data: BigInt(n)
|
|
3151
3154
|
}
|
|
3152
3155
|
]
|
|
3153
3156
|
}));
|
|
3154
3157
|
t.length !== 0 && (this.attachmentsElement = {
|
|
3155
|
-
id:
|
|
3158
|
+
id: W.Attachments,
|
|
3156
3159
|
data: t
|
|
3157
3160
|
});
|
|
3158
3161
|
}
|
|
3159
3162
|
createSegment() {
|
|
3160
3163
|
this.createTracks(), this.maybeCreateTags(), this.maybeCreateAttachments(), this.maybeCreateSeekHead(!1);
|
|
3161
3164
|
let e = {
|
|
3162
|
-
id:
|
|
3163
|
-
size: this.format._options.appendOnly ? -1 :
|
|
3165
|
+
id: W.Segment,
|
|
3166
|
+
size: this.format._options.appendOnly ? -1 : mn,
|
|
3164
3167
|
data: [
|
|
3165
3168
|
this.seekHead,
|
|
3166
3169
|
this.segmentInfo,
|
|
@@ -3176,7 +3179,7 @@ var Qt = class {
|
|
|
3176
3179
|
}
|
|
3177
3180
|
createCues() {
|
|
3178
3181
|
this.cues = {
|
|
3179
|
-
id:
|
|
3182
|
+
id: W.Cues,
|
|
3180
3183
|
data: []
|
|
3181
3184
|
};
|
|
3182
3185
|
}
|
|
@@ -3190,8 +3193,8 @@ var Qt = class {
|
|
|
3190
3193
|
async getMimeType() {
|
|
3191
3194
|
await this.allTracksKnown.promise;
|
|
3192
3195
|
let e = this.trackDatas.map((e) => e.type === "video" || e.type === "audio" ? e.info.decoderConfig.codec : { webvtt: "wvtt" }[e.track.source._codec]);
|
|
3193
|
-
return
|
|
3194
|
-
isWebM: this.format instanceof
|
|
3196
|
+
return yt({
|
|
3197
|
+
isWebM: this.format instanceof Mn,
|
|
3195
3198
|
hasVideo: this.trackDatas.some((e) => e.type === "video"),
|
|
3196
3199
|
hasAudio: this.trackDatas.some((e) => e.type === "audio"),
|
|
3197
3200
|
codecStrings: e
|
|
@@ -3200,8 +3203,8 @@ var Qt = class {
|
|
|
3200
3203
|
getVideoTrackData(e, n, r) {
|
|
3201
3204
|
let i = this.trackDatas.find((t) => t.track === e);
|
|
3202
3205
|
if (i) return i;
|
|
3203
|
-
|
|
3204
|
-
let a = r.decoderConfig.displayAspectWidth, o = r.decoderConfig.displayAspectHeight, s = a === void 0 || o === void 0 ? null :
|
|
3206
|
+
at(r, e.source._codec), t(r), t(r.decoderConfig), t(r.decoderConfig.codedWidth !== void 0), t(r.decoderConfig.codedHeight !== void 0);
|
|
3207
|
+
let a = r.decoderConfig.displayAspectWidth, o = r.decoderConfig.displayAspectHeight, s = a === void 0 || o === void 0 ? null : me({
|
|
3205
3208
|
num: a,
|
|
3206
3209
|
den: o
|
|
3207
3210
|
}), l = {
|
|
@@ -3219,23 +3222,23 @@ var Qt = class {
|
|
|
3219
3222
|
codecPrivate: r.decoderConfig.description ?? null,
|
|
3220
3223
|
closed: !1
|
|
3221
3224
|
};
|
|
3222
|
-
return e.source._codec === "vp9" ? l.codecPrivate = new Uint8Array(
|
|
3225
|
+
return e.source._codec === "vp9" ? l.codecPrivate = new Uint8Array(Je(l.info.decoderConfig.codec)) : e.source._codec === "av1" ? l.codecPrivate = new Uint8Array(Ye(l.info.decoderConfig.codec)) : e.source._codec === "prores" && (l.codecPrivate = c.encode(r.decoderConfig.codec)), this.trackDatas.push(l), this.trackDatas.sort((e, t) => e.track.id - t.track.id), this.allTracksAreKnown() && this.allTracksKnown.resolve(), l;
|
|
3223
3226
|
}
|
|
3224
3227
|
getAudioTrackData(e, n, r) {
|
|
3225
3228
|
let i = this.trackDatas.find((t) => t.track === e);
|
|
3226
3229
|
if (i) return i;
|
|
3227
|
-
|
|
3230
|
+
st(r, e.source._codec), t(r), t(r.decoderConfig);
|
|
3228
3231
|
let a = { ...r.decoderConfig }, o = !1;
|
|
3229
3232
|
if (e.source._codec === "aac" && !a.description) {
|
|
3230
3233
|
if (!n) throw Error("No AAC description provided; you must therefore provide a priming packet.");
|
|
3231
|
-
let e =
|
|
3234
|
+
let e = bt(Xt.tempFromBytes(n.data));
|
|
3232
3235
|
if (!e) throw Error("Couldn't parse ADTS header from the AAC packet. Make sure the packets are in ADTS format (as specified in ISO 13818-7) when not providing a description, or provide a description (must be an AudioSpecificConfig as specified in ISO 14496-3) and ensure the packets are raw AAC data.");
|
|
3233
|
-
let t =
|
|
3236
|
+
let t = Se[e.samplingFrequencyIndex], r = Ce[e.channelConfiguration];
|
|
3234
3237
|
if (t === void 0 || r === void 0) throw Error("Invalid ADTS frame header.");
|
|
3235
|
-
a.description =
|
|
3238
|
+
a.description = we({
|
|
3236
3239
|
objectType: e.objectType,
|
|
3237
|
-
|
|
3238
|
-
|
|
3240
|
+
outputSampleRate: t,
|
|
3241
|
+
outputNumberOfChannels: r
|
|
3239
3242
|
}), o = !0;
|
|
3240
3243
|
}
|
|
3241
3244
|
let s = {
|
|
@@ -3257,7 +3260,7 @@ var Qt = class {
|
|
|
3257
3260
|
getSubtitleTrackData(e, n) {
|
|
3258
3261
|
let r = this.trackDatas.find((t) => t.track === e);
|
|
3259
3262
|
if (r) return r;
|
|
3260
|
-
|
|
3263
|
+
ct(n), t(n), t(n.config);
|
|
3261
3264
|
let i = {
|
|
3262
3265
|
track: e,
|
|
3263
3266
|
type: "subtitle",
|
|
@@ -3282,7 +3285,7 @@ var Qt = class {
|
|
|
3282
3285
|
let a = t.type === "key";
|
|
3283
3286
|
this.validateTimestamp(r.track, t.timestamp, a);
|
|
3284
3287
|
let o = t.timestamp, s = t.duration;
|
|
3285
|
-
e.metadata.frameRate !== void 0 && (o =
|
|
3288
|
+
e.metadata.frameRate !== void 0 && (o = S(o, e.metadata.frameRate), s = S(s, e.metadata.frameRate));
|
|
3286
3289
|
let c = r.info.alphaMode ? t.sideData.alpha ?? null : null, l = this.createInternalChunk(i, o, s, t.type, c);
|
|
3287
3290
|
e.source._codec === "vp9" && this.fixVP9ColorSpace(r, l), r.chunkQueue.push(l), await this.interleaveChunks();
|
|
3288
3291
|
} finally {
|
|
@@ -3294,7 +3297,7 @@ var Qt = class {
|
|
|
3294
3297
|
try {
|
|
3295
3298
|
let r = this.getAudioTrackData(e, t, n), i = t.data;
|
|
3296
3299
|
if (r.info.requiresAdtsStripping) {
|
|
3297
|
-
let e =
|
|
3300
|
+
let e = bt(Xt.tempFromBytes(i));
|
|
3298
3301
|
if (!e) throw Error("Expected ADTS frame, didn't get one.");
|
|
3299
3302
|
let t = e.crcCheck === null ? 7 : 9;
|
|
3300
3303
|
i = i.subarray(t);
|
|
@@ -3313,7 +3316,7 @@ var Qt = class {
|
|
|
3313
3316
|
let r = this.getSubtitleTrackData(e, n);
|
|
3314
3317
|
this.validateTimestamp(r.track, t.timestamp, !0);
|
|
3315
3318
|
let i = t.text, a = Math.round(t.timestamp * 1e3);
|
|
3316
|
-
|
|
3319
|
+
en.lastIndex = 0, i = i.replace(en, (e) => `<${rn(nn(e.slice(1, -1)) - a)}>`);
|
|
3317
3320
|
let o = c.encode(i), s = `${t.settings ?? ""}\n${t.identifier ?? ""}\n${t.notes ?? ""}`, l = this.createInternalChunk(o, t.timestamp, t.duration, "key", s.trim() ? c.encode(s) : null);
|
|
3318
3321
|
r.chunkQueue.push(l), await this.interleaveChunks();
|
|
3319
3322
|
} finally {
|
|
@@ -3370,41 +3373,41 @@ var Qt = class {
|
|
|
3370
3373
|
else {
|
|
3371
3374
|
t(this.currentClusterStartMsTimestamp !== null), t(this.currentClusterMaxMsTimestamp !== null);
|
|
3372
3375
|
let e = r - this.currentClusterStartMsTimestamp;
|
|
3373
|
-
a = i && r > this.currentClusterMaxMsTimestamp && e >= 1e3 * (this.format._options.minimumClusterDuration ?? 1) || e >
|
|
3376
|
+
a = i && r > this.currentClusterMaxMsTimestamp && e >= 1e3 * (this.format._options.minimumClusterDuration ?? 1) || e > fn;
|
|
3374
3377
|
}
|
|
3375
3378
|
a && this.createNewCluster(r);
|
|
3376
3379
|
let o = r - this.currentClusterStartMsTimestamp;
|
|
3377
|
-
if (o <
|
|
3378
|
-
let s =
|
|
3380
|
+
if (o < dn) return;
|
|
3381
|
+
let s = new Uint8Array(4), c = new DataView(s.buffer);
|
|
3379
3382
|
c.setUint8(0, 128 | e.track.id), c.setInt16(1, o, !1);
|
|
3380
3383
|
let l = Math.round(1e3 * n.duration);
|
|
3381
3384
|
if (n.additions || e.type === "subtitle") {
|
|
3382
3385
|
let t = {
|
|
3383
|
-
id:
|
|
3386
|
+
id: W.BlockGroup,
|
|
3384
3387
|
data: [
|
|
3385
3388
|
{
|
|
3386
|
-
id:
|
|
3389
|
+
id: W.Block,
|
|
3387
3390
|
data: [s, n.data]
|
|
3388
3391
|
},
|
|
3389
3392
|
n.type === "delta" ? {
|
|
3390
|
-
id:
|
|
3391
|
-
data: new
|
|
3393
|
+
id: W.ReferenceBlock,
|
|
3394
|
+
data: new ut(e.lastWrittenMsTimestamp - r)
|
|
3392
3395
|
} : null,
|
|
3393
3396
|
n.additions ? {
|
|
3394
|
-
id:
|
|
3397
|
+
id: W.BlockAdditions,
|
|
3395
3398
|
data: [{
|
|
3396
|
-
id:
|
|
3399
|
+
id: W.BlockMore,
|
|
3397
3400
|
data: [{
|
|
3398
|
-
id:
|
|
3401
|
+
id: W.BlockAddID,
|
|
3399
3402
|
data: 1
|
|
3400
3403
|
}, {
|
|
3401
|
-
id:
|
|
3404
|
+
id: W.BlockAdditional,
|
|
3402
3405
|
data: n.additions
|
|
3403
3406
|
}]
|
|
3404
3407
|
}]
|
|
3405
3408
|
} : null,
|
|
3406
3409
|
l > 0 ? {
|
|
3407
|
-
id:
|
|
3410
|
+
id: W.BlockDuration,
|
|
3408
3411
|
data: l
|
|
3409
3412
|
} : null
|
|
3410
3413
|
]
|
|
@@ -3413,7 +3416,7 @@ var Qt = class {
|
|
|
3413
3416
|
} else {
|
|
3414
3417
|
c.setUint8(3, Number(n.type === "key") << 7);
|
|
3415
3418
|
let e = {
|
|
3416
|
-
id:
|
|
3419
|
+
id: W.SimpleBlock,
|
|
3417
3420
|
data: [s, n.data]
|
|
3418
3421
|
};
|
|
3419
3422
|
this.ebmlWriter.writeEBML(e);
|
|
@@ -3422,10 +3425,10 @@ var Qt = class {
|
|
|
3422
3425
|
}
|
|
3423
3426
|
createNewCluster(e) {
|
|
3424
3427
|
this.currentCluster && this.finalizeCurrentCluster(), this.format._options.onCluster && this.writer.startTrackingWrites(), this.currentCluster = {
|
|
3425
|
-
id:
|
|
3426
|
-
size: this.format._options.appendOnly ? -1 :
|
|
3428
|
+
id: W.Cluster,
|
|
3429
|
+
size: this.format._options.appendOnly ? -1 : hn,
|
|
3427
3430
|
data: [{
|
|
3428
|
-
id:
|
|
3431
|
+
id: W.Timestamp,
|
|
3429
3432
|
data: e
|
|
3430
3433
|
}]
|
|
3431
3434
|
}, this.ebmlWriter.writeEBML(this.currentCluster), this.currentClusterStartMsTimestamp = e, this.currentClusterMaxMsTimestamp = e, this.trackDatasInCurrentCluster.clear();
|
|
@@ -3433,7 +3436,7 @@ var Qt = class {
|
|
|
3433
3436
|
finalizeCurrentCluster() {
|
|
3434
3437
|
if (t(this.currentCluster), !this.format._options.appendOnly) {
|
|
3435
3438
|
let e = this.writer.getPos() - this.ebmlWriter.dataOffsets.get(this.currentCluster), t = this.writer.getPos();
|
|
3436
|
-
this.writer.seek(this.ebmlWriter.offsets.get(this.currentCluster) + 4), this.ebmlWriter.writeVarInt(e,
|
|
3439
|
+
this.writer.seek(this.ebmlWriter.offsets.get(this.currentCluster) + 4), this.ebmlWriter.writeVarInt(e, hn), this.writer.seek(t);
|
|
3437
3440
|
}
|
|
3438
3441
|
if (this.format._options.onCluster) {
|
|
3439
3442
|
t(this.currentClusterStartMsTimestamp !== null);
|
|
@@ -3444,17 +3447,17 @@ var Qt = class {
|
|
|
3444
3447
|
for (let [e, { firstMsTimestamp: t }] of this.trackDatasInCurrentCluster) n.has(t) || n.set(t, []), n.get(t).push(e);
|
|
3445
3448
|
let r = [...n.entries()].sort((e, t) => e[0] - t[0]);
|
|
3446
3449
|
for (let [n, i] of r) t(this.cues), this.cues.data.push({
|
|
3447
|
-
id:
|
|
3450
|
+
id: W.CuePoint,
|
|
3448
3451
|
data: [{
|
|
3449
|
-
id:
|
|
3452
|
+
id: W.CueTime,
|
|
3450
3453
|
data: n
|
|
3451
3454
|
}, ...i.map((t) => ({
|
|
3452
|
-
id:
|
|
3455
|
+
id: W.CueTrackPositions,
|
|
3453
3456
|
data: [{
|
|
3454
|
-
id:
|
|
3457
|
+
id: W.CueTrack,
|
|
3455
3458
|
data: t.track.id
|
|
3456
3459
|
}, {
|
|
3457
|
-
id:
|
|
3460
|
+
id: W.CueClusterPosition,
|
|
3458
3461
|
data: e
|
|
3459
3462
|
}]
|
|
3460
3463
|
}))]
|
|
@@ -3470,13 +3473,13 @@ var Qt = class {
|
|
|
3470
3473
|
for (let e of this.trackDatas) e.closed = !0;
|
|
3471
3474
|
if (this.segment || this.createSegment(), await this.interleaveChunks(!0), this.currentCluster && this.finalizeCurrentCluster(), t(this.cues), this.ebmlWriter.writeEBML(this.cues), !this.format._options.appendOnly) {
|
|
3472
3475
|
let e = this.writer.getPos() - this.segmentDataOffset;
|
|
3473
|
-
this.writer.seek(this.ebmlWriter.offsets.get(this.segment) + 4), this.ebmlWriter.writeVarInt(e,
|
|
3476
|
+
this.writer.seek(this.ebmlWriter.offsets.get(this.segment) + 4), this.ebmlWriter.writeVarInt(e, mn);
|
|
3474
3477
|
let n = this.startTimestamp === Infinity ? 0 : this.endTimestamp - this.startTimestamp;
|
|
3475
|
-
this.segmentDuration.data = new
|
|
3478
|
+
this.segmentDuration.data = new H(n), this.writer.seek(this.ebmlWriter.offsets.get(this.segmentDuration)), this.ebmlWriter.writeEBML(this.segmentDuration), t(this.seekHead), this.writer.seek(this.ebmlWriter.offsets.get(this.seekHead)), this.maybeCreateSeekHead(!0), this.ebmlWriter.writeEBML(this.seekHead);
|
|
3476
3479
|
}
|
|
3477
3480
|
e();
|
|
3478
3481
|
}
|
|
3479
|
-
},
|
|
3482
|
+
}, vn = function(e, t, n) {
|
|
3480
3483
|
if (t != null) {
|
|
3481
3484
|
if (typeof t != "object" && typeof t != "function") throw TypeError("Object expected.");
|
|
3482
3485
|
var r, i;
|
|
@@ -3502,7 +3505,7 @@ var Qt = class {
|
|
|
3502
3505
|
});
|
|
3503
3506
|
} else n && e.stack.push({ async: !0 });
|
|
3504
3507
|
return t;
|
|
3505
|
-
},
|
|
3508
|
+
}, yn = (function(e) {
|
|
3506
3509
|
return function(t) {
|
|
3507
3510
|
function n(n) {
|
|
3508
3511
|
t.error = t.hasError ? new e(n, t.error, "An error was suppressed during disposal.") : n, t.hasError = !0;
|
|
@@ -3528,7 +3531,7 @@ var Qt = class {
|
|
|
3528
3531
|
})(typeof SuppressedError == "function" ? SuppressedError : function(e, t, n) {
|
|
3529
3532
|
var r = Error(n);
|
|
3530
3533
|
return r.name = "SuppressedError", r.error = e, r.suppressed = t, r;
|
|
3531
|
-
}),
|
|
3534
|
+
}), bn = class {
|
|
3532
3535
|
constructor() {
|
|
3533
3536
|
this._connectedTrack = null, this._closingPromise = null, this._closed = !1;
|
|
3534
3537
|
}
|
|
@@ -3547,7 +3550,7 @@ var Qt = class {
|
|
|
3547
3550
|
if (!e) throw Error("Cannot call close without connecting the source to an output track.");
|
|
3548
3551
|
if (e.output.state === "pending") throw Error("Cannot call close before output has been started.");
|
|
3549
3552
|
this._closingPromise = (async () => {
|
|
3550
|
-
await this._flushAndClose(!1), this._closed = !0, e.output.state
|
|
3553
|
+
await this._flushAndClose(!1), this._closed = !0, !(e.output.state === "finalizing" || e.output.state === "finalized") && e.output._muxer.onTrackClose(e);
|
|
3551
3554
|
})();
|
|
3552
3555
|
}
|
|
3553
3556
|
async _flushOrWaitForOngoingClose(e) {
|
|
@@ -3555,19 +3558,19 @@ var Qt = class {
|
|
|
3555
3558
|
await this._flushAndClose(e), this._closed = !0;
|
|
3556
3559
|
})();
|
|
3557
3560
|
}
|
|
3558
|
-
},
|
|
3561
|
+
}, xn = class extends bn {
|
|
3559
3562
|
constructor(e) {
|
|
3560
|
-
if (super(), this._connectedTrack = null, !
|
|
3563
|
+
if (super(), this._connectedTrack = null, !N.includes(e)) throw TypeError(`Invalid video codec '${e}'. Must be one of: ${N.join(", ")}.`);
|
|
3561
3564
|
this._codec = e;
|
|
3562
3565
|
}
|
|
3563
|
-
},
|
|
3566
|
+
}, Sn = (e, t) => {
|
|
3564
3567
|
if (e.metadata.hasOnlyKeyPackets && t.type !== "key") throw Error("Cannot add non-key packets to a hasOnlyKeyPackets video track.");
|
|
3565
|
-
},
|
|
3568
|
+
}, Cn = class {
|
|
3566
3569
|
setError(e) {
|
|
3567
3570
|
this.errorSet ||= (this.error = e, !0);
|
|
3568
3571
|
}
|
|
3569
3572
|
constructor(e, t) {
|
|
3570
|
-
this.source = e, this.encodingConfig = t, this.ensureEncoderPromise = null, this.encoderInitialized = !1, this.encoder = null, this.muxer = null, this.lastMultipleOfKeyFrameInterval = -1, this.emittedEncoderPackets = 0, this.codedWidth = null, this.codedHeight = null, this.outputWidth = null, this.outputHeight = null, this.frameRateLastSample = null, this.frameRateLastTimestamp = null, this.frameRateLastEndTimestamp = null, this.preciseTimings = [], this.customEncoder = null, this.customEncoderCallSerializer = new
|
|
3573
|
+
this.source = e, this.encodingConfig = t, this.ensureEncoderPromise = null, this.encoderInitialized = !1, this.encoder = null, this.muxer = null, this.lastMultipleOfKeyFrameInterval = -1, this.emittedEncoderPackets = 0, this.codedWidth = null, this.codedHeight = null, this.outputWidth = null, this.outputHeight = null, this.frameRateLastSample = null, this.frameRateLastTimestamp = null, this.frameRateLastEndTimestamp = null, this.preciseTimings = [], this.customEncoder = null, this.customEncoderCallSerializer = new ne(), this.customEncoderQueueSize = 0, this.defaultEncodeOptions = {}, this.alphaEncoder = null, this.splitter = null, this.splitterCreationFailed = !1, this.alphaFrameQueue = [], this.error = null, this.errorSet = !1, this.lastMuxerPromise = Promise.resolve(), this.closed = !1;
|
|
3571
3574
|
}
|
|
3572
3575
|
async add(e, n, r) {
|
|
3573
3576
|
let i = e;
|
|
@@ -3593,14 +3596,11 @@ var Qt = class {
|
|
|
3593
3596
|
} else (this.outputWidth === null || this.outputHeight === null) && (this.outputWidth = e.codedWidth, this.outputHeight = e.codedHeight);
|
|
3594
3597
|
let c = a.transform?.frameRate;
|
|
3595
3598
|
if (c !== void 0) {
|
|
3596
|
-
let t = e.timestamp + e.duration, a =
|
|
3597
|
-
if (this.frameRateLastSample !== null) {
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
}
|
|
3602
|
-
await this.padFrameRate(a, r);
|
|
3603
|
-
}
|
|
3599
|
+
let t = e.timestamp + e.duration, a = C(e.timestamp, c);
|
|
3600
|
+
if (this.frameRateLastSample !== null) if (a <= this.frameRateLastTimestamp) {
|
|
3601
|
+
this.frameRateLastSample.close(), this.frameRateLastSample = e.clone(), this.frameRateLastEndTimestamp = t;
|
|
3602
|
+
return;
|
|
3603
|
+
} else await this.padFrameRate(a, r);
|
|
3604
3604
|
e === i && (e = e.clone(), n = !0), e.setTimestamp(a), e.setDuration(1 / c), this.frameRateLastSample?.close(), this.frameRateLastSample = e.clone(), this.frameRateLastTimestamp = a, this.frameRateLastEndTimestamp = t;
|
|
3605
3605
|
}
|
|
3606
3606
|
await this.processAndEncode(e, r);
|
|
@@ -3612,17 +3612,17 @@ var Qt = class {
|
|
|
3612
3612
|
let r = this.encodingConfig, i;
|
|
3613
3613
|
if (r.transform?.process) {
|
|
3614
3614
|
let t = r.transform.process(e);
|
|
3615
|
-
if (t
|
|
3615
|
+
if (E(t) && (t = await t), t === null) return;
|
|
3616
3616
|
Array.isArray(t) || (t = [t]);
|
|
3617
3617
|
let n = [];
|
|
3618
3618
|
try {
|
|
3619
|
-
for (let r of t) r instanceof
|
|
3619
|
+
for (let r of t) r instanceof q ? n.push(r) : typeof VideoFrame < "u" && r instanceof VideoFrame ? n.push(new q(r)) : n.push(new q(r, {
|
|
3620
3620
|
timestamp: e.timestamp,
|
|
3621
3621
|
duration: e.duration
|
|
3622
3622
|
}));
|
|
3623
3623
|
} catch (r) {
|
|
3624
3624
|
for (let t of n) t !== e && t.close();
|
|
3625
|
-
for (let n of t) (n instanceof
|
|
3625
|
+
for (let n of t) (n instanceof q && n !== e || typeof VideoFrame < "u" && n instanceof VideoFrame) && n.close();
|
|
3626
3626
|
throw r;
|
|
3627
3627
|
}
|
|
3628
3628
|
i = n;
|
|
@@ -3666,7 +3666,7 @@ var Qt = class {
|
|
|
3666
3666
|
n.close();
|
|
3667
3667
|
}
|
|
3668
3668
|
} else {
|
|
3669
|
-
this.splitter ||= new
|
|
3669
|
+
this.splitter ||= new Tn();
|
|
3670
3670
|
let { colorFrame: e, alphaFrame: t } = await this.splitter.split(n);
|
|
3671
3671
|
this.alphaFrameQueue.push(t);
|
|
3672
3672
|
try {
|
|
@@ -3694,20 +3694,20 @@ var Qt = class {
|
|
|
3694
3694
|
hasError: !1
|
|
3695
3695
|
};
|
|
3696
3696
|
try {
|
|
3697
|
-
let i =
|
|
3697
|
+
let i = vn(t, this.frameRateLastSample.clone(), !1);
|
|
3698
3698
|
i.setTimestamp(this.frameRateLastTimestamp + e / r), i.setDuration(1 / r), await this.processAndEncode(i, n);
|
|
3699
3699
|
} catch (e) {
|
|
3700
3700
|
t.error = e, t.hasError = !0;
|
|
3701
3701
|
} finally {
|
|
3702
|
-
|
|
3702
|
+
yn(t);
|
|
3703
3703
|
}
|
|
3704
3704
|
}
|
|
3705
3705
|
}
|
|
3706
3706
|
ensureEncoder(e) {
|
|
3707
3707
|
this.ensureEncoderPromise = (async () => {
|
|
3708
|
-
let n =
|
|
3708
|
+
let n = Jt(this.encodingConfig.quality, this.encodingConfig.bitrate);
|
|
3709
3709
|
t(n !== void 0);
|
|
3710
|
-
let r =
|
|
3710
|
+
let r = Ht({
|
|
3711
3711
|
...this.encodingConfig,
|
|
3712
3712
|
quality: n,
|
|
3713
3713
|
width: e.codedWidth,
|
|
@@ -3718,7 +3718,7 @@ var Qt = class {
|
|
|
3718
3718
|
}), i = null, a;
|
|
3719
3719
|
for (let e of r) {
|
|
3720
3720
|
let t = e.config;
|
|
3721
|
-
if (this.encodingConfig.onEncoderConfig?.(t), a =
|
|
3721
|
+
if (this.encodingConfig.onEncoderConfig?.(t), a = Yt.find((e) => e.supports(this.encodingConfig.codec, t)), a) {
|
|
3722
3722
|
i = e;
|
|
3723
3723
|
break;
|
|
3724
3724
|
}
|
|
@@ -3733,15 +3733,15 @@ var Qt = class {
|
|
|
3733
3733
|
}
|
|
3734
3734
|
}
|
|
3735
3735
|
if (!i) {
|
|
3736
|
-
if (typeof VideoEncoder > "u") throw Error("VideoEncoder
|
|
3736
|
+
if (typeof VideoEncoder > "u") throw Error(oe("VideoEncoder"));
|
|
3737
3737
|
let e = r[0].config, t = r.map(({ config: e, quantizer: t }) => t === null ? `${e.bitrate} bps` : `quantizer ${t}`);
|
|
3738
|
-
throw Error(`This specific encoder configuration (${e.codec}, ${t.join(" / ")}, ${e.width}x${e.height}, hardware acceleration: ${e.hardwareAcceleration ?? "no-preference"}) is not supported
|
|
3738
|
+
throw Error(`This specific encoder configuration (${e.codec}, ${t.join(" / ")}, ${e.width}x${e.height}, hardware acceleration: ${e.hardwareAcceleration ?? "no-preference"}) is not supported in this environment. Consider using another codec or changing your video parameters.`);
|
|
3739
3739
|
}
|
|
3740
3740
|
let o = i.config;
|
|
3741
|
-
if (i.quantizer !== null && (this.defaultEncodeOptions =
|
|
3742
|
-
if (!(e instanceof
|
|
3741
|
+
if (i.quantizer !== null && (this.defaultEncodeOptions = qt(this.encodingConfig.codec, i.quantizer)), a) this.customEncoder = new a(), this.customEncoder.codec = this.encodingConfig.codec, this.customEncoder.config = o, this.customEncoder.onPacket = (e, t) => {
|
|
3742
|
+
if (!(e instanceof B)) throw TypeError("The first argument passed to onPacket must be an EncodedPacket.");
|
|
3743
3743
|
if (t !== void 0 && (!t || typeof t != "object")) throw TypeError("The second argument passed to onPacket must be an object or undefined.");
|
|
3744
|
-
|
|
3744
|
+
Sn(this.source._connectedTrack, e), this.encodingConfig.onEncodedPacket?.(e, t), this.lastMuxerPromise = this.muxer.addEncodedVideoPacket(this.source._connectedTrack, e, t).catch((e) => {
|
|
3745
3745
|
this.setError(e);
|
|
3746
3746
|
});
|
|
3747
3747
|
}, this.customEncoder.onError = (e) => {
|
|
@@ -3754,12 +3754,12 @@ var Qt = class {
|
|
|
3754
3754
|
let e = new Uint8Array(t.byteLength);
|
|
3755
3755
|
t.copyTo(e), r.alpha = e;
|
|
3756
3756
|
}
|
|
3757
|
-
let i =
|
|
3758
|
-
this.emittedEncoderPackets === 0 && i.type === "delta" && n?.decoderConfig && (s =
|
|
3757
|
+
let i = B.fromEncodedChunk(e, r), a = h(this.preciseTimings, e.timestamp, (e) => e.microsecondTimestamp), o = a === -1 ? null : this.preciseTimings[a], s = null;
|
|
3758
|
+
this.emittedEncoderPackets === 0 && i.type === "delta" && n?.decoderConfig && (s = ze(this.encodingConfig.codec, n.decoderConfig, i.data)), (o && o.microsecondTimestamp === e.timestamp || s !== null) && (i = i.clone({
|
|
3759
3759
|
timestamp: o?.timestampIsValid ? o.timestamp : void 0,
|
|
3760
3760
|
duration: o?.durationIsValid ? o.duration : void 0,
|
|
3761
3761
|
type: s ?? void 0
|
|
3762
|
-
})),
|
|
3762
|
+
})), Sn(this.source._connectedTrack, i), this.encodingConfig.onEncodedPacket?.(i, n), this.lastMuxerPromise = this.muxer.addEncodedVideoPacket(this.source._connectedTrack, i, n).catch((e) => {
|
|
3763
3763
|
this.setError(e);
|
|
3764
3764
|
}), this.emittedEncoderPackets++;
|
|
3765
3765
|
}, s = (/* @__PURE__ */ Error("Encoding error")).stack;
|
|
@@ -3808,10 +3808,10 @@ var Qt = class {
|
|
|
3808
3808
|
async flushAndClose(e) {
|
|
3809
3809
|
try {
|
|
3810
3810
|
if (!e && (this.checkForEncoderError(), this.frameRateLastSample)) {
|
|
3811
|
-
let e = this.encodingConfig.transform.frameRate, t =
|
|
3811
|
+
let e = this.encodingConfig.transform.frameRate, t = C(this.frameRateLastEndTimestamp, e);
|
|
3812
3812
|
await this.padFrameRate(t);
|
|
3813
3813
|
}
|
|
3814
|
-
this.closed = !0, e || (this.customEncoder ? this.customEncoderCallSerializer.call(() => this.customEncoder.flush()) : this.encoder && (await this.encoder.flush(), await this.alphaEncoder?.flush(), await
|
|
3814
|
+
this.closed = !0, e || (this.customEncoder ? this.customEncoderCallSerializer.call(() => this.customEncoder.flush()) : this.encoder && (await this.encoder.flush(), await this.alphaEncoder?.flush(), await he(25)));
|
|
3815
3815
|
} finally {
|
|
3816
3816
|
this.closed = !0, this.frameRateLastSample?.close(), this.frameRateLastSample = null, this.customEncoder ? await this.customEncoderCallSerializer.call(() => this.customEncoder.close()).catch((e) => this.setError(e)) : this.encoder && (this.encoder.state !== "closed" && this.encoder.close(), this.alphaEncoder && this.alphaEncoder.state !== "closed" && this.alphaEncoder.close(), this.alphaFrameQueue.forEach((e) => e?.close()), this.alphaFrameQueue.length = 0, this.splitter?.close());
|
|
3817
3817
|
}
|
|
@@ -3823,17 +3823,17 @@ var Qt = class {
|
|
|
3823
3823
|
checkForEncoderError() {
|
|
3824
3824
|
if (this.errorSet) throw this.error;
|
|
3825
3825
|
}
|
|
3826
|
-
},
|
|
3826
|
+
}, wn = null, Tn = class {
|
|
3827
3827
|
constructor() {
|
|
3828
3828
|
this.worker = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.nextRequestId = 0;
|
|
3829
3829
|
}
|
|
3830
3830
|
split(e) {
|
|
3831
3831
|
if (!this.worker) {
|
|
3832
|
-
if (!
|
|
3833
|
-
let e = new Blob([`(${
|
|
3834
|
-
|
|
3832
|
+
if (!wn) {
|
|
3833
|
+
let e = new Blob([`(${En.toString()})()`], { type: "application/javascript" });
|
|
3834
|
+
wn = URL.createObjectURL(e);
|
|
3835
3835
|
}
|
|
3836
|
-
this.worker = new Worker(
|
|
3836
|
+
this.worker = new Worker(wn), this.worker.addEventListener("message", (e) => {
|
|
3837
3837
|
let t = e.data, n = this.pendingRequests.get(t.id);
|
|
3838
3838
|
n && (this.pendingRequests.delete(t.id), "error" in t ? n.reject(Error(t.error)) : n.resolve({
|
|
3839
3839
|
colorFrame: t.colorFrame,
|
|
@@ -3857,7 +3857,7 @@ var Qt = class {
|
|
|
3857
3857
|
for (let t of this.pendingRequests.values()) t.reject(e);
|
|
3858
3858
|
this.pendingRequests.clear();
|
|
3859
3859
|
}
|
|
3860
|
-
},
|
|
3860
|
+
}, En = () => {
|
|
3861
3861
|
let e = null, t = Promise.resolve();
|
|
3862
3862
|
self.addEventListener("message", (e) => {
|
|
3863
3863
|
let { id: r, sourceFrame: i } = e.data;
|
|
@@ -3911,38 +3911,38 @@ var Qt = class {
|
|
|
3911
3911
|
}, i = (e, t, n) => {
|
|
3912
3912
|
let r = n.visibleRect?.width ?? n.codedWidth, i = n.visibleRect?.height ?? n.codedHeight, a = t.includes("P10"), o = t.includes("P12"), s = a || o ? 2 : 1, c, l;
|
|
3913
3913
|
t.startsWith("I420") ? (c = Math.ceil(r / 2), l = Math.ceil(i / 2)) : t.startsWith("I422") ? (c = Math.ceil(r / 2), l = i) : (c = r, l = i);
|
|
3914
|
-
let u = r * i, d = c * l, f = u * s, p = d * s, m = u * s, h = f + p * 2, g = t.replace("A", ""), _ = Math.ceil(r / 2) * Math.ceil(i / 2),
|
|
3915
|
-
|
|
3916
|
-
let
|
|
3917
|
-
s === 1 ?
|
|
3918
|
-
let
|
|
3914
|
+
let u = r * i, d = c * l, f = u * s, p = d * s, m = u * s, h = f + p * 2, g = t.replace("A", ""), _ = Math.ceil(r / 2) * Math.ceil(i / 2), v = m + _ * s * 2, y = new Uint8Array(v), b = h;
|
|
3915
|
+
y.set(e.subarray(b, b + m), 0);
|
|
3916
|
+
let x = m, S = a ? 512 : o ? 2048 : 128;
|
|
3917
|
+
s === 1 ? y.fill(S, x) : new Uint16Array(y.buffer, x, 2 * _).fill(S);
|
|
3918
|
+
let C = a ? "I420P10" : o ? "I420P12" : "I420", ee = new VideoFrame(e.subarray(0, h), {
|
|
3919
3919
|
format: g,
|
|
3920
3920
|
codedWidth: r,
|
|
3921
3921
|
codedHeight: i,
|
|
3922
3922
|
timestamp: n.timestamp,
|
|
3923
3923
|
duration: n.duration ?? void 0
|
|
3924
|
-
}),
|
|
3925
|
-
format:
|
|
3924
|
+
}), te = {
|
|
3925
|
+
format: C,
|
|
3926
3926
|
codedWidth: r,
|
|
3927
3927
|
codedHeight: i,
|
|
3928
3928
|
timestamp: n.timestamp,
|
|
3929
3929
|
duration: n.duration ?? void 0,
|
|
3930
|
-
transfer: [
|
|
3930
|
+
transfer: [y.buffer]
|
|
3931
3931
|
};
|
|
3932
3932
|
return {
|
|
3933
|
-
colorFrame:
|
|
3934
|
-
alphaFrame: new VideoFrame(
|
|
3933
|
+
colorFrame: ee,
|
|
3934
|
+
alphaFrame: new VideoFrame(y, te)
|
|
3935
3935
|
};
|
|
3936
3936
|
};
|
|
3937
|
-
},
|
|
3937
|
+
}, Dn = class extends xn {
|
|
3938
3938
|
constructor(e, t) {
|
|
3939
3939
|
if (!(typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement) && !(typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas)) throw TypeError("canvas must be an HTMLCanvasElement or OffscreenCanvas.");
|
|
3940
|
-
|
|
3940
|
+
Bt(t), super(t.codec), this._encoder = new Cn(this, t), this._canvas = e;
|
|
3941
3941
|
}
|
|
3942
3942
|
add(e, t = 0, n) {
|
|
3943
3943
|
if (!Number.isFinite(e) || e < 0) throw TypeError("timestamp must be a non-negative number.");
|
|
3944
3944
|
if (!Number.isFinite(t) || t < 0) throw TypeError("duration must be a non-negative number.");
|
|
3945
|
-
let r = new
|
|
3945
|
+
let r = new q(this._canvas, {
|
|
3946
3946
|
timestamp: e,
|
|
3947
3947
|
duration: t
|
|
3948
3948
|
});
|
|
@@ -3951,25 +3951,25 @@ var Qt = class {
|
|
|
3951
3951
|
_flushAndClose(e) {
|
|
3952
3952
|
return this._encoder.flushAndClose(e);
|
|
3953
3953
|
}
|
|
3954
|
-
},
|
|
3954
|
+
}, On = class extends bn {
|
|
3955
3955
|
constructor(e) {
|
|
3956
|
-
if (super(), this._connectedTrack = null, !
|
|
3956
|
+
if (super(), this._connectedTrack = null, !F.includes(e)) throw TypeError(`Invalid audio codec '${e}'. Must be one of: ${F.join(", ")}.`);
|
|
3957
3957
|
this._codec = e;
|
|
3958
3958
|
}
|
|
3959
|
-
},
|
|
3959
|
+
}, kn = class extends bn {
|
|
3960
3960
|
constructor(e) {
|
|
3961
|
-
if (super(), this._connectedTrack = null, !
|
|
3961
|
+
if (super(), this._connectedTrack = null, !I.includes(e)) throw TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${I.join(", ")}.`);
|
|
3962
3962
|
this._codec = e;
|
|
3963
3963
|
}
|
|
3964
|
-
},
|
|
3964
|
+
}, An = class {
|
|
3965
3965
|
getSupportedVideoCodecs() {
|
|
3966
|
-
return this.getSupportedCodecs().filter((e) =>
|
|
3966
|
+
return this.getSupportedCodecs().filter((e) => N.includes(e));
|
|
3967
3967
|
}
|
|
3968
3968
|
getSupportedAudioCodecs() {
|
|
3969
|
-
return this.getSupportedCodecs().filter((e) =>
|
|
3969
|
+
return this.getSupportedCodecs().filter((e) => F.includes(e));
|
|
3970
3970
|
}
|
|
3971
3971
|
getSupportedSubtitleCodecs() {
|
|
3972
|
-
return this.getSupportedCodecs().filter((e) =>
|
|
3972
|
+
return this.getSupportedCodecs().filter((e) => I.includes(e));
|
|
3973
3973
|
}
|
|
3974
3974
|
_codecUnsupportedHint(e) {
|
|
3975
3975
|
return "";
|
|
@@ -3977,18 +3977,18 @@ var Qt = class {
|
|
|
3977
3977
|
_isFragmentedIsobmff() {
|
|
3978
3978
|
return !1;
|
|
3979
3979
|
}
|
|
3980
|
-
},
|
|
3980
|
+
}, jn = class extends An {
|
|
3981
3981
|
constructor(e = {}) {
|
|
3982
3982
|
if (!e || typeof e != "object") throw TypeError("options must be an object.");
|
|
3983
3983
|
if (e.appendOnly !== void 0 && typeof e.appendOnly != "boolean") throw TypeError("options.appendOnly, when provided, must be a boolean.");
|
|
3984
|
-
if (e.minimumClusterDuration !== void 0 && (!
|
|
3984
|
+
if (e.minimumClusterDuration !== void 0 && (!fe(e.minimumClusterDuration) || e.minimumClusterDuration < 0)) throw TypeError("options.minimumClusterDuration, when provided, must be a non-negative number.");
|
|
3985
3985
|
if (e.onEbmlHeader !== void 0 && typeof e.onEbmlHeader != "function") throw TypeError("options.onEbmlHeader, when provided, must be a function.");
|
|
3986
3986
|
if (e.onSegmentHeader !== void 0 && typeof e.onSegmentHeader != "function") throw TypeError("options.onHeader, when provided, must be a function.");
|
|
3987
3987
|
if (e.onCluster !== void 0 && typeof e.onCluster != "function") throw TypeError("options.onCluster, when provided, must be a function.");
|
|
3988
3988
|
super(), this._options = e;
|
|
3989
3989
|
}
|
|
3990
3990
|
_createMuxer(e) {
|
|
3991
|
-
return new
|
|
3991
|
+
return new _n(e, this);
|
|
3992
3992
|
}
|
|
3993
3993
|
get _name() {
|
|
3994
3994
|
return "Matroska";
|
|
@@ -4021,16 +4021,16 @@ var Qt = class {
|
|
|
4021
4021
|
}
|
|
4022
4022
|
getSupportedCodecs() {
|
|
4023
4023
|
return [
|
|
4024
|
-
...
|
|
4025
|
-
...
|
|
4026
|
-
...
|
|
4024
|
+
...N,
|
|
4025
|
+
...Ve,
|
|
4026
|
+
...P.filter((e) => ![
|
|
4027
4027
|
"pcm-s8",
|
|
4028
4028
|
"pcm-f32be",
|
|
4029
4029
|
"pcm-f64be",
|
|
4030
4030
|
"ulaw",
|
|
4031
4031
|
"alaw"
|
|
4032
4032
|
].includes(e)),
|
|
4033
|
-
...
|
|
4033
|
+
...I
|
|
4034
4034
|
];
|
|
4035
4035
|
}
|
|
4036
4036
|
get supportsVideoRotationMetadata() {
|
|
@@ -4039,19 +4039,19 @@ var Qt = class {
|
|
|
4039
4039
|
get supportsTimestampedMediaData() {
|
|
4040
4040
|
return !0;
|
|
4041
4041
|
}
|
|
4042
|
-
},
|
|
4042
|
+
}, Mn = class extends jn {
|
|
4043
4043
|
constructor(e) {
|
|
4044
4044
|
super(e);
|
|
4045
4045
|
}
|
|
4046
4046
|
getSupportedCodecs() {
|
|
4047
4047
|
return [
|
|
4048
|
-
...
|
|
4048
|
+
...N.filter((e) => [
|
|
4049
4049
|
"vp8",
|
|
4050
4050
|
"vp9",
|
|
4051
4051
|
"av1"
|
|
4052
4052
|
].includes(e)),
|
|
4053
|
-
...
|
|
4054
|
-
...
|
|
4053
|
+
...F.filter((e) => ["opus", "vorbis"].includes(e)),
|
|
4054
|
+
...I
|
|
4055
4055
|
];
|
|
4056
4056
|
}
|
|
4057
4057
|
get _name() {
|
|
@@ -4064,13 +4064,13 @@ var Qt = class {
|
|
|
4064
4064
|
return "video/webm";
|
|
4065
4065
|
}
|
|
4066
4066
|
_codecUnsupportedHint(e) {
|
|
4067
|
-
return new
|
|
4067
|
+
return new jn().getSupportedCodecs().includes(e) ? " Switching to MKV will grant support for this codec." : "";
|
|
4068
4068
|
}
|
|
4069
|
-
},
|
|
4069
|
+
}, Nn = [
|
|
4070
4070
|
"video",
|
|
4071
4071
|
"audio",
|
|
4072
4072
|
"subtitle"
|
|
4073
|
-
],
|
|
4073
|
+
], Pn = class e {
|
|
4074
4074
|
constructor(e, t, n, r, i) {
|
|
4075
4075
|
this.id = e, this.output = t, this.type = n, this.source = r, this.metadata = i;
|
|
4076
4076
|
}
|
|
@@ -4086,23 +4086,23 @@ var Qt = class {
|
|
|
4086
4086
|
canBePairedWith(t) {
|
|
4087
4087
|
if (!(t instanceof e)) throw TypeError("other must be an OutputTrack.");
|
|
4088
4088
|
if (this === t) return !1;
|
|
4089
|
-
let n =
|
|
4089
|
+
let n = ge(this.metadata.group), r = ge(t.metadata.group);
|
|
4090
4090
|
for (let e of n) if (this.type !== t.type && r.some((t) => e === t) || r.some((t) => e._pairedGroups.has(t))) return !0;
|
|
4091
4091
|
return !1;
|
|
4092
4092
|
}
|
|
4093
|
-
},
|
|
4093
|
+
}, Fn = class extends Pn {
|
|
4094
4094
|
constructor(e, t, n, r) {
|
|
4095
4095
|
super(e, t, "video", n, r);
|
|
4096
4096
|
}
|
|
4097
|
-
},
|
|
4097
|
+
}, In = class extends Pn {
|
|
4098
4098
|
constructor(e, t, n, r) {
|
|
4099
4099
|
super(e, t, "audio", n, r);
|
|
4100
4100
|
}
|
|
4101
|
-
},
|
|
4101
|
+
}, Ln = class extends Pn {
|
|
4102
4102
|
constructor(e, t, n, r) {
|
|
4103
4103
|
super(e, t, "subtitle", n, r);
|
|
4104
4104
|
}
|
|
4105
|
-
},
|
|
4105
|
+
}, Rn = class e {
|
|
4106
4106
|
constructor() {
|
|
4107
4107
|
this._pairedGroups = /* @__PURE__ */ new Set();
|
|
4108
4108
|
}
|
|
@@ -4111,38 +4111,38 @@ var Qt = class {
|
|
|
4111
4111
|
if (this === t) throw TypeError("Cannot pair a group with itself.");
|
|
4112
4112
|
this._pairedGroups.add(t), t._pairedGroups.add(this);
|
|
4113
4113
|
}
|
|
4114
|
-
},
|
|
4114
|
+
}, $ = (e) => {
|
|
4115
4115
|
if (!e || typeof e != "object") throw TypeError("metadata must be an object.");
|
|
4116
|
-
if (e.languageCode !== void 0 && !
|
|
4116
|
+
if (e.languageCode !== void 0 && !te(e.languageCode)) throw TypeError("metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.");
|
|
4117
4117
|
if (e.name !== void 0 && typeof e.name != "string") throw TypeError("metadata.name, when provided, must be a string.");
|
|
4118
|
-
if (e.disposition !== void 0 &&
|
|
4119
|
-
if (e.group !== void 0 && !(e.group instanceof
|
|
4120
|
-
},
|
|
4118
|
+
if (e.disposition !== void 0 && xe(e.disposition), e.maximumPacketCount !== void 0 && (!Number.isInteger(e.maximumPacketCount) || e.maximumPacketCount < 0)) throw TypeError("metadata.maximumPacketCount, when provided, must be a non-negative integer.");
|
|
4119
|
+
if (e.group !== void 0 && !(e.group instanceof Rn) && (!Array.isArray(e.group) || e.group.some((e) => !(e instanceof Rn)))) throw TypeError("metadata.group, when provided, must be an OutputTrackGroup instance or an array of OutputTrackGroup instances.");
|
|
4120
|
+
}, zn = class extends O {
|
|
4121
4121
|
get target() {
|
|
4122
4122
|
let e = "Output.target cannot be used when using PathedTarget with an async callback. Use the 'target' event instead.";
|
|
4123
4123
|
if (this._rootTargetPromise) throw TypeError(e);
|
|
4124
4124
|
let t = this._getRootTarget();
|
|
4125
|
-
if (t
|
|
4125
|
+
if (E(t)) throw TypeError(e);
|
|
4126
4126
|
return t;
|
|
4127
4127
|
}
|
|
4128
4128
|
constructor(e) {
|
|
4129
|
-
if (super(), this.state = "pending", this.defaultTrackGroup = new
|
|
4130
|
-
if (!(e.format instanceof
|
|
4131
|
-
if (!(e.target instanceof Q || e.target instanceof
|
|
4129
|
+
if (super(), this.state = "pending", this.defaultTrackGroup = new Rn(), this.tracks = [], this._onFinalize = null, this._unfinalizedTargets = /* @__PURE__ */ new Set(), this._rootWriterPromise = null, this._startPromise = null, this._cancelPromise = null, this._finalizePromise = null, this._mutex = new m(), this._metadataTags = {}, this._rootTarget = null, this._rootTargetPromise = null, this._firstMediaStreamTimestamp = null, !e || typeof e != "object") throw TypeError("options must be an object.");
|
|
4130
|
+
if (!(e.format instanceof An)) throw TypeError("options.format must be an OutputFormat.");
|
|
4131
|
+
if (!(e.target instanceof Q || e.target instanceof un)) throw TypeError("options.target must be a Target or a PathedTarget.");
|
|
4132
4132
|
if (e.target instanceof Q && this._rememberTarget(e.target), e.initTarget !== void 0 && !(e.initTarget instanceof Q) && typeof e.initTarget != "function") throw Error("options.initTarget, when provided, must be a Target or a function that returns or resolves to a Target.");
|
|
4133
4133
|
if (e.onFinalize !== void 0 && typeof e.onFinalize != "function") throw TypeError("options.onFinalize, when provided, must be a function.");
|
|
4134
4134
|
this.format = e.format, this._target = e.target, this._onFinalize = e.onFinalize ?? null, this._initTarget = e.initTarget ?? null, this._initTarget instanceof Q && this._rememberTarget(this._initTarget), this._muxer = e.format._createMuxer(this);
|
|
4135
4135
|
}
|
|
4136
4136
|
_getTargetValidated(e) {
|
|
4137
|
-
t(this._target instanceof
|
|
4137
|
+
t(this._target instanceof un);
|
|
4138
4138
|
let n = this._target.getTarget(e), r = (e) => {
|
|
4139
4139
|
if (!(e instanceof Q)) throw TypeError("getTarget must return a Target.");
|
|
4140
4140
|
return e;
|
|
4141
4141
|
};
|
|
4142
|
-
return n
|
|
4142
|
+
return E(n) ? n.then(r) : r(n);
|
|
4143
4143
|
}
|
|
4144
4144
|
async _getTarget(e) {
|
|
4145
|
-
t(this._target instanceof
|
|
4145
|
+
t(this._target instanceof un);
|
|
4146
4146
|
let n = await this._getTargetValidated(e);
|
|
4147
4147
|
return this._emit("target", {
|
|
4148
4148
|
target: n,
|
|
@@ -4178,17 +4178,17 @@ var Qt = class {
|
|
|
4178
4178
|
request: e,
|
|
4179
4179
|
isRoot: !0
|
|
4180
4180
|
}), this._rootTarget = t, t);
|
|
4181
|
-
return t
|
|
4181
|
+
return E(t) ? this._rootTargetPromise = t.then(n) : n(t);
|
|
4182
4182
|
}
|
|
4183
4183
|
_getRootWriter(e) {
|
|
4184
4184
|
return this._rootWriterPromise ??= (async () => {
|
|
4185
|
-
let t = await this._getRootTarget(), n = new
|
|
4185
|
+
let t = await this._getRootTarget(), n = new an(t, typeof e == "boolean" ? e : e(t));
|
|
4186
4186
|
return n.start(), n;
|
|
4187
4187
|
})();
|
|
4188
4188
|
}
|
|
4189
4189
|
addVideoTrack(e, t = {}) {
|
|
4190
|
-
if (!(e instanceof
|
|
4191
|
-
if (
|
|
4190
|
+
if (!(e instanceof xn)) throw TypeError("source must be a VideoSource.");
|
|
4191
|
+
if ($(t), t.rotation !== void 0 && ![
|
|
4192
4192
|
0,
|
|
4193
4193
|
90,
|
|
4194
4194
|
180,
|
|
@@ -4196,30 +4196,30 @@ var Qt = class {
|
|
|
4196
4196
|
].includes(t.rotation)) throw TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);
|
|
4197
4197
|
if (!this.format.supportsVideoRotationMetadata && t.rotation) throw Error(`${this.format._name} does not support video rotation metadata.`);
|
|
4198
4198
|
if (t.frameRate !== void 0 && (!Number.isFinite(t.frameRate) || t.frameRate <= 0)) throw TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);
|
|
4199
|
-
if (t.decoderConfig !== void 0 &&
|
|
4200
|
-
if (!(t.primingPacket instanceof
|
|
4199
|
+
if (t.decoderConfig !== void 0 && at({ decoderConfig: t.decoderConfig }, e._codec), t.primingPacket !== void 0) {
|
|
4200
|
+
if (!(t.primingPacket instanceof B)) throw TypeError("metadata.primingPacket, when provided, must be an EncodedPacket.");
|
|
4201
4201
|
if (t.decoderConfig === void 0) throw TypeError("metadata.primingPacket can only be provided alongside metadata.decoderConfig.");
|
|
4202
4202
|
}
|
|
4203
4203
|
let n = { ...t };
|
|
4204
|
-
return n.group ??= this.defaultTrackGroup, this._addTrack(new
|
|
4204
|
+
return n.group ??= this.defaultTrackGroup, this._addTrack(new Fn(this.tracks.length + 1, this, e, n));
|
|
4205
4205
|
}
|
|
4206
4206
|
addAudioTrack(e, t = {}) {
|
|
4207
|
-
if (!(e instanceof
|
|
4208
|
-
if (
|
|
4209
|
-
if (!(t.primingPacket instanceof
|
|
4207
|
+
if (!(e instanceof On)) throw TypeError("source must be an AudioSource.");
|
|
4208
|
+
if ($(t), t.decoderConfig !== void 0 && st({ decoderConfig: t.decoderConfig }, e._codec), t.primingPacket !== void 0) {
|
|
4209
|
+
if (!(t.primingPacket instanceof B)) throw TypeError("metadata.primingPacket, when provided, must be an EncodedPacket.");
|
|
4210
4210
|
if (t.decoderConfig === void 0) throw TypeError("metadata.primingPacket can only be provided alongside metadata.decoderConfig.");
|
|
4211
4211
|
}
|
|
4212
4212
|
let n = { ...t };
|
|
4213
|
-
return n.group ??= this.defaultTrackGroup, this._addTrack(new
|
|
4213
|
+
return n.group ??= this.defaultTrackGroup, this._addTrack(new In(this.tracks.length + 1, this, e, n));
|
|
4214
4214
|
}
|
|
4215
4215
|
addSubtitleTrack(e, t = {}) {
|
|
4216
|
-
if (!(e instanceof
|
|
4217
|
-
|
|
4216
|
+
if (!(e instanceof kn)) throw TypeError("source must be a SubtitleSource.");
|
|
4217
|
+
$(t);
|
|
4218
4218
|
let n = { ...t };
|
|
4219
|
-
return n.group ??= this.defaultTrackGroup, this._addTrack(new
|
|
4219
|
+
return n.group ??= this.defaultTrackGroup, this._addTrack(new Ln(this.tracks.length + 1, this, e, n));
|
|
4220
4220
|
}
|
|
4221
4221
|
setMetadataTags(e) {
|
|
4222
|
-
if (
|
|
4222
|
+
if (be(e), this.state !== "pending") throw Error("Cannot set metadata tags after output has been started or canceled.");
|
|
4223
4223
|
this._metadataTags = e;
|
|
4224
4224
|
}
|
|
4225
4225
|
_addTrack(e) {
|
|
@@ -4246,13 +4246,13 @@ var Qt = class {
|
|
|
4246
4246
|
}
|
|
4247
4247
|
hasEnoughTracks() {
|
|
4248
4248
|
let e = this.format.getSupportedTrackCounts();
|
|
4249
|
-
for (let t of
|
|
4249
|
+
for (let t of Nn) if (this.tracks.reduce((e, n) => e + +(n.type === t), 0) < e[t].min) return !1;
|
|
4250
4250
|
let t = e.total.min;
|
|
4251
4251
|
return !(this.tracks.length < t);
|
|
4252
4252
|
}
|
|
4253
4253
|
async start() {
|
|
4254
4254
|
let e = this.format.getSupportedTrackCounts();
|
|
4255
|
-
for (let t of
|
|
4255
|
+
for (let t of Nn) {
|
|
4256
4256
|
let n = this.tracks.reduce((e, n) => e + +(n.type === t), 0), r = e[t].min;
|
|
4257
4257
|
if (n < r) throw Error(r === e[t].max ? `${this.format._name} requires exactly ${r} ${t} track${r === 1 ? "" : "s"}.` : `${this.format._name} requires at least ${r} ${t} track${r === 1 ? "" : "s"}.`);
|
|
4258
4258
|
}
|
|
@@ -4309,6 +4309,7 @@ var Qt = class {
|
|
|
4309
4309
|
}
|
|
4310
4310
|
})();
|
|
4311
4311
|
}
|
|
4312
|
-
};
|
|
4312
|
+
}, Bn = Symbol.for("mediabunny loaded");
|
|
4313
|
+
globalThis[Bn] && A._error("[WARNING]\nMediabunny was loaded twice. This will likely cause Mediabunny not to work correctly. Check if multiple dependencies are importing different versions of Mediabunny, or if something is being bundled incorrectly."), globalThis[Bn] = !0;
|
|
4313
4314
|
//#endregion
|
|
4314
|
-
export {
|
|
4315
|
+
export { cn as BufferTarget, Dn as CanvasSource, zn as Output, Mn as WebMOutputFormat };
|