mediabunny 1.59.0 → 1.59.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.
@@ -10278,6 +10278,7 @@ var Mediabunny = (() => {
10278
10278
  };
10279
10279
  this.segments.push(this.currentSegment);
10280
10280
  let currentPos = segmentDataStart;
10281
+ const visitedSeekHeadPositions = /* @__PURE__ */ new Set();
10281
10282
  while (this.currentSegment.elementEndPos === null || currentPos < this.currentSegment.elementEndPos) {
10282
10283
  let slice = this.reader.requestSliceRange(currentPos, MIN_HEADER_SIZE, MAX_HEADER_SIZE);
10283
10284
  if (isThenable(slice)) slice = await slice;
@@ -10304,6 +10305,9 @@ var Mediabunny = (() => {
10304
10305
  if (metadataElementIndex !== -1) {
10305
10306
  const field = METADATA_ELEMENTS[metadataElementIndex].flag;
10306
10307
  this.currentSegment[field] = true;
10308
+ if (id === 290298740 /* SeekHead */) {
10309
+ visitedSeekHeadPositions.add(elementStartPos - segmentDataStart);
10310
+ }
10307
10311
  assertDefinedSize(size);
10308
10312
  let slice2 = this.reader.requestSlice(dataStartPos, size);
10309
10313
  if (isThenable(slice2)) slice2 = await slice2;
@@ -10332,6 +10336,32 @@ var Mediabunny = (() => {
10332
10336
  currentPos = dataStartPos + size;
10333
10337
  }
10334
10338
  }
10339
+ if (this.reader.fileSize !== null) {
10340
+ while (true) {
10341
+ const seekEntry = this.currentSegment.seekEntries.find(
10342
+ (x) => x.id === 290298740 /* SeekHead */ && !visitedSeekHeadPositions.has(x.segmentPosition)
10343
+ );
10344
+ if (!seekEntry) {
10345
+ break;
10346
+ }
10347
+ visitedSeekHeadPositions.add(seekEntry.segmentPosition);
10348
+ let slice = this.reader.requestSliceRange(
10349
+ segmentDataStart + seekEntry.segmentPosition,
10350
+ MIN_HEADER_SIZE,
10351
+ MAX_HEADER_SIZE
10352
+ );
10353
+ if (isThenable(slice)) slice = await slice;
10354
+ if (!slice) continue;
10355
+ const header = readElementHeader(slice);
10356
+ if (!header || header.id !== 290298740 /* SeekHead */) continue;
10357
+ const { size } = header;
10358
+ assertDefinedSize(size);
10359
+ let dataSlice = this.reader.requestSlice(slice.filePos, size);
10360
+ if (isThenable(dataSlice)) dataSlice = await dataSlice;
10361
+ if (!dataSlice) continue;
10362
+ this.readContiguousElements(dataSlice);
10363
+ }
10364
+ }
10335
10365
  this.currentSegment.seekEntries.sort((a, b) => a.segmentPosition - b.segmentPosition);
10336
10366
  if (this.reader.fileSize !== null) {
10337
10367
  for (const seekEntry of this.currentSegment.seekEntries) {
@@ -40972,6 +41002,7 @@ The @mediabunny/mp3-encoder extension package provides support for encoding MP3.
40972
41002
  const sink = new EncodedPacketSink(track);
40973
41003
  const decoderConfig = await track.getDecoderConfig();
40974
41004
  const meta = { decoderConfig: decoderConfig ?? void 0 };
41005
+ let maxTimestamp = null;
40975
41006
  if (copyStartPacket) for await (const packet of sink.packets(copyStartPacket)) {
40976
41007
  if (this._state === "canceled") {
40977
41008
  break;
@@ -40982,8 +41013,13 @@ The @mediabunny/mp3-encoder extension package provides support for encoding MP3.
40982
41013
  if (this._copyBoundaryPolicy === "shrink" && packet.timestamp + packet.duration > this._endTimestamp) {
40983
41014
  break;
40984
41015
  }
41016
+ const packetTimestamp = packet.timestamp + this._timestampOffset;
41017
+ if (maxTimestamp !== null && packetTimestamp < maxTimestamp) {
41018
+ continue;
41019
+ }
41020
+ maxTimestamp = packetTimestamp;
40985
41021
  const modifiedPacket = packet.clone({
40986
- timestamp: packet.timestamp + this._timestampOffset,
41022
+ timestamp: packetTimestamp,
40987
41023
  duration: packet.duration
40988
41024
  });
40989
41025
  this._reportProgress(outputTrackId, modifiedPacket.timestamp + modifiedPacket.duration);