mediabunny 1.14.3 → 1.14.4
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 -15
- package/dist/bundles/mediabunny.min.cjs +3 -3
- package/dist/bundles/mediabunny.min.mjs +3 -3
- package/dist/bundles/mediabunny.mjs +18 -15
- package/dist/modules/src/codec.d.ts +1 -1
- package/dist/modules/src/codec.d.ts.map +1 -1
- package/dist/modules/src/codec.js +1 -1
- package/dist/modules/src/conversion.d.ts +3 -5
- package/dist/modules/src/conversion.d.ts.map +1 -1
- package/dist/modules/src/conversion.js +13 -10
- package/dist/modules/src/isobmff/isobmff-demuxer.d.ts.map +1 -1
- package/dist/modules/src/isobmff/isobmff-demuxer.js +5 -2
- package/dist/modules/src/matroska/matroska-demuxer.d.ts.map +1 -1
- package/dist/modules/src/matroska/matroska-demuxer.js +2 -1
- package/dist/modules/src/matroska/matroska-muxer.js +2 -2
- package/dist/modules/src/ogg/ogg-demuxer.js +3 -3
- package/dist/modules/src/ogg/ogg-muxer.js +2 -2
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/codec.ts +1 -1
- package/src/conversion.ts +17 -17
- package/src/isobmff/isobmff-demuxer.ts +6 -1
- package/src/matroska/matroska-demuxer.ts +2 -0
- package/src/matroska/matroska-muxer.ts +2 -2
- package/src/ogg/ogg-demuxer.ts +3 -3
- package/src/ogg/ogg-muxer.ts +2 -2
|
@@ -1239,7 +1239,7 @@ var Mediabunny = (() => {
|
|
|
1239
1239
|
numberOfChannels
|
|
1240
1240
|
};
|
|
1241
1241
|
};
|
|
1242
|
-
var
|
|
1242
|
+
var OPUS_SAMPLE_RATE = 48e3;
|
|
1243
1243
|
var PCM_CODEC_REGEX = /^pcm-([usf])(\d+)+(be)?$/;
|
|
1244
1244
|
var parsePcmCodec = (codec) => {
|
|
1245
1245
|
assert(PCM_AUDIO_CODECS.includes(codec));
|
|
@@ -6391,7 +6391,7 @@ var Mediabunny = (() => {
|
|
|
6391
6391
|
if (description) {
|
|
6392
6392
|
const bytes2 = toUint8Array(description);
|
|
6393
6393
|
const header = parseOpusIdentificationHeader(bytes2);
|
|
6394
|
-
seekPreRollNs = Math.round(1e9 * (header.preSkip /
|
|
6394
|
+
seekPreRollNs = Math.round(1e9 * (header.preSkip / OPUS_SAMPLE_RATE));
|
|
6395
6395
|
}
|
|
6396
6396
|
}
|
|
6397
6397
|
tracksElement.data.push({ id: 174 /* TrackEntry */, data: [
|
|
@@ -8513,7 +8513,7 @@ ${cue.notes ?? ""}`;
|
|
|
8513
8513
|
const newTrackData = {
|
|
8514
8514
|
track,
|
|
8515
8515
|
serialNumber,
|
|
8516
|
-
internalSampleRate: track.source._codec === "opus" ?
|
|
8516
|
+
internalSampleRate: track.source._codec === "opus" ? OPUS_SAMPLE_RATE : meta2.decoderConfig.sampleRate,
|
|
8517
8517
|
codecInfo: {
|
|
8518
8518
|
codec: track.source._codec,
|
|
8519
8519
|
vorbisInfo: null,
|
|
@@ -16265,6 +16265,9 @@ ${cue.notes ?? ""}`;
|
|
|
16265
16265
|
}
|
|
16266
16266
|
}
|
|
16267
16267
|
}
|
|
16268
|
+
if (track.info.codec === "opus") {
|
|
16269
|
+
sampleRate = OPUS_SAMPLE_RATE;
|
|
16270
|
+
}
|
|
16268
16271
|
track.info.numberOfChannels = channelCount;
|
|
16269
16272
|
track.info.sampleRate = sampleRate;
|
|
16270
16273
|
if (lowercaseBoxName === "twos") {
|
|
@@ -16603,7 +16606,6 @@ ${cue.notes ?? ""}`;
|
|
|
16603
16606
|
description.set(channelMappingTable, 19);
|
|
16604
16607
|
track.info.codecDescription = description;
|
|
16605
16608
|
track.info.numberOfChannels = outputChannelCount;
|
|
16606
|
-
track.info.sampleRate = inputSampleRate;
|
|
16607
16609
|
}
|
|
16608
16610
|
;
|
|
16609
16611
|
break;
|
|
@@ -18684,6 +18686,7 @@ ${cue.notes ?? ""}`;
|
|
|
18684
18686
|
} else if (codecIdWithoutSuffix === CODEC_STRING_MAP.opus) {
|
|
18685
18687
|
this.currentTrack.info.codec = "opus";
|
|
18686
18688
|
this.currentTrack.info.codecDescription = this.currentTrack.codecPrivate;
|
|
18689
|
+
this.currentTrack.info.sampleRate = OPUS_SAMPLE_RATE;
|
|
18687
18690
|
} else if (codecIdWithoutSuffix === CODEC_STRING_MAP.vorbis) {
|
|
18688
18691
|
this.currentTrack.info.codec = "vorbis";
|
|
18689
18692
|
this.currentTrack.info.codecDescription = this.currentTrack.codecPrivate;
|
|
@@ -20218,7 +20221,7 @@ ${cue.notes ?? ""}`;
|
|
|
20218
20221
|
bitstream.lastMetadataPacket = secondPacket;
|
|
20219
20222
|
const header = parseOpusIdentificationHeader(firstPacket.data);
|
|
20220
20223
|
bitstream.numberOfChannels = header.outputChannelCount;
|
|
20221
|
-
bitstream.sampleRate =
|
|
20224
|
+
bitstream.sampleRate = OPUS_SAMPLE_RATE;
|
|
20222
20225
|
bitstream.codecInfo.opusInfo = {
|
|
20223
20226
|
preSkip: header.preSkip
|
|
20224
20227
|
};
|
|
@@ -20506,7 +20509,7 @@ ${cue.notes ?? ""}`;
|
|
|
20506
20509
|
this.encodedPacketToMetadata = /* @__PURE__ */ new WeakMap();
|
|
20507
20510
|
this.sequentialScanCache = [];
|
|
20508
20511
|
this.sequentialScanMutex = new AsyncMutex();
|
|
20509
|
-
this.internalSampleRate = bitstream.codecInfo.codec === "opus" ?
|
|
20512
|
+
this.internalSampleRate = bitstream.codecInfo.codec === "opus" ? OPUS_SAMPLE_RATE : bitstream.sampleRate;
|
|
20510
20513
|
}
|
|
20511
20514
|
getId() {
|
|
20512
20515
|
return this.bitstream.serialNumber;
|
|
@@ -22281,8 +22284,6 @@ ${cue.notes ?? ""}`;
|
|
|
22281
22284
|
this._trackPromises.push((async () => {
|
|
22282
22285
|
await this._started;
|
|
22283
22286
|
const resampler = new AudioResampler({
|
|
22284
|
-
sourceNumberOfChannels: track.numberOfChannels,
|
|
22285
|
-
sourceSampleRate: track.sampleRate,
|
|
22286
22287
|
targetNumberOfChannels,
|
|
22287
22288
|
targetSampleRate,
|
|
22288
22289
|
startTime: this._startTimestamp,
|
|
@@ -22366,9 +22367,9 @@ ${cue.notes ?? ""}`;
|
|
|
22366
22367
|
};
|
|
22367
22368
|
var AudioResampler = class {
|
|
22368
22369
|
constructor(options) {
|
|
22369
|
-
this.sourceSampleRate =
|
|
22370
|
+
this.sourceSampleRate = null;
|
|
22371
|
+
this.sourceNumberOfChannels = null;
|
|
22370
22372
|
this.targetSampleRate = options.targetSampleRate;
|
|
22371
|
-
this.sourceNumberOfChannels = options.sourceNumberOfChannels;
|
|
22372
22373
|
this.targetNumberOfChannels = options.targetNumberOfChannels;
|
|
22373
22374
|
this.startTime = options.startTime;
|
|
22374
22375
|
this.endTime = options.endTime;
|
|
@@ -22378,13 +22379,12 @@ ${cue.notes ?? ""}`;
|
|
|
22378
22379
|
this.outputBuffer = new Float32Array(this.bufferSizeInSamples);
|
|
22379
22380
|
this.bufferStartFrame = 0;
|
|
22380
22381
|
this.maxWrittenFrame = -1;
|
|
22381
|
-
this.setupChannelMixer();
|
|
22382
|
-
this.tempSourceBuffer = new Float32Array(this.sourceSampleRate * this.sourceNumberOfChannels);
|
|
22383
22382
|
}
|
|
22384
22383
|
/**
|
|
22385
22384
|
* Sets up the channel mixer to handle up/downmixing in the case where input and output channel counts don't match.
|
|
22386
22385
|
*/
|
|
22387
|
-
|
|
22386
|
+
doChannelMixerSetup() {
|
|
22387
|
+
assert(this.sourceNumberOfChannels !== null);
|
|
22388
22388
|
const sourceNum = this.sourceNumberOfChannels;
|
|
22389
22389
|
const targetNum = this.targetNumberOfChannels;
|
|
22390
22390
|
if (sourceNum === 1 && targetNum === 2) {
|
|
@@ -22465,8 +22465,11 @@ ${cue.notes ?? ""}`;
|
|
|
22465
22465
|
}
|
|
22466
22466
|
}
|
|
22467
22467
|
async add(audioSample) {
|
|
22468
|
-
if (
|
|
22469
|
-
|
|
22468
|
+
if (this.sourceSampleRate === null) {
|
|
22469
|
+
this.sourceSampleRate = audioSample.sampleRate;
|
|
22470
|
+
this.sourceNumberOfChannels = audioSample.numberOfChannels;
|
|
22471
|
+
this.tempSourceBuffer = new Float32Array(this.sourceSampleRate * this.sourceNumberOfChannels);
|
|
22472
|
+
this.doChannelMixerSetup();
|
|
22470
22473
|
}
|
|
22471
22474
|
const requiredSamples = audioSample.numberOfFrames * audioSample.numberOfChannels;
|
|
22472
22475
|
this.ensureTempBufferSize(requiredSamples);
|