@remotion/media-parser 4.0.213 → 4.0.215

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.
Files changed (98) hide show
  1. package/dist/boxes/webm/ebml.d.ts +1 -1
  2. package/dist/boxes/webm/make-header.js +2 -2
  3. package/dist/boxes/webm/segments/block-simple-block-flags.d.ts +1 -1
  4. package/dist/esm/from-node.mjs +3 -3
  5. package/dist/esm/index.mjs +51 -51
  6. package/dist/readers/from-fetch.js +2 -2
  7. package/dist/truthy.js +1 -2
  8. package/package.json +3 -3
  9. package/dist/av1-codec-string.d.ts +0 -3
  10. package/dist/av1-codec-string.js +0 -91
  11. package/dist/boxes/iso-base-media/ftype.d.ts +0 -9
  12. package/dist/boxes/iso-base-media/ftype.js +0 -31
  13. package/dist/boxes/iso-base-media/stsd/avcc-hvcc.d.ts +0 -20
  14. package/dist/boxes/iso-base-media/stsd/avcc-hvcc.js +0 -73
  15. package/dist/boxes/iso-base-media/stts/stts.d.ts +0 -15
  16. package/dist/boxes/iso-base-media/stts/stts.js +0 -35
  17. package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.d.ts +0 -14
  18. package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.js +0 -67
  19. package/dist/boxes/webm/bitstream/av1/bitstream-frame.d.ts +0 -11
  20. package/dist/boxes/webm/bitstream/av1/bitstream-frame.js +0 -14
  21. package/dist/boxes/webm/bitstream/av1/chroma-sample-position.d.ts +0 -6
  22. package/dist/boxes/webm/bitstream/av1/chroma-sample-position.js +0 -9
  23. package/dist/boxes/webm/bitstream/av1/color-config.d.ts +0 -16
  24. package/dist/boxes/webm/bitstream/av1/color-config.js +0 -103
  25. package/dist/boxes/webm/bitstream/av1/color-primaries.d.ts +0 -14
  26. package/dist/boxes/webm/bitstream/av1/color-primaries.js +0 -17
  27. package/dist/boxes/webm/bitstream/av1/decoder-model-info.d.ts +0 -9
  28. package/dist/boxes/webm/bitstream/av1/decoder-model-info.js +0 -17
  29. package/dist/boxes/webm/bitstream/av1/frame.d.ts +0 -0
  30. package/dist/boxes/webm/bitstream/av1/frame.js +0 -1
  31. package/dist/boxes/webm/bitstream/av1/header-segment.d.ts +0 -51
  32. package/dist/boxes/webm/bitstream/av1/header-segment.js +0 -183
  33. package/dist/boxes/webm/bitstream/av1/matrix-coefficients.d.ts +0 -17
  34. package/dist/boxes/webm/bitstream/av1/matrix-coefficients.js +0 -20
  35. package/dist/boxes/webm/bitstream/av1/operating-parameters-info.d.ts +0 -10
  36. package/dist/boxes/webm/bitstream/av1/operating-parameters-info.js +0 -15
  37. package/dist/boxes/webm/bitstream/av1/temporal-point-info.d.ts +0 -5
  38. package/dist/boxes/webm/bitstream/av1/temporal-point-info.js +0 -8
  39. package/dist/boxes/webm/bitstream/av1/timing-info.d.ts +0 -8
  40. package/dist/boxes/webm/bitstream/av1/timing-info.js +0 -20
  41. package/dist/boxes/webm/bitstream/av1/transfer-characteristics.d.ts +0 -21
  42. package/dist/boxes/webm/bitstream/av1/transfer-characteristics.js +0 -24
  43. package/dist/boxes/webm/bitstream/av1/uvlc.d.ts +0 -2
  44. package/dist/boxes/webm/bitstream/av1/uvlc.js +0 -20
  45. package/dist/boxes/webm/bitstream/av1.d.ts +0 -20
  46. package/dist/boxes/webm/bitstream/av1.js +0 -118
  47. package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.d.ts +0 -0
  48. package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.js +0 -1
  49. package/dist/boxes/webm/get-track.d.ts +0 -6
  50. package/dist/boxes/webm/get-track.js +0 -184
  51. package/dist/boxes/webm/segments/duration.d.ts +0 -6
  52. package/dist/boxes/webm/segments/duration.js +0 -19
  53. package/dist/boxes/webm/segments/info.d.ts +0 -9
  54. package/dist/boxes/webm/segments/info.js +0 -22
  55. package/dist/boxes/webm/segments/main.d.ts +0 -5
  56. package/dist/boxes/webm/segments/main.js +0 -2
  57. package/dist/boxes/webm/segments/muxing.d.ts +0 -6
  58. package/dist/boxes/webm/segments/muxing.js +0 -11
  59. package/dist/boxes/webm/segments/seek-head.d.ts +0 -9
  60. package/dist/boxes/webm/segments/seek-head.js +0 -22
  61. package/dist/boxes/webm/segments/seek-position.d.ts +0 -6
  62. package/dist/boxes/webm/segments/seek-position.js +0 -11
  63. package/dist/boxes/webm/segments/seek.d.ts +0 -13
  64. package/dist/boxes/webm/segments/seek.js +0 -35
  65. package/dist/boxes/webm/segments/timestamp-scale.d.ts +0 -6
  66. package/dist/boxes/webm/segments/timestamp-scale.js +0 -11
  67. package/dist/boxes/webm/segments/tracks.d.ts +0 -8
  68. package/dist/boxes/webm/segments/tracks.js +0 -21
  69. package/dist/boxes/webm/segments/unknown.d.ts +0 -6
  70. package/dist/boxes/webm/segments/unknown.js +0 -11
  71. package/dist/boxes/webm/segments/void.d.ts +0 -6
  72. package/dist/boxes/webm/segments/void.js +0 -11
  73. package/dist/boxes/webm/segments/writing.d.ts +0 -6
  74. package/dist/boxes/webm/segments/writing.js +0 -11
  75. package/dist/boxes/webm/tracks.d.ts +0 -8
  76. package/dist/boxes/webm/tracks.js +0 -21
  77. package/dist/combine-uint8array.d.ts +0 -1
  78. package/dist/combine-uint8array.js +0 -13
  79. package/dist/create/cues.d.ts +0 -0
  80. package/dist/create/cues.js +0 -1
  81. package/dist/from-fetch.d.ts +0 -2
  82. package/dist/from-fetch.js +0 -64
  83. package/dist/from-node.d.ts +0 -2
  84. package/dist/from-node.js +0 -40
  85. package/dist/from-web-file.d.ts +0 -2
  86. package/dist/from-web-file.js +0 -39
  87. package/dist/from-web.d.ts +0 -2
  88. package/dist/from-web.js +0 -45
  89. package/dist/get-video-metadata.d.ts +0 -2
  90. package/dist/get-video-metadata.js +0 -44
  91. package/dist/read-and-increment-offset.d.ts +0 -28
  92. package/dist/read-and-increment-offset.js +0 -177
  93. package/dist/reader.d.ts +0 -11
  94. package/dist/reader.js +0 -2
  95. package/dist/traversal.d.ts +0 -65
  96. package/dist/traversal.js +0 -368
  97. package/dist/understand-vorbis.d.ts +0 -1
  98. package/dist/understand-vorbis.js +0 -12
@@ -1,2 +1,2 @@
1
- export declare const measureEBMLVarInt: (value: number) => 1 | 2 | 5 | 3 | 6 | 4;
1
+ export declare const measureEBMLVarInt: (value: number) => 1 | 2 | 3 | 4 | 5 | 6;
2
2
  export declare const getVariableInt: (value: number, minWidth: number | null) => Uint8Array;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeUint16 = exports.combineUint8Arrays = exports.padMatroskaBytes = exports.makeMatroskaBytes = exports.matroskaToHex = exports.webmPattern = void 0;
3
+ exports.combineUint8Arrays = exports.padMatroskaBytes = exports.makeMatroskaBytes = exports.matroskaToHex = exports.webmPattern = void 0;
4
+ exports.serializeUint16 = serializeUint16;
4
5
  const ebml_1 = require("./ebml");
5
6
  const all_segments_1 = require("./segments/all-segments");
6
7
  exports.webmPattern = new Uint8Array([0x1a, 0x45, 0xdf, 0xa3]);
@@ -183,4 +184,3 @@ function serializeUint16(value) {
183
184
  view.setUint16(0, value);
184
185
  return new Uint8Array(buffer);
185
186
  }
186
- exports.serializeUint16 = serializeUint16;
@@ -5,5 +5,5 @@ type BlockFlags = {
5
5
  lacing: number;
6
6
  keyframe: boolean | null;
7
7
  };
8
- export declare const parseBlockFlags: (iterator: BufferIterator, type: (typeof matroskaElements)['Block'] | (typeof matroskaElements)['SimpleBlock']) => BlockFlags;
8
+ export declare const parseBlockFlags: (iterator: BufferIterator, type: (typeof matroskaElements)["Block"] | (typeof matroskaElements)["SimpleBlock"]) => BlockFlags;
9
9
  export {};
@@ -1,7 +1,7 @@
1
1
  // src/readers/from-node.ts
2
- import {createReadStream} from "fs";
3
- import {stat} from "node:fs/promises";
4
- import {Readable} from "stream";
2
+ import { createReadStream } from "fs";
3
+ import { stat } from "node:fs/promises";
4
+ import { Readable } from "stream";
5
5
  var nodeReader = {
6
6
  read: async (src, range, signal) => {
7
7
  if (typeof src !== "string") {
@@ -1233,14 +1233,14 @@ var makeMatroskaHeader = () => {
1233
1233
  };
1234
1234
 
1235
1235
  // src/create/matroska-info.ts
1236
- var makeMatroskaInfo = ({ timescale: timescale2 }) => {
1236
+ var makeMatroskaInfo = ({ timescale }) => {
1237
1237
  return makeMatroskaBytes({
1238
1238
  type: "Info",
1239
1239
  value: [
1240
1240
  {
1241
1241
  type: "TimestampScale",
1242
1242
  value: {
1243
- value: timescale2,
1243
+ value: timescale,
1244
1244
  byteLength: null
1245
1245
  },
1246
1246
  minVintWidth: null
@@ -1569,7 +1569,7 @@ var makeMatroskaColorBytes = ({
1569
1569
 
1570
1570
  // src/create/matroska-trackentry.ts
1571
1571
  var makeMatroskaVideoBytes = ({
1572
- color: color3,
1572
+ color: color2,
1573
1573
  width,
1574
1574
  height
1575
1575
  }) => {
@@ -1600,7 +1600,7 @@ var makeMatroskaVideoBytes = ({
1600
1600
  },
1601
1601
  minVintWidth: null
1602
1602
  },
1603
- makeMatroskaColorBytes(color3)
1603
+ makeMatroskaColorBytes(color2)
1604
1604
  ],
1605
1605
  minVintWidth: null
1606
1606
  });
@@ -1735,7 +1735,7 @@ var makeMatroskaAudioTrackEntryBytes = ({
1735
1735
  });
1736
1736
  };
1737
1737
  var makeMatroskaVideoTrackEntryBytes = ({
1738
- color: color3,
1738
+ color: color2,
1739
1739
  width,
1740
1740
  height,
1741
1741
  trackNumber: trackNumber2,
@@ -1794,7 +1794,7 @@ var makeMatroskaVideoTrackEntryBytes = ({
1794
1794
  minVintWidth: null
1795
1795
  },
1796
1796
  makeMatroskaVideoBytes({
1797
- color: color3,
1797
+ color: color2,
1798
1798
  width,
1799
1799
  height
1800
1800
  }),
@@ -1890,13 +1890,13 @@ var createMedia = async (writer) => {
1890
1890
  };
1891
1891
  const addSample = async (chunk, trackNumber2, isVideo) => {
1892
1892
  trackNumberProgresses[trackNumber2] = chunk.timestamp;
1893
- const { cluster: cluster2, isNew, smallestProgress } = await getClusterOrMakeNew({
1893
+ const { cluster, isNew, smallestProgress } = await getClusterOrMakeNew({
1894
1894
  chunk,
1895
1895
  isVideo
1896
1896
  });
1897
1897
  const newDuration = Math.round((chunk.timestamp + (chunk.duration ?? 0)) / 1000);
1898
1898
  await updateDuration(newDuration);
1899
- const { timecodeRelativeToCluster } = await cluster2.addSample(chunk, trackNumber2);
1899
+ const { timecodeRelativeToCluster } = await cluster.addSample(chunk, trackNumber2);
1900
1900
  if (isNew) {
1901
1901
  const newCluster = w.getWrittenByteCount();
1902
1902
  cues.push({
@@ -3474,7 +3474,7 @@ var getMatroskaAudioCodecString = (track) => {
3474
3474
  throw new Error(`Unknown codec: ${codec.value}`);
3475
3475
  };
3476
3476
  var getTrack = ({
3477
- timescale: timescale3,
3477
+ timescale,
3478
3478
  track
3479
3479
  }) => {
3480
3480
  const trackType2 = getTrackTypeSegment(track);
@@ -3517,7 +3517,7 @@ var getTrack = ({
3517
3517
  numerator: 1,
3518
3518
  denominator: 1
3519
3519
  },
3520
- timescale: timescale3,
3520
+ timescale,
3521
3521
  codedHeight: height.value.value,
3522
3522
  codedWidth: width.value.value,
3523
3523
  displayAspectHeight: displayHeight2 ? displayHeight2.value.value : height.value.value,
@@ -3547,7 +3547,7 @@ var getTrack = ({
3547
3547
  type: "audio",
3548
3548
  trackId,
3549
3549
  codec: getMatroskaAudioCodecString(track),
3550
- timescale: timescale3,
3550
+ timescale,
3551
3551
  numberOfChannels,
3552
3552
  sampleRate,
3553
3553
  description: getAudioDescription(track),
@@ -3562,7 +3562,7 @@ var getTrack = ({
3562
3562
  };
3563
3563
 
3564
3564
  // src/boxes/webm/get-ready-tracks.ts
3565
- var getTracksFromMatroska = (segment, timescale3) => {
3565
+ var getTracksFromMatroska = (segment, timescale) => {
3566
3566
  const tracksSegment = getTracksSegment(segment);
3567
3567
  if (!tracksSegment) {
3568
3568
  throw new Error("No tracks segment");
@@ -3577,7 +3577,7 @@ var getTracksFromMatroska = (segment, timescale3) => {
3577
3577
  }
3578
3578
  const track = getTrack({
3579
3579
  track: trackEntrySegment,
3580
- timescale: timescale3
3580
+ timescale
3581
3581
  });
3582
3582
  if (track) {
3583
3583
  tracks2.push(track);
@@ -4383,7 +4383,7 @@ var parseMdhd = ({
4383
4383
  data.discard(3);
4384
4384
  const creationTime = version === 1 ? Number(data.getUint64()) : data.getUint32();
4385
4385
  const modificationTime = version === 1 ? Number(data.getUint64()) : data.getUint32();
4386
- const timescale3 = data.getUint32();
4386
+ const timescale = data.getUint32();
4387
4387
  const duration2 = version === 1 ? data.getUint64() : data.getUint32();
4388
4388
  const language2 = data.getUint16();
4389
4389
  const quality = data.getUint16();
@@ -4394,7 +4394,7 @@ var parseMdhd = ({
4394
4394
  return {
4395
4395
  type: "mdhd-box",
4396
4396
  duration: Number(duration2),
4397
- timescale: timescale3,
4397
+ timescale,
4398
4398
  version,
4399
4399
  language: language2,
4400
4400
  quality,
@@ -5133,13 +5133,13 @@ var parseStsz = ({
5133
5133
  sampleSize
5134
5134
  };
5135
5135
  }
5136
- const samples2 = [];
5136
+ const samples = [];
5137
5137
  for (let i = 0;i < sampleCount; i++) {
5138
5138
  const bytesRemaining = size - (iterator.counter.getOffset() - offset);
5139
5139
  if (bytesRemaining < 4) {
5140
5140
  break;
5141
5141
  }
5142
- samples2.push(iterator.getUint32());
5142
+ samples.push(iterator.getUint32());
5143
5143
  }
5144
5144
  iterator.discard(size - (iterator.counter.getOffset() - offset));
5145
5145
  return {
@@ -5150,7 +5150,7 @@ var parseStsz = ({
5150
5150
  flags: [...flags],
5151
5151
  sampleCount,
5152
5152
  countType: "variable",
5153
- entries: samples2
5153
+ entries: samples
5154
5154
  };
5155
5155
  };
5156
5156
 
@@ -5371,13 +5371,13 @@ var parseTrun = ({
5371
5371
  const sampleCount = iterator.getUint32();
5372
5372
  const dataOffset = flags & 1 ? iterator.getInt32() : null;
5373
5373
  const firstSampleFlags = flags & 4 ? iterator.getUint32() : null;
5374
- const samples2 = [];
5374
+ const samples = [];
5375
5375
  for (let i = 0;i < sampleCount; i++) {
5376
5376
  const sampleDuration = flags & 256 ? iterator.getUint32() : null;
5377
5377
  const sampleSize = flags & 512 ? iterator.getUint32() : null;
5378
5378
  const sampleFlags = flags & 1024 ? iterator.getUint32() : null;
5379
5379
  const sampleCompositionTimeOffset = flags & 2048 ? version === 0 ? iterator.getUint32() : iterator.getInt32Le() : null;
5380
- samples2.push({
5380
+ samples.push({
5381
5381
  sampleDuration,
5382
5382
  sampleSize,
5383
5383
  sampleFlags,
@@ -5395,7 +5395,7 @@ var parseTrun = ({
5395
5395
  sampleCount,
5396
5396
  dataOffset,
5397
5397
  firstSampleFlags,
5398
- samples: samples2
5398
+ samples
5399
5399
  };
5400
5400
  };
5401
5401
 
@@ -6075,26 +6075,26 @@ var parseBlockFlags = (iterator, type) => {
6075
6075
  };
6076
6076
 
6077
6077
  // src/boxes/webm/get-sample-from-block.ts
6078
- var getSampleFromBlock = (ebml5, parserContext, offset) => {
6079
- const iterator = getArrayBufferIterator(ebml5.value, ebml5.value.length);
6078
+ var getSampleFromBlock = (ebml, parserContext, offset) => {
6079
+ const iterator = getArrayBufferIterator(ebml.value, ebml.value.length);
6080
6080
  const trackNumber2 = iterator.getVint();
6081
6081
  if (trackNumber2 === null) {
6082
6082
  throw new Error("Not enough data to get track number, should not happen");
6083
6083
  }
6084
6084
  const timecodeRelativeToCluster = iterator.getInt16();
6085
- const { keyframe } = parseBlockFlags(iterator, ebml5.type === "SimpleBlock" ? matroskaElements.SimpleBlock : matroskaElements.Block);
6085
+ const { keyframe } = parseBlockFlags(iterator, ebml.type === "SimpleBlock" ? matroskaElements.SimpleBlock : matroskaElements.Block);
6086
6086
  const { codec, trackTimescale } = parserContext.parserState.getTrackInfoByNumber(trackNumber2);
6087
6087
  const clusterOffset = parserContext.parserState.getTimestampOffsetForByteOffset(offset);
6088
- const timescale3 = parserContext.parserState.getTimescale();
6088
+ const timescale = parserContext.parserState.getTimescale();
6089
6089
  if (clusterOffset === undefined) {
6090
6090
  throw new Error("Could not find offset for byte offset " + offset);
6091
6091
  }
6092
- const timecodeInNanoSeconds = (timecodeRelativeToCluster + clusterOffset) * timescale3 * (trackTimescale ?? 1);
6092
+ const timecodeInNanoSeconds = (timecodeRelativeToCluster + clusterOffset) * timescale * (trackTimescale ?? 1);
6093
6093
  const timecodeInMicroseconds = timecodeInNanoSeconds / 1000;
6094
6094
  if (!codec) {
6095
6095
  throw new Error(`Could not find codec for track ${trackNumber2}`);
6096
6096
  }
6097
- const remainingNow = ebml5.value.length - (iterator.counter.getOffset() - 0);
6097
+ const remainingNow = ebml.value.length - (iterator.counter.getOffset() - 0);
6098
6098
  if (codec.startsWith("V_")) {
6099
6099
  const partialVideoSample = {
6100
6100
  data: iterator.getSlice(remainingNow),
@@ -6231,16 +6231,16 @@ var parseEbml = async (iterator, parserContext) => {
6231
6231
  };
6232
6232
  var postprocessEbml = async ({
6233
6233
  offset,
6234
- ebml: ebml5,
6234
+ ebml,
6235
6235
  parserContext
6236
6236
  }) => {
6237
- if (ebml5.type === "TimestampScale") {
6238
- parserContext.parserState.setTimescale(ebml5.value.value);
6237
+ if (ebml.type === "TimestampScale") {
6238
+ parserContext.parserState.setTimescale(ebml.value.value);
6239
6239
  }
6240
- if (ebml5.type === "TrackEntry") {
6241
- parserContext.parserState.onTrackEntrySegment(ebml5);
6240
+ if (ebml.type === "TrackEntry") {
6241
+ parserContext.parserState.onTrackEntrySegment(ebml);
6242
6242
  const track = getTrack({
6243
- track: ebml5,
6243
+ track: ebml,
6244
6244
  timescale: parserContext.parserState.getTimescale()
6245
6245
  });
6246
6246
  if (track) {
@@ -6251,17 +6251,17 @@ var postprocessEbml = async ({
6251
6251
  });
6252
6252
  }
6253
6253
  }
6254
- if (ebml5.type === "Timestamp") {
6255
- parserContext.parserState.setTimestampOffset(offset, ebml5.value.value);
6254
+ if (ebml.type === "Timestamp") {
6255
+ parserContext.parserState.setTimestampOffset(offset, ebml.value.value);
6256
6256
  }
6257
- if (ebml5.type === "Block" || ebml5.type === "SimpleBlock") {
6258
- const sample = getSampleFromBlock(ebml5, parserContext, offset);
6257
+ if (ebml.type === "Block" || ebml.type === "SimpleBlock") {
6258
+ const sample = getSampleFromBlock(ebml, parserContext, offset);
6259
6259
  if (sample.type === "video-sample" && parserContext.nullifySamples) {
6260
6260
  await parserContext.parserState.onVideoSample(sample.videoSample.trackId, sample.videoSample);
6261
6261
  return {
6262
6262
  type: "Block",
6263
6263
  value: new Uint8Array([]),
6264
- minVintWidth: ebml5.minVintWidth
6264
+ minVintWidth: ebml.minVintWidth
6265
6265
  };
6266
6266
  }
6267
6267
  if (sample.type === "audio-sample" && parserContext.nullifySamples) {
@@ -6269,23 +6269,23 @@ var postprocessEbml = async ({
6269
6269
  return {
6270
6270
  type: "Block",
6271
6271
  value: new Uint8Array([]),
6272
- minVintWidth: ebml5.minVintWidth
6272
+ minVintWidth: ebml.minVintWidth
6273
6273
  };
6274
6274
  }
6275
6275
  if (sample.type === "no-sample" && parserContext.nullifySamples) {
6276
6276
  return {
6277
6277
  type: "Block",
6278
6278
  value: new Uint8Array([]),
6279
- minVintWidth: ebml5.minVintWidth
6279
+ minVintWidth: ebml.minVintWidth
6280
6280
  };
6281
6281
  }
6282
6282
  }
6283
- if (ebml5.type === "BlockGroup") {
6284
- const block2 = ebml5.value.find((c) => c.type === "SimpleBlock" || c.type === "Block");
6283
+ if (ebml.type === "BlockGroup") {
6284
+ const block2 = ebml.value.find((c) => c.type === "SimpleBlock" || c.type === "Block");
6285
6285
  if (!block2 || block2.type !== "SimpleBlock" && block2.type !== "Block") {
6286
6286
  throw new Error("Expected block segment");
6287
6287
  }
6288
- const hasReferenceBlock = ebml5.value.find((c) => c.type === "ReferenceBlock");
6288
+ const hasReferenceBlock = ebml.value.find((c) => c.type === "ReferenceBlock");
6289
6289
  const sample = block2.value.length === 0 ? null : getSampleFromBlock(block2, parserContext, offset);
6290
6290
  if (sample && sample.type === "partial-video-sample") {
6291
6291
  const completeFrame = {
@@ -6298,11 +6298,11 @@ var postprocessEbml = async ({
6298
6298
  return {
6299
6299
  type: "BlockGroup",
6300
6300
  value: [],
6301
- minVintWidth: ebml5.minVintWidth
6301
+ minVintWidth: ebml.minVintWidth
6302
6302
  };
6303
6303
  }
6304
6304
  }
6305
- return ebml5;
6305
+ return ebml;
6306
6306
  };
6307
6307
 
6308
6308
  // src/boxes/webm/segments.ts
@@ -6318,8 +6318,8 @@ var parseSegment = async ({
6318
6318
  }
6319
6319
  iterator.counter.decrement(headerReadSoFar);
6320
6320
  const offset = iterator.counter.getOffset();
6321
- const ebml5 = await parseEbml(iterator, parserContext);
6322
- const remapped = await postprocessEbml({ offset, ebml: ebml5, parserContext });
6321
+ const ebml = await parseEbml(iterator, parserContext);
6322
+ const remapped = await postprocessEbml({ offset, ebml, parserContext });
6323
6323
  return remapped;
6324
6324
  };
6325
6325
  var expectSegment = async (iterator, parserContext) => {
@@ -6612,15 +6612,15 @@ var makeParserState = ({
6612
6612
  const queuedAudioSamples = {};
6613
6613
  const queuedVideoSamples = {};
6614
6614
  const declinedTrackNumbers = [];
6615
- let timescale3 = null;
6615
+ let timescale = null;
6616
6616
  const getTimescale = () => {
6617
- if (timescale3 === null) {
6617
+ if (timescale === null) {
6618
6618
  return 1e6;
6619
6619
  }
6620
- return timescale3;
6620
+ return timescale;
6621
6621
  };
6622
6622
  const setTimescale = (newTimescale) => {
6623
- timescale3 = newTimescale;
6623
+ timescale = newTimescale;
6624
6624
  };
6625
6625
  const timestampMap = new Map;
6626
6626
  const setTimestampOffset = (byteOffset, timestamp) => {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchReader = exports.parseContentRange = void 0;
3
+ exports.fetchReader = void 0;
4
+ exports.parseContentRange = parseContentRange;
4
5
  /**
5
6
  * Parse Content-Range header.
6
7
  * From: https://github.com/gregberge/content-range/blob/main/src/index.ts
@@ -21,7 +22,6 @@ function parseContentRange(input) {
21
22
  }
22
23
  return range;
23
24
  }
24
- exports.parseContentRange = parseContentRange;
25
25
  const validateContentRangeAndDetectIfSupported = (actualRange, parsedContentRange, statusCode) => {
26
26
  if (statusCode === 206) {
27
27
  return { supportsContentRange: true };
package/dist/truthy.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.truthy = void 0;
3
+ exports.truthy = truthy;
4
4
  function truthy(value) {
5
5
  return Boolean(value);
6
6
  }
7
- exports.truthy = truthy;
package/package.json CHANGED
@@ -3,12 +3,12 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/media-parser"
4
4
  },
5
5
  "name": "@remotion/media-parser",
6
- "version": "4.0.213",
6
+ "version": "4.0.215",
7
7
  "main": "dist/index.js",
8
8
  "sideEffects": false,
9
9
  "devDependencies": {
10
10
  "@types/wicg-file-system-access": "2023.10.5",
11
- "@remotion/renderer": "4.0.213"
11
+ "@remotion/renderer": "4.0.215"
12
12
  },
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -90,6 +90,6 @@
90
90
  "lint": "eslint src --ext ts,tsx",
91
91
  "test": "bun test src/test",
92
92
  "watch": "tsc -w",
93
- "build": "bun --env-file=../.env.bundle bundle.ts"
93
+ "make": "bun --env-file=../.env.bundle bundle.ts"
94
94
  }
95
95
  }
@@ -1,3 +0,0 @@
1
- import type { ColorParameterBox } from './boxes/iso-base-media/stsd/colr';
2
- import type { Av1BitstreamHeaderSegment } from './boxes/webm/bitstream/av1/header-segment';
3
- export declare const constructAv1CodecString: (av1BitstreamHeader: Av1BitstreamHeaderSegment, colrAtom: ColorParameterBox | null) => string;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- // https://aomediacodec.github.io/av1-isobmff/#codecsparam
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.constructAv1CodecString = void 0;
5
- const constructAv1CodecString = (av1BitstreamHeader, colrAtom) => {
6
- let str = 'av01.';
7
- // Profile
8
- str += av1BitstreamHeader.seq_profile;
9
- str += '.';
10
- // Level
11
- // The level parameter value SHALL equal the first level value indicated by seq_level_idx in the Sequence Header OBU
12
- str += av1BitstreamHeader.seq_level[0].seq_level_idx
13
- .toString()
14
- .padStart(2, '0');
15
- // Tier
16
- // The tier parameter value SHALL be equal to M when the first seq_tier value in the Sequence Header OBU is equal to 0, and H when it is equal to 1
17
- str += av1BitstreamHeader.seq_level[0].seq_tier ? 'H' : 'M';
18
- str += '.';
19
- // bitDepth
20
- // The bitDepth parameter value SHALL equal the value of BitDepth variable as defined in [AV1] derived from the Sequence Header OBU
21
- str += av1BitstreamHeader.color_config.bitDepth.toString().padStart(2, '0');
22
- str += '.';
23
- // monochrome
24
- // The monochrome parameter value, represented by a single digit decimal, SHALL equal the value of mono_chrome in the Sequence Header OBU
25
- str += av1BitstreamHeader.color_config.mono_chrome ? '1' : '0';
26
- str += '.';
27
- // The chromaSubsampling parameter value, represented by a three-digit decimal,
28
- // SHALL have its first digit equal to subsampling_x
29
- str += av1BitstreamHeader.color_config.subsampling_x ? '1' : '0';
30
- // and its second digit equal to subsampling_y.
31
- str += av1BitstreamHeader.color_config.subsampling_y ? '1' : '0';
32
- // If both subsampling_x and subsampling_y are set to 1, then the third digit SHALL be equal to chroma_sample_position, otherwise it SHALL be set to 0
33
- str +=
34
- av1BitstreamHeader.color_config.subsampling_x &&
35
- av1BitstreamHeader.color_config.subsampling_y
36
- ? av1BitstreamHeader.color_config.chroma_sample_position === 1
37
- ? '1'
38
- : '0'
39
- : '0';
40
- str += '.';
41
- // The colorPrimaries, transferCharacteristics, matrixCoefficients, and videoFullRangeFlag parameter values are set as follows:
42
- // If a colr box with colour_type set to nclx is present, the colorPrimaries, transferCharacteristics, matrixCoefficients, and videoFullRangeFlag parameter values SHALL equal the values of matching fields in the colr box.
43
- if (colrAtom) {
44
- str += colrAtom.primaries.toString().padStart(2, '0');
45
- str += '.';
46
- str += colrAtom.transfer.toString().padStart(2, '0');
47
- str += '.';
48
- str += colrAtom.matrixIndex.toString().padStart(2, '0');
49
- str += '.';
50
- str += colrAtom.fullRangeFlag ? '1' : '0';
51
- }
52
- // Otherwise, a colr box with colour_type set to nclx is absent.
53
- // If the color_description_present_flag is set to 1 in the Sequence Header OBU, the colorPrimaries, transferCharacteristics, and matrixCoefficients parameter values SHALL equal the values of matching fields in the Sequence Header OBU.
54
- else if (av1BitstreamHeader.color_config.color_description_present_flag) {
55
- str += av1BitstreamHeader.color_config.color_primaries
56
- .toString()
57
- .padStart(2, '0');
58
- str += '.';
59
- str += av1BitstreamHeader.color_config.transfer_characteristics
60
- .toString()
61
- .padStart(2, '0');
62
- str += '.';
63
- str += av1BitstreamHeader.color_config.matrix_coefficients
64
- .toString()
65
- .padStart(2, '0');
66
- str += '.';
67
- // The videoFullRangeFlag parameter value SHALL equal the color_range flag in the Sequence Header OBU.
68
- str += av1BitstreamHeader.color_config.color_range ? '1' : '0';
69
- }
70
- else {
71
- // Otherwise, the color_description_present_flag is set to 0 in the Sequence Header OBU. The colorPrimaries, transferCharacteristics, and matrixCoefficients parameter values SHOULD be set to the default values below.
72
- // colorPrimaries 01 (ITU-R BT.709)
73
- str += '01';
74
- str += '.';
75
- // transferCharacteristics 01 (ITU-R BT.709)
76
- str += '01';
77
- str += '.';
78
- // matrixCoefficients 00 (ITU-R BT.709)
79
- str += '01';
80
- str += '.';
81
- // videoFullRangeFlag 0 (studio swing representation)
82
- str += '0';
83
- }
84
- // If the codecs parameter string ends with ".0.110.01.01.01.0" (containing all the default values below), that trailing part of the string SHOULD be omitted.
85
- const suffix = '.0.110.01.01.01.0';
86
- if (str.endsWith(suffix)) {
87
- str = str.slice(0, -suffix.length);
88
- }
89
- return str;
90
- };
91
- exports.constructAv1CodecString = constructAv1CodecString;
@@ -1,9 +0,0 @@
1
- import type { BaseBox } from './base-type';
2
- export interface FtypBox extends BaseBox {
3
- type: 'ftyp-box';
4
- majorBrand: string;
5
- minorVersion: number;
6
- compatibleBrands: string[];
7
- }
8
- export declare const fourByteToNumber: (data: ArrayBuffer, from: number) => number;
9
- export declare const parseFtyp: (data: ArrayBuffer, offset: number) => FtypBox;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseFtyp = exports.fourByteToNumber = void 0;
4
- const fourByteToNumber = (data, from) => {
5
- const view = new DataView(data);
6
- return ((view.getUint8(from + 0) << 24) |
7
- (view.getUint8(from + 1) << 16) |
8
- (view.getUint8(from + 2) << 8) |
9
- view.getUint8(from + 3));
10
- };
11
- exports.fourByteToNumber = fourByteToNumber;
12
- const parseFtyp = (data, offset) => {
13
- const majorBrand = new TextDecoder().decode(data.slice(8, 12)).trim();
14
- const minorVersion = (0, exports.fourByteToNumber)(data, 12);
15
- const rest = data.slice(16);
16
- const types = rest.byteLength / 4;
17
- const compatibleBrands = [];
18
- for (let i = 0; i < types; i++) {
19
- const fourBytes = rest.slice(i * 4, i * 4 + 4);
20
- compatibleBrands.push(new TextDecoder().decode(fourBytes).trim());
21
- }
22
- return {
23
- type: 'ftyp-box',
24
- majorBrand,
25
- minorVersion,
26
- compatibleBrands,
27
- offset,
28
- boxSize: data.byteLength,
29
- };
30
- };
31
- exports.parseFtyp = parseFtyp;
@@ -1,20 +0,0 @@
1
- import type { BufferIterator } from '../../../buffer-iterator';
2
- export interface AvccBox {
3
- type: 'avcc-box';
4
- data: Uint8Array;
5
- configurationString: string;
6
- }
7
- export declare const parseAvcc: ({ data, size, }: {
8
- data: BufferIterator;
9
- size: number;
10
- }) => AvccBox;
11
- export interface HvccBox {
12
- type: 'hvcc-box';
13
- data: Uint8Array;
14
- configurationString: string;
15
- }
16
- export declare const parseHvcc: ({ data, size, offset, }: {
17
- data: BufferIterator;
18
- size: number;
19
- offset: number;
20
- }) => HvccBox;
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseHvcc = exports.parseAvcc = void 0;
4
- const parseAvcc = ({ data, size, }) => {
5
- const confVersion = data.getUint8();
6
- if (confVersion !== 1) {
7
- throw new Error(`Unsupported AVCC version ${confVersion}`);
8
- }
9
- const profile = data.getUint8();
10
- const profileCompatibility = data.getUint8();
11
- const level = data.getUint8();
12
- const str = `${profile.toString(16).padStart(2, '0')}${profileCompatibility.toString(16).padStart(2, '0')}${level.toString(16).padStart(2, '0')}`;
13
- data.counter.decrement(4);
14
- return {
15
- type: 'avcc-box',
16
- data: data.getSlice(size - 8),
17
- configurationString: str,
18
- };
19
- };
20
- exports.parseAvcc = parseAvcc;
21
- const parseHvcc = ({ data, size, offset, }) => {
22
- const raw = data.getSlice(size - 8);
23
- data.counter.decrement(size - 8);
24
- const configurationVersion = data.getUint8();
25
- if (configurationVersion !== 1) {
26
- throw new Error(`Unsupported HVCC version ${configurationVersion}`);
27
- }
28
- const generalProfileSpaceTierFlagAndIdc = data.getUint8();
29
- let generalProfileCompatibility = data.getUint32();
30
- // unsigned int(2) general_profile_space;
31
- // unsigned int(1) general_tier_flag;
32
- // unsigned int(5) general_profile_idc;
33
- const generalProfileSpace = generalProfileSpaceTierFlagAndIdc >> 6;
34
- const generalTierFlag = generalProfileSpaceTierFlagAndIdc >> 5;
35
- const generalProfileIdc = generalProfileSpaceTierFlagAndIdc >> 0;
36
- // general_constraint_indicator_flags(48)
37
- const generalConstraintIndicator = data.getSlice(6);
38
- const generalLevelIdc = data.getUint8();
39
- let reversedGeneralProfileSpace = 0;
40
- for (let i = 0; i < 32; i++) {
41
- reversedGeneralProfileSpace |= generalProfileCompatibility & 1;
42
- if (i === 31)
43
- break;
44
- reversedGeneralProfileSpace <<= 1;
45
- generalProfileCompatibility >>= 1;
46
- }
47
- const profileSpaceChar = generalProfileSpace === 0
48
- ? ''
49
- : generalProfileSpace === 1
50
- ? 'A'
51
- : generalProfileSpace === 2
52
- ? 'B'
53
- : 'C';
54
- const generalTierChar = generalTierFlag === 0 ? 'L' : 'H';
55
- let hasByte = false;
56
- let generalConstraintString = '';
57
- for (let i = 5; i >= 0; i--) {
58
- if (generalConstraintIndicator[i] || hasByte) {
59
- generalConstraintString =
60
- generalConstraintIndicator[i].toString(16) + generalConstraintString;
61
- hasByte = true;
62
- }
63
- }
64
- const constraintString = `${profileSpaceChar}${generalProfileIdc.toString(16)}.${reversedGeneralProfileSpace.toString(16)}.${generalTierChar}${generalLevelIdc}.${generalConstraintString}`;
65
- const remaining = size - (data.counter.getOffset() - offset);
66
- data.discard(remaining);
67
- return {
68
- type: 'hvcc-box',
69
- data: raw,
70
- configurationString: constraintString,
71
- };
72
- };
73
- exports.parseHvcc = parseHvcc;
@@ -1,15 +0,0 @@
1
- import type { BufferIterator } from '../../../buffer-iterator';
2
- export interface SttsBox {
3
- type: 'stts-box';
4
- sampleDistribution: SampleDistribution[];
5
- }
6
- type SampleDistribution = {
7
- sampleCount: number;
8
- sampleDelta: number;
9
- };
10
- export declare const parseStts: ({ data, size, fileOffset, }: {
11
- data: BufferIterator;
12
- size: number;
13
- fileOffset: number;
14
- }) => SttsBox;
15
- export {};