@fluxerjs/voice 1.2.0 → 1.2.1

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.
@@ -1,2552 +0,0 @@
1
- import {
2
- __commonJS,
3
- __require
4
- } from "./chunk-EBO3CZXG.mjs";
5
-
6
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/VideoColorSpace.js
7
- var require_VideoColorSpace = __commonJS({
8
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/VideoColorSpace.js"(exports) {
9
- "use strict";
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.VideoColorSpace = void 0;
12
- var VideoColorSpace = class {
13
- constructor(init) {
14
- this.primaries = init?.primaries ?? null;
15
- this.transfer = init?.transfer ?? null;
16
- this.matrix = init?.matrix ?? null;
17
- this.fullRange = init?.fullRange ?? null;
18
- }
19
- toJSON() {
20
- return {
21
- primaries: this.primaries,
22
- transfer: this.transfer,
23
- matrix: this.matrix,
24
- fullRange: this.fullRange
25
- };
26
- }
27
- };
28
- exports.VideoColorSpace = VideoColorSpace;
29
- }
30
- });
31
-
32
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/types.js
33
- var require_types = __commonJS({
34
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/types.js"(exports) {
35
- "use strict";
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.DOMException = exports.WebCodecsDOMException = exports.DOMRectReadOnly = void 0;
38
- exports.createDOMException = createDOMException;
39
- var DOMRectReadOnly = class {
40
- constructor(x = 0, y = 0, width = 0, height = 0) {
41
- this.x = x;
42
- this.y = y;
43
- this.width = width;
44
- this.height = height;
45
- this.top = y;
46
- this.right = x + width;
47
- this.bottom = y + height;
48
- this.left = x;
49
- }
50
- toJSON() {
51
- return { x: this.x, y: this.y, width: this.width, height: this.height };
52
- }
53
- };
54
- exports.DOMRectReadOnly = DOMRectReadOnly;
55
- var WebCodecsDOMException = class _WebCodecsDOMException extends Error {
56
- constructor(message, name) {
57
- super(message);
58
- this.name = name ?? "Error";
59
- this.code = _WebCodecsDOMException.ERROR_CODES[this.name] ?? 0;
60
- Object.setPrototypeOf(this, _WebCodecsDOMException.prototype);
61
- }
62
- };
63
- exports.WebCodecsDOMException = WebCodecsDOMException;
64
- exports.DOMException = WebCodecsDOMException;
65
- WebCodecsDOMException.INDEX_SIZE_ERR = 1;
66
- WebCodecsDOMException.DOMSTRING_SIZE_ERR = 2;
67
- WebCodecsDOMException.HIERARCHY_REQUEST_ERR = 3;
68
- WebCodecsDOMException.WRONG_DOCUMENT_ERR = 4;
69
- WebCodecsDOMException.INVALID_CHARACTER_ERR = 5;
70
- WebCodecsDOMException.NO_DATA_ALLOWED_ERR = 6;
71
- WebCodecsDOMException.NO_MODIFICATION_ALLOWED_ERR = 7;
72
- WebCodecsDOMException.NOT_FOUND_ERR = 8;
73
- WebCodecsDOMException.NOT_SUPPORTED_ERR = 9;
74
- WebCodecsDOMException.INUSE_ATTRIBUTE_ERR = 10;
75
- WebCodecsDOMException.INVALID_STATE_ERR = 11;
76
- WebCodecsDOMException.SYNTAX_ERR = 12;
77
- WebCodecsDOMException.INVALID_MODIFICATION_ERR = 13;
78
- WebCodecsDOMException.NAMESPACE_ERR = 14;
79
- WebCodecsDOMException.INVALID_ACCESS_ERR = 15;
80
- WebCodecsDOMException.VALIDATION_ERR = 16;
81
- WebCodecsDOMException.TYPE_MISMATCH_ERR = 17;
82
- WebCodecsDOMException.SECURITY_ERR = 18;
83
- WebCodecsDOMException.NETWORK_ERR = 19;
84
- WebCodecsDOMException.ABORT_ERR = 20;
85
- WebCodecsDOMException.URL_MISMATCH_ERR = 21;
86
- WebCodecsDOMException.QUOTA_EXCEEDED_ERR = 22;
87
- WebCodecsDOMException.TIMEOUT_ERR = 23;
88
- WebCodecsDOMException.INVALID_NODE_TYPE_ERR = 24;
89
- WebCodecsDOMException.DATA_CLONE_ERR = 25;
90
- WebCodecsDOMException.ERROR_CODES = {
91
- IndexSizeError: 1,
92
- HierarchyRequestError: 3,
93
- WrongDocumentError: 4,
94
- InvalidCharacterError: 5,
95
- NoModificationAllowedError: 7,
96
- NotFoundError: 8,
97
- NotSupportedError: 9,
98
- InUseAttributeError: 10,
99
- InvalidStateError: 11,
100
- SyntaxError: 12,
101
- InvalidModificationError: 13,
102
- NamespaceError: 14,
103
- InvalidAccessError: 15,
104
- TypeMismatchError: 17,
105
- SecurityError: 18,
106
- NetworkError: 19,
107
- AbortError: 20,
108
- URLMismatchError: 21,
109
- QuotaExceededError: 22,
110
- TimeoutError: 23,
111
- InvalidNodeTypeError: 24,
112
- DataCloneError: 25,
113
- EncodingError: 0,
114
- NotReadableError: 0,
115
- UnknownError: 0,
116
- ConstraintError: 0,
117
- DataError: 0,
118
- TransactionInactiveError: 0,
119
- ReadOnlyError: 0,
120
- VersionError: 0,
121
- OperationError: 0
122
- };
123
- function createDOMException(message, name) {
124
- return new WebCodecsDOMException(message, name);
125
- }
126
- }
127
- });
128
-
129
- // ../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js
130
- var require_node_gyp_build = __commonJS({
131
- "../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js"(exports, module) {
132
- "use strict";
133
- var fs = __require("fs");
134
- var path = __require("path");
135
- var os = __require("os");
136
- var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
137
- var vars = process.config && process.config.variables || {};
138
- var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
139
- var abi = process.versions.modules;
140
- var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
141
- var arch = process.env.npm_config_arch || os.arch();
142
- var platform = process.env.npm_config_platform || os.platform();
143
- var libc = process.env.LIBC || (isAlpine(platform) ? "musl" : "glibc");
144
- var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
145
- var uv = (process.versions.uv || "").split(".")[0];
146
- module.exports = load;
147
- function load(dir) {
148
- return runtimeRequire(load.resolve(dir));
149
- }
150
- load.resolve = load.path = function(dir) {
151
- dir = path.resolve(dir || ".");
152
- try {
153
- var name = runtimeRequire(path.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
154
- if (process.env[name + "_PREBUILD"]) dir = process.env[name + "_PREBUILD"];
155
- } catch (err) {
156
- }
157
- if (!prebuildsOnly) {
158
- var release = getFirst(path.join(dir, "build/Release"), matchBuild);
159
- if (release) return release;
160
- var debug = getFirst(path.join(dir, "build/Debug"), matchBuild);
161
- if (debug) return debug;
162
- }
163
- var prebuild = resolve(dir);
164
- if (prebuild) return prebuild;
165
- var nearby = resolve(path.dirname(process.execPath));
166
- if (nearby) return nearby;
167
- var target = [
168
- "platform=" + platform,
169
- "arch=" + arch,
170
- "runtime=" + runtime,
171
- "abi=" + abi,
172
- "uv=" + uv,
173
- armv ? "armv=" + armv : "",
174
- "libc=" + libc,
175
- "node=" + process.versions.node,
176
- process.versions.electron ? "electron=" + process.versions.electron : "",
177
- typeof __webpack_require__ === "function" ? "webpack=true" : ""
178
- // eslint-disable-line
179
- ].filter(Boolean).join(" ");
180
- throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
181
- function resolve(dir2) {
182
- var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
183
- var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
184
- if (!tuple) return;
185
- var prebuilds = path.join(dir2, "prebuilds", tuple.name);
186
- var parsed = readdirSync(prebuilds).map(parseTags);
187
- var candidates = parsed.filter(matchTags(runtime, abi));
188
- var winner = candidates.sort(compareTags(runtime))[0];
189
- if (winner) return path.join(prebuilds, winner.file);
190
- }
191
- };
192
- function readdirSync(dir) {
193
- try {
194
- return fs.readdirSync(dir);
195
- } catch (err) {
196
- return [];
197
- }
198
- }
199
- function getFirst(dir, filter) {
200
- var files = readdirSync(dir).filter(filter);
201
- return files[0] && path.join(dir, files[0]);
202
- }
203
- function matchBuild(name) {
204
- return /\.node$/.test(name);
205
- }
206
- function parseTuple(name) {
207
- var arr = name.split("-");
208
- if (arr.length !== 2) return;
209
- var platform2 = arr[0];
210
- var architectures = arr[1].split("+");
211
- if (!platform2) return;
212
- if (!architectures.length) return;
213
- if (!architectures.every(Boolean)) return;
214
- return { name, platform: platform2, architectures };
215
- }
216
- function matchTuple(platform2, arch2) {
217
- return function(tuple) {
218
- if (tuple == null) return false;
219
- if (tuple.platform !== platform2) return false;
220
- return tuple.architectures.includes(arch2);
221
- };
222
- }
223
- function compareTuples(a, b) {
224
- return a.architectures.length - b.architectures.length;
225
- }
226
- function parseTags(file) {
227
- var arr = file.split(".");
228
- var extension = arr.pop();
229
- var tags = { file, specificity: 0 };
230
- if (extension !== "node") return;
231
- for (var i = 0; i < arr.length; i++) {
232
- var tag = arr[i];
233
- if (tag === "node" || tag === "electron" || tag === "node-webkit") {
234
- tags.runtime = tag;
235
- } else if (tag === "napi") {
236
- tags.napi = true;
237
- } else if (tag.slice(0, 3) === "abi") {
238
- tags.abi = tag.slice(3);
239
- } else if (tag.slice(0, 2) === "uv") {
240
- tags.uv = tag.slice(2);
241
- } else if (tag.slice(0, 4) === "armv") {
242
- tags.armv = tag.slice(4);
243
- } else if (tag === "glibc" || tag === "musl") {
244
- tags.libc = tag;
245
- } else {
246
- continue;
247
- }
248
- tags.specificity++;
249
- }
250
- return tags;
251
- }
252
- function matchTags(runtime2, abi2) {
253
- return function(tags) {
254
- if (tags == null) return false;
255
- if (tags.runtime && tags.runtime !== runtime2 && !runtimeAgnostic(tags)) return false;
256
- if (tags.abi && tags.abi !== abi2 && !tags.napi) return false;
257
- if (tags.uv && tags.uv !== uv) return false;
258
- if (tags.armv && tags.armv !== armv) return false;
259
- if (tags.libc && tags.libc !== libc) return false;
260
- return true;
261
- };
262
- }
263
- function runtimeAgnostic(tags) {
264
- return tags.runtime === "node" && tags.napi;
265
- }
266
- function compareTags(runtime2) {
267
- return function(a, b) {
268
- if (a.runtime !== b.runtime) {
269
- return a.runtime === runtime2 ? -1 : 1;
270
- } else if (a.abi !== b.abi) {
271
- return a.abi ? -1 : 1;
272
- } else if (a.specificity !== b.specificity) {
273
- return a.specificity > b.specificity ? -1 : 1;
274
- } else {
275
- return 0;
276
- }
277
- };
278
- }
279
- function isNwjs() {
280
- return !!(process.versions && process.versions.nw);
281
- }
282
- function isElectron() {
283
- if (process.versions && process.versions.electron) return true;
284
- if (process.env.ELECTRON_RUN_AS_NODE) return true;
285
- return typeof window !== "undefined" && window.process && window.process.type === "renderer";
286
- }
287
- function isAlpine(platform2) {
288
- return platform2 === "linux" && fs.existsSync("/etc/alpine-release");
289
- }
290
- load.parseTags = parseTags;
291
- load.matchTags = matchTags;
292
- load.compareTags = compareTags;
293
- load.parseTuple = parseTuple;
294
- load.matchTuple = matchTuple;
295
- load.compareTuples = compareTuples;
296
- }
297
- });
298
-
299
- // ../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/index.js
300
- var require_node_gyp_build2 = __commonJS({
301
- "../../node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/index.js"(exports, module) {
302
- "use strict";
303
- var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
304
- if (typeof runtimeRequire.addon === "function") {
305
- module.exports = runtimeRequire.addon.bind(runtimeRequire);
306
- } else {
307
- module.exports = require_node_gyp_build();
308
- }
309
- }
310
- });
311
-
312
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/native.js
313
- var require_native = __commonJS({
314
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/native.js"(exports) {
315
- "use strict";
316
- var __importDefault = exports && exports.__importDefault || function(mod) {
317
- return mod && mod.__esModule ? mod : { "default": mod };
318
- };
319
- Object.defineProperty(exports, "__esModule", { value: true });
320
- exports.native = void 0;
321
- var path_1 = __importDefault(__require("path"));
322
- var nodeGypBuild = require_node_gyp_build2();
323
- var native;
324
- try {
325
- exports.native = native = nodeGypBuild(path_1.default.join(__dirname, ".."));
326
- } catch (error) {
327
- exports.native = native = new Proxy({}, {
328
- get() {
329
- throw error;
330
- }
331
- });
332
- }
333
- }
334
- });
335
-
336
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/VideoFrame.js
337
- var require_VideoFrame = __commonJS({
338
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/VideoFrame.js"(exports) {
339
- "use strict";
340
- Object.defineProperty(exports, "__esModule", { value: true });
341
- exports.VideoFrame = void 0;
342
- var VideoColorSpace_1 = require_VideoColorSpace();
343
- var types_1 = require_types();
344
- var native_1 = require_native();
345
- var VideoFrame = class _VideoFrame {
346
- // Per WebCodecs spec, after close() these should return null/0
347
- // Note: timestamp is preserved after close per spec
348
- get format() {
349
- return this._closed ? null : this._format;
350
- }
351
- get codedWidth() {
352
- return this._closed ? 0 : this._codedWidth;
353
- }
354
- get codedHeight() {
355
- return this._closed ? 0 : this._codedHeight;
356
- }
357
- get displayWidth() {
358
- return this._closed ? 0 : this._displayWidth;
359
- }
360
- get displayHeight() {
361
- return this._closed ? 0 : this._displayHeight;
362
- }
363
- get timestamp() {
364
- return this._timestamp;
365
- }
366
- get duration() {
367
- return this._closed ? null : this._duration;
368
- }
369
- get colorSpace() {
370
- return this._colorSpace;
371
- }
372
- get visibleRect() {
373
- return this._closed ? null : this._visibleRect;
374
- }
375
- constructor(dataOrImage, init) {
376
- this._closed = false;
377
- this._buffer = null;
378
- if (dataOrImage instanceof _VideoFrame) {
379
- if (dataOrImage._closed) {
380
- throw new types_1.DOMException("Source VideoFrame is closed", "InvalidStateError");
381
- }
382
- this._native = dataOrImage._native ? dataOrImage._native.clone() : null;
383
- this._buffer = dataOrImage._buffer ? new Uint8Array(dataOrImage._buffer) : null;
384
- this._format = dataOrImage._format;
385
- this._codedWidth = dataOrImage._codedWidth;
386
- this._codedHeight = dataOrImage._codedHeight;
387
- this._displayWidth = init?.displayWidth ?? dataOrImage._displayWidth;
388
- this._displayHeight = init?.displayHeight ?? dataOrImage._displayHeight;
389
- this._timestamp = init?.timestamp ?? dataOrImage._timestamp;
390
- this._duration = init?.duration ?? dataOrImage._duration;
391
- this._colorSpace = dataOrImage._colorSpace;
392
- this._visibleRect = dataOrImage._visibleRect;
393
- } else {
394
- const bufferInit = init;
395
- if (!bufferInit?.format || !bufferInit.codedWidth || !bufferInit.codedHeight) {
396
- throw new TypeError("format, codedWidth, and codedHeight are required");
397
- }
398
- if (bufferInit.timestamp === void 0) {
399
- throw new TypeError("timestamp is required");
400
- }
401
- let buffer;
402
- if (dataOrImage instanceof ArrayBuffer) {
403
- buffer = new Uint8Array(dataOrImage);
404
- } else {
405
- buffer = new Uint8Array(dataOrImage.buffer, dataOrImage.byteOffset, dataOrImage.byteLength);
406
- }
407
- this._buffer = new Uint8Array(buffer);
408
- if (native_1.native) {
409
- try {
410
- this._native = native_1.native.createVideoFrame(Buffer.from(buffer), bufferInit.format, bufferInit.codedWidth, bufferInit.codedHeight);
411
- } catch (e) {
412
- this._native = null;
413
- }
414
- }
415
- this._format = bufferInit.format;
416
- this._codedWidth = bufferInit.codedWidth;
417
- this._codedHeight = bufferInit.codedHeight;
418
- this._displayWidth = bufferInit.displayWidth ?? bufferInit.codedWidth;
419
- this._displayHeight = bufferInit.displayHeight ?? bufferInit.codedHeight;
420
- this._timestamp = bufferInit.timestamp;
421
- this._duration = bufferInit.duration ?? null;
422
- const isRgbFormat = ["RGBA", "RGBX", "BGRA", "BGRX"].includes(bufferInit.format);
423
- const defaultColorSpace = isRgbFormat ? { primaries: "bt709", transfer: "iec61966-2-1", matrix: "rgb", fullRange: true } : { primaries: "bt709", transfer: "bt709", matrix: "bt709", fullRange: false };
424
- this._colorSpace = new VideoColorSpace_1.VideoColorSpace({
425
- primaries: bufferInit.colorSpace?.primaries ?? defaultColorSpace.primaries,
426
- transfer: bufferInit.colorSpace?.transfer ?? defaultColorSpace.transfer,
427
- matrix: bufferInit.colorSpace?.matrix ?? defaultColorSpace.matrix,
428
- fullRange: bufferInit.colorSpace?.fullRange ?? defaultColorSpace.fullRange
429
- });
430
- this._visibleRect = bufferInit.visibleRect ? new types_1.DOMRectReadOnly(bufferInit.visibleRect.x, bufferInit.visibleRect.y, bufferInit.visibleRect.width, bufferInit.visibleRect.height) : new types_1.DOMRectReadOnly(0, 0, bufferInit.codedWidth, bufferInit.codedHeight);
431
- }
432
- }
433
- /**
434
- * Get the native frame handle (internal use only)
435
- */
436
- _getNative() {
437
- this._assertNotClosed();
438
- return this._native;
439
- }
440
- /**
441
- * Calculate the size in bytes needed to hold the frame data
442
- */
443
- allocationSize(options) {
444
- this._assertNotClosed();
445
- const width = options?.rect?.width ?? this.codedWidth;
446
- const height = options?.rect?.height ?? this.codedHeight;
447
- const targetFormat = options?.format ?? this.format;
448
- return this._calculateFormatSize(targetFormat, width, height);
449
- }
450
- _calculateFormatSize(format, width, height) {
451
- switch (format) {
452
- case "RGBA":
453
- case "RGBX":
454
- case "BGRA":
455
- case "BGRX":
456
- return width * height * 4;
457
- case "I420":
458
- return Math.floor(width * height * 1.5);
459
- case "I420A":
460
- return width * height * 2;
461
- case "I422":
462
- return width * height * 2;
463
- case "I444":
464
- return width * height * 3;
465
- case "NV12":
466
- return Math.floor(width * height * 1.5);
467
- default:
468
- return width * height * 4;
469
- }
470
- }
471
- /**
472
- * Copy the frame data to a destination buffer
473
- */
474
- async copyTo(destination, options) {
475
- this._assertNotClosed();
476
- let dest;
477
- if (destination instanceof ArrayBuffer) {
478
- dest = new Uint8Array(destination);
479
- } else {
480
- dest = new Uint8Array(destination.buffer, destination.byteOffset, destination.byteLength);
481
- }
482
- if (this._native) {
483
- this._native.copyTo(Buffer.from(dest.buffer, dest.byteOffset, dest.byteLength), options);
484
- } else if (this._buffer) {
485
- const size = Math.min(dest.byteLength, this._buffer.byteLength);
486
- dest.set(this._buffer.subarray(0, size));
487
- }
488
- return this._getPlaneLayouts(options);
489
- }
490
- /**
491
- * Create a clone of this frame
492
- */
493
- clone() {
494
- this._assertNotClosed();
495
- return new _VideoFrame(this);
496
- }
497
- /**
498
- * Close the frame and release resources
499
- */
500
- close() {
501
- if (!this._closed) {
502
- if (this._native) {
503
- this._native.close();
504
- this._native = null;
505
- }
506
- this._buffer = null;
507
- this._closed = true;
508
- }
509
- }
510
- _assertNotClosed() {
511
- if (this._closed) {
512
- throw new types_1.DOMException("VideoFrame is closed", "InvalidStateError");
513
- }
514
- }
515
- _getPlaneLayouts(options) {
516
- const width = options?.rect?.width ?? this.codedWidth;
517
- const height = options?.rect?.height ?? this.codedHeight;
518
- const targetFormat = options?.format ?? this.format;
519
- switch (targetFormat) {
520
- case "RGBA":
521
- case "RGBX":
522
- case "BGRA":
523
- case "BGRX":
524
- return [{ offset: 0, stride: width * 4 }];
525
- case "I420": {
526
- const ySize = width * height;
527
- const uvSize = Math.floor(width / 2 * (height / 2));
528
- return [
529
- { offset: 0, stride: width },
530
- { offset: ySize, stride: Math.floor(width / 2) },
531
- { offset: ySize + uvSize, stride: Math.floor(width / 2) }
532
- ];
533
- }
534
- case "I420A": {
535
- const ySize = width * height;
536
- const uvSize = Math.floor(width / 2 * (height / 2));
537
- return [
538
- { offset: 0, stride: width },
539
- { offset: ySize, stride: Math.floor(width / 2) },
540
- { offset: ySize + uvSize, stride: Math.floor(width / 2) },
541
- { offset: ySize + 2 * uvSize, stride: width }
542
- ];
543
- }
544
- case "I422": {
545
- const ySize = width * height;
546
- const uvSize = Math.floor(width / 2 * height);
547
- return [
548
- { offset: 0, stride: width },
549
- { offset: ySize, stride: Math.floor(width / 2) },
550
- { offset: ySize + uvSize, stride: Math.floor(width / 2) }
551
- ];
552
- }
553
- case "I444": {
554
- const planeSize = width * height;
555
- return [
556
- { offset: 0, stride: width },
557
- { offset: planeSize, stride: width },
558
- { offset: planeSize * 2, stride: width }
559
- ];
560
- }
561
- case "NV12": {
562
- const ySize = width * height;
563
- return [
564
- { offset: 0, stride: width },
565
- { offset: ySize, stride: width }
566
- ];
567
- }
568
- default:
569
- return [{ offset: 0, stride: width * 4 }];
570
- }
571
- }
572
- };
573
- exports.VideoFrame = VideoFrame;
574
- }
575
- });
576
-
577
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/AudioData.js
578
- var require_AudioData = __commonJS({
579
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/AudioData.js"(exports) {
580
- "use strict";
581
- Object.defineProperty(exports, "__esModule", { value: true });
582
- exports.AudioData = void 0;
583
- var types_1 = require_types();
584
- var native_1 = require_native();
585
- function getBytesPerSample(format) {
586
- switch (format) {
587
- case "u8":
588
- case "u8-planar":
589
- return 1;
590
- case "s16":
591
- case "s16-planar":
592
- return 2;
593
- case "s32":
594
- case "s32-planar":
595
- case "f32":
596
- case "f32-planar":
597
- return 4;
598
- default:
599
- return 4;
600
- }
601
- }
602
- function isPlanar(format) {
603
- return format.endsWith("-planar");
604
- }
605
- var AudioData = class _AudioData {
606
- // Per WebCodecs spec, after close() these should return null/0
607
- get format() {
608
- return this._closed ? null : this._format;
609
- }
610
- get sampleRate() {
611
- return this._closed ? 0 : this._sampleRate;
612
- }
613
- get numberOfFrames() {
614
- return this._closed ? 0 : this._numberOfFrames;
615
- }
616
- get numberOfChannels() {
617
- return this._closed ? 0 : this._numberOfChannels;
618
- }
619
- get duration() {
620
- return this._closed ? 0 : this._duration;
621
- }
622
- get timestamp() {
623
- return this._closed ? 0 : this._timestamp;
624
- }
625
- constructor(init) {
626
- this._closed = false;
627
- this._buffer = null;
628
- if (!init.format) {
629
- throw new TypeError("format is required");
630
- }
631
- if (!init.sampleRate || init.sampleRate <= 0) {
632
- throw new TypeError("sampleRate must be positive");
633
- }
634
- if (!init.numberOfFrames || init.numberOfFrames <= 0) {
635
- throw new TypeError("numberOfFrames must be positive");
636
- }
637
- if (!init.numberOfChannels || init.numberOfChannels <= 0) {
638
- throw new TypeError("numberOfChannels must be positive");
639
- }
640
- if (init.timestamp === void 0) {
641
- throw new TypeError("timestamp is required");
642
- }
643
- if (!init.data) {
644
- throw new TypeError("data is required");
645
- }
646
- let buffer;
647
- if (init.data instanceof ArrayBuffer) {
648
- buffer = new Uint8Array(init.data);
649
- } else {
650
- buffer = new Uint8Array(init.data.buffer, init.data.byteOffset, init.data.byteLength);
651
- }
652
- this._buffer = new Uint8Array(buffer);
653
- if (native_1.native) {
654
- try {
655
- this._native = native_1.native.createAudioData(Buffer.from(buffer), init.format, init.sampleRate, init.numberOfFrames, init.numberOfChannels, init.timestamp);
656
- } catch {
657
- this._native = null;
658
- }
659
- }
660
- this._format = init.format;
661
- this._sampleRate = init.sampleRate;
662
- this._numberOfFrames = init.numberOfFrames;
663
- this._numberOfChannels = init.numberOfChannels;
664
- this._timestamp = init.timestamp;
665
- this._duration = Math.floor(init.numberOfFrames / init.sampleRate * 1e6);
666
- }
667
- /**
668
- * Calculate the size in bytes needed to hold the audio data for a plane
669
- */
670
- allocationSize(options) {
671
- this._assertNotClosed();
672
- const frameOffset = options.frameOffset ?? 0;
673
- const frameCount = options.frameCount ?? this.numberOfFrames - frameOffset;
674
- const format = options.format ?? this.format;
675
- if (!format) {
676
- throw new types_1.DOMException("No format available", "InvalidStateError");
677
- }
678
- const bytesPerSample = getBytesPerSample(format);
679
- if (isPlanar(format)) {
680
- return frameCount * bytesPerSample;
681
- } else {
682
- return frameCount * this.numberOfChannels * bytesPerSample;
683
- }
684
- }
685
- /**
686
- * Copy audio data to a destination buffer
687
- */
688
- copyTo(destination, options) {
689
- this._assertNotClosed();
690
- if (options.planeIndex < 0) {
691
- throw new RangeError("planeIndex must be non-negative");
692
- }
693
- const format = options.format ?? this.format;
694
- if (!format) {
695
- throw new types_1.DOMException("No format available", "InvalidStateError");
696
- }
697
- if (isPlanar(format)) {
698
- if (options.planeIndex >= this.numberOfChannels) {
699
- throw new RangeError(`planeIndex ${options.planeIndex} out of range for ${this.numberOfChannels} channels`);
700
- }
701
- } else {
702
- if (options.planeIndex !== 0) {
703
- throw new RangeError("planeIndex must be 0 for interleaved formats");
704
- }
705
- }
706
- let dest;
707
- if (destination instanceof ArrayBuffer) {
708
- dest = new Uint8Array(destination);
709
- } else {
710
- dest = new Uint8Array(destination.buffer, destination.byteOffset, destination.byteLength);
711
- }
712
- if (this._native) {
713
- this._native.copyTo(Buffer.from(dest.buffer, dest.byteOffset, dest.byteLength), options);
714
- } else if (this._buffer) {
715
- const frameOffset = options.frameOffset ?? 0;
716
- const frameCount = options.frameCount ?? this.numberOfFrames - frameOffset;
717
- const bytesPerSample = getBytesPerSample(format);
718
- if (isPlanar(format)) {
719
- const planeSize = this.numberOfFrames * bytesPerSample;
720
- const srcOffset = options.planeIndex * planeSize + frameOffset * bytesPerSample;
721
- const copySize = frameCount * bytesPerSample;
722
- dest.set(this._buffer.subarray(srcOffset, srcOffset + copySize));
723
- } else {
724
- const srcOffset = frameOffset * this.numberOfChannels * bytesPerSample;
725
- const copySize = frameCount * this.numberOfChannels * bytesPerSample;
726
- dest.set(this._buffer.subarray(srcOffset, srcOffset + copySize));
727
- }
728
- }
729
- }
730
- /**
731
- * Create a clone of this audio data
732
- */
733
- clone() {
734
- this._assertNotClosed();
735
- if (!this._buffer || !this.format) {
736
- throw new types_1.DOMException("Cannot clone AudioData without data", "InvalidStateError");
737
- }
738
- return new _AudioData({
739
- format: this.format,
740
- sampleRate: this.sampleRate,
741
- numberOfFrames: this.numberOfFrames,
742
- numberOfChannels: this.numberOfChannels,
743
- timestamp: this.timestamp,
744
- data: new Uint8Array(this._buffer)
745
- });
746
- }
747
- /**
748
- * Close the audio data and release resources
749
- */
750
- close() {
751
- if (!this._closed) {
752
- if (this._native) {
753
- this._native.close();
754
- this._native = null;
755
- }
756
- this._buffer = null;
757
- this._closed = true;
758
- }
759
- }
760
- _assertNotClosed() {
761
- if (this._closed) {
762
- throw new types_1.DOMException("AudioData is closed", "InvalidStateError");
763
- }
764
- }
765
- };
766
- exports.AudioData = AudioData;
767
- }
768
- });
769
-
770
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/EncodedVideoChunk.js
771
- var require_EncodedVideoChunk = __commonJS({
772
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/EncodedVideoChunk.js"(exports) {
773
- "use strict";
774
- Object.defineProperty(exports, "__esModule", { value: true });
775
- exports.EncodedVideoChunk = void 0;
776
- var EncodedVideoChunk = class {
777
- constructor(init) {
778
- if (!init.type) {
779
- throw new TypeError("type is required");
780
- }
781
- if (init.type !== "key" && init.type !== "delta") {
782
- throw new TypeError('type must be "key" or "delta"');
783
- }
784
- if (init.timestamp === void 0) {
785
- throw new TypeError("timestamp is required");
786
- }
787
- if (!init.data) {
788
- throw new TypeError("data is required");
789
- }
790
- this.type = init.type;
791
- this.timestamp = init.timestamp;
792
- this.duration = init.duration ?? null;
793
- let source;
794
- if (init.data instanceof ArrayBuffer) {
795
- source = new Uint8Array(init.data);
796
- } else {
797
- source = new Uint8Array(init.data.buffer, init.data.byteOffset, init.data.byteLength);
798
- }
799
- this._data = new Uint8Array(source);
800
- this.byteLength = this._data.byteLength;
801
- }
802
- /**
803
- * Copy the encoded data to a destination buffer
804
- */
805
- copyTo(destination) {
806
- let dest;
807
- if (destination instanceof ArrayBuffer) {
808
- dest = new Uint8Array(destination);
809
- } else {
810
- dest = new Uint8Array(destination.buffer, destination.byteOffset, destination.byteLength);
811
- }
812
- if (dest.byteLength < this._data.byteLength) {
813
- throw new TypeError("Destination buffer is too small");
814
- }
815
- dest.set(this._data);
816
- }
817
- };
818
- exports.EncodedVideoChunk = EncodedVideoChunk;
819
- }
820
- });
821
-
822
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/EncodedAudioChunk.js
823
- var require_EncodedAudioChunk = __commonJS({
824
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/EncodedAudioChunk.js"(exports) {
825
- "use strict";
826
- Object.defineProperty(exports, "__esModule", { value: true });
827
- exports.EncodedAudioChunk = void 0;
828
- var EncodedAudioChunk = class {
829
- constructor(init) {
830
- if (!init.type) {
831
- throw new TypeError("type is required");
832
- }
833
- if (init.type !== "key" && init.type !== "delta") {
834
- throw new TypeError('type must be "key" or "delta"');
835
- }
836
- if (init.timestamp === void 0) {
837
- throw new TypeError("timestamp is required");
838
- }
839
- if (!init.data) {
840
- throw new TypeError("data is required");
841
- }
842
- this.type = init.type;
843
- this.timestamp = init.timestamp;
844
- this.duration = init.duration ?? null;
845
- let source;
846
- if (init.data instanceof ArrayBuffer) {
847
- source = new Uint8Array(init.data);
848
- } else {
849
- source = new Uint8Array(init.data.buffer, init.data.byteOffset, init.data.byteLength);
850
- }
851
- this._data = new Uint8Array(source);
852
- this.byteLength = this._data.byteLength;
853
- }
854
- /**
855
- * Copy the encoded data to a destination buffer
856
- */
857
- copyTo(destination) {
858
- let dest;
859
- if (destination instanceof ArrayBuffer) {
860
- dest = new Uint8Array(destination);
861
- } else {
862
- dest = new Uint8Array(destination.buffer, destination.byteOffset, destination.byteLength);
863
- }
864
- if (dest.byteLength < this._data.byteLength) {
865
- throw new TypeError("Destination buffer is too small");
866
- }
867
- dest.set(this._data);
868
- }
869
- };
870
- exports.EncodedAudioChunk = EncodedAudioChunk;
871
- }
872
- });
873
-
874
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/ImageDecoder.js
875
- var require_ImageDecoder = __commonJS({
876
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/ImageDecoder.js"(exports) {
877
- "use strict";
878
- Object.defineProperty(exports, "__esModule", { value: true });
879
- exports.ImageDecoder = void 0;
880
- var VideoFrame_1 = require_VideoFrame();
881
- var types_1 = require_types();
882
- var native_1 = require_native();
883
- function isReadableStream(value) {
884
- return typeof value === "object" && value !== null && typeof value.getReader === "function";
885
- }
886
- var ImageDecoder = class {
887
- /**
888
- * Check if a MIME type is supported for decoding
889
- */
890
- static isTypeSupported(type) {
891
- if (!native_1.native || !native_1.native.ImageDecoderNative) {
892
- return Promise.resolve(false);
893
- }
894
- return Promise.resolve(native_1.native.ImageDecoderNative.isTypeSupported(type));
895
- }
896
- constructor(init) {
897
- this._complete = false;
898
- this._closed = false;
899
- if (!init.data) {
900
- throw new TypeError("data is required");
901
- }
902
- if (!init.type) {
903
- throw new TypeError("type is required");
904
- }
905
- if (!native_1.native || !native_1.native.ImageDecoderNative) {
906
- throw new types_1.DOMException("Native addon not available", "NotSupportedError");
907
- }
908
- this._type = init.type;
909
- this._completedPromise = new Promise((resolve, reject) => {
910
- this._completedResolve = resolve;
911
- this._completedReject = reject;
912
- });
913
- if (isReadableStream(init.data)) {
914
- this._handleReadableStream(init.data);
915
- return;
916
- }
917
- let dataBuffer;
918
- if (init.data instanceof ArrayBuffer) {
919
- dataBuffer = Buffer.from(init.data);
920
- } else if (ArrayBuffer.isView(init.data)) {
921
- dataBuffer = Buffer.from(init.data.buffer, init.data.byteOffset, init.data.byteLength);
922
- } else {
923
- throw new TypeError("Invalid data type: expected BufferSource or ReadableStream");
924
- }
925
- this._initNative(dataBuffer);
926
- }
927
- /**
928
- * Handle ReadableStream input by reading all chunks and concatenating them
929
- */
930
- async _handleReadableStream(stream) {
931
- this._streamReader = stream.getReader();
932
- const chunks = [];
933
- try {
934
- while (true) {
935
- const { done, value } = await this._streamReader.read();
936
- if (done)
937
- break;
938
- let chunk;
939
- if (value instanceof ArrayBuffer) {
940
- chunk = new Uint8Array(value);
941
- } else if (ArrayBuffer.isView(value)) {
942
- chunk = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
943
- } else {
944
- throw new TypeError("ReadableStream yielded invalid chunk type");
945
- }
946
- chunks.push(chunk);
947
- }
948
- const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
949
- const fullData = new Uint8Array(totalLength);
950
- let offset = 0;
951
- for (const chunk of chunks) {
952
- fullData.set(chunk, offset);
953
- offset += chunk.length;
954
- }
955
- this._initNative(Buffer.from(fullData));
956
- } catch (error) {
957
- this._completedReject(error instanceof Error ? error : new Error(String(error)));
958
- }
959
- }
960
- /**
961
- * Initialize the native decoder with buffer data
962
- */
963
- _initNative(dataBuffer) {
964
- try {
965
- this._native = new native_1.native.ImageDecoderNative({
966
- data: dataBuffer,
967
- type: this._type
968
- });
969
- this._complete = this._native.complete;
970
- if (this._complete) {
971
- this._completedResolve();
972
- }
973
- } catch (e) {
974
- const error = new types_1.DOMException(e.message || "Failed to create ImageDecoder", "NotSupportedError");
975
- this._completedReject(error);
976
- throw error;
977
- }
978
- }
979
- /**
980
- * Whether all image data has been received
981
- */
982
- get complete() {
983
- return this._complete;
984
- }
985
- /**
986
- * Promise that resolves when complete becomes true
987
- */
988
- get completed() {
989
- return this._completedPromise;
990
- }
991
- /**
992
- * The MIME type of the image
993
- */
994
- get type() {
995
- return this._type;
996
- }
997
- /**
998
- * Decode an image frame
999
- */
1000
- async decode(options) {
1001
- if (this._closed) {
1002
- throw new types_1.DOMException("ImageDecoder is closed", "InvalidStateError");
1003
- }
1004
- if (!this._complete) {
1005
- throw new types_1.DOMException("Image data is not complete", "InvalidStateError");
1006
- }
1007
- try {
1008
- const result = this._native.decode(options?.frameIndex ?? 0);
1009
- const videoFrame = new VideoFrame_1.VideoFrame(result.image);
1010
- return {
1011
- image: videoFrame,
1012
- complete: result.complete
1013
- };
1014
- } catch (e) {
1015
- throw new types_1.DOMException(e.message || "Failed to decode image", "EncodingError");
1016
- }
1017
- }
1018
- /**
1019
- * Reset the decoder state
1020
- */
1021
- reset() {
1022
- if (!this._closed) {
1023
- this._native.reset();
1024
- }
1025
- }
1026
- /**
1027
- * Close the decoder and release resources
1028
- */
1029
- close() {
1030
- if (!this._closed) {
1031
- this._closed = true;
1032
- this._native.close();
1033
- }
1034
- }
1035
- };
1036
- exports.ImageDecoder = ImageDecoder;
1037
- }
1038
- });
1039
-
1040
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/codec-registry.js
1041
- var require_codec_registry = __commonJS({
1042
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/codec-registry.js"(exports) {
1043
- "use strict";
1044
- Object.defineProperty(exports, "__esModule", { value: true });
1045
- exports.AUDIO_CODECS = exports.VIDEO_CODECS = void 0;
1046
- exports.parseAvcCodecString = parseAvcCodecString;
1047
- exports.parseAacCodecString = parseAacCodecString;
1048
- exports.parseVp9CodecString = parseVp9CodecString;
1049
- exports.isVideoCodecSupported = isVideoCodecSupported;
1050
- exports.isAudioCodecSupported = isAudioCodecSupported;
1051
- exports.getFFmpegVideoCodec = getFFmpegVideoCodec;
1052
- exports.getFFmpegVideoDecoder = getFFmpegVideoDecoder;
1053
- exports.getFFmpegAudioCodec = getFFmpegAudioCodec;
1054
- exports.getFFmpegAudioDecoder = getFFmpegAudioDecoder;
1055
- function parseAvcCodecString(codec) {
1056
- const match = codec.match(/^avc1\.([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);
1057
- if (!match)
1058
- return null;
1059
- const profile = parseInt(match[1], 16);
1060
- const level = parseInt(match[3], 16);
1061
- return { profile, level };
1062
- }
1063
- function parseAacCodecString(codec) {
1064
- const match = codec.match(/^mp4a\.40\.(\d+)$/);
1065
- if (!match)
1066
- return null;
1067
- return { objectType: parseInt(match[1], 10) };
1068
- }
1069
- function parseVp9CodecString(codec) {
1070
- if (codec === "vp9" || codec === "vp09") {
1071
- return { profile: 0, level: 10, bitDepth: 8 };
1072
- }
1073
- const match = codec.match(/^vp09\.(\d{2})\.(\d{2})\.(\d{2})/);
1074
- if (!match)
1075
- return null;
1076
- return {
1077
- profile: parseInt(match[1], 10),
1078
- level: parseInt(match[2], 10),
1079
- bitDepth: parseInt(match[3], 10)
1080
- };
1081
- }
1082
- exports.VIDEO_CODECS = {
1083
- // H.264/AVC
1084
- "avc1": {
1085
- ffmpegCodec: "libx264",
1086
- type: "video",
1087
- profiles: {
1088
- "42": 66,
1089
- // Baseline
1090
- "4d": 77,
1091
- // Main
1092
- "58": 88,
1093
- // Extended
1094
- "64": 100
1095
- // High
1096
- }
1097
- },
1098
- // VP8
1099
- "vp8": {
1100
- ffmpegCodec: "libvpx",
1101
- type: "video"
1102
- },
1103
- // VP9
1104
- "vp09": {
1105
- ffmpegCodec: "libvpx-vp9",
1106
- type: "video"
1107
- },
1108
- "vp9": {
1109
- ffmpegCodec: "libvpx-vp9",
1110
- type: "video"
1111
- },
1112
- // H.265/HEVC
1113
- "hvc1": {
1114
- ffmpegCodec: "libx265",
1115
- type: "video"
1116
- },
1117
- "hev1": {
1118
- ffmpegCodec: "libx265",
1119
- type: "video"
1120
- },
1121
- // AV1
1122
- "av01": {
1123
- ffmpegCodec: "libaom-av1",
1124
- type: "video"
1125
- }
1126
- };
1127
- exports.AUDIO_CODECS = {
1128
- // AAC
1129
- "mp4a.40": {
1130
- ffmpegCodec: "aac",
1131
- type: "audio"
1132
- },
1133
- // Opus
1134
- "opus": {
1135
- ffmpegCodec: "libopus",
1136
- type: "audio"
1137
- },
1138
- // MP3
1139
- "mp3": {
1140
- ffmpegCodec: "libmp3lame",
1141
- type: "audio"
1142
- },
1143
- // FLAC
1144
- "flac": {
1145
- ffmpegCodec: "flac",
1146
- type: "audio"
1147
- },
1148
- // Vorbis
1149
- "vorbis": {
1150
- ffmpegCodec: "libvorbis",
1151
- type: "audio"
1152
- },
1153
- // PCM
1154
- "pcm": {
1155
- ffmpegCodec: "pcm_f32le",
1156
- type: "audio"
1157
- }
1158
- };
1159
- function isVideoCodecSupported(codec) {
1160
- if (codec.startsWith("avc1.")) {
1161
- return parseAvcCodecString(codec) !== null;
1162
- }
1163
- if (codec.startsWith("vp09.")) {
1164
- return parseVp9CodecString(codec) !== null;
1165
- }
1166
- if (codec.startsWith("hvc1.") || codec.startsWith("hev1.")) {
1167
- return true;
1168
- }
1169
- if (codec.startsWith("av01.")) {
1170
- return true;
1171
- }
1172
- return codec in exports.VIDEO_CODECS;
1173
- }
1174
- function isAudioCodecSupported(codec) {
1175
- if (codec.startsWith("mp4a.40.")) {
1176
- return parseAacCodecString(codec) !== null;
1177
- }
1178
- return codec in exports.AUDIO_CODECS;
1179
- }
1180
- function getFFmpegVideoCodec(codec) {
1181
- if (codec.startsWith("avc1.")) {
1182
- return "libx264";
1183
- }
1184
- if (codec.startsWith("vp09.") || codec === "vp9") {
1185
- return "libvpx-vp9";
1186
- }
1187
- if (codec === "vp8") {
1188
- return "libvpx";
1189
- }
1190
- if (codec.startsWith("hvc1.") || codec.startsWith("hev1.")) {
1191
- return "libx265";
1192
- }
1193
- if (codec.startsWith("av01.")) {
1194
- return "libaom-av1";
1195
- }
1196
- const info = exports.VIDEO_CODECS[codec];
1197
- return info?.ffmpegCodec ?? null;
1198
- }
1199
- function getFFmpegVideoDecoder(codec) {
1200
- if (codec.startsWith("avc1.")) {
1201
- return "h264";
1202
- }
1203
- if (codec.startsWith("vp09.") || codec === "vp9") {
1204
- return "vp9";
1205
- }
1206
- if (codec === "vp8") {
1207
- return "vp8";
1208
- }
1209
- if (codec.startsWith("hvc1.") || codec.startsWith("hev1.")) {
1210
- return "hevc";
1211
- }
1212
- if (codec.startsWith("av01.")) {
1213
- return "av1";
1214
- }
1215
- const encoderToDecoder = {
1216
- "libx264": "h264",
1217
- "libvpx": "vp8",
1218
- "libvpx-vp9": "vp9",
1219
- "libx265": "hevc",
1220
- "libaom-av1": "av1"
1221
- };
1222
- const info = exports.VIDEO_CODECS[codec];
1223
- if (info) {
1224
- return encoderToDecoder[info.ffmpegCodec] ?? info.ffmpegCodec;
1225
- }
1226
- return null;
1227
- }
1228
- function getFFmpegAudioCodec(codec) {
1229
- if (codec.startsWith("mp4a.40.")) {
1230
- return "aac";
1231
- }
1232
- const info = exports.AUDIO_CODECS[codec];
1233
- return info?.ffmpegCodec ?? null;
1234
- }
1235
- function getFFmpegAudioDecoder(codec) {
1236
- if (codec.startsWith("mp4a.40.")) {
1237
- return "aac";
1238
- }
1239
- const encoderToDecoder = {
1240
- "libopus": "opus",
1241
- "libmp3lame": "mp3",
1242
- "libvorbis": "vorbis"
1243
- };
1244
- const info = exports.AUDIO_CODECS[codec];
1245
- if (info) {
1246
- return encoderToDecoder[info.ffmpegCodec] ?? info.ffmpegCodec;
1247
- }
1248
- return null;
1249
- }
1250
- }
1251
- });
1252
-
1253
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/VideoEncoder.js
1254
- var require_VideoEncoder = __commonJS({
1255
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/VideoEncoder.js"(exports) {
1256
- "use strict";
1257
- Object.defineProperty(exports, "__esModule", { value: true });
1258
- exports.VideoEncoder = void 0;
1259
- var EncodedVideoChunk_1 = require_EncodedVideoChunk();
1260
- var codec_registry_1 = require_codec_registry();
1261
- var types_1 = require_types();
1262
- var native_1 = require_native();
1263
- var VideoEncoder = class {
1264
- /**
1265
- * Check if a VideoEncoder configuration is supported
1266
- *
1267
- * Tests whether the specified codec and parameters can be encoded on this platform.
1268
- * This method probes the native FFmpeg installation for codec availability.
1269
- *
1270
- * @param config - Configuration to test
1271
- * @returns Promise resolving to support status and normalized config
1272
- *
1273
- * @example
1274
- * ```ts
1275
- * const result = await VideoEncoder.isConfigSupported({
1276
- * codec: 'avc1.42E01E',
1277
- * width: 1920,
1278
- * height: 1080
1279
- * });
1280
- *
1281
- * if (result.supported) {
1282
- * console.log('H.264 encoding is supported');
1283
- * } else {
1284
- * console.log('H.264 encoding is NOT supported');
1285
- * }
1286
- * ```
1287
- *
1288
- * @example Check hardware encoder
1289
- * ```ts
1290
- * const hwSupport = await VideoEncoder.isConfigSupported({
1291
- * codec: 'h264_videotoolbox',
1292
- * width: 3840,
1293
- * height: 2160,
1294
- * hardwareAcceleration: 'prefer-hardware'
1295
- * });
1296
- *
1297
- * if (!hwSupport.supported) {
1298
- * // Fallback to software encoder
1299
- * encoder.configure({ codec: 'avc1.42E01E', ... });
1300
- * }
1301
- * ```
1302
- */
1303
- static async isConfigSupported(config) {
1304
- if (!config.codec || config.width <= 0 || config.height <= 0) {
1305
- return { supported: false, config };
1306
- }
1307
- if (!(0, codec_registry_1.isVideoCodecSupported)(config.codec)) {
1308
- return { supported: false, config };
1309
- }
1310
- if (native_1.native?.CapabilityProbe?.probeVideoEncoder) {
1311
- try {
1312
- const ffmpegCodec = (0, codec_registry_1.getFFmpegVideoCodec)(config.codec);
1313
- const result = native_1.native.CapabilityProbe.probeVideoEncoder({
1314
- codec: ffmpegCodec,
1315
- width: config.width,
1316
- height: config.height,
1317
- hardwareAcceleration: config.hardwareAcceleration || "no-preference"
1318
- });
1319
- return {
1320
- supported: result.supported,
1321
- config
1322
- };
1323
- } catch {
1324
- }
1325
- }
1326
- return { supported: true, config };
1327
- }
1328
- /**
1329
- * Create a new VideoEncoder
1330
- *
1331
- * @param init - Initialization callbacks for output and errors
1332
- * @throws TypeError if callbacks are not functions
1333
- *
1334
- * @example
1335
- * ```ts
1336
- * const encoder = new VideoEncoder({
1337
- * output: (chunk, metadata) => {
1338
- * // Handle encoded chunk
1339
- * if (metadata?.decoderConfig) {
1340
- * console.log('Received decoder config:', metadata.decoderConfig);
1341
- * }
1342
- * },
1343
- * error: (err) => {
1344
- * console.error('Encoding failed:', err.message);
1345
- * }
1346
- * });
1347
- * ```
1348
- */
1349
- constructor(init) {
1350
- this._state = "unconfigured";
1351
- this._encodeQueueSize = 0;
1352
- this._pendingCallbacks = 0;
1353
- this._config = null;
1354
- this._sentDecoderConfig = false;
1355
- this._listeners = /* @__PURE__ */ new Map();
1356
- this._useAsync = true;
1357
- this._nativeCreated = false;
1358
- this._ondequeue = null;
1359
- if (!init.output || typeof init.output !== "function") {
1360
- throw new TypeError("output callback is required");
1361
- }
1362
- if (!init.error || typeof init.error !== "function") {
1363
- throw new TypeError("error callback is required");
1364
- }
1365
- this._outputCallback = init.output;
1366
- this._errorCallback = init.error;
1367
- }
1368
- /**
1369
- * Current encoder state
1370
- * - `unconfigured`: Not configured yet, or reset() was called
1371
- * - `configured`: Ready to encode frames
1372
- * - `closed`: Encoder has been closed and cannot be used
1373
- */
1374
- get state() {
1375
- return this._state;
1376
- }
1377
- /**
1378
- * Number of pending encode operations
1379
- * Useful for backpressure management in async mode
1380
- *
1381
- * @example Backpressure handling
1382
- * ```ts
1383
- * for (const frame of frames) {
1384
- * encoder.encode(frame);
1385
- *
1386
- * // Wait if queue gets too large
1387
- * if (encoder.encodeQueueSize > 10) {
1388
- * await new Promise(resolve => {
1389
- * encoder.addEventListener('dequeue', resolve, { once: true });
1390
- * });
1391
- * }
1392
- * }
1393
- * ```
1394
- */
1395
- get encodeQueueSize() {
1396
- return this._encodeQueueSize;
1397
- }
1398
- /**
1399
- * Event handler for dequeue events
1400
- *
1401
- * Called when an item is removed from the encode queue. Useful for backpressure
1402
- * management. This is an alternative to using addEventListener('dequeue', ...).
1403
- *
1404
- * @example
1405
- * ```ts
1406
- * encoder.ondequeue = () => {
1407
- * console.log('Queue size:', encoder.encodeQueueSize);
1408
- * };
1409
- * ```
1410
- */
1411
- get ondequeue() {
1412
- return this._ondequeue;
1413
- }
1414
- set ondequeue(handler) {
1415
- this._ondequeue = handler;
1416
- }
1417
- /**
1418
- * Add an event listener
1419
- * Currently supports 'dequeue' events fired when encode queue decreases
1420
- *
1421
- * @param type - Event type ('dequeue')
1422
- * @param listener - Callback to invoke
1423
- * @param options - Event listener options
1424
- *
1425
- * @example Wait for queue to drain
1426
- * ```ts
1427
- * encoder.addEventListener('dequeue', () => {
1428
- * console.log('Queue size:', encoder.encodeQueueSize);
1429
- * });
1430
- * ```
1431
- */
1432
- addEventListener(type, listener, options) {
1433
- if (typeof listener !== "function")
1434
- return;
1435
- const once = !!(options && options.once);
1436
- const wrapper = once ? () => {
1437
- this.removeEventListener(type, wrapper);
1438
- listener();
1439
- } : listener;
1440
- let set = this._listeners.get(type);
1441
- if (!set) {
1442
- set = /* @__PURE__ */ new Set();
1443
- this._listeners.set(type, set);
1444
- }
1445
- set.add(wrapper);
1446
- }
1447
- /**
1448
- * Remove an event listener
1449
- *
1450
- * @param type - Event type ('dequeue')
1451
- * @param listener - Callback to remove
1452
- */
1453
- removeEventListener(type, listener) {
1454
- const set = this._listeners.get(type);
1455
- if (!set)
1456
- return;
1457
- if (set.has(listener)) {
1458
- set.delete(listener);
1459
- }
1460
- if (set.size === 0) {
1461
- this._listeners.delete(type);
1462
- }
1463
- }
1464
- _dispatchEvent(type) {
1465
- if (type === "dequeue" && this._ondequeue) {
1466
- try {
1467
- this._ondequeue(new Event("dequeue"));
1468
- } catch {
1469
- }
1470
- }
1471
- const set = this._listeners.get(type);
1472
- if (!set)
1473
- return;
1474
- for (const listener of Array.from(set)) {
1475
- try {
1476
- listener();
1477
- } catch {
1478
- }
1479
- }
1480
- }
1481
- /**
1482
- * Configure the encoder with codec parameters
1483
- *
1484
- * Must be called before encoding frames. Can be called multiple times to
1485
- * reconfigure (e.g., to change bitrate or resolution).
1486
- *
1487
- * @param config - Encoder configuration
1488
- * @throws DOMException if encoder is closed
1489
- * @throws DOMException if codec is not supported
1490
- * @throws DOMException if dimensions are invalid
1491
- *
1492
- * @example Basic H.264
1493
- * ```ts
1494
- * encoder.configure({
1495
- * codec: 'avc1.42E01E',
1496
- * width: 1920,
1497
- * height: 1080,
1498
- * bitrate: 5_000_000,
1499
- * framerate: 30
1500
- * });
1501
- * ```
1502
- *
1503
- * @example Hardware acceleration
1504
- * ```ts
1505
- * encoder.configure({
1506
- * codec: 'h264_videotoolbox', // macOS
1507
- * width: 1920,
1508
- * height: 1080,
1509
- * hardwareAcceleration: 'prefer-hardware'
1510
- * });
1511
- * ```
1512
- *
1513
- * @example VP9 with HDR
1514
- * ```ts
1515
- * encoder.configure({
1516
- * codec: 'vp09.00.10.08',
1517
- * width: 3840,
1518
- * height: 2160,
1519
- * bitrate: 20_000_000,
1520
- * colorSpace: {
1521
- * primaries: 'bt2020',
1522
- * transfer: 'pq',
1523
- * matrix: 'bt2020-ncl'
1524
- * }
1525
- * });
1526
- * ```
1527
- */
1528
- configure(config) {
1529
- if (this._state === "closed") {
1530
- throw new types_1.DOMException("Encoder is closed", "InvalidStateError");
1531
- }
1532
- if (!(0, codec_registry_1.isVideoCodecSupported)(config.codec)) {
1533
- throw new types_1.DOMException(`Unsupported codec: ${config.codec}`, "NotSupportedError");
1534
- }
1535
- if (config.width <= 0 || config.height <= 0) {
1536
- throw new types_1.DOMException("Invalid dimensions", "NotSupportedError");
1537
- }
1538
- if (config.latencyMode && !["quality", "realtime"].includes(config.latencyMode)) {
1539
- throw new types_1.DOMException(`Invalid latencyMode: ${config.latencyMode}. Must be 'quality' or 'realtime'.`, "TypeError");
1540
- }
1541
- if (config.bitrateMode && !["constant", "variable", "quantizer"].includes(config.bitrateMode)) {
1542
- throw new types_1.DOMException(`Invalid bitrateMode: ${config.bitrateMode}. Must be 'constant', 'variable', or 'quantizer'.`, "TypeError");
1543
- }
1544
- if (!native_1.native) {
1545
- throw new types_1.DOMException("Native addon not available", "NotSupportedError");
1546
- }
1547
- this._useAsync = config.useWorkerThread !== false && !!native_1.native.VideoEncoderAsync;
1548
- if (!this._nativeCreated) {
1549
- if (this._useAsync) {
1550
- this._native = new native_1.native.VideoEncoderAsync(this._onChunk.bind(this), this._onError.bind(this));
1551
- } else {
1552
- this._native = new native_1.native.VideoEncoderNative(this._onChunk.bind(this), this._onError.bind(this));
1553
- }
1554
- this._nativeCreated = true;
1555
- }
1556
- const ffmpegCodec = (0, codec_registry_1.getFFmpegVideoCodec)(config.codec);
1557
- const codecParams = {
1558
- codec: ffmpegCodec,
1559
- width: config.width,
1560
- height: config.height
1561
- };
1562
- if (config.codec.startsWith("avc1.")) {
1563
- const avcInfo = (0, codec_registry_1.parseAvcCodecString)(config.codec);
1564
- if (avcInfo) {
1565
- codecParams.profile = avcInfo.profile;
1566
- codecParams.level = avcInfo.level;
1567
- }
1568
- codecParams.avcFormat = config.avc?.format ?? "annexb";
1569
- }
1570
- if (config.bitrate)
1571
- codecParams.bitrate = config.bitrate;
1572
- if (config.framerate)
1573
- codecParams.framerate = config.framerate;
1574
- if (config.bitrateMode)
1575
- codecParams.bitrateMode = config.bitrateMode;
1576
- if (config.latencyMode)
1577
- codecParams.latencyMode = config.latencyMode;
1578
- if (config.colorSpace)
1579
- codecParams.colorSpace = config.colorSpace;
1580
- if (config.hardwareAcceleration)
1581
- codecParams.hardwareAcceleration = config.hardwareAcceleration;
1582
- if (config.alpha)
1583
- codecParams.alpha = config.alpha;
1584
- if (config.scalabilityMode)
1585
- codecParams.scalabilityMode = config.scalabilityMode;
1586
- this._native.configure(codecParams);
1587
- this._config = config;
1588
- this._state = "configured";
1589
- this._sentDecoderConfig = false;
1590
- }
1591
- /**
1592
- * Encode a video frame
1593
- *
1594
- * Queues a frame for encoding. In async mode (default), encoding happens in
1595
- * a worker thread and the output callback is invoked when complete.
1596
- *
1597
- * **IMPORTANT**: Always call `frame.close()` after encoding to prevent memory leaks.
1598
- *
1599
- * @param frame - VideoFrame to encode
1600
- * @param options - Encoding options (keyFrame)
1601
- * @throws DOMException if encoder is not configured
1602
- * @throws DOMException if frame is invalid
1603
- *
1604
- * @example Basic encoding
1605
- * ```ts
1606
- * const frame = new VideoFrame(buffer, {
1607
- * format: 'RGBA',
1608
- * codedWidth: 1920,
1609
- * codedHeight: 1080,
1610
- * timestamp: 0
1611
- * });
1612
- *
1613
- * encoder.encode(frame);
1614
- * frame.close(); // MUST close to prevent memory leak
1615
- * ```
1616
- *
1617
- * @example Force keyframe
1618
- * ```ts
1619
- * // Force first frame to be keyframe
1620
- * encoder.encode(frame, { keyFrame: true });
1621
- * frame.close();
1622
- *
1623
- * // Keyframe every 2 seconds at 30fps
1624
- * for (let i = 0; i < frames.length; i++) {
1625
- * encoder.encode(frames[i], { keyFrame: i % 60 === 0 });
1626
- * frames[i].close();
1627
- * }
1628
- * ```
1629
- */
1630
- encode(frame, options) {
1631
- if (this._state !== "configured") {
1632
- throw new types_1.DOMException("Encoder is not configured", "InvalidStateError");
1633
- }
1634
- const nativeFrame = frame._getNative();
1635
- if (!nativeFrame) {
1636
- throw new types_1.DOMException("VideoFrame has no native handle", "InvalidStateError");
1637
- }
1638
- const keyFrame = options?.keyFrame ?? false;
1639
- this._encodeQueueSize++;
1640
- this._pendingCallbacks++;
1641
- this._native.encode(nativeFrame, frame.timestamp, keyFrame);
1642
- setImmediate(() => {
1643
- this._pendingCallbacks--;
1644
- this._encodeQueueSize = Math.max(0, this._encodeQueueSize - 1);
1645
- this._dispatchEvent("dequeue");
1646
- });
1647
- }
1648
- /**
1649
- * Wait for all pending encodes to complete
1650
- *
1651
- * Flushes the internal encode queue and returns a promise that resolves when
1652
- * all frames have been encoded. Call this before closing the encoder to ensure
1653
- * no frames are lost.
1654
- *
1655
- * @returns Promise that resolves when flush is complete
1656
- * @throws DOMException if encoder is not configured
1657
- * @throws DOMException if encoding fails
1658
- *
1659
- * @example
1660
- * ```ts
1661
- * // Encode all frames
1662
- * for (const frame of frames) {
1663
- * encoder.encode(frame);
1664
- * frame.close();
1665
- * }
1666
- *
1667
- * // Wait for encoding to finish
1668
- * await encoder.flush();
1669
- *
1670
- * console.log('All frames encoded!');
1671
- * encoder.close();
1672
- * ```
1673
- */
1674
- async flush() {
1675
- if (this._state !== "configured") {
1676
- throw new types_1.DOMException("Encoder is not configured", "InvalidStateError");
1677
- }
1678
- return new Promise((resolve, reject) => {
1679
- this._native.flush(async (err) => {
1680
- if (err) {
1681
- reject(new types_1.DOMException(err.message, "EncodingError"));
1682
- } else {
1683
- while (this._pendingCallbacks > 0) {
1684
- await new Promise((r) => setImmediate(r));
1685
- }
1686
- resolve();
1687
- }
1688
- });
1689
- });
1690
- }
1691
- /**
1692
- * Reset the encoder to unconfigured state
1693
- *
1694
- * Aborts all pending encode operations and resets to unconfigured state.
1695
- * You must call `configure()` again before encoding more frames.
1696
- *
1697
- * @throws DOMException if encoder is closed
1698
- *
1699
- * @example
1700
- * ```ts
1701
- * encoder.configure({ codec: 'avc1.42E01E', width: 1920, height: 1080 });
1702
- * encoder.encode(frame1);
1703
- *
1704
- * // Abort and reconfigure with different settings
1705
- * encoder.reset();
1706
- * encoder.configure({ codec: 'vp09.00.10.08', width: 1280, height: 720 });
1707
- * encoder.encode(frame2);
1708
- * ```
1709
- */
1710
- reset() {
1711
- if (this._state === "closed") {
1712
- throw new types_1.DOMException("Encoder is closed", "InvalidStateError");
1713
- }
1714
- if (this._native) {
1715
- this._native.reset();
1716
- }
1717
- this._encodeQueueSize = 0;
1718
- this._state = "unconfigured";
1719
- this._sentDecoderConfig = false;
1720
- this._config = null;
1721
- }
1722
- /**
1723
- * Close the encoder and release resources
1724
- *
1725
- * Closes the encoder and frees all native resources. The encoder cannot be
1726
- * used after calling close(). Any pending encode operations are aborted.
1727
- *
1728
- * @example
1729
- * ```ts
1730
- * // Encode frames
1731
- * for (const frame of frames) {
1732
- * encoder.encode(frame);
1733
- * frame.close();
1734
- * }
1735
- *
1736
- * await encoder.flush();
1737
- * encoder.close(); // Release resources
1738
- *
1739
- * // encoder.encode() will now throw
1740
- * ```
1741
- */
1742
- close() {
1743
- if (this._state === "closed")
1744
- return;
1745
- if (this._native) {
1746
- this._native.close();
1747
- }
1748
- this._state = "closed";
1749
- this._encodeQueueSize = 0;
1750
- this._config = null;
1751
- }
1752
- _onChunk(data, isKeyframe, timestamp, duration, extradata) {
1753
- const dataCopy = new Uint8Array(data);
1754
- const extradataCopy = extradata ? new Uint8Array(extradata) : void 0;
1755
- const chunk = new EncodedVideoChunk_1.EncodedVideoChunk({
1756
- type: isKeyframe ? "key" : "delta",
1757
- timestamp,
1758
- duration: duration > 0 ? duration : void 0,
1759
- data: dataCopy
1760
- });
1761
- let metadata;
1762
- if (isKeyframe && !this._sentDecoderConfig && this._config) {
1763
- const colorSpace = this._config.colorSpace ?? {
1764
- primaries: "bt709",
1765
- transfer: "iec61966-2-1",
1766
- matrix: "rgb",
1767
- fullRange: true
1768
- };
1769
- metadata = {
1770
- decoderConfig: {
1771
- codec: this._config.codec,
1772
- codedWidth: this._config.width,
1773
- codedHeight: this._config.height,
1774
- description: extradataCopy ? extradataCopy.buffer : void 0,
1775
- colorSpace
1776
- }
1777
- };
1778
- this._sentDecoderConfig = true;
1779
- }
1780
- try {
1781
- this._outputCallback(chunk, metadata);
1782
- } catch (e) {
1783
- }
1784
- }
1785
- _onError(message) {
1786
- try {
1787
- this._errorCallback(new types_1.DOMException(message, "EncodingError"));
1788
- } catch (e) {
1789
- }
1790
- }
1791
- };
1792
- exports.VideoEncoder = VideoEncoder;
1793
- }
1794
- });
1795
-
1796
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/VideoDecoder.js
1797
- var require_VideoDecoder = __commonJS({
1798
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/VideoDecoder.js"(exports) {
1799
- "use strict";
1800
- Object.defineProperty(exports, "__esModule", { value: true });
1801
- exports.VideoDecoder = void 0;
1802
- var VideoFrame_1 = require_VideoFrame();
1803
- var codec_registry_1 = require_codec_registry();
1804
- var types_1 = require_types();
1805
- var native_1 = require_native();
1806
- var VideoDecoder = class {
1807
- static async isConfigSupported(config) {
1808
- if (!config.codec) {
1809
- return { supported: false, config };
1810
- }
1811
- if (!(0, codec_registry_1.isVideoCodecSupported)(config.codec)) {
1812
- return { supported: false, config };
1813
- }
1814
- if (native_1.native?.CapabilityProbe?.probeVideoDecoder) {
1815
- try {
1816
- const ffmpegCodec = (0, codec_registry_1.getFFmpegVideoDecoder)(config.codec);
1817
- const result = native_1.native.CapabilityProbe.probeVideoDecoder({
1818
- codec: ffmpegCodec,
1819
- width: config.codedWidth || 1920,
1820
- height: config.codedHeight || 1080,
1821
- hardwareAcceleration: config.hardwareAcceleration || "no-preference"
1822
- });
1823
- return {
1824
- supported: result.supported,
1825
- config
1826
- };
1827
- } catch {
1828
- }
1829
- }
1830
- return { supported: true, config };
1831
- }
1832
- constructor(init) {
1833
- this._state = "unconfigured";
1834
- this._decodeQueueSize = 0;
1835
- this._pendingCallbacks = 0;
1836
- this._config = null;
1837
- this._listeners = /* @__PURE__ */ new Map();
1838
- this._useAsync = true;
1839
- this._nativeCreated = false;
1840
- this._ondequeue = null;
1841
- if (!init.output || typeof init.output !== "function") {
1842
- throw new TypeError("output callback is required");
1843
- }
1844
- if (!init.error || typeof init.error !== "function") {
1845
- throw new TypeError("error callback is required");
1846
- }
1847
- this._outputCallback = init.output;
1848
- this._errorCallback = init.error;
1849
- }
1850
- get state() {
1851
- return this._state;
1852
- }
1853
- get decodeQueueSize() {
1854
- return this._decodeQueueSize;
1855
- }
1856
- /**
1857
- * Event handler for dequeue events
1858
- */
1859
- get ondequeue() {
1860
- return this._ondequeue;
1861
- }
1862
- set ondequeue(handler) {
1863
- this._ondequeue = handler;
1864
- }
1865
- /**
1866
- * Minimal EventTarget-style API for 'dequeue' events.
1867
- * Enables compatibility with MediaBunny and browser WebCodecs code.
1868
- */
1869
- addEventListener(type, listener, options) {
1870
- if (typeof listener !== "function")
1871
- return;
1872
- const once = !!(options && options.once);
1873
- const wrapper = once ? () => {
1874
- this.removeEventListener(type, wrapper);
1875
- listener();
1876
- } : listener;
1877
- let set = this._listeners.get(type);
1878
- if (!set) {
1879
- set = /* @__PURE__ */ new Set();
1880
- this._listeners.set(type, set);
1881
- }
1882
- set.add(wrapper);
1883
- }
1884
- removeEventListener(type, listener) {
1885
- const set = this._listeners.get(type);
1886
- if (!set)
1887
- return;
1888
- if (set.has(listener)) {
1889
- set.delete(listener);
1890
- }
1891
- if (set.size === 0) {
1892
- this._listeners.delete(type);
1893
- }
1894
- }
1895
- _dispatchEvent(type) {
1896
- if (type === "dequeue" && this._ondequeue) {
1897
- try {
1898
- this._ondequeue(new Event("dequeue"));
1899
- } catch {
1900
- }
1901
- }
1902
- const set = this._listeners.get(type);
1903
- if (!set)
1904
- return;
1905
- for (const listener of Array.from(set)) {
1906
- try {
1907
- listener();
1908
- } catch {
1909
- }
1910
- }
1911
- }
1912
- configure(config) {
1913
- if (this._state === "closed") {
1914
- throw new types_1.DOMException("Decoder is closed", "InvalidStateError");
1915
- }
1916
- if (!(0, codec_registry_1.isVideoCodecSupported)(config.codec)) {
1917
- throw new types_1.DOMException(`Unsupported codec: ${config.codec}`, "NotSupportedError");
1918
- }
1919
- if (!native_1.native) {
1920
- throw new types_1.DOMException("Native addon not available", "NotSupportedError");
1921
- }
1922
- this._useAsync = config.useWorkerThread !== false && !!native_1.native.VideoDecoderAsync;
1923
- if (!this._nativeCreated) {
1924
- if (this._useAsync) {
1925
- this._native = new native_1.native.VideoDecoderAsync(this._onFrame.bind(this), this._onError.bind(this));
1926
- } else {
1927
- this._native = new native_1.native.VideoDecoderNative(this._onFrame.bind(this), this._onError.bind(this));
1928
- }
1929
- this._nativeCreated = true;
1930
- }
1931
- const ffmpegCodec = (0, codec_registry_1.getFFmpegVideoDecoder)(config.codec);
1932
- const codecParams = { codec: ffmpegCodec };
1933
- if (config.codec.startsWith("avc1.")) {
1934
- const avcInfo = (0, codec_registry_1.parseAvcCodecString)(config.codec);
1935
- if (avcInfo) {
1936
- codecParams.profile = avcInfo.profile;
1937
- codecParams.level = avcInfo.level;
1938
- }
1939
- }
1940
- if (config.codedWidth)
1941
- codecParams.width = config.codedWidth;
1942
- if (config.codedHeight)
1943
- codecParams.height = config.codedHeight;
1944
- if (config.description) {
1945
- let desc;
1946
- if (config.description instanceof ArrayBuffer) {
1947
- desc = new Uint8Array(config.description);
1948
- } else {
1949
- desc = new Uint8Array(config.description.buffer, config.description.byteOffset, config.description.byteLength);
1950
- }
1951
- codecParams.extradata = Buffer.from(desc);
1952
- }
1953
- this._native.configure(codecParams);
1954
- this._config = config;
1955
- this._state = "configured";
1956
- }
1957
- decode(chunk) {
1958
- if (this._state !== "configured") {
1959
- throw new types_1.DOMException("Decoder is not configured", "InvalidStateError");
1960
- }
1961
- const data = new Uint8Array(chunk.byteLength);
1962
- chunk.copyTo(data);
1963
- this._decodeQueueSize++;
1964
- this._pendingCallbacks++;
1965
- this._native.decode(Buffer.from(data), chunk.type === "key", chunk.timestamp, chunk.duration ?? 0);
1966
- setImmediate(() => {
1967
- this._pendingCallbacks--;
1968
- this._decodeQueueSize = Math.max(0, this._decodeQueueSize - 1);
1969
- this._dispatchEvent("dequeue");
1970
- });
1971
- }
1972
- async flush() {
1973
- if (this._state !== "configured") {
1974
- throw new types_1.DOMException("Decoder is not configured", "InvalidStateError");
1975
- }
1976
- return new Promise((resolve, reject) => {
1977
- this._native.flush(async (err) => {
1978
- if (err) {
1979
- reject(new types_1.DOMException(err.message, "EncodingError"));
1980
- } else {
1981
- while (this._pendingCallbacks > 0) {
1982
- await new Promise((r) => setImmediate(r));
1983
- }
1984
- resolve();
1985
- }
1986
- });
1987
- });
1988
- }
1989
- reset() {
1990
- if (this._state === "closed") {
1991
- throw new types_1.DOMException("Decoder is closed", "InvalidStateError");
1992
- }
1993
- if (this._native) {
1994
- this._native.reset();
1995
- }
1996
- this._decodeQueueSize = 0;
1997
- this._state = "unconfigured";
1998
- this._config = null;
1999
- }
2000
- close() {
2001
- if (this._state === "closed")
2002
- return;
2003
- if (this._native) {
2004
- this._native.close();
2005
- }
2006
- this._state = "closed";
2007
- this._decodeQueueSize = 0;
2008
- this._config = null;
2009
- }
2010
- _onFrame(nativeFrame, timestamp, duration) {
2011
- const width = nativeFrame.width;
2012
- const height = nativeFrame.height;
2013
- const format = nativeFrame.format || "I420";
2014
- const size = nativeFrame.allocationSize();
2015
- const buffer = Buffer.alloc(size);
2016
- nativeFrame.copyTo(buffer);
2017
- try {
2018
- const frame = new VideoFrame_1.VideoFrame(buffer, {
2019
- format,
2020
- codedWidth: width,
2021
- codedHeight: height,
2022
- timestamp,
2023
- duration: duration > 0 ? duration : void 0
2024
- });
2025
- this._outputCallback(frame);
2026
- } catch (e) {
2027
- console.error("VideoDecoder output callback error:", e);
2028
- }
2029
- }
2030
- _onError(message) {
2031
- try {
2032
- this._errorCallback(new types_1.DOMException(message, "EncodingError"));
2033
- } catch (e) {
2034
- }
2035
- }
2036
- };
2037
- exports.VideoDecoder = VideoDecoder;
2038
- }
2039
- });
2040
-
2041
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/AudioEncoder.js
2042
- var require_AudioEncoder = __commonJS({
2043
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/AudioEncoder.js"(exports) {
2044
- "use strict";
2045
- Object.defineProperty(exports, "__esModule", { value: true });
2046
- exports.AudioEncoder = void 0;
2047
- var EncodedAudioChunk_1 = require_EncodedAudioChunk();
2048
- var codec_registry_1 = require_codec_registry();
2049
- var types_1 = require_types();
2050
- var native_1 = require_native();
2051
- var AudioEncoder = class {
2052
- static async isConfigSupported(config) {
2053
- const supported = (0, codec_registry_1.isAudioCodecSupported)(config.codec) && config.sampleRate > 0 && config.numberOfChannels > 0;
2054
- return { supported, config };
2055
- }
2056
- constructor(init) {
2057
- this._state = "unconfigured";
2058
- this._encodeQueueSize = 0;
2059
- this._pendingCallbacks = 0;
2060
- this._config = null;
2061
- this._sentDecoderConfig = false;
2062
- this._listeners = /* @__PURE__ */ new Map();
2063
- this._ondequeue = null;
2064
- if (!init.output || typeof init.output !== "function") {
2065
- throw new TypeError("output callback is required");
2066
- }
2067
- if (!init.error || typeof init.error !== "function") {
2068
- throw new TypeError("error callback is required");
2069
- }
2070
- this._outputCallback = init.output;
2071
- this._errorCallback = init.error;
2072
- if (native_1.native) {
2073
- this._native = new native_1.native.AudioEncoderNative(this._onChunk.bind(this), this._onError.bind(this));
2074
- }
2075
- }
2076
- get state() {
2077
- return this._state;
2078
- }
2079
- get encodeQueueSize() {
2080
- return this._encodeQueueSize;
2081
- }
2082
- /**
2083
- * Event handler for dequeue events
2084
- */
2085
- get ondequeue() {
2086
- return this._ondequeue;
2087
- }
2088
- set ondequeue(handler) {
2089
- this._ondequeue = handler;
2090
- }
2091
- /**
2092
- * Minimal EventTarget-style API for 'dequeue' events, mirroring VideoEncoder.
2093
- */
2094
- addEventListener(type, listener, options) {
2095
- if (typeof listener !== "function")
2096
- return;
2097
- const once = !!(options && options.once);
2098
- const wrapper = once ? () => {
2099
- this.removeEventListener(type, wrapper);
2100
- listener();
2101
- } : listener;
2102
- let set = this._listeners.get(type);
2103
- if (!set) {
2104
- set = /* @__PURE__ */ new Set();
2105
- this._listeners.set(type, set);
2106
- }
2107
- set.add(wrapper);
2108
- }
2109
- removeEventListener(type, listener) {
2110
- const set = this._listeners.get(type);
2111
- if (!set)
2112
- return;
2113
- if (set.has(listener)) {
2114
- set.delete(listener);
2115
- }
2116
- if (set.size === 0) {
2117
- this._listeners.delete(type);
2118
- }
2119
- }
2120
- _dispatchEvent(type) {
2121
- if (type === "dequeue" && this._ondequeue) {
2122
- try {
2123
- this._ondequeue(new Event("dequeue"));
2124
- } catch {
2125
- }
2126
- }
2127
- const set = this._listeners.get(type);
2128
- if (!set)
2129
- return;
2130
- for (const listener of Array.from(set)) {
2131
- try {
2132
- listener();
2133
- } catch {
2134
- }
2135
- }
2136
- }
2137
- configure(config) {
2138
- if (this._state === "closed") {
2139
- throw new types_1.DOMException("Encoder is closed", "InvalidStateError");
2140
- }
2141
- if (!(0, codec_registry_1.isAudioCodecSupported)(config.codec)) {
2142
- throw new types_1.DOMException(`Unsupported codec: ${config.codec}`, "NotSupportedError");
2143
- }
2144
- if (!native_1.native) {
2145
- throw new types_1.DOMException("Native addon not available", "NotSupportedError");
2146
- }
2147
- if (config.sampleRate <= 0 || config.numberOfChannels <= 0) {
2148
- throw new types_1.DOMException("Invalid audio parameters", "NotSupportedError");
2149
- }
2150
- const ffmpegCodec = (0, codec_registry_1.getFFmpegAudioCodec)(config.codec);
2151
- const codecParams = {
2152
- codec: ffmpegCodec,
2153
- sampleRate: config.sampleRate,
2154
- channels: config.numberOfChannels
2155
- };
2156
- if (config.bitrate)
2157
- codecParams.bitrate = config.bitrate;
2158
- this._native.configure(codecParams);
2159
- this._config = config;
2160
- this._state = "configured";
2161
- this._sentDecoderConfig = false;
2162
- }
2163
- encode(data) {
2164
- if (this._state !== "configured") {
2165
- throw new types_1.DOMException("Encoder is not configured", "InvalidStateError");
2166
- }
2167
- const bufferSize = data.allocationSize({ planeIndex: 0 });
2168
- const buffer = new ArrayBuffer(bufferSize);
2169
- data.copyTo(buffer, { planeIndex: 0 });
2170
- this._encodeQueueSize++;
2171
- this._pendingCallbacks++;
2172
- this._native.encode(new Float32Array(buffer), data.format, data.sampleRate, data.numberOfFrames, data.numberOfChannels, data.timestamp);
2173
- setImmediate(() => {
2174
- this._pendingCallbacks--;
2175
- this._encodeQueueSize = Math.max(0, this._encodeQueueSize - 1);
2176
- this._dispatchEvent("dequeue");
2177
- });
2178
- }
2179
- async flush() {
2180
- if (this._state !== "configured") {
2181
- throw new types_1.DOMException("Encoder is not configured", "InvalidStateError");
2182
- }
2183
- return new Promise((resolve, reject) => {
2184
- this._native.flush(async (err) => {
2185
- if (err) {
2186
- reject(new types_1.DOMException(err.message, "EncodingError"));
2187
- } else {
2188
- while (this._pendingCallbacks > 0) {
2189
- await new Promise((r) => setImmediate(r));
2190
- }
2191
- resolve();
2192
- }
2193
- });
2194
- });
2195
- }
2196
- reset() {
2197
- if (this._state === "closed") {
2198
- throw new types_1.DOMException("Encoder is closed", "InvalidStateError");
2199
- }
2200
- if (this._native) {
2201
- this._native.reset();
2202
- }
2203
- this._encodeQueueSize = 0;
2204
- this._state = "unconfigured";
2205
- this._sentDecoderConfig = false;
2206
- this._config = null;
2207
- }
2208
- close() {
2209
- if (this._state === "closed")
2210
- return;
2211
- if (this._native) {
2212
- this._native.close();
2213
- }
2214
- this._state = "closed";
2215
- this._encodeQueueSize = 0;
2216
- this._config = null;
2217
- }
2218
- _onChunk(data, timestamp, duration, extradata) {
2219
- const chunk = new EncodedAudioChunk_1.EncodedAudioChunk({
2220
- type: "key",
2221
- // Audio frames are typically all keyframes
2222
- timestamp,
2223
- duration: duration > 0 ? duration : void 0,
2224
- data
2225
- });
2226
- let metadata;
2227
- if (!this._sentDecoderConfig && this._config) {
2228
- metadata = {
2229
- decoderConfig: {
2230
- codec: this._config.codec,
2231
- sampleRate: this._config.sampleRate,
2232
- numberOfChannels: this._config.numberOfChannels,
2233
- description: extradata ? new Uint8Array(extradata).buffer : void 0
2234
- }
2235
- };
2236
- this._sentDecoderConfig = true;
2237
- }
2238
- try {
2239
- this._outputCallback(chunk, metadata);
2240
- } catch (e) {
2241
- }
2242
- }
2243
- _onError(message) {
2244
- try {
2245
- this._errorCallback(new types_1.DOMException(message, "EncodingError"));
2246
- } catch (e) {
2247
- }
2248
- }
2249
- };
2250
- exports.AudioEncoder = AudioEncoder;
2251
- }
2252
- });
2253
-
2254
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/AudioDecoder.js
2255
- var require_AudioDecoder = __commonJS({
2256
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/AudioDecoder.js"(exports) {
2257
- "use strict";
2258
- Object.defineProperty(exports, "__esModule", { value: true });
2259
- exports.AudioDecoder = void 0;
2260
- var AudioData_1 = require_AudioData();
2261
- var codec_registry_1 = require_codec_registry();
2262
- var types_1 = require_types();
2263
- var native_1 = require_native();
2264
- var AudioDecoder = class {
2265
- static async isConfigSupported(config) {
2266
- const supported = (0, codec_registry_1.isAudioCodecSupported)(config.codec);
2267
- return { supported, config };
2268
- }
2269
- constructor(init) {
2270
- this._state = "unconfigured";
2271
- this._decodeQueueSize = 0;
2272
- this._config = null;
2273
- this._ondequeue = null;
2274
- this._listeners = /* @__PURE__ */ new Map();
2275
- if (!init.output || typeof init.output !== "function") {
2276
- throw new TypeError("output callback is required");
2277
- }
2278
- if (!init.error || typeof init.error !== "function") {
2279
- throw new TypeError("error callback is required");
2280
- }
2281
- this._outputCallback = init.output;
2282
- this._errorCallback = init.error;
2283
- if (native_1.native) {
2284
- this._native = new native_1.native.AudioDecoderNative(this._onData.bind(this), this._onError.bind(this));
2285
- }
2286
- }
2287
- get state() {
2288
- return this._state;
2289
- }
2290
- get decodeQueueSize() {
2291
- return this._decodeQueueSize;
2292
- }
2293
- /**
2294
- * Event handler for dequeue events
2295
- */
2296
- get ondequeue() {
2297
- return this._ondequeue;
2298
- }
2299
- set ondequeue(handler) {
2300
- this._ondequeue = handler;
2301
- }
2302
- /**
2303
- * Minimal EventTarget-style API for 'dequeue' events.
2304
- * Enables compatibility with MediaBunny and browser WebCodecs code.
2305
- */
2306
- addEventListener(type, listener, options) {
2307
- if (typeof listener !== "function")
2308
- return;
2309
- const once = !!(options && options.once);
2310
- const wrapper = once ? () => {
2311
- this.removeEventListener(type, wrapper);
2312
- listener();
2313
- } : listener;
2314
- let set = this._listeners.get(type);
2315
- if (!set) {
2316
- set = /* @__PURE__ */ new Set();
2317
- this._listeners.set(type, set);
2318
- }
2319
- set.add(wrapper);
2320
- }
2321
- removeEventListener(type, listener) {
2322
- const set = this._listeners.get(type);
2323
- if (!set)
2324
- return;
2325
- if (set.has(listener)) {
2326
- set.delete(listener);
2327
- }
2328
- if (set.size === 0) {
2329
- this._listeners.delete(type);
2330
- }
2331
- }
2332
- _dispatchEvent(type) {
2333
- if (type === "dequeue" && this._ondequeue) {
2334
- try {
2335
- this._ondequeue(new Event("dequeue"));
2336
- } catch {
2337
- }
2338
- }
2339
- const set = this._listeners.get(type);
2340
- if (set) {
2341
- for (const listener of set) {
2342
- try {
2343
- listener();
2344
- } catch {
2345
- }
2346
- }
2347
- }
2348
- }
2349
- configure(config) {
2350
- if (this._state === "closed") {
2351
- throw new types_1.DOMException("Decoder is closed", "InvalidStateError");
2352
- }
2353
- if (!(0, codec_registry_1.isAudioCodecSupported)(config.codec)) {
2354
- throw new types_1.DOMException(`Unsupported codec: ${config.codec}`, "NotSupportedError");
2355
- }
2356
- if (!native_1.native) {
2357
- throw new types_1.DOMException("Native addon not available", "NotSupportedError");
2358
- }
2359
- const ffmpegCodec = (0, codec_registry_1.getFFmpegAudioDecoder)(config.codec);
2360
- const codecParams = {
2361
- codec: ffmpegCodec,
2362
- sampleRate: config.sampleRate,
2363
- channels: config.numberOfChannels
2364
- };
2365
- if (config.description) {
2366
- let desc;
2367
- if (config.description instanceof ArrayBuffer) {
2368
- desc = new Uint8Array(config.description);
2369
- } else {
2370
- desc = new Uint8Array(config.description.buffer, config.description.byteOffset, config.description.byteLength);
2371
- }
2372
- codecParams.extradata = Buffer.from(desc);
2373
- }
2374
- this._native.configure(codecParams);
2375
- this._config = config;
2376
- this._state = "configured";
2377
- }
2378
- decode(chunk) {
2379
- if (this._state !== "configured") {
2380
- throw new types_1.DOMException("Decoder is not configured", "InvalidStateError");
2381
- }
2382
- const data = new Uint8Array(chunk.byteLength);
2383
- chunk.copyTo(data);
2384
- this._decodeQueueSize++;
2385
- this._native.decode(Buffer.from(data), chunk.type === "key", chunk.timestamp, chunk.duration ?? 0);
2386
- }
2387
- async flush() {
2388
- if (this._state !== "configured") {
2389
- throw new types_1.DOMException("Decoder is not configured", "InvalidStateError");
2390
- }
2391
- return new Promise((resolve, reject) => {
2392
- this._native.flush((err) => {
2393
- if (err) {
2394
- reject(new types_1.DOMException(err.message, "EncodingError"));
2395
- } else {
2396
- resolve();
2397
- }
2398
- });
2399
- });
2400
- }
2401
- reset() {
2402
- if (this._state === "closed") {
2403
- throw new types_1.DOMException("Decoder is closed", "InvalidStateError");
2404
- }
2405
- if (this._native) {
2406
- this._native.reset();
2407
- }
2408
- this._decodeQueueSize = 0;
2409
- this._state = "unconfigured";
2410
- this._config = null;
2411
- }
2412
- close() {
2413
- if (this._state === "closed")
2414
- return;
2415
- if (this._native) {
2416
- this._native.close();
2417
- }
2418
- this._state = "closed";
2419
- this._decodeQueueSize = 0;
2420
- this._config = null;
2421
- }
2422
- _onData(buffer, format, sampleRate, numberOfFrames, numberOfChannels, timestamp) {
2423
- const bufferCopy = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength).slice();
2424
- setImmediate(() => {
2425
- this._decodeQueueSize = Math.max(0, this._decodeQueueSize - 1);
2426
- this._dispatchEvent("dequeue");
2427
- try {
2428
- const audioData = new AudioData_1.AudioData({
2429
- format,
2430
- sampleRate,
2431
- numberOfFrames,
2432
- numberOfChannels,
2433
- timestamp,
2434
- data: bufferCopy.buffer
2435
- });
2436
- this._outputCallback(audioData);
2437
- } catch (e) {
2438
- console.error("AudioDecoder output callback error:", e);
2439
- }
2440
- });
2441
- }
2442
- _onError(message) {
2443
- try {
2444
- this._errorCallback(new types_1.DOMException(message, "EncodingError"));
2445
- } catch (e) {
2446
- }
2447
- }
2448
- };
2449
- exports.AudioDecoder = AudioDecoder;
2450
- }
2451
- });
2452
-
2453
- // ../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/index.js
2454
- var require_dist = __commonJS({
2455
- "../../node_modules/.pnpm/node-webcodecs@1.0.0/node_modules/node-webcodecs/dist/index.js"(exports) {
2456
- Object.defineProperty(exports, "__esModule", { value: true });
2457
- exports.DOMRectReadOnly = exports.parseVp9CodecString = exports.parseAacCodecString = exports.parseAvcCodecString = exports.getFFmpegAudioCodec = exports.getFFmpegVideoCodec = exports.isAudioCodecSupported = exports.isVideoCodecSupported = exports.AudioDecoder = exports.AudioEncoder = exports.VideoDecoder = exports.VideoEncoder = exports.ImageDecoder = exports.VideoColorSpace = exports.EncodedAudioChunk = exports.EncodedVideoChunk = exports.AudioData = exports.VideoFrame = void 0;
2458
- exports.getFFmpegVersion = getFFmpegVersion;
2459
- exports.listCodecs = listCodecs;
2460
- exports.hasCodec = hasCodec;
2461
- exports.isNativeAvailable = isNativeAvailable;
2462
- var VideoFrame_1 = require_VideoFrame();
2463
- Object.defineProperty(exports, "VideoFrame", { enumerable: true, get: function() {
2464
- return VideoFrame_1.VideoFrame;
2465
- } });
2466
- var AudioData_1 = require_AudioData();
2467
- Object.defineProperty(exports, "AudioData", { enumerable: true, get: function() {
2468
- return AudioData_1.AudioData;
2469
- } });
2470
- var EncodedVideoChunk_1 = require_EncodedVideoChunk();
2471
- Object.defineProperty(exports, "EncodedVideoChunk", { enumerable: true, get: function() {
2472
- return EncodedVideoChunk_1.EncodedVideoChunk;
2473
- } });
2474
- var EncodedAudioChunk_1 = require_EncodedAudioChunk();
2475
- Object.defineProperty(exports, "EncodedAudioChunk", { enumerable: true, get: function() {
2476
- return EncodedAudioChunk_1.EncodedAudioChunk;
2477
- } });
2478
- var VideoColorSpace_1 = require_VideoColorSpace();
2479
- Object.defineProperty(exports, "VideoColorSpace", { enumerable: true, get: function() {
2480
- return VideoColorSpace_1.VideoColorSpace;
2481
- } });
2482
- var ImageDecoder_1 = require_ImageDecoder();
2483
- Object.defineProperty(exports, "ImageDecoder", { enumerable: true, get: function() {
2484
- return ImageDecoder_1.ImageDecoder;
2485
- } });
2486
- var VideoEncoder_1 = require_VideoEncoder();
2487
- Object.defineProperty(exports, "VideoEncoder", { enumerable: true, get: function() {
2488
- return VideoEncoder_1.VideoEncoder;
2489
- } });
2490
- var VideoDecoder_1 = require_VideoDecoder();
2491
- Object.defineProperty(exports, "VideoDecoder", { enumerable: true, get: function() {
2492
- return VideoDecoder_1.VideoDecoder;
2493
- } });
2494
- var AudioEncoder_1 = require_AudioEncoder();
2495
- Object.defineProperty(exports, "AudioEncoder", { enumerable: true, get: function() {
2496
- return AudioEncoder_1.AudioEncoder;
2497
- } });
2498
- var AudioDecoder_1 = require_AudioDecoder();
2499
- Object.defineProperty(exports, "AudioDecoder", { enumerable: true, get: function() {
2500
- return AudioDecoder_1.AudioDecoder;
2501
- } });
2502
- var codec_registry_1 = require_codec_registry();
2503
- Object.defineProperty(exports, "isVideoCodecSupported", { enumerable: true, get: function() {
2504
- return codec_registry_1.isVideoCodecSupported;
2505
- } });
2506
- Object.defineProperty(exports, "isAudioCodecSupported", { enumerable: true, get: function() {
2507
- return codec_registry_1.isAudioCodecSupported;
2508
- } });
2509
- Object.defineProperty(exports, "getFFmpegVideoCodec", { enumerable: true, get: function() {
2510
- return codec_registry_1.getFFmpegVideoCodec;
2511
- } });
2512
- Object.defineProperty(exports, "getFFmpegAudioCodec", { enumerable: true, get: function() {
2513
- return codec_registry_1.getFFmpegAudioCodec;
2514
- } });
2515
- Object.defineProperty(exports, "parseAvcCodecString", { enumerable: true, get: function() {
2516
- return codec_registry_1.parseAvcCodecString;
2517
- } });
2518
- Object.defineProperty(exports, "parseAacCodecString", { enumerable: true, get: function() {
2519
- return codec_registry_1.parseAacCodecString;
2520
- } });
2521
- Object.defineProperty(exports, "parseVp9CodecString", { enumerable: true, get: function() {
2522
- return codec_registry_1.parseVp9CodecString;
2523
- } });
2524
- var types_1 = require_types();
2525
- Object.defineProperty(exports, "DOMRectReadOnly", { enumerable: true, get: function() {
2526
- return types_1.DOMRectReadOnly;
2527
- } });
2528
- var native_1 = require_native();
2529
- function getFFmpegVersion() {
2530
- if (native_1.native && native_1.native.getFFmpegVersion) {
2531
- return native_1.native.getFFmpegVersion();
2532
- }
2533
- return null;
2534
- }
2535
- function listCodecs() {
2536
- if (native_1.native && native_1.native.listCodecs) {
2537
- return native_1.native.listCodecs();
2538
- }
2539
- return null;
2540
- }
2541
- function hasCodec(codecName, type) {
2542
- if (native_1.native && native_1.native.hasCodec) {
2543
- return native_1.native.hasCodec(codecName, type);
2544
- }
2545
- return false;
2546
- }
2547
- function isNativeAvailable() {
2548
- return native_1.native !== null;
2549
- }
2550
- }
2551
- });
2552
- export default require_dist();