@remotion/media-parser 4.0.240 → 4.0.242

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 (186) hide show
  1. package/dist/add-avc-profile-to-track.js +2 -2
  2. package/dist/boxes/avc/codec-private.d.ts +1 -1
  3. package/dist/boxes/avc/codec-private.js +2 -2
  4. package/dist/boxes/avc/create-sps-pps-data.d.ts +2 -0
  5. package/dist/boxes/avc/create-sps-pps-data.js +28 -0
  6. package/dist/boxes/iso-base-media/get-keyframes.d.ts +3 -0
  7. package/dist/boxes/iso-base-media/get-keyframes.js +30 -0
  8. package/dist/boxes/iso-base-media/mdat/mdat.d.ts +3 -3
  9. package/dist/boxes/iso-base-media/mdat/mdat.js +9 -5
  10. package/dist/boxes/iso-base-media/moov/moov.d.ts +3 -3
  11. package/dist/boxes/iso-base-media/moov/moov.js +5 -4
  12. package/dist/boxes/iso-base-media/process-box.d.ts +9 -9
  13. package/dist/boxes/iso-base-media/process-box.js +48 -56
  14. package/dist/boxes/iso-base-media/stsd/mebx.d.ts +3 -3
  15. package/dist/boxes/iso-base-media/stsd/mebx.js +5 -4
  16. package/dist/boxes/iso-base-media/stsd/samples.d.ts +5 -5
  17. package/dist/boxes/iso-base-media/stsd/samples.js +19 -16
  18. package/dist/boxes/iso-base-media/stsd/stsd.d.ts +3 -3
  19. package/dist/boxes/iso-base-media/stsd/stsd.js +2 -2
  20. package/dist/boxes/iso-base-media/trak/trak.d.ts +3 -3
  21. package/dist/boxes/iso-base-media/trak/trak.js +7 -6
  22. package/dist/boxes/riff/expect-riff-box.d.ts +3 -3
  23. package/dist/boxes/riff/expect-riff-box.js +5 -5
  24. package/dist/boxes/riff/get-tracks-from-avi.js +1 -1
  25. package/dist/boxes/riff/parse-box.d.ts +7 -7
  26. package/dist/boxes/riff/parse-box.js +29 -24
  27. package/dist/boxes/riff/parse-list-box.d.ts +3 -3
  28. package/dist/boxes/riff/parse-list-box.js +2 -2
  29. package/dist/boxes/riff/parse-movi.d.ts +5 -5
  30. package/dist/boxes/riff/parse-movi.js +35 -20
  31. package/dist/boxes/riff/parse-riff-box.d.ts +3 -3
  32. package/dist/boxes/riff/parse-riff-box.js +2 -2
  33. package/dist/boxes/transport-stream/adts-header.d.ts +1 -1
  34. package/dist/boxes/transport-stream/discard-rest-of-packet.d.ts +1 -1
  35. package/dist/boxes/transport-stream/get-tracks.js +1 -1
  36. package/dist/boxes/transport-stream/handle-aac-packet.d.ts +4 -3
  37. package/dist/boxes/transport-stream/handle-aac-packet.js +6 -4
  38. package/dist/boxes/transport-stream/handle-avc-packet.d.ts +4 -3
  39. package/dist/boxes/transport-stream/handle-avc-packet.js +8 -6
  40. package/dist/boxes/transport-stream/parse-packet.d.ts +3 -3
  41. package/dist/boxes/transport-stream/parse-packet.js +2 -2
  42. package/dist/boxes/transport-stream/parse-stream-packet.d.ts +3 -3
  43. package/dist/boxes/transport-stream/parse-stream-packet.js +14 -7
  44. package/dist/boxes/transport-stream/parse-transport-stream.d.ts +5 -6
  45. package/dist/boxes/transport-stream/parse-transport-stream.js +10 -9
  46. package/dist/boxes/transport-stream/process-stream-buffers.d.ts +6 -5
  47. package/dist/boxes/transport-stream/process-stream-buffers.js +18 -8
  48. package/dist/boxes/webm/ebml.d.ts +1 -1
  49. package/dist/boxes/webm/get-sample-from-block.d.ts +2 -2
  50. package/dist/boxes/webm/get-sample-from-block.js +8 -4
  51. package/dist/boxes/webm/make-header.d.ts +3 -3
  52. package/dist/boxes/webm/parse-ebml.d.ts +4 -4
  53. package/dist/boxes/webm/parse-ebml.js +18 -18
  54. package/dist/boxes/webm/parse-webm-header.d.ts +5 -5
  55. package/dist/boxes/webm/parse-webm-header.js +6 -5
  56. package/dist/boxes/webm/segments/parse-children.d.ts +5 -5
  57. package/dist/boxes/webm/segments/parse-children.js +12 -13
  58. package/dist/boxes/webm/segments.d.ts +3 -3
  59. package/dist/boxes/webm/segments.js +13 -13
  60. package/dist/buffer-iterator.d.ts +2 -6
  61. package/dist/buffer-iterator.js +4 -29
  62. package/dist/convert-audio-or-video-sample.js +2 -0
  63. package/dist/create/iso-base-media/codec-specific/avc1.d.ts +1 -1
  64. package/dist/create/iso-base-media/codec-specific/create-codec-specific-data.d.ts +1 -1
  65. package/dist/create/iso-base-media/codec-specific/mp4a.d.ts +1 -1
  66. package/dist/create/iso-base-media/create-colr.d.ts +1 -1
  67. package/dist/create/iso-base-media/create-ftyp.d.ts +2 -2
  68. package/dist/create/iso-base-media/create-ilst.d.ts +1 -1
  69. package/dist/create/iso-base-media/create-mdia.d.ts +1 -1
  70. package/dist/create/iso-base-media/create-moov.d.ts +1 -1
  71. package/dist/create/iso-base-media/create-mvhd.d.ts +1 -1
  72. package/dist/create/iso-base-media/create-trak.d.ts +1 -1
  73. package/dist/create/iso-base-media/create-udta.d.ts +1 -1
  74. package/dist/create/iso-base-media/create-url.d.ts +1 -1
  75. package/dist/create/iso-base-media/ilst/create-cmt.d.ts +1 -1
  76. package/dist/create/iso-base-media/ilst/create-too.d.ts +1 -1
  77. package/dist/create/iso-base-media/mdia/create-mdhd.d.ts +1 -1
  78. package/dist/create/iso-base-media/mp4-header.d.ts +1 -1
  79. package/dist/create/iso-base-media/primitives.d.ts +13 -13
  80. package/dist/create/iso-base-media/serialize-track.d.ts +1 -1
  81. package/dist/create/iso-base-media/trak/create-tkhd.d.ts +2 -2
  82. package/dist/create/iso-base-media/trak/mdia/create-minf.d.ts +1 -1
  83. package/dist/create/iso-base-media/trak/mdia/minf/create-dinf.d.ts +1 -1
  84. package/dist/create/iso-base-media/trak/mdia/minf/create-smhd.d.ts +1 -1
  85. package/dist/create/iso-base-media/trak/mdia/minf/create-stbl.d.ts +1 -1
  86. package/dist/create/iso-base-media/trak/mdia/minf/create-vmhd.d.ts +1 -1
  87. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.d.ts +1 -1
  88. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stco.d.ts +1 -1
  89. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.d.ts +1 -1
  90. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stss.d.ts +1 -1
  91. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.d.ts +1 -1
  92. package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stts.d.ts +1 -1
  93. package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avc1.d.ts +1 -1
  94. package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avcc.d.ts +1 -1
  95. package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-pasp.d.ts +1 -1
  96. package/dist/create/iso-base-media/udta/create-meta.d.ts +1 -1
  97. package/dist/create/iso-base-media/udta/meta/create-hdlr.d.ts +1 -1
  98. package/dist/create/matroska/cluster-segment.d.ts +1 -1
  99. package/dist/emit-available-info.d.ts +6 -4
  100. package/dist/emit-available-info.js +231 -79
  101. package/dist/errors/detect-file-type.d.ts +1 -0
  102. package/dist/errors/detect-file-type.js +88 -0
  103. package/dist/errors/file-types.d.ts +1 -0
  104. package/dist/errors/file-types.js +88 -0
  105. package/dist/errors.d.ts +68 -0
  106. package/dist/errors.js +71 -0
  107. package/dist/esm/from-fetch.mjs +1 -0
  108. package/dist/esm/from-node.mjs +1 -0
  109. package/dist/esm/from-web-file.mjs +2 -1
  110. package/dist/esm/index.mjs +1457 -542
  111. package/dist/file-types/bmp.d.ts +6 -0
  112. package/dist/file-types/bmp.js +23 -0
  113. package/dist/file-types/detect-file-type.d.ts +42 -0
  114. package/dist/file-types/detect-file-type.js +59 -0
  115. package/dist/file-types/get-jpeg-dimensions.d.ts +4 -0
  116. package/dist/file-types/get-jpeg-dimensions.js +32 -0
  117. package/dist/file-types/index.d.ts +2 -0
  118. package/dist/file-types/index.js +57 -0
  119. package/dist/file-types/jpeg.d.ts +12 -0
  120. package/dist/file-types/jpeg.js +44 -0
  121. package/dist/file-types/pdf.d.ts +4 -0
  122. package/dist/file-types/pdf.js +12 -0
  123. package/dist/file-types/png.d.ts +10 -0
  124. package/dist/file-types/png.js +32 -0
  125. package/dist/file-types/webp.d.ts +6 -0
  126. package/dist/file-types/webp.js +69 -0
  127. package/dist/file-types.d.ts +1 -0
  128. package/dist/file-types.js +88 -0
  129. package/dist/get-audio-codec.d.ts +1 -1
  130. package/dist/get-duration.d.ts +1 -0
  131. package/dist/get-duration.js +14 -1
  132. package/dist/get-fields-from-callbacks.d.ts +5 -0
  133. package/dist/get-fields-from-callbacks.js +32 -0
  134. package/dist/get-fps.d.ts +1 -0
  135. package/dist/get-fps.js +17 -12
  136. package/dist/get-keyframes.d.ts +5 -0
  137. package/dist/get-keyframes.js +20 -0
  138. package/dist/get-tracks.d.ts +7 -1
  139. package/dist/get-tracks.js +15 -10
  140. package/dist/has-all-info.d.ts +5 -4
  141. package/dist/has-all-info.js +31 -5
  142. package/dist/index.d.ts +2 -0
  143. package/dist/index.js +7 -1
  144. package/dist/may-skip-video-data/may-skip-video-data.d.ts +4 -0
  145. package/dist/may-skip-video-data/may-skip-video-data.js +14 -0
  146. package/dist/may-skip-video-data/need-samples-for-fields.d.ts +5 -0
  147. package/dist/may-skip-video-data/need-samples-for-fields.js +33 -0
  148. package/dist/options.d.ts +68 -53
  149. package/dist/parse-media.js +42 -31
  150. package/dist/parse-result.d.ts +2 -4
  151. package/dist/parse-video.d.ts +8 -5
  152. package/dist/parse-video.js +94 -17
  153. package/dist/probing/detect-file-type.d.ts +1 -0
  154. package/dist/probing/detect-file-type.js +88 -0
  155. package/dist/probing/get-jpeg-dimensions.d.ts +4 -0
  156. package/dist/probing/get-jpeg-dimensions.js +32 -0
  157. package/dist/readers/from-fetch.js +1 -0
  158. package/dist/readers/from-node.js +1 -0
  159. package/dist/readers/from-web-file.js +1 -0
  160. package/dist/readers/reader.d.ts +1 -0
  161. package/dist/register-track.d.ts +5 -5
  162. package/dist/register-track.js +12 -12
  163. package/dist/state/can-skip-tracks.js +6 -0
  164. package/dist/state/emitted-fields.d.ts +2 -0
  165. package/dist/state/emitted-fields.js +31 -0
  166. package/dist/state/has-tracks-section.d.ts +1 -0
  167. package/dist/state/keyframes.d.ts +6 -0
  168. package/dist/state/keyframes.js +15 -0
  169. package/dist/state/parser-state.d.ts +60 -29
  170. package/dist/state/parser-state.js +32 -150
  171. package/dist/state/riff.d.ts +10 -0
  172. package/dist/state/riff.js +32 -0
  173. package/dist/state/sample-callbacks.d.ts +31 -0
  174. package/dist/state/sample-callbacks.js +96 -0
  175. package/dist/state/slow-duration-fps.d.ts +8 -0
  176. package/dist/state/slow-duration-fps.js +36 -0
  177. package/dist/state/structure.d.ts +7 -0
  178. package/dist/state/structure.js +21 -0
  179. package/dist/state/tracks-and-samples.d.ts +0 -0
  180. package/dist/state/tracks-and-samples.js +1 -0
  181. package/dist/state/webm.d.ts +11 -0
  182. package/dist/state/webm.js +67 -0
  183. package/dist/version.d.ts +1 -1
  184. package/dist/version.js +1 -1
  185. package/dist/webcodec-sample-types.d.ts +2 -0
  186. package/package.json +3 -3
@@ -7,4 +7,4 @@ export declare const createMvhd: ({ timescale, durationInUnits, rate, volume, ne
7
7
  matrix: number[];
8
8
  creationTime: number | null;
9
9
  modificationTime: number | null;
10
- }) => Uint8Array;
10
+ }) => Uint8Array<ArrayBufferLike>;
@@ -1,4 +1,4 @@
1
1
  export declare const createTrak: ({ tkhd, mdia, }: {
2
2
  tkhd: Uint8Array;
3
3
  mdia: Uint8Array;
4
- }) => Uint8Array;
4
+ }) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createUdta: (children: Uint8Array) => Uint8Array;
1
+ export declare const createUdta: (children: Uint8Array) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createUrlAtom: () => Uint8Array;
1
+ export declare const createUrlAtom: () => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createCmt: (comment: string) => Uint8Array;
1
+ export declare const createCmt: (comment: string) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createToo: (value: string) => Uint8Array;
1
+ export declare const createToo: (value: string) => Uint8Array<ArrayBufferLike>;
@@ -3,4 +3,4 @@ export declare const createMdhd: ({ creationTime, modificationTime, timescale, d
3
3
  modificationTime: number | null;
4
4
  timescale: number;
5
5
  duration: number;
6
- }) => Uint8Array;
6
+ }) => Uint8Array<ArrayBufferLike>;
@@ -3,4 +3,4 @@ export declare const createPaddedMoovAtom: ({ durationInUnits, trackInfo, timesc
3
3
  durationInUnits: number;
4
4
  trackInfo: IsoBaseMediaTrackData[];
5
5
  timescale: number;
6
- }) => Uint8Array;
6
+ }) => Uint8Array<ArrayBufferLike>;
@@ -1,15 +1,15 @@
1
1
  import type { ThreeDMatrix } from '../../boxes/iso-base-media/mvhd';
2
- export declare const stringsToUint8Array: (str: string) => Uint8Array;
3
- export declare const numberTo32BitUIntOrInt: (num: number) => Uint8Array;
4
- export declare const numberTo32BitUIntOrIntLeading128: (num: number) => Uint8Array;
5
- export declare const numberTo16BitUIntOrInt: (num: number) => Uint8Array;
6
- export declare const setFixedPointSignedOrUnsigned1616Number: (num: number) => Uint8Array;
7
- export declare const setFixedPointSigned230Number: (num: number) => Uint8Array;
8
- export declare const addSize: (arr: Uint8Array) => Uint8Array;
9
- export declare const addLeading128Size: (arr: Uint8Array) => Uint8Array;
10
- export declare const floatTo16Point1632Bit: (number: number) => Uint8Array;
11
- export declare const floatTo16Point16_16Bit: (number: number) => Uint8Array;
12
- export declare const serializeMatrix: (matrix: number[]) => Uint8Array;
13
- export declare const stringToPascalString: (str: string) => Uint8Array;
14
- export declare const padIsoBaseMediaBytes: (data: Uint8Array, totalLength: number) => Uint8Array;
2
+ export declare const stringsToUint8Array: (str: string) => Uint8Array<ArrayBufferLike>;
3
+ export declare const numberTo32BitUIntOrInt: (num: number) => Uint8Array<ArrayBuffer>;
4
+ export declare const numberTo32BitUIntOrIntLeading128: (num: number) => Uint8Array<ArrayBuffer>;
5
+ export declare const numberTo16BitUIntOrInt: (num: number) => Uint8Array<ArrayBuffer>;
6
+ export declare const setFixedPointSignedOrUnsigned1616Number: (num: number) => Uint8Array<ArrayBuffer>;
7
+ export declare const setFixedPointSigned230Number: (num: number) => Uint8Array<ArrayBuffer>;
8
+ export declare const addSize: (arr: Uint8Array) => Uint8Array<ArrayBufferLike>;
9
+ export declare const addLeading128Size: (arr: Uint8Array) => Uint8Array<ArrayBufferLike>;
10
+ export declare const floatTo16Point1632Bit: (number: number) => Uint8Array<ArrayBuffer>;
11
+ export declare const floatTo16Point16_16Bit: (number: number) => Uint8Array<ArrayBuffer>;
12
+ export declare const serializeMatrix: (matrix: number[]) => Uint8Array<ArrayBufferLike>;
13
+ export declare const stringToPascalString: (str: string) => Uint8Array<ArrayBuffer>;
14
+ export declare const padIsoBaseMediaBytes: (data: Uint8Array, totalLength: number) => Uint8Array<ArrayBufferLike>;
15
15
  export declare const IDENTITY_MATRIX: ThreeDMatrix;
@@ -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;
9
+ export declare const serializeTrack: ({ track, durationInUnits, samplePositions, timescale, }: IsoBaseMediaTrackData) => Uint8Array<ArrayBufferLike>;
@@ -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;
15
+ }) => Uint8Array<ArrayBufferLike>;
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;
27
+ }) => Uint8Array<ArrayBufferLike>;
@@ -1,4 +1,4 @@
1
1
  export declare const createMinf: ({ vmhdAtom, stblAtom, }: {
2
2
  vmhdAtom: Uint8Array;
3
3
  stblAtom: Uint8Array;
4
- }) => Uint8Array;
4
+ }) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createDinf: () => Uint8Array;
1
+ export declare const createDinf: () => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createSmhd: () => Uint8Array;
1
+ export declare const createSmhd: () => Uint8Array<ArrayBufferLike>;
@@ -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;
6
+ }) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createVmhd: () => Uint8Array;
1
+ export declare const createVmhd: () => Uint8Array<ArrayBufferLike>;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createCttsBox: (samplePositions: SamplePosition[]) => Uint8Array | null;
2
+ export declare const createCttsBox: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike> | null;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createStcoAtom: (samplePositions: SamplePosition[]) => Uint8Array;
2
+ export declare const createStcoAtom: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createStsc: (samplePositions: SamplePosition[]) => Uint8Array;
2
+ export declare const createStsc: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createStss: (samplePositions: SamplePosition[]) => Uint8Array;
2
+ export declare const createStss: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createStsz: (samplePositions: SamplePosition[]) => Uint8Array;
2
+ export declare const createStsz: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
@@ -1,2 +1,2 @@
1
1
  import type { SamplePosition } from '../../../../../../get-sample-positions';
2
- export declare const createSttsAtom: (samplePositions: SamplePosition[]) => Uint8Array;
2
+ export declare const createSttsAtom: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createStsdData: (codecSpecificData: Uint8Array) => Uint8Array;
1
+ export declare const createStsdData: (codecSpecificData: Uint8Array) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createAvccBox: (privateData: Uint8Array | null) => Uint8Array;
1
+ export declare const createAvccBox: (privateData: Uint8Array | null) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createPasp: (x: number, y: number) => Uint8Array;
1
+ export declare const createPasp: (x: number, y: number) => Uint8Array<ArrayBufferLike>;
@@ -1,4 +1,4 @@
1
1
  export declare const createMeta: ({ hdlr, ilst, }: {
2
2
  hdlr: Uint8Array;
3
3
  ilst: Uint8Array;
4
- }) => Uint8Array;
4
+ }) => Uint8Array<ArrayBufferLike>;
@@ -1 +1 @@
1
- export declare const createHdlr: (type: "video" | "audio" | "mdir") => Uint8Array;
1
+ export declare const createHdlr: (type: "video" | "audio" | "mdir") => Uint8Array<ArrayBufferLike>;
@@ -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;
10
+ }) => Uint8Array<ArrayBufferLike>;
@@ -1,12 +1,14 @@
1
1
  import type { AllParseMediaFields, Options, ParseMediaCallbacks, ParseMediaFields, ParseMediaResult } from './options';
2
- import type { ParseResult, Structure } from './parse-result';
2
+ import type { ParseResult } from './parse-result';
3
3
  import type { ParserState } from './state/parser-state';
4
- export declare const emitAvailableInfo: ({ hasInfo, parseResult, moreFields, state, returnValue, contentLength, name, }: {
4
+ export declare const emitAvailableInfo: ({ hasInfo, parseResult, callbacks, state, returnValue, contentLength, name, mimeType, fieldsInReturnValue, }: {
5
5
  hasInfo: Record<keyof Options<ParseMediaFields>, boolean>;
6
- parseResult: ParseResult<Structure> | null;
7
- moreFields: ParseMediaCallbacks<AllParseMediaFields>;
6
+ parseResult: ParseResult | null;
7
+ callbacks: ParseMediaCallbacks;
8
+ fieldsInReturnValue: Options<ParseMediaFields>;
8
9
  state: ParserState;
9
10
  returnValue: ParseMediaResult<AllParseMediaFields>;
10
11
  contentLength: number | null;
12
+ mimeType: string | null;
11
13
  name: string;
12
14
  }) => void;
@@ -7,109 +7,192 @@ const get_dimensions_1 = require("./get-dimensions");
7
7
  const get_duration_1 = require("./get-duration");
8
8
  const get_fps_1 = require("./get-fps");
9
9
  const get_is_hdr_1 = require("./get-is-hdr");
10
+ const get_keyframes_1 = require("./get-keyframes");
10
11
  const get_location_1 = require("./get-location");
11
12
  const get_tracks_1 = require("./get-tracks");
12
13
  const get_video_codec_1 = require("./get-video-codec");
13
14
  const get_metadata_1 = require("./metadata/get-metadata");
14
- const emitAvailableInfo = ({ hasInfo, parseResult, moreFields, state, returnValue, contentLength, name, }) => {
15
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
15
+ const emitAvailableInfo = ({ hasInfo, parseResult, callbacks, state, returnValue, contentLength, name, mimeType, fieldsInReturnValue, }) => {
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
16
17
  const keys = Object.keys(hasInfo);
18
+ const segments = state.structure.getStructureOrNull();
19
+ const { emittedFields } = state;
17
20
  for (const key of keys) {
18
21
  if (key === 'structure') {
19
22
  if (parseResult &&
20
23
  hasInfo.structure &&
21
- returnValue.structure === undefined) {
22
- (_a = moreFields.onStructure) === null || _a === void 0 ? void 0 : _a.call(moreFields, parseResult.segments);
23
- returnValue.structure = parseResult.segments;
24
+ !emittedFields.structure &&
25
+ segments) {
26
+ (_a = callbacks.onStructure) === null || _a === void 0 ? void 0 : _a.call(callbacks, segments);
27
+ if (fieldsInReturnValue.structure) {
28
+ returnValue.structure = segments;
29
+ }
30
+ emittedFields.structure = true;
24
31
  }
25
32
  continue;
26
33
  }
27
34
  if (key === 'durationInSeconds') {
28
- if (hasInfo.durationInSeconds &&
29
- returnValue.durationInSeconds === undefined &&
30
- parseResult) {
31
- const durationInSeconds = (0, get_duration_1.getDuration)(parseResult.segments, state);
32
- (_b = moreFields.onDurationInSeconds) === null || _b === void 0 ? void 0 : _b.call(moreFields, durationInSeconds);
33
- returnValue.durationInSeconds = durationInSeconds;
35
+ if (hasInfo.durationInSeconds && parseResult && segments) {
36
+ if (!emittedFields.durationInSeconds) {
37
+ const durationInSeconds = (0, get_duration_1.getDuration)(segments, state);
38
+ (_b = callbacks.onDurationInSeconds) === null || _b === void 0 ? void 0 : _b.call(callbacks, durationInSeconds);
39
+ if (fieldsInReturnValue.durationInSeconds) {
40
+ returnValue.durationInSeconds = durationInSeconds;
41
+ }
42
+ emittedFields.durationInSeconds = true;
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
+ }
55
+ continue;
56
+ }
57
+ if (key === 'slowDurationInSeconds') {
58
+ if (hasInfo.slowDurationInSeconds &&
59
+ !emittedFields.slowDurationInSeconds &&
60
+ parseResult &&
61
+ segments) {
62
+ const slowDurationInSeconds = state.slowDurationAndFps.getSlowDurationInSeconds();
63
+ (_d = callbacks.onSlowDurationInSeconds) === null || _d === void 0 ? void 0 : _d.call(callbacks, slowDurationInSeconds);
64
+ if (fieldsInReturnValue.slowDurationInSeconds) {
65
+ returnValue.slowDurationInSeconds = slowDurationInSeconds;
66
+ }
67
+ emittedFields.slowDurationInSeconds = true;
68
+ }
69
+ continue;
70
+ }
71
+ if (key === 'fps') {
72
+ if (hasInfo.fps && parseResult && segments) {
73
+ if (!emittedFields.fps) {
74
+ const fps = (0, get_fps_1.getFps)(segments);
75
+ (_e = callbacks.onFps) === null || _e === void 0 ? void 0 : _e.call(callbacks, fps);
76
+ if (fieldsInReturnValue.fps) {
77
+ returnValue.fps = fps;
78
+ }
79
+ emittedFields.fps = true;
80
+ }
81
+ if (!emittedFields.slowFps) {
82
+ const fps = (0, get_fps_1.getFps)(segments);
83
+ if (fps) {
84
+ (_f = callbacks.onSlowFps) === null || _f === void 0 ? void 0 : _f.call(callbacks, fps);
85
+ if (fieldsInReturnValue.slowFps) {
86
+ returnValue.slowFps = fps;
87
+ }
88
+ emittedFields.slowFps = true;
89
+ }
90
+ }
91
+ }
92
+ continue;
93
+ }
94
+ // must be handled after fps
95
+ if (key === 'slowFps') {
96
+ if (hasInfo.slowFps &&
97
+ !emittedFields.slowFps &&
98
+ parseResult &&
99
+ segments) {
100
+ const slowFps = state.slowDurationAndFps.getFps();
101
+ (_g = callbacks.onSlowFps) === null || _g === void 0 ? void 0 : _g.call(callbacks, slowFps);
102
+ if (fieldsInReturnValue.slowFps) {
103
+ returnValue.slowFps = slowFps;
104
+ }
105
+ emittedFields.slowFps = true;
34
106
  }
35
107
  continue;
36
108
  }
37
109
  if (key === 'dimensions') {
38
110
  if (hasInfo.dimensions &&
39
- returnValue.dimensions === undefined &&
40
- parseResult) {
41
- const dimensionsQueried = (0, get_dimensions_1.getDimensions)(parseResult.segments, state);
111
+ !emittedFields.dimensions &&
112
+ parseResult &&
113
+ segments) {
114
+ const dimensionsQueried = (0, get_dimensions_1.getDimensions)(segments, state);
42
115
  const dimensions = {
43
116
  height: dimensionsQueried.height,
44
117
  width: dimensionsQueried.width,
45
118
  };
46
- (_c = moreFields.onDimensions) === null || _c === void 0 ? void 0 : _c.call(moreFields, dimensions);
47
- returnValue.dimensions = dimensions;
119
+ (_h = callbacks.onDimensions) === null || _h === void 0 ? void 0 : _h.call(callbacks, dimensions);
120
+ if (fieldsInReturnValue.dimensions) {
121
+ returnValue.dimensions = dimensions;
122
+ }
123
+ emittedFields.dimensions = true;
48
124
  }
49
125
  continue;
50
126
  }
51
127
  if (key === 'unrotatedDimensions') {
52
- if (returnValue.unrotatedDimensions === undefined &&
53
- hasInfo.unrotatedDimensions &&
54
- parseResult) {
55
- const dimensionsQueried = (0, get_dimensions_1.getDimensions)(parseResult.segments, state);
128
+ if (hasInfo.unrotatedDimensions &&
129
+ !emittedFields.unrotatedDimensions &&
130
+ parseResult &&
131
+ segments) {
132
+ const dimensionsQueried = (0, get_dimensions_1.getDimensions)(segments, state);
56
133
  const unrotatedDimensions = {
57
134
  height: dimensionsQueried.unrotatedHeight,
58
135
  width: dimensionsQueried.unrotatedWidth,
59
136
  };
60
- (_d = moreFields.onUnrotatedDimensions) === null || _d === void 0 ? void 0 : _d.call(moreFields, unrotatedDimensions);
61
- returnValue.unrotatedDimensions = unrotatedDimensions;
137
+ (_j = callbacks.onUnrotatedDimensions) === null || _j === void 0 ? void 0 : _j.call(callbacks, unrotatedDimensions);
138
+ if (fieldsInReturnValue.unrotatedDimensions) {
139
+ returnValue.unrotatedDimensions = unrotatedDimensions;
140
+ }
141
+ emittedFields.unrotatedDimensions = true;
62
142
  }
63
143
  continue;
64
144
  }
65
145
  if (key === 'rotation') {
66
- if (returnValue.rotation === undefined &&
67
- hasInfo.rotation &&
68
- parseResult) {
69
- const dimensionsQueried = (0, get_dimensions_1.getDimensions)(parseResult.segments, state);
146
+ if (hasInfo.rotation &&
147
+ !emittedFields.rotation &&
148
+ parseResult &&
149
+ segments) {
150
+ const dimensionsQueried = (0, get_dimensions_1.getDimensions)(segments, state);
70
151
  const { rotation } = dimensionsQueried;
71
- (_e = moreFields.onRotation) === null || _e === void 0 ? void 0 : _e.call(moreFields, rotation);
72
- returnValue.rotation = rotation;
73
- }
74
- continue;
75
- }
76
- if (key === 'fps') {
77
- if (returnValue.fps === undefined && hasInfo.fps && parseResult) {
78
- const fps = (0, get_fps_1.getFps)(parseResult.segments);
79
- (_f = moreFields.onFps) === null || _f === void 0 ? void 0 : _f.call(moreFields, fps);
80
- returnValue.fps = fps;
152
+ (_k = callbacks.onRotation) === null || _k === void 0 ? void 0 : _k.call(callbacks, rotation);
153
+ if (fieldsInReturnValue.rotation) {
154
+ returnValue.rotation = rotation;
155
+ }
156
+ emittedFields.rotation = true;
81
157
  }
82
158
  continue;
83
159
  }
84
160
  if (key === 'videoCodec') {
85
- if (returnValue.videoCodec === undefined &&
161
+ if (!emittedFields.videoCodec &&
86
162
  hasInfo.videoCodec &&
87
- parseResult) {
88
- const videoCodec = (0, get_video_codec_1.getVideoCodec)(parseResult.segments, state);
89
- (_g = moreFields.onVideoCodec) === null || _g === void 0 ? void 0 : _g.call(moreFields, videoCodec);
90
- returnValue.videoCodec = videoCodec;
163
+ parseResult &&
164
+ segments) {
165
+ const videoCodec = (0, get_video_codec_1.getVideoCodec)(segments, state);
166
+ (_l = callbacks.onVideoCodec) === null || _l === void 0 ? void 0 : _l.call(callbacks, videoCodec);
167
+ if (fieldsInReturnValue.videoCodec) {
168
+ returnValue.videoCodec = videoCodec;
169
+ }
170
+ emittedFields.videoCodec = true;
91
171
  }
92
172
  continue;
93
173
  }
94
174
  if (key === 'audioCodec') {
95
- if (returnValue.audioCodec === undefined &&
175
+ if (!emittedFields.audioCodec &&
96
176
  hasInfo.audioCodec &&
97
- parseResult) {
98
- const audioCodec = (0, get_audio_codec_1.getAudioCodec)(parseResult.segments, state);
99
- (_h = moreFields.onAudioCodec) === null || _h === void 0 ? void 0 : _h.call(moreFields, audioCodec);
100
- returnValue.audioCodec = audioCodec;
177
+ parseResult &&
178
+ segments) {
179
+ const audioCodec = (0, get_audio_codec_1.getAudioCodec)(segments, state);
180
+ (_m = callbacks.onAudioCodec) === null || _m === void 0 ? void 0 : _m.call(callbacks, audioCodec);
181
+ if (fieldsInReturnValue.audioCodec) {
182
+ returnValue.audioCodec = audioCodec;
183
+ }
184
+ emittedFields.audioCodec = true;
101
185
  }
102
186
  continue;
103
187
  }
104
188
  if (key === 'tracks') {
105
- if (hasInfo.tracks &&
106
- returnValue.videoTracks === undefined &&
107
- returnValue.audioTracks === undefined &&
108
- parseResult) {
109
- const { videoTracks, audioTracks } = (0, get_tracks_1.getTracks)(parseResult.segments, state);
110
- (_j = moreFields.onTracks) === null || _j === void 0 ? void 0 : _j.call(moreFields, { videoTracks, audioTracks });
111
- returnValue.videoTracks = videoTracks;
112
- returnValue.audioTracks = audioTracks;
189
+ if (!emittedFields.tracks && hasInfo.tracks && parseResult && segments) {
190
+ const { videoTracks, audioTracks } = (0, get_tracks_1.getTracks)(segments, state);
191
+ (_o = callbacks.onTracks) === null || _o === void 0 ? void 0 : _o.call(callbacks, { videoTracks, audioTracks });
192
+ if (fieldsInReturnValue.tracks) {
193
+ returnValue.tracks = { videoTracks, audioTracks };
194
+ }
195
+ emittedFields.tracks = true;
113
196
  }
114
197
  continue;
115
198
  }
@@ -117,59 +200,128 @@ const emitAvailableInfo = ({ hasInfo, parseResult, moreFields, state, returnValu
117
200
  // Special case: Always emitting internal stats at the end
118
201
  if (hasInfo.internalStats) {
119
202
  const internalStats = state.getInternalStats();
120
- returnValue.internalStats = internalStats;
203
+ if (fieldsInReturnValue.internalStats) {
204
+ returnValue.internalStats = internalStats;
205
+ }
206
+ emittedFields.internalStats = true;
121
207
  }
122
208
  continue;
123
209
  }
124
210
  if (key === 'size') {
125
- if (returnValue.size === undefined && hasInfo.size) {
126
- (_k = moreFields.onSize) === null || _k === void 0 ? void 0 : _k.call(moreFields, contentLength);
127
- returnValue.size = contentLength;
211
+ if (!emittedFields.size && hasInfo.size) {
212
+ (_p = callbacks.onSize) === null || _p === void 0 ? void 0 : _p.call(callbacks, contentLength);
213
+ if (fieldsInReturnValue.size) {
214
+ returnValue.size = contentLength;
215
+ }
216
+ emittedFields.size = true;
217
+ }
218
+ continue;
219
+ }
220
+ if (key === 'mimeType') {
221
+ if (!emittedFields.mimeType && hasInfo.mimeType) {
222
+ (_q = callbacks.onMimeType) === null || _q === void 0 ? void 0 : _q.call(callbacks, mimeType);
223
+ if (fieldsInReturnValue.mimeType) {
224
+ returnValue.mimeType = mimeType;
225
+ }
226
+ emittedFields.mimeType = true;
128
227
  }
129
228
  continue;
130
229
  }
131
230
  if (key === 'name') {
132
- if (returnValue.name === undefined && hasInfo.name) {
133
- (_l = moreFields.onName) === null || _l === void 0 ? void 0 : _l.call(moreFields, name);
134
- returnValue.name = name;
231
+ if (!emittedFields.name && hasInfo.name) {
232
+ (_r = callbacks.onName) === null || _r === void 0 ? void 0 : _r.call(callbacks, name);
233
+ if (fieldsInReturnValue.name) {
234
+ returnValue.name = name;
235
+ }
236
+ emittedFields.name = true;
135
237
  }
136
238
  continue;
137
239
  }
138
240
  if (key === 'isHdr') {
139
- if (returnValue.isHdr === undefined && hasInfo.isHdr && parseResult) {
140
- const isHdr = (0, get_is_hdr_1.getIsHdr)(parseResult.segments, state);
141
- (_m = moreFields.onIsHdr) === null || _m === void 0 ? void 0 : _m.call(moreFields, isHdr);
142
- returnValue.isHdr = isHdr;
241
+ if (!returnValue.isHdr && hasInfo.isHdr && parseResult && segments) {
242
+ const isHdr = (0, get_is_hdr_1.getIsHdr)(segments, state);
243
+ (_s = callbacks.onIsHdr) === null || _s === void 0 ? void 0 : _s.call(callbacks, isHdr);
244
+ if (fieldsInReturnValue.isHdr) {
245
+ returnValue.isHdr = isHdr;
246
+ }
247
+ emittedFields.isHdr = true;
143
248
  }
144
249
  continue;
145
250
  }
146
251
  if (key === 'container') {
147
- if (returnValue.container === undefined &&
252
+ if (!returnValue.container &&
148
253
  hasInfo.container &&
149
- parseResult) {
150
- const container = (0, get_container_1.getContainer)(parseResult.segments);
151
- (_o = moreFields.onContainer) === null || _o === void 0 ? void 0 : _o.call(moreFields, container);
152
- returnValue.container = container;
254
+ parseResult &&
255
+ segments) {
256
+ const container = (0, get_container_1.getContainer)(segments);
257
+ (_t = callbacks.onContainer) === null || _t === void 0 ? void 0 : _t.call(callbacks, container);
258
+ if (fieldsInReturnValue.container) {
259
+ returnValue.container = container;
260
+ }
261
+ emittedFields.container = true;
153
262
  }
154
263
  continue;
155
264
  }
156
265
  if (key === 'metadata') {
157
- if (returnValue.metadata === undefined &&
266
+ if (!emittedFields.metadata &&
158
267
  hasInfo.metadata &&
159
- parseResult) {
160
- const metadata = (0, get_metadata_1.getMetadata)(parseResult.segments);
161
- (_p = moreFields.onMetadata) === null || _p === void 0 ? void 0 : _p.call(moreFields, metadata);
162
- returnValue.metadata = metadata;
268
+ parseResult &&
269
+ segments) {
270
+ const metadata = (0, get_metadata_1.getMetadata)(segments);
271
+ (_u = callbacks.onMetadata) === null || _u === void 0 ? void 0 : _u.call(callbacks, metadata);
272
+ if (fieldsInReturnValue.metadata) {
273
+ returnValue.metadata = metadata;
274
+ }
275
+ emittedFields.metadata = true;
163
276
  }
164
277
  continue;
165
278
  }
166
279
  if (key === 'location') {
167
- if (returnValue.location === undefined &&
280
+ if (!emittedFields.location &&
168
281
  hasInfo.location &&
282
+ parseResult &&
283
+ segments) {
284
+ const location = (0, get_location_1.getLocation)(segments);
285
+ (_v = callbacks.onLocation) === null || _v === void 0 ? void 0 : _v.call(callbacks, location);
286
+ if (fieldsInReturnValue.location) {
287
+ returnValue.location = location;
288
+ }
289
+ emittedFields.location = true;
290
+ }
291
+ continue;
292
+ }
293
+ if (key === 'slowKeyframes') {
294
+ if (!emittedFields.slowKeyframes &&
295
+ hasInfo.slowKeyframes &&
169
296
  parseResult) {
170
- const location = (0, get_location_1.getLocation)(parseResult.segments);
171
- (_q = moreFields.onLocation) === null || _q === void 0 ? void 0 : _q.call(moreFields, location);
172
- returnValue.location = location;
297
+ (_w = callbacks.onSlowKeyframes) === null || _w === void 0 ? void 0 : _w.call(callbacks, state.keyframes.getKeyframes());
298
+ if (fieldsInReturnValue.slowKeyframes) {
299
+ returnValue.slowKeyframes = state.keyframes.getKeyframes();
300
+ }
301
+ emittedFields.slowKeyframes = true;
302
+ }
303
+ continue;
304
+ }
305
+ if (key === 'slowNumberOfFrames') {
306
+ if (!emittedFields.slowNumberOfFrames &&
307
+ hasInfo.slowNumberOfFrames &&
308
+ parseResult) {
309
+ (_x = callbacks.onSlowNumberOfFrames) === null || _x === void 0 ? void 0 : _x.call(callbacks, state.slowDurationAndFps.getSlowNumberOfFrames());
310
+ if (fieldsInReturnValue.slowNumberOfFrames) {
311
+ returnValue.slowNumberOfFrames =
312
+ state.slowDurationAndFps.getSlowNumberOfFrames();
313
+ }
314
+ emittedFields.slowNumberOfFrames = true;
315
+ }
316
+ continue;
317
+ }
318
+ if (key === 'keyframes') {
319
+ if (!emittedFields.keyframes && hasInfo.keyframes && parseResult) {
320
+ (_y = callbacks.onKeyframes) === null || _y === void 0 ? void 0 : _y.call(callbacks, (0, get_keyframes_1.getKeyframes)(state.structure.getStructure()));
321
+ if (fieldsInReturnValue.keyframes) {
322
+ returnValue.keyframes = (0, get_keyframes_1.getKeyframes)(state.structure.getStructure());
323
+ }
324
+ emittedFields.keyframes = true;
173
325
  }
174
326
  continue;
175
327
  }
@@ -0,0 +1 @@
1
+ export declare const detectFileType: (data: Uint8Array) => "webp" | "riff" | "webm" | "iso-base-media" | "transport-stream" | "mp3" | "gif" | "png" | "bmp" | "jpeg" | "unknown";