mediabunny 1.27.6 → 1.28.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 +31 -16
- package/dist/bundles/mediabunny.min.cjs +6 -6
- package/dist/bundles/mediabunny.min.mjs +6 -6
- package/dist/bundles/mediabunny.mjs +31 -16
- package/dist/mediabunny.d.ts +5 -0
- package/dist/modules/src/ogg/ogg-demuxer.d.ts.map +1 -1
- package/dist/modules/src/ogg/ogg-demuxer.js +3 -0
- package/dist/modules/src/ogg/ogg-muxer.d.ts +3 -2
- package/dist/modules/src/ogg/ogg-muxer.d.ts.map +1 -1
- package/dist/modules/src/ogg/ogg-muxer.js +26 -15
- package/dist/modules/src/output-format.d.ts +5 -0
- package/dist/modules/src/output-format.d.ts.map +1 -1
- package/dist/modules/src/output-format.js +4 -0
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/ogg/ogg-demuxer.ts +4 -0
- package/src/ogg/ogg-muxer.ts +34 -17
- package/src/output-format.ts +12 -0
|
@@ -13602,6 +13602,9 @@ var Mediabunny = (() => {
|
|
|
13602
13602
|
currentSegmentIndex = 0;
|
|
13603
13603
|
}
|
|
13604
13604
|
const totalPacketSize = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
13605
|
+
if (totalPacketSize === 0) {
|
|
13606
|
+
return null;
|
|
13607
|
+
}
|
|
13605
13608
|
const packetData = new Uint8Array(totalPacketSize);
|
|
13606
13609
|
let offset = 0;
|
|
13607
13610
|
for (let i = 0; i < chunks.length; i++) {
|
|
@@ -21403,7 +21406,8 @@ ${cue.notes ?? ""}`;
|
|
|
21403
21406
|
currentLacingValues: [],
|
|
21404
21407
|
currentPageData: [],
|
|
21405
21408
|
currentPageSize: 27,
|
|
21406
|
-
currentPageStartsWithFreshPacket: true
|
|
21409
|
+
currentPageStartsWithFreshPacket: true,
|
|
21410
|
+
currentPageStartTimestampInSamples: 0
|
|
21407
21411
|
};
|
|
21408
21412
|
this.queueHeaderPackets(newTrackData, meta);
|
|
21409
21413
|
this.trackDatas.push(newTrackData);
|
|
@@ -21454,18 +21458,18 @@ ${cue.notes ?? ""}`;
|
|
|
21454
21458
|
const commentHeader = createVorbisComments(commentHeaderHeader, this.output._metadataTags, true);
|
|
21455
21459
|
trackData.packetQueue.push({
|
|
21456
21460
|
data: identificationHeader,
|
|
21457
|
-
|
|
21458
|
-
|
|
21461
|
+
timestampInSamples: 0,
|
|
21462
|
+
durationInSamples: 0,
|
|
21459
21463
|
forcePageFlush: true
|
|
21460
21464
|
}, {
|
|
21461
21465
|
data: commentHeader,
|
|
21462
|
-
|
|
21463
|
-
|
|
21466
|
+
timestampInSamples: 0,
|
|
21467
|
+
durationInSamples: 0,
|
|
21464
21468
|
forcePageFlush: false
|
|
21465
21469
|
}, {
|
|
21466
21470
|
data: setupHeader,
|
|
21467
|
-
|
|
21468
|
-
|
|
21471
|
+
timestampInSamples: 0,
|
|
21472
|
+
durationInSamples: 0,
|
|
21469
21473
|
forcePageFlush: true
|
|
21470
21474
|
// The last header packet must flush the page
|
|
21471
21475
|
});
|
|
@@ -21490,13 +21494,13 @@ ${cue.notes ?? ""}`;
|
|
|
21490
21494
|
const commentHeader = createVorbisComments(commentHeaderHeader, this.output._metadataTags, true);
|
|
21491
21495
|
trackData.packetQueue.push({
|
|
21492
21496
|
data: identificationHeader,
|
|
21493
|
-
|
|
21494
|
-
|
|
21497
|
+
timestampInSamples: 0,
|
|
21498
|
+
durationInSamples: 0,
|
|
21495
21499
|
forcePageFlush: true
|
|
21496
21500
|
}, {
|
|
21497
21501
|
data: commentHeader,
|
|
21498
|
-
|
|
21499
|
-
|
|
21502
|
+
timestampInSamples: 0,
|
|
21503
|
+
durationInSamples: 0,
|
|
21500
21504
|
forcePageFlush: true
|
|
21501
21505
|
// The last header packet must flush the page
|
|
21502
21506
|
});
|
|
@@ -21520,8 +21524,8 @@ ${cue.notes ?? ""}`;
|
|
|
21520
21524
|
trackData.vorbisLastBlocksize = vorbisBlockSize;
|
|
21521
21525
|
trackData.packetQueue.push({
|
|
21522
21526
|
data: packet.data,
|
|
21523
|
-
|
|
21524
|
-
|
|
21527
|
+
timestampInSamples: currentTimestampInSamples,
|
|
21528
|
+
durationInSamples,
|
|
21525
21529
|
forcePageFlush: false
|
|
21526
21530
|
});
|
|
21527
21531
|
await this.interleavePages();
|
|
@@ -21564,9 +21568,9 @@ ${cue.notes ?? ""}`;
|
|
|
21564
21568
|
if (!isFinalCall && trackData.packetQueue.length <= 1 && !trackData.track.source._closed) {
|
|
21565
21569
|
break outer;
|
|
21566
21570
|
}
|
|
21567
|
-
if (trackData.packetQueue.length > 0 && trackData.packetQueue[0].
|
|
21571
|
+
if (trackData.packetQueue.length > 0 && trackData.packetQueue[0].timestampInSamples < minTimestamp) {
|
|
21568
21572
|
trackWithMinTimestamp = trackData;
|
|
21569
|
-
minTimestamp = trackData.packetQueue[0].
|
|
21573
|
+
minTimestamp = trackData.packetQueue[0].timestampInSamples;
|
|
21570
21574
|
}
|
|
21571
21575
|
}
|
|
21572
21576
|
if (!trackWithMinTimestamp) {
|
|
@@ -21581,6 +21585,13 @@ ${cue.notes ?? ""}`;
|
|
|
21581
21585
|
}
|
|
21582
21586
|
}
|
|
21583
21587
|
writePacket(trackData, packet, isFinalPacket) {
|
|
21588
|
+
const packetEndTimestampInSamples = packet.timestampInSamples + packet.durationInSamples;
|
|
21589
|
+
if (this.format._options.maximumPageDuration !== void 0) {
|
|
21590
|
+
const maxDurationInSamples = this.format._options.maximumPageDuration * trackData.internalSampleRate;
|
|
21591
|
+
if (trackData.currentLacingValues.length > 0 && packetEndTimestampInSamples - trackData.currentPageStartTimestampInSamples > maxDurationInSamples) {
|
|
21592
|
+
this.writePage(trackData, false);
|
|
21593
|
+
}
|
|
21594
|
+
}
|
|
21584
21595
|
let remainingLength = packet.data.length;
|
|
21585
21596
|
let dataStartOffset = 0;
|
|
21586
21597
|
let dataOffset = 0;
|
|
@@ -21611,7 +21622,7 @@ ${cue.notes ?? ""}`;
|
|
|
21611
21622
|
const slice = packet.data.subarray(dataStartOffset);
|
|
21612
21623
|
trackData.currentPageData.push(slice);
|
|
21613
21624
|
trackData.currentPageSize += slice.length;
|
|
21614
|
-
trackData.currentGranulePosition =
|
|
21625
|
+
trackData.currentGranulePosition = packetEndTimestampInSamples;
|
|
21615
21626
|
if (trackData.currentPageSize >= PAGE_SIZE_TARGET || packet.forcePageFlush) {
|
|
21616
21627
|
this.writePage(trackData, isFinalPacket);
|
|
21617
21628
|
}
|
|
@@ -21650,6 +21661,7 @@ ${cue.notes ?? ""}`;
|
|
|
21650
21661
|
trackData.currentPageData.length = 0;
|
|
21651
21662
|
trackData.currentPageSize = 27;
|
|
21652
21663
|
trackData.currentPageStartsWithFreshPacket = true;
|
|
21664
|
+
trackData.currentPageStartTimestampInSamples = trackData.currentGranulePosition;
|
|
21653
21665
|
if (this.format._options.onPage) {
|
|
21654
21666
|
this.writer.startTrackingWrites();
|
|
21655
21667
|
}
|
|
@@ -22314,6 +22326,9 @@ ${cue.notes ?? ""}`;
|
|
|
22314
22326
|
if (!options || typeof options !== "object") {
|
|
22315
22327
|
throw new TypeError("options must be an object.");
|
|
22316
22328
|
}
|
|
22329
|
+
if (options.maximumPageDuration !== void 0 && (!Number.isFinite(options.maximumPageDuration) || options.maximumPageDuration <= 0)) {
|
|
22330
|
+
throw new TypeError("options.maximumPageDuration, when provided, must be a positive number.");
|
|
22331
|
+
}
|
|
22317
22332
|
if (options.onPage !== void 0 && typeof options.onPage !== "function") {
|
|
22318
22333
|
throw new TypeError("options.onPage, when provided, must be a function.");
|
|
22319
22334
|
}
|