mediabunny 1.31.0 → 1.32.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/dist/bundles/mediabunny.cjs +18 -8
- package/dist/bundles/mediabunny.min.cjs +7 -7
- package/dist/bundles/mediabunny.min.mjs +8 -8
- package/dist/bundles/mediabunny.mjs +18 -8
- package/dist/mediabunny.d.ts +2 -0
- package/dist/modules/src/conversion.d.ts.map +1 -1
- package/dist/modules/src/conversion.js +4 -1
- package/dist/modules/src/input-format.d.ts.map +1 -1
- package/dist/modules/src/input-format.js +15 -8
- package/dist/modules/src/source.d.ts +2 -0
- package/dist/modules/src/source.d.ts.map +1 -1
- package/dist/modules/src/source.js +7 -3
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/conversion.ts +5 -1
- package/src/input-format.ts +17 -7
- package/src/source.ts +11 -3
|
@@ -16372,9 +16372,6 @@ var Mediabunny = (() => {
|
|
|
16372
16372
|
var Mp3InputFormat = class extends InputFormat {
|
|
16373
16373
|
/** @internal */
|
|
16374
16374
|
async _canReadInput(input) {
|
|
16375
|
-
let slice = input._reader.requestSlice(0, 10);
|
|
16376
|
-
if (slice instanceof Promise) slice = await slice;
|
|
16377
|
-
if (!slice) return false;
|
|
16378
16375
|
let currentPos = 0;
|
|
16379
16376
|
while (true) {
|
|
16380
16377
|
let slice2 = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
@@ -16390,12 +16387,21 @@ var Mediabunny = (() => {
|
|
|
16390
16387
|
if (!firstResult) {
|
|
16391
16388
|
return false;
|
|
16392
16389
|
}
|
|
16390
|
+
const firstHeader = firstResult.header;
|
|
16391
|
+
const xingOffset = getXingOffset(firstHeader.mpegVersionId, firstHeader.channel);
|
|
16392
|
+
let slice = input._reader.requestSlice(firstResult.startPos + xingOffset, 4);
|
|
16393
|
+
if (slice instanceof Promise) slice = await slice;
|
|
16394
|
+
if (!slice) return false;
|
|
16395
|
+
const word = readU32Be(slice);
|
|
16396
|
+
const isXing = word === XING || word === INFO;
|
|
16397
|
+
if (isXing) {
|
|
16398
|
+
return true;
|
|
16399
|
+
}
|
|
16393
16400
|
currentPos = firstResult.startPos + firstResult.header.totalSize;
|
|
16394
16401
|
const secondResult = await readNextMp3FrameHeader(input._reader, currentPos, currentPos + FRAME_HEADER_SIZE);
|
|
16395
16402
|
if (!secondResult) {
|
|
16396
16403
|
return false;
|
|
16397
16404
|
}
|
|
16398
|
-
const firstHeader = firstResult.header;
|
|
16399
16405
|
const secondHeader = secondResult.header;
|
|
16400
16406
|
if (firstHeader.channel !== secondHeader.channel || firstHeader.sampleRate !== secondHeader.sampleRate) {
|
|
16401
16407
|
return false;
|
|
@@ -16765,6 +16771,9 @@ var Mediabunny = (() => {
|
|
|
16765
16771
|
if (options.maxCacheSize !== void 0 && (!isNumber(options.maxCacheSize) || options.maxCacheSize < 0)) {
|
|
16766
16772
|
throw new TypeError("options.maxCacheSize, when provided, must be a non-negative number.");
|
|
16767
16773
|
}
|
|
16774
|
+
if (options.parallelism !== void 0 && (!Number.isInteger(options.parallelism) || options.parallelism < 1)) {
|
|
16775
|
+
throw new TypeError("options.parallelism, when provided, must be a positive number.");
|
|
16776
|
+
}
|
|
16768
16777
|
if (options.fetchFn !== void 0 && typeof options.fetchFn !== "function") {
|
|
16769
16778
|
throw new TypeError("options.fetchFn, when provided, must be a function.");
|
|
16770
16779
|
}
|
|
@@ -16774,11 +16783,10 @@ var Mediabunny = (() => {
|
|
|
16774
16783
|
this._url = url2;
|
|
16775
16784
|
this._options = options;
|
|
16776
16785
|
this._getRetryDelay = options.getRetryDelay ?? DEFAULT_RETRY_DELAY;
|
|
16786
|
+
const DEFAULT_PARALLELISM = 2;
|
|
16777
16787
|
this._orchestrator = new ReadOrchestrator({
|
|
16778
16788
|
maxCacheSize: options.maxCacheSize ?? 64 * 2 ** 20,
|
|
16779
|
-
|
|
16780
|
-
// also happen
|
|
16781
|
-
maxWorkerCount: 2,
|
|
16789
|
+
maxWorkerCount: options.parallelism ?? DEFAULT_PARALLELISM,
|
|
16782
16790
|
runWorker: this._runWorker.bind(this),
|
|
16783
16791
|
prefetchProfile: PREFETCH_PROFILES.network
|
|
16784
16792
|
});
|
|
@@ -27742,9 +27750,11 @@ The @mediabunny/mp3-encoder extension package provides support for encoding MP3.
|
|
|
27742
27750
|
}
|
|
27743
27751
|
this._executed = true;
|
|
27744
27752
|
if (this.onProgress) {
|
|
27753
|
+
const durationPromises = this.utilizedTracks.map((x) => x.computeDuration());
|
|
27754
|
+
const duration = Math.max(0, ...await Promise.all(durationPromises));
|
|
27745
27755
|
this._computeProgress = true;
|
|
27746
27756
|
this._totalDuration = Math.min(
|
|
27747
|
-
|
|
27757
|
+
duration - this._startTimestamp,
|
|
27748
27758
|
this._endTimestamp - this._startTimestamp
|
|
27749
27759
|
);
|
|
27750
27760
|
for (const track of this.utilizedTracks) {
|