@remotion/media-parser 4.0.243 → 4.0.245

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 (89) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/boxes/iso-base-media/ftyp.js +2 -2
  3. package/dist/boxes/iso-base-media/mdat/mdat.js +17 -5
  4. package/dist/boxes/iso-base-media/meta/hdlr.js +1 -1
  5. package/dist/boxes/iso-base-media/meta/ilst.js +1 -1
  6. package/dist/boxes/iso-base-media/parse-icc-profile.js +12 -12
  7. package/dist/boxes/iso-base-media/process-box.js +1 -4
  8. package/dist/boxes/iso-base-media/stsd/colr.js +1 -1
  9. package/dist/boxes/iso-base-media/stsd/keys.js +1 -1
  10. package/dist/boxes/riff/expect-riff-box.js +1 -1
  11. package/dist/boxes/riff/is-movi.js +1 -1
  12. package/dist/boxes/riff/parse-box.js +2 -2
  13. package/dist/boxes/riff/parse-isft.js +1 -1
  14. package/dist/boxes/riff/parse-list-box.js +1 -1
  15. package/dist/boxes/riff/parse-movi.js +1 -1
  16. package/dist/boxes/riff/parse-strf.js +1 -1
  17. package/dist/boxes/riff/parse-strh.js +4 -2
  18. package/dist/boxes/transport-stream/adts-header.d.ts +1 -1
  19. package/dist/boxes/transport-stream/discard-rest-of-packet.d.ts +1 -1
  20. package/dist/boxes/webm/description.js +1 -1
  21. package/dist/boxes/webm/ebml.d.ts +1 -1
  22. package/dist/boxes/webm/make-header.d.ts +3 -3
  23. package/dist/boxes/webm/parse-ebml.js +1 -1
  24. package/dist/boxes/webm/segments/all-segments.d.ts +32 -0
  25. package/dist/boxes/webm/segments/all-segments.js +22 -2
  26. package/dist/buffer-iterator.d.ts +2 -2
  27. package/dist/buffer-iterator.js +8 -2
  28. package/dist/create/iso-base-media/codec-specific/avc1.d.ts +1 -1
  29. package/dist/create/iso-base-media/codec-specific/create-codec-specific-data.d.ts +1 -1
  30. package/dist/create/iso-base-media/codec-specific/mp4a.d.ts +1 -1
  31. package/dist/create/iso-base-media/create-colr.d.ts +1 -1
  32. package/dist/create/iso-base-media/create-ftyp.d.ts +2 -2
  33. package/dist/create/iso-base-media/create-ilst.d.ts +1 -1
  34. package/dist/create/iso-base-media/create-mdia.d.ts +1 -1
  35. package/dist/create/iso-base-media/create-moov.d.ts +1 -1
  36. package/dist/create/iso-base-media/create-mvhd.d.ts +1 -1
  37. package/dist/create/iso-base-media/create-trak.d.ts +1 -1
  38. package/dist/create/iso-base-media/create-udta.d.ts +1 -1
  39. package/dist/create/iso-base-media/create-url.d.ts +1 -1
  40. package/dist/create/iso-base-media/ilst/create-cmt.d.ts +1 -1
  41. package/dist/create/iso-base-media/ilst/create-too.d.ts +1 -1
  42. package/dist/create/iso-base-media/mdia/create-mdhd.d.ts +1 -1
  43. package/dist/create/iso-base-media/mp4-header.d.ts +1 -1
  44. package/dist/create/iso-base-media/primitives.d.ts +13 -13
  45. package/dist/create/iso-base-media/serialize-track.d.ts +1 -1
  46. package/dist/create/iso-base-media/trak/create-tkhd.d.ts +2 -2
  47. package/dist/create/iso-base-media/trak/mdia/create-minf.d.ts +1 -1
  48. package/dist/create/iso-base-media/trak/mdia/minf/create-dinf.d.ts +1 -1
  49. package/dist/create/iso-base-media/trak/mdia/minf/create-smhd.d.ts +1 -1
  50. package/dist/create/iso-base-media/trak/mdia/minf/create-stbl.d.ts +1 -1
  51. package/dist/create/iso-base-media/trak/mdia/minf/create-vmhd.d.ts +1 -1
  52. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.d.ts +1 -1
  53. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stco.d.ts +1 -1
  54. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.d.ts +1 -1
  55. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stss.d.ts +1 -1
  56. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.d.ts +1 -1
  57. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stts.d.ts +1 -1
  58. package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avc1.d.ts +1 -1
  59. package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avcc.d.ts +1 -1
  60. package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-pasp.d.ts +1 -1
  61. package/dist/create/iso-base-media/udta/create-meta.d.ts +1 -1
  62. package/dist/create/iso-base-media/udta/meta/create-hdlr.d.ts +1 -1
  63. package/dist/create/matroska/cluster-segment.d.ts +1 -1
  64. package/dist/emit-available-info.js +1 -11
  65. package/dist/esm/index.mjs +69 -53
  66. package/dist/esm/web-fs.mjs +9 -8
  67. package/dist/get-audio-codec.d.ts +1 -1
  68. package/dist/version.d.ts +1 -1
  69. package/dist/version.js +1 -1
  70. package/dist/writers/web-fs.js +9 -8
  71. package/package.json +3 -3
  72. package/dist/boxes/avc/codec-private.d.ts +0 -2
  73. package/dist/boxes/avc/codec-private.js +0 -28
  74. package/dist/errors/detect-file-type.d.ts +0 -1
  75. package/dist/errors/detect-file-type.js +0 -88
  76. package/dist/errors/file-types.d.ts +0 -1
  77. package/dist/errors/file-types.js +0 -88
  78. package/dist/file-types/get-jpeg-dimensions.d.ts +0 -4
  79. package/dist/file-types/get-jpeg-dimensions.js +0 -32
  80. package/dist/file-types.d.ts +0 -1
  81. package/dist/file-types.js +0 -88
  82. package/dist/parser-context.d.ts +0 -10
  83. package/dist/parser-context.js +0 -2
  84. package/dist/probing/detect-file-type.d.ts +0 -1
  85. package/dist/probing/detect-file-type.js +0 -88
  86. package/dist/probing/get-jpeg-dimensions.d.ts +0 -4
  87. package/dist/probing/get-jpeg-dimensions.js +0 -32
  88. package/dist/state/tracks-and-samples.d.ts +0 -0
  89. package/dist/state/tracks-and-samples.js +0 -1
@@ -6,4 +6,4 @@ export type IsoBaseMediaTrackData = {
6
6
  samplePositions: SamplePosition[];
7
7
  timescale: number;
8
8
  };
9
- export declare const serializeTrack: ({ track, durationInUnits, samplePositions, timescale, }: IsoBaseMediaTrackData) => Uint8Array<ArrayBufferLike>;
9
+ export declare const serializeTrack: ({ track, durationInUnits, samplePositions, timescale, }: IsoBaseMediaTrackData) => Uint8Array;
@@ -12,7 +12,7 @@ export declare const createTkhdForAudio: ({ creationTime, modificationTime, flag
12
12
  duration: number;
13
13
  volume: number;
14
14
  timescale: number;
15
- }) => Uint8Array<ArrayBufferLike>;
15
+ }) => Uint8Array;
16
16
  export declare const createTkhdForVideo: ({ creationTime, modificationTime, duration, trackId, volume, matrix, width, height, flags, timescale, }: {
17
17
  creationTime: number | null;
18
18
  modificationTime: number | null;
@@ -24,4 +24,4 @@ export declare const createTkhdForVideo: ({ creationTime, modificationTime, dura
24
24
  height: number;
25
25
  flags: number;
26
26
  timescale: number;
27
- }) => Uint8Array<ArrayBufferLike>;
27
+ }) => Uint8Array;
@@ -1,4 +1,4 @@
1
1
  export declare const createMinf: ({ vmhdAtom, stblAtom, }: {
2
2
  vmhdAtom: Uint8Array;
3
3
  stblAtom: Uint8Array;
4
- }) => Uint8Array<ArrayBufferLike>;
4
+ }) => Uint8Array;
@@ -1 +1 @@
1
- export declare const createDinf: () => Uint8Array<ArrayBufferLike>;
1
+ export declare const createDinf: () => Uint8Array;
@@ -1 +1 @@
1
- export declare const createSmhd: () => Uint8Array<ArrayBufferLike>;
1
+ export declare const createSmhd: () => Uint8Array;
@@ -3,4 +3,4 @@ export declare const createStbl: ({ samplePositions, codecSpecificData, isVideo,
3
3
  samplePositions: SamplePosition[];
4
4
  codecSpecificData: Uint8Array;
5
5
  isVideo: boolean;
6
- }) => Uint8Array<ArrayBufferLike>;
6
+ }) => Uint8Array;
@@ -1 +1 @@
1
- export declare const createVmhd: () => Uint8Array<ArrayBufferLike>;
1
+ export declare const createVmhd: () => Uint8Array;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createCttsBox: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike> | null;
2
+ export declare const createCttsBox: (samplePositions: SamplePosition[]) => Uint8Array | null;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createStcoAtom: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
2
+ export declare const createStcoAtom: (samplePositions: SamplePosition[]) => Uint8Array;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createStsc: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
2
+ export declare const createStsc: (samplePositions: SamplePosition[]) => Uint8Array;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createStss: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
2
+ export declare const createStss: (samplePositions: SamplePosition[]) => Uint8Array;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createStsz: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
2
+ export declare const createStsz: (samplePositions: SamplePosition[]) => Uint8Array;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createSttsAtom: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
2
+ export declare const createSttsAtom: (samplePositions: SamplePosition[]) => Uint8Array;
@@ -1 +1 @@
1
- export declare const createStsdData: (codecSpecificData: Uint8Array) => Uint8Array<ArrayBufferLike>;
1
+ export declare const createStsdData: (codecSpecificData: Uint8Array) => Uint8Array;
@@ -1 +1 @@
1
- export declare const createAvccBox: (privateData: Uint8Array | null) => Uint8Array<ArrayBufferLike>;
1
+ export declare const createAvccBox: (privateData: Uint8Array | null) => Uint8Array;
@@ -1 +1 @@
1
- export declare const createPasp: (x: number, y: number) => Uint8Array<ArrayBufferLike>;
1
+ export declare const createPasp: (x: number, y: number) => Uint8Array;
@@ -1,4 +1,4 @@
1
1
  export declare const createMeta: ({ hdlr, ilst, }: {
2
2
  hdlr: Uint8Array;
3
3
  ilst: Uint8Array;
4
- }) => Uint8Array<ArrayBufferLike>;
4
+ }) => Uint8Array;
@@ -1 +1 @@
1
- export declare const createHdlr: (type: "video" | "audio" | "mdir") => Uint8Array<ArrayBufferLike>;
1
+ export declare const createHdlr: (type: "video" | "audio" | "mdir") => Uint8Array;
@@ -7,4 +7,4 @@ export declare const makeSimpleBlock: ({ bytes, trackNumber, timecodeRelativeToC
7
7
  keyframe: boolean;
8
8
  invisible: boolean;
9
9
  lacing: number;
10
- }) => Uint8Array<ArrayBufferLike>;
10
+ }) => Uint8Array;
@@ -41,16 +41,6 @@ const emitAvailableInfo = ({ hasInfo, parseResult, callbacks, state, returnValue
41
41
  }
42
42
  emittedFields.durationInSeconds = true;
43
43
  }
44
- if (!emittedFields.slowDurationInSeconds) {
45
- const durationInSeconds = (0, get_duration_1.getDuration)(segments, state);
46
- if (durationInSeconds !== null) {
47
- (_c = callbacks.onSlowDurationInSeconds) === null || _c === void 0 ? void 0 : _c.call(callbacks, durationInSeconds);
48
- if (fieldsInReturnValue.slowDurationInSeconds) {
49
- returnValue.slowDurationInSeconds = durationInSeconds;
50
- }
51
- emittedFields.slowDurationInSeconds = true;
52
- }
53
- }
54
44
  }
55
45
  continue;
56
46
  }
@@ -59,7 +49,7 @@ const emitAvailableInfo = ({ hasInfo, parseResult, callbacks, state, returnValue
59
49
  !emittedFields.slowDurationInSeconds &&
60
50
  parseResult &&
61
51
  segments) {
62
- const slowDurationInSeconds = state.slowDurationAndFps.getSlowDurationInSeconds();
52
+ const slowDurationInSeconds = (_c = (0, get_duration_1.getDuration)(segments, state)) !== null && _c !== void 0 ? _c : state.slowDurationAndFps.getSlowDurationInSeconds();
63
53
  (_d = callbacks.onSlowDurationInSeconds) === null || _d === void 0 ? void 0 : _d.call(callbacks, slowDurationInSeconds);
64
54
  if (fieldsInReturnValue.slowDurationInSeconds) {
65
55
  returnValue.slowDurationInSeconds = slowDurationInSeconds;
@@ -663,6 +663,18 @@ var seekId = {
663
663
  name: "SeekID",
664
664
  type: "hex-string"
665
665
  };
666
+ var _name = {
667
+ name: "Name",
668
+ type: "string"
669
+ };
670
+ var minCache = {
671
+ name: "MinCache",
672
+ type: "uint"
673
+ };
674
+ var maxCache = {
675
+ name: "MaxCache",
676
+ type: "uint"
677
+ };
666
678
  var seekPosition = {
667
679
  name: "SeekPosition",
668
680
  type: "uint"
@@ -823,6 +835,10 @@ var referenceBlock = {
823
835
  name: "ReferenceBlock",
824
836
  type: "uint"
825
837
  };
838
+ var blockDurationSegment = {
839
+ name: "BlockDuration",
840
+ type: "uint"
841
+ };
826
842
  var codecName = {
827
843
  name: "CodecName",
828
844
  type: "string"
@@ -947,6 +963,9 @@ var ebmlMap = {
947
963
  [matroskaElements.SeekHead]: seekHead,
948
964
  [matroskaElements.Seek]: seek,
949
965
  [matroskaElements.SeekID]: seekId,
966
+ [matroskaElements.Name]: _name,
967
+ [matroskaElements.MinCache]: minCache,
968
+ [matroskaElements.MaxCache]: maxCache,
950
969
  [matroskaElements.SeekPosition]: seekPosition,
951
970
  [matroskaElements.Crc32]: {
952
971
  name: "Crc32",
@@ -988,6 +1007,7 @@ var ebmlMap = {
988
1007
  [matroskaElements.Language]: language,
989
1008
  [matroskaElements.DefaultDuration]: defaultDuration,
990
1009
  [matroskaElements.CodecPrivate]: codecPrivate,
1010
+ [matroskaElements.BlockDuration]: blockDurationSegment,
991
1011
  [matroskaElements.BlockAdditions]: blockAdditionsSegment,
992
1012
  [matroskaElements.MaxBlockAdditionID]: maxBlockAdditionIdSegment,
993
1013
  [matroskaElements.Audio]: audioSegment,
@@ -1367,7 +1387,7 @@ var createIsoBaseMediaFtyp = ({
1367
1387
  };
1368
1388
 
1369
1389
  // src/version.ts
1370
- var VERSION = "4.0.243";
1390
+ var VERSION = "4.0.245";
1371
1391
 
1372
1392
  // src/create/iso-base-media/create-ilst.ts
1373
1393
  var createIlst = (items) => {
@@ -5143,8 +5163,11 @@ var getArrayBufferIterator = (initialData, maxBytes) => {
5143
5163
  const numbers = [...Array.from(new Uint8Array(bytes))];
5144
5164
  return numbers.reduce((acc, byte, index) => acc + (byte << 8 * (numbers.length - index - 1)), 0);
5145
5165
  },
5146
- getByteString(length) {
5147
- const bytes = getSlice(length);
5166
+ getByteString(length, trimTrailingZeroes) {
5167
+ let bytes = getSlice(length);
5168
+ while (trimTrailingZeroes && bytes[bytes.length - 1] === 0) {
5169
+ bytes = bytes.slice(0, -1);
5170
+ }
5148
5171
  return new TextDecoder().decode(bytes).trim();
5149
5172
  },
5150
5173
  getFloat64: () => {
@@ -5731,7 +5754,7 @@ var getAudioDescription = (track) => {
5731
5754
  const vorbisBooks = privateData.slice(offset);
5732
5755
  const bufferIterator = getArrayBufferIterator(vorbisInfo.slice(0), vorbisInfo.length);
5733
5756
  bufferIterator.getUint8();
5734
- const vorbis = bufferIterator.getByteString(6);
5757
+ const vorbis = bufferIterator.getByteString(6, false);
5735
5758
  if (vorbis !== "vorbis") {
5736
5759
  throw new Error("Error parsing vorbis codec private");
5737
5760
  }
@@ -6608,22 +6631,12 @@ var emitAvailableInfo = ({
6608
6631
  }
6609
6632
  emittedFields.durationInSeconds = true;
6610
6633
  }
6611
- if (!emittedFields.slowDurationInSeconds) {
6612
- const durationInSeconds = getDuration(segments, state);
6613
- if (durationInSeconds !== null) {
6614
- callbacks.onSlowDurationInSeconds?.(durationInSeconds);
6615
- if (fieldsInReturnValue.slowDurationInSeconds) {
6616
- returnValue.slowDurationInSeconds = durationInSeconds;
6617
- }
6618
- emittedFields.slowDurationInSeconds = true;
6619
- }
6620
- }
6621
6634
  }
6622
6635
  continue;
6623
6636
  }
6624
6637
  if (key === "slowDurationInSeconds") {
6625
6638
  if (hasInfo.slowDurationInSeconds && !emittedFields.slowDurationInSeconds && parseResult && segments) {
6626
- const slowDurationInSeconds = state.slowDurationAndFps.getSlowDurationInSeconds();
6639
+ const slowDurationInSeconds = getDuration(segments, state) ?? state.slowDurationAndFps.getSlowDurationInSeconds();
6627
6640
  callbacks.onSlowDurationInSeconds?.(slowDurationInSeconds);
6628
6641
  if (fieldsInReturnValue.slowDurationInSeconds) {
6629
6642
  returnValue.slowDurationInSeconds = slowDurationInSeconds;
@@ -7195,12 +7208,12 @@ var parseFtyp = ({
7195
7208
  size,
7196
7209
  offset
7197
7210
  }) => {
7198
- const majorBrand = iterator.getByteString(4);
7211
+ const majorBrand = iterator.getByteString(4, false);
7199
7212
  const minorVersion = iterator.getFourByteNumber();
7200
7213
  const types = (size - iterator.counter.getOffset()) / 4;
7201
7214
  const compatibleBrands = [];
7202
7215
  for (let i = 0;i < types; i++) {
7203
- compatibleBrands.push(iterator.getByteString(4).trim());
7216
+ compatibleBrands.push(iterator.getByteString(4, false).trim());
7204
7217
  }
7205
7218
  const offsetAtEnd = iterator.counter.getOffset();
7206
7219
  return {
@@ -7302,7 +7315,7 @@ var parseMdat = async ({
7302
7315
  break;
7303
7316
  }
7304
7317
  const bytes = data.getSlice(samplesWithIndex.samplePosition.size);
7305
- const { cts, dts, duration: duration2 } = samplesWithIndex.samplePosition;
7318
+ const { cts, dts, duration: duration2, isKeyframe, offset } = samplesWithIndex.samplePosition;
7306
7319
  if (samplesWithIndex.track.type === "audio") {
7307
7320
  await state.callbacks.onAudioSample(samplesWithIndex.track.trackId, convertAudioOrVideoSampleToWebCodecsTimestamps({
7308
7321
  data: bytes,
@@ -7311,12 +7324,18 @@ var parseMdat = async ({
7311
7324
  cts,
7312
7325
  dts,
7313
7326
  trackId: samplesWithIndex.track.trackId,
7314
- type: samplesWithIndex.samplePosition.isKeyframe ? "key" : "delta",
7315
- offset: samplesWithIndex.samplePosition.offset,
7327
+ type: isKeyframe ? "key" : "delta",
7328
+ offset,
7316
7329
  timescale: samplesWithIndex.track.timescale
7317
7330
  }, samplesWithIndex.track.timescale));
7318
7331
  }
7319
7332
  if (samplesWithIndex.track.type === "video") {
7333
+ const nalUnitType = bytes[4] & 31;
7334
+ let isRecoveryPoint = false;
7335
+ if (nalUnitType === 6) {
7336
+ const seiType = bytes[5];
7337
+ isRecoveryPoint = seiType === 6;
7338
+ }
7320
7339
  await state.callbacks.onVideoSample(samplesWithIndex.track.trackId, convertAudioOrVideoSampleToWebCodecsTimestamps({
7321
7340
  data: bytes,
7322
7341
  timestamp: cts,
@@ -7324,8 +7343,8 @@ var parseMdat = async ({
7324
7343
  cts,
7325
7344
  dts,
7326
7345
  trackId: samplesWithIndex.track.trackId,
7327
- type: samplesWithIndex.samplePosition.isKeyframe ? "key" : "delta",
7328
- offset: samplesWithIndex.samplePosition.offset,
7346
+ type: isKeyframe && !isRecoveryPoint ? "key" : "delta",
7347
+ offset,
7329
7348
  timescale: samplesWithIndex.track.timescale
7330
7349
  }, samplesWithIndex.track.timescale));
7331
7350
  }
@@ -7386,7 +7405,7 @@ var parseHdlr = ({
7386
7405
  }
7387
7406
  iterator.discard(3);
7388
7407
  iterator.discard(4);
7389
- const hdlrType = iterator.getByteString(4);
7408
+ const hdlrType = iterator.getByteString(4, false);
7390
7409
  iterator.discard(4);
7391
7410
  iterator.discard(4);
7392
7411
  iterator.discard(4);
@@ -7404,7 +7423,7 @@ var parseHdlr = ({
7404
7423
  // src/boxes/iso-base-media/meta/ilst.ts
7405
7424
  var parseFromWellKnownType = (wellKnownType, iterator, size) => {
7406
7425
  if (wellKnownType === 1) {
7407
- const value = iterator.getByteString(size);
7426
+ const value = iterator.getByteString(size, false);
7408
7427
  return { type: "text", value };
7409
7428
  }
7410
7429
  if (wellKnownType === 21) {
@@ -7615,33 +7634,33 @@ var parseIccProfile = (data) => {
7615
7634
  if (size !== data.length) {
7616
7635
  throw new Error("Invalid ICC profile size");
7617
7636
  }
7618
- const preferredCMMType = iterator.getByteString(4);
7619
- const profileVersion = iterator.getByteString(4);
7620
- const profileDeviceClass = iterator.getByteString(4);
7621
- const colorSpace = iterator.getByteString(4);
7622
- const pcs = iterator.getByteString(4);
7637
+ const preferredCMMType = iterator.getByteString(4, false);
7638
+ const profileVersion = iterator.getByteString(4, false);
7639
+ const profileDeviceClass = iterator.getByteString(4, false);
7640
+ const colorSpace = iterator.getByteString(4, false);
7641
+ const pcs = iterator.getByteString(4, false);
7623
7642
  const dateTime = iterator.getSlice(12);
7624
- const signature = iterator.getByteString(4);
7643
+ const signature = iterator.getByteString(4, false);
7625
7644
  if (signature !== "acsp") {
7626
7645
  throw new Error("Invalid ICC profile signature");
7627
7646
  }
7628
- const primaryPlatform = iterator.getByteString(4);
7647
+ const primaryPlatform = iterator.getByteString(4, false);
7629
7648
  const profileFlags = iterator.getUint32();
7630
- const deviceManufacturer = iterator.getByteString(4);
7631
- const deviceModel = iterator.getByteString(4);
7649
+ const deviceManufacturer = iterator.getByteString(4, false);
7650
+ const deviceModel = iterator.getByteString(4, false);
7632
7651
  const deviceAttributes = iterator.getUint64();
7633
7652
  const renderingIntent = iterator.getUint32();
7634
7653
  const pcsIlluminant1 = iterator.getUint32();
7635
7654
  const pcsIlluminant2 = iterator.getUint32();
7636
7655
  const pcsIlluminant3 = iterator.getUint32();
7637
- const profileCreator = iterator.getByteString(4);
7638
- const profileId = iterator.getByteString(16);
7656
+ const profileCreator = iterator.getByteString(4, false);
7657
+ const profileId = iterator.getByteString(16, false);
7639
7658
  iterator.discard(28);
7640
7659
  const tagCount = iterator.getUint32();
7641
7660
  const entries = [];
7642
7661
  for (let i = 0;i < tagCount; i++) {
7643
7662
  const entry = {
7644
- tag: iterator.getByteString(4),
7663
+ tag: iterator.getByteString(4, false),
7645
7664
  offset: iterator.getUint32(),
7646
7665
  size: iterator.getUint32()
7647
7666
  };
@@ -7718,7 +7737,7 @@ var parseColorParameterBox = ({
7718
7737
  iterator,
7719
7738
  size
7720
7739
  }) => {
7721
- const byteString = iterator.getByteString(4);
7740
+ const byteString = iterator.getByteString(4, false);
7722
7741
  if (byteString === "nclx") {
7723
7742
  const primaries2 = iterator.getUint16();
7724
7743
  const transfer = iterator.getUint16();
@@ -7824,7 +7843,7 @@ var parseKeys = ({
7824
7843
  for (let i = 0;i < entryCount; i++) {
7825
7844
  const keySize = iterator.getUint32();
7826
7845
  const namespace = iterator.getAtom();
7827
- const value = iterator.getByteString(keySize - 8);
7846
+ const value = iterator.getByteString(keySize - 8, false);
7828
7847
  const entry = {
7829
7848
  keySize,
7830
7849
  namespace,
@@ -8752,7 +8771,7 @@ var processBox = async ({
8752
8771
  skipTo: null
8753
8772
  };
8754
8773
  }
8755
- const boxType = iterator.getByteString(4);
8774
+ const boxType = iterator.getByteString(4, false);
8756
8775
  const boxSize = boxSizeRaw === 1 ? iterator.getEightByteNumber() : boxSizeRaw;
8757
8776
  if (bytesRemaining < boxSize) {
8758
8777
  if (boxType === "mdat") {
@@ -9241,9 +9260,6 @@ var parseIsoBaseMediaBoxes = async ({
9241
9260
  initialBoxes = initialBoxes.filter((b) => b.type !== "mdat-box");
9242
9261
  initialBoxes.push(result.box);
9243
9262
  iterator.allowDiscard();
9244
- if (result.box.status !== "samples-processed") {
9245
- throw new Error("unexpected");
9246
- }
9247
9263
  break;
9248
9264
  } else {
9249
9265
  initialBoxes.push(result.box);
@@ -9331,7 +9347,7 @@ var isMoviAtom = (iterator, ckId) => {
9331
9347
  if (ckId !== "LIST") {
9332
9348
  return false;
9333
9349
  }
9334
- const listType = iterator.getByteString(4);
9350
+ const listType = iterator.getByteString(4, false);
9335
9351
  iterator.counter.decrement(4);
9336
9352
  return listType === "movi";
9337
9353
  };
@@ -9663,7 +9679,7 @@ var parseMovi = async ({
9663
9679
  }
9664
9680
  };
9665
9681
  }
9666
- const ckId = iterator.getByteString(4);
9682
+ const ckId = iterator.getByteString(4, false);
9667
9683
  const ckSize = iterator.getUint32Le();
9668
9684
  if (maySkipVideoData({
9669
9685
  state
@@ -9787,7 +9803,7 @@ var parseIsft = ({
9787
9803
  size
9788
9804
  }) => {
9789
9805
  const { expectNoMoreBytes } = iterator.startBox(size);
9790
- const software = iterator.getByteString(size - 1);
9806
+ const software = iterator.getByteString(size - 1, false);
9791
9807
  const last = iterator.getUint8();
9792
9808
  if (last !== 0) {
9793
9809
  throw new Error(`Expected 0 byte, got ${last}`);
@@ -9806,7 +9822,7 @@ var parseListBox = async ({
9806
9822
  state
9807
9823
  }) => {
9808
9824
  const counter = iterator.counter.getOffset();
9809
- const listType = iterator.getByteString(4);
9825
+ const listType = iterator.getByteString(4, false);
9810
9826
  if (listType === "movi") {
9811
9827
  throw new Error("should not be handled here");
9812
9828
  }
@@ -9865,7 +9881,7 @@ var parseStrfVideo = ({
9865
9881
  const height = iterator.getInt32Le();
9866
9882
  const planes = iterator.getUint16Le();
9867
9883
  const bitCount = iterator.getUint16Le();
9868
- const compression = iterator.getByteString(4);
9884
+ const compression = iterator.getByteString(4, false);
9869
9885
  const sizeImage = iterator.getUint32Le();
9870
9886
  const xPelsPerMeter = iterator.getInt32Le();
9871
9887
  const yPelsPerMeter = iterator.getInt32Le();
@@ -9911,11 +9927,11 @@ var parseStrh = ({
9911
9927
  size
9912
9928
  }) => {
9913
9929
  const box = iterator.startBox(size);
9914
- const fccType = iterator.getByteString(4);
9930
+ const fccType = iterator.getByteString(4, false);
9915
9931
  if (fccType !== "vids" && fccType !== "auds") {
9916
9932
  throw new Error("Expected AVI handler to be vids / auds");
9917
9933
  }
9918
- const handler = fccType === "vids" ? iterator.getByteString(4) : iterator.getUint32Le();
9934
+ const handler = fccType === "vids" ? iterator.getByteString(4, false) : iterator.getUint32Le();
9919
9935
  if (typeof handler === "string" && handler !== "H264") {
9920
9936
  throw new Error(`Only H264 is supported as a stream type in .avi, got ${handler}`);
9921
9937
  }
@@ -10001,7 +10017,7 @@ var expectRiffBox = async ({
10001
10017
  }
10002
10018
  };
10003
10019
  }
10004
- const ckId = iterator.getByteString(4);
10020
+ const ckId = iterator.getByteString(4, false);
10005
10021
  const ckSize = iterator.getUint32Le();
10006
10022
  if (isMoviAtom(iterator, ckId)) {
10007
10023
  iterator.discard(4);
@@ -10159,7 +10175,7 @@ var parseRiff = ({
10159
10175
  state,
10160
10176
  fields
10161
10177
  }) => {
10162
- const riff = iterator.getByteString(4);
10178
+ const riff = iterator.getByteString(4, false);
10163
10179
  if (riff !== "RIFF") {
10164
10180
  throw new Error("Not a RIFF file");
10165
10181
  }
@@ -10168,7 +10184,7 @@ var parseRiff = ({
10168
10184
  throw new Error("Structure is not a RIFF structure");
10169
10185
  }
10170
10186
  const size = iterator.getUint32Le();
10171
- const fileType = iterator.getByteString(4);
10187
+ const fileType = iterator.getByteString(4, false);
10172
10188
  if (fileType !== "WAVE" && fileType !== "AVI") {
10173
10189
  throw new Error(`File type ${fileType} not supported`);
10174
10190
  }
@@ -11090,7 +11106,7 @@ var parseEbml = async (iterator, state) => {
11090
11106
  };
11091
11107
  }
11092
11108
  if (hasInMap.type === "string") {
11093
- const value = iterator.getByteString(size);
11109
+ const value = iterator.getByteString(size, true);
11094
11110
  return {
11095
11111
  type: hasInMap.name,
11096
11112
  value,
@@ -1,8 +1,14 @@
1
1
  // src/writers/web-fs.ts
2
2
  var createContent = async ({ filename }) => {
3
3
  const directoryHandle = await navigator.storage.getDirectory();
4
- directoryHandle.removeEntry(filename);
5
- const fileHandle = await directoryHandle.getFileHandle(filename, {
4
+ const actualFilename = `__remotion_mediaparser:${filename}`;
5
+ const remove = async () => {
6
+ await directoryHandle.removeEntry(actualFilename, {
7
+ recursive: true
8
+ });
9
+ };
10
+ await remove();
11
+ const fileHandle = await directoryHandle.getFileHandle(actualFilename, {
6
12
  create: true
7
13
  });
8
14
  const writable = await fileHandle.createWritable();
@@ -17,11 +23,6 @@ var createContent = async ({ filename }) => {
17
23
  await writable.write(data);
18
24
  await writable.seek(written);
19
25
  };
20
- const remove = async () => {
21
- await directoryHandle.removeEntry(filename, {
22
- recursive: true
23
- });
24
- };
25
26
  const writer = {
26
27
  write: (arr) => {
27
28
  writPromise = writPromise.then(() => write(arr));
@@ -32,7 +33,7 @@ var createContent = async ({ filename }) => {
32
33
  await writable.close();
33
34
  } catch {
34
35
  }
35
- const newHandle = await directoryHandle.getFileHandle(filename, {
36
+ const newHandle = await directoryHandle.getFileHandle(actualFilename, {
36
37
  create: true
37
38
  });
38
39
  const newFile = await newHandle.getFile();
@@ -11,7 +11,7 @@ type AudioCodecInfo = {
11
11
  secondarySpecificator: number | null;
12
12
  description: Uint8Array | undefined;
13
13
  };
14
- export declare const getCodecPrivateFromTrak: (trakBox: TrakBox) => Uint8Array<ArrayBufferLike> | null;
14
+ export declare const getCodecPrivateFromTrak: (trakBox: TrakBox) => Uint8Array | null;
15
15
  export declare const getNumberOfChannelsFromTrak: (trak: TrakBox) => number | null;
16
16
  export declare const getSampleRate: (trak: TrakBox) => number | null;
17
17
  export declare const getAudioCodecFromTrak: (trak: TrakBox) => AudioCodecInfo | null;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.243";
1
+ export declare const VERSION = "4.0.245";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.0.243';
5
+ exports.VERSION = '4.0.245';
@@ -3,8 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.canUseWebFsWriter = exports.webFsWriter = void 0;
4
4
  const createContent = async ({ filename }) => {
5
5
  const directoryHandle = await navigator.storage.getDirectory();
6
- directoryHandle.removeEntry(filename);
7
- const fileHandle = await directoryHandle.getFileHandle(filename, {
6
+ const actualFilename = `__remotion_mediaparser:${filename}`;
7
+ const remove = async () => {
8
+ await directoryHandle.removeEntry(actualFilename, {
9
+ recursive: true,
10
+ });
11
+ };
12
+ await remove();
13
+ const fileHandle = await directoryHandle.getFileHandle(actualFilename, {
8
14
  create: true,
9
15
  });
10
16
  const writable = await fileHandle.createWritable();
@@ -19,11 +25,6 @@ const createContent = async ({ filename }) => {
19
25
  await writable.write(data);
20
26
  await writable.seek(written);
21
27
  };
22
- const remove = async () => {
23
- await directoryHandle.removeEntry(filename, {
24
- recursive: true,
25
- });
26
- };
27
28
  const writer = {
28
29
  write: (arr) => {
29
30
  writPromise = writPromise.then(() => write(arr));
@@ -36,7 +37,7 @@ const createContent = async ({ filename }) => {
36
37
  catch (_a) {
37
38
  // Ignore, could already be closed
38
39
  }
39
- const newHandle = await directoryHandle.getFileHandle(filename, {
40
+ const newHandle = await directoryHandle.getFileHandle(actualFilename, {
40
41
  create: true,
41
42
  });
42
43
  const newFile = await newHandle.getFile();
package/package.json CHANGED
@@ -3,14 +3,14 @@
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.243",
6
+ "version": "4.0.245",
7
7
  "main": "dist/index.js",
8
8
  "sideEffects": false,
9
9
  "devDependencies": {
10
10
  "@types/wicg-file-system-access": "2023.10.5",
11
11
  "eslint": "9.14.0",
12
- "@remotion/example-videos": "4.0.243",
13
- "@remotion/eslint-config-internal": "4.0.243"
12
+ "@remotion/example-videos": "4.0.245",
13
+ "@remotion/eslint-config-internal": "4.0.245"
14
14
  },
15
15
  "publishConfig": {
16
16
  "access": "public"
@@ -1,2 +0,0 @@
1
- import type { SpsAndPps } from '../../state/parser-state';
2
- export declare const getAvccBoxContent: (avc1Profile: SpsAndPps) => Uint8Array<ArrayBufferLike>;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAvccBoxContent = void 0;
4
- const make_header_1 = require("../webm/make-header");
5
- const getAvccBoxContent = (avc1Profile) => {
6
- return (0, make_header_1.combineUint8Arrays)([
7
- new Uint8Array([
8
- // https://gist.github.com/uupaa/8493378ec15f644a3d2b
9
- 1, // version
10
- avc1Profile.sps.spsData.profile,
11
- avc1Profile.sps.spsData.compatibility,
12
- avc1Profile.sps.spsData.level,
13
- 0xff,
14
- 0xe1,
15
- ]),
16
- // sequence parameter set length
17
- (0, make_header_1.serializeUint16)(avc1Profile.sps.sps.length),
18
- // sequence parameter set
19
- avc1Profile.sps.sps,
20
- // num of PPS
21
- new Uint8Array([0x01]),
22
- // picture parameter set length
23
- (0, make_header_1.serializeUint16)(avc1Profile.pps.pps.length),
24
- // PPS
25
- avc1Profile.pps.pps,
26
- ]);
27
- };
28
- exports.getAvccBoxContent = getAvccBoxContent;
@@ -1 +0,0 @@
1
- export declare const detectFileType: (data: Uint8Array) => "webp" | "riff" | "webm" | "iso-base-media" | "transport-stream" | "mp3" | "gif" | "png" | "bmp" | "jpeg" | "unknown";