@remotion/media-parser 4.0.193 → 4.0.195

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 (266) hide show
  1. package/dist/add-new-matroska-tracks.d.ts +8 -0
  2. package/dist/add-new-matroska-tracks.js +14 -0
  3. package/dist/av1-codec-string.d.ts +3 -0
  4. package/dist/av1-codec-string.js +91 -0
  5. package/dist/boxes/iso-base-media/esds/decoder-specific-config.d.ts +14 -0
  6. package/dist/boxes/iso-base-media/esds/decoder-specific-config.js +38 -0
  7. package/dist/boxes/iso-base-media/esds/esds-descriptors.d.ts +8 -0
  8. package/dist/boxes/iso-base-media/esds/esds-descriptors.js +22 -2
  9. package/dist/boxes/iso-base-media/make-track.d.ts +3 -0
  10. package/dist/boxes/iso-base-media/make-track.js +112 -0
  11. package/dist/boxes/iso-base-media/mdat/mdat.d.ts +16 -0
  12. package/dist/boxes/iso-base-media/mdat/mdat.js +97 -0
  13. package/dist/boxes/iso-base-media/moov/moov.d.ts +4 -2
  14. package/dist/boxes/iso-base-media/moov/moov.js +4 -2
  15. package/dist/boxes/iso-base-media/mvhd.js +7 -1
  16. package/dist/boxes/iso-base-media/process-box.d.ts +20 -3
  17. package/dist/boxes/iso-base-media/process-box.js +356 -18
  18. package/dist/boxes/iso-base-media/stsd/av1c.d.ts +9 -0
  19. package/dist/boxes/iso-base-media/stsd/av1c.js +10 -0
  20. package/dist/boxes/iso-base-media/stsd/avcc-hvcc.d.ts +20 -0
  21. package/dist/boxes/iso-base-media/stsd/avcc-hvcc.js +73 -0
  22. package/dist/boxes/iso-base-media/stsd/avcc.d.ts +10 -0
  23. package/dist/boxes/iso-base-media/stsd/avcc.js +21 -0
  24. package/dist/boxes/iso-base-media/stsd/colr.d.ts +11 -0
  25. package/dist/boxes/iso-base-media/stsd/colr.js +35 -0
  26. package/dist/boxes/iso-base-media/stsd/ctts.d.ts +19 -0
  27. package/dist/boxes/iso-base-media/stsd/ctts.js +30 -0
  28. package/dist/boxes/iso-base-media/stsd/hvcc.d.ts +11 -0
  29. package/dist/boxes/iso-base-media/stsd/hvcc.js +17 -0
  30. package/dist/boxes/iso-base-media/stsd/keys.js +1 -0
  31. package/dist/boxes/iso-base-media/stsd/mebx.d.ts +4 -2
  32. package/dist/boxes/iso-base-media/stsd/mebx.js +4 -2
  33. package/dist/boxes/iso-base-media/stsd/pasp.d.ts +12 -0
  34. package/dist/boxes/iso-base-media/stsd/pasp.js +17 -0
  35. package/dist/boxes/iso-base-media/stsd/samples.d.ts +12 -5
  36. package/dist/boxes/iso-base-media/stsd/samples.js +27 -10
  37. package/dist/boxes/iso-base-media/stsd/stco.d.ts +14 -0
  38. package/dist/boxes/iso-base-media/stsd/stco.js +30 -0
  39. package/dist/boxes/iso-base-media/stsd/stsc.d.ts +19 -0
  40. package/dist/boxes/iso-base-media/stsd/stsc.js +34 -0
  41. package/dist/boxes/iso-base-media/stsd/stsd.d.ts +4 -2
  42. package/dist/boxes/iso-base-media/stsd/stsd.js +6 -2
  43. package/dist/boxes/iso-base-media/stsd/stss.d.ts +13 -0
  44. package/dist/boxes/iso-base-media/stsd/stss.js +28 -0
  45. package/dist/boxes/iso-base-media/stsd/stsz.d.ts +21 -0
  46. package/dist/boxes/iso-base-media/stsd/stsz.js +44 -0
  47. package/dist/boxes/iso-base-media/stsd/stts.d.ts +15 -0
  48. package/dist/boxes/iso-base-media/stsd/stts.js +35 -0
  49. package/dist/boxes/iso-base-media/tkhd.d.ts +3 -0
  50. package/dist/boxes/iso-base-media/tkhd.js +41 -14
  51. package/dist/boxes/iso-base-media/trak/trak.d.ts +4 -2
  52. package/dist/boxes/iso-base-media/trak/trak.js +4 -2
  53. package/dist/boxes/iso-base-media/void-box.d.ts +4 -0
  54. package/dist/boxes/iso-base-media/void-box.js +2 -0
  55. package/dist/boxes/webm/allowed-partial-segments.d.ts +1 -0
  56. package/dist/boxes/webm/allowed-partial-segments.js +4 -0
  57. package/dist/boxes/webm/av1-codec-private.d.ts +2 -0
  58. package/dist/boxes/webm/av1-codec-private.js +95 -0
  59. package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.d.ts +14 -0
  60. package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.js +67 -0
  61. package/dist/boxes/webm/bitstream/av1/bitstream-frame.d.ts +11 -0
  62. package/dist/boxes/webm/bitstream/av1/bitstream-frame.js +14 -0
  63. package/dist/boxes/webm/bitstream/av1/chroma-sample-position.d.ts +6 -0
  64. package/dist/boxes/webm/bitstream/av1/chroma-sample-position.js +9 -0
  65. package/dist/boxes/webm/bitstream/av1/color-config.d.ts +16 -0
  66. package/dist/boxes/webm/bitstream/av1/color-config.js +103 -0
  67. package/dist/boxes/webm/bitstream/av1/color-primaries.d.ts +14 -0
  68. package/dist/boxes/webm/bitstream/av1/color-primaries.js +17 -0
  69. package/dist/boxes/webm/bitstream/av1/decoder-model-info.d.ts +9 -0
  70. package/dist/boxes/webm/bitstream/av1/decoder-model-info.js +17 -0
  71. package/dist/boxes/webm/bitstream/av1/frame.d.ts +0 -0
  72. package/dist/boxes/webm/bitstream/av1/frame.js +1 -0
  73. package/dist/boxes/webm/bitstream/av1/header-segment.d.ts +51 -0
  74. package/dist/boxes/webm/bitstream/av1/header-segment.js +183 -0
  75. package/dist/boxes/webm/bitstream/av1/matrix-coefficients.d.ts +17 -0
  76. package/dist/boxes/webm/bitstream/av1/matrix-coefficients.js +20 -0
  77. package/dist/boxes/webm/bitstream/av1/operating-parameters-info.d.ts +10 -0
  78. package/dist/boxes/webm/bitstream/av1/operating-parameters-info.js +15 -0
  79. package/dist/boxes/webm/bitstream/av1/temporal-point-info.d.ts +5 -0
  80. package/dist/boxes/webm/bitstream/av1/temporal-point-info.js +8 -0
  81. package/dist/boxes/webm/bitstream/av1/timing-info.d.ts +8 -0
  82. package/dist/boxes/webm/bitstream/av1/timing-info.js +20 -0
  83. package/dist/boxes/webm/bitstream/av1/transfer-characteristics.d.ts +21 -0
  84. package/dist/boxes/webm/bitstream/av1/transfer-characteristics.js +24 -0
  85. package/dist/boxes/webm/bitstream/av1/uvlc.d.ts +2 -0
  86. package/dist/boxes/webm/bitstream/av1/uvlc.js +20 -0
  87. package/dist/boxes/webm/bitstream/av1.d.ts +20 -0
  88. package/dist/boxes/webm/bitstream/av1.js +118 -0
  89. package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.d.ts +0 -0
  90. package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.js +1 -0
  91. package/dist/boxes/webm/description.d.ts +2 -0
  92. package/dist/boxes/webm/description.js +83 -0
  93. package/dist/boxes/webm/get-ready-tracks.d.ts +3 -0
  94. package/dist/boxes/webm/get-ready-tracks.js +29 -0
  95. package/dist/boxes/webm/get-track.d.ts +6 -0
  96. package/dist/boxes/webm/get-track.js +183 -0
  97. package/dist/boxes/webm/parse-webm-header.d.ts +2 -1
  98. package/dist/boxes/webm/parse-webm-header.js +2 -2
  99. package/dist/boxes/webm/segments/all-segments.d.ts +269 -0
  100. package/dist/boxes/webm/segments/all-segments.js +277 -0
  101. package/dist/boxes/webm/segments/duration.d.ts +1 -1
  102. package/dist/boxes/webm/segments/duration.js +13 -9
  103. package/dist/boxes/webm/segments/info.d.ts +2 -1
  104. package/dist/boxes/webm/segments/info.js +12 -4
  105. package/dist/boxes/webm/segments/main.d.ts +0 -2
  106. package/dist/boxes/webm/segments/main.js +0 -11
  107. package/dist/boxes/webm/segments/muxing.d.ts +1 -1
  108. package/dist/boxes/webm/segments/muxing.js +1 -2
  109. package/dist/boxes/webm/segments/parse-children.d.ts +11 -1
  110. package/dist/boxes/webm/segments/parse-children.js +82 -6
  111. package/dist/boxes/webm/segments/seek-head.d.ts +2 -1
  112. package/dist/boxes/webm/segments/seek-head.js +12 -3
  113. package/dist/boxes/webm/segments/seek-position.d.ts +1 -1
  114. package/dist/boxes/webm/segments/seek-position.js +1 -2
  115. package/dist/boxes/webm/segments/seek.d.ts +7 -2
  116. package/dist/boxes/webm/segments/seek.js +22 -9
  117. package/dist/boxes/webm/segments/track-entry.d.ts +102 -22
  118. package/dist/boxes/webm/segments/track-entry.js +269 -57
  119. package/dist/boxes/webm/segments/tracks.d.ts +2 -1
  120. package/dist/boxes/webm/segments/tracks.js +12 -4
  121. package/dist/boxes/webm/segments/void.d.ts +1 -1
  122. package/dist/boxes/webm/segments/void.js +1 -2
  123. package/dist/boxes/webm/segments/writing.d.ts +1 -1
  124. package/dist/boxes/webm/segments/writing.js +1 -2
  125. package/dist/boxes/webm/segments.d.ts +8 -4
  126. package/dist/boxes/webm/segments.js +176 -40
  127. package/dist/boxes/webm/traversal.d.ts +7 -0
  128. package/dist/boxes/webm/traversal.js +25 -0
  129. package/dist/buffer-iterator.d.ts +16 -1
  130. package/dist/buffer-iterator.js +124 -41
  131. package/dist/combine-uint8array.d.ts +1 -0
  132. package/dist/combine-uint8array.js +13 -0
  133. package/dist/from-fetch.d.ts +2 -0
  134. package/dist/from-fetch.js +54 -0
  135. package/dist/from-node.js +12 -2
  136. package/dist/from-web-file.d.ts +2 -0
  137. package/dist/from-web-file.js +34 -0
  138. package/dist/get-audio-codec.d.ts +19 -0
  139. package/dist/get-audio-codec.js +153 -60
  140. package/dist/get-dimensions.d.ts +8 -2
  141. package/dist/get-dimensions.js +13 -91
  142. package/dist/get-duration.js +4 -7
  143. package/dist/get-fps.d.ts +4 -3
  144. package/dist/get-fps.js +17 -116
  145. package/dist/get-sample-aspect-ratio.d.ts +37 -0
  146. package/dist/get-sample-aspect-ratio.js +137 -0
  147. package/dist/get-sample-positions.d.ts +22 -0
  148. package/dist/get-sample-positions.js +54 -0
  149. package/dist/get-tracks.d.ts +49 -0
  150. package/dist/get-tracks.js +84 -0
  151. package/dist/get-video-codec.d.ts +2 -0
  152. package/dist/get-video-codec.js +47 -31
  153. package/dist/has-all-info.d.ts +2 -1
  154. package/dist/has-all-info.js +14 -5
  155. package/dist/index.d.ts +1 -0
  156. package/dist/make-hvc1-codec-strings.d.ts +2 -0
  157. package/dist/make-hvc1-codec-strings.js +47 -0
  158. package/dist/options.d.ts +26 -4
  159. package/dist/parse-media.js +76 -20
  160. package/dist/parse-result.d.ts +17 -5
  161. package/dist/parse-video.d.ts +12 -2
  162. package/dist/parse-video.js +15 -6
  163. package/dist/parser-context.d.ts +8 -0
  164. package/dist/parser-context.js +2 -0
  165. package/dist/parser-state.d.ts +23 -0
  166. package/dist/parser-state.js +112 -0
  167. package/dist/reader.d.ts +2 -2
  168. package/dist/traversal.d.ts +56 -0
  169. package/dist/traversal.js +331 -0
  170. package/dist/understand-vorbis.d.ts +1 -0
  171. package/dist/understand-vorbis.js +12 -0
  172. package/dist/webcodec-sample-types.d.ts +21 -0
  173. package/dist/webcodec-sample-types.js +2 -0
  174. package/package.json +10 -2
  175. package/src/add-new-matroska-tracks.ts +23 -0
  176. package/src/boxes/iso-base-media/esds/decoder-specific-config.ts +61 -0
  177. package/src/boxes/iso-base-media/esds/esds-descriptors.ts +33 -2
  178. package/src/boxes/iso-base-media/make-track.ts +157 -0
  179. package/src/boxes/iso-base-media/mdat/mdat.ts +131 -0
  180. package/src/boxes/iso-base-media/moov/moov.ts +8 -3
  181. package/src/boxes/iso-base-media/mvhd.ts +7 -1
  182. package/src/boxes/iso-base-media/process-box.ts +426 -21
  183. package/src/boxes/iso-base-media/stsd/av1c.ts +19 -0
  184. package/src/boxes/iso-base-media/stsd/avcc.ts +36 -0
  185. package/src/boxes/iso-base-media/stsd/colr.ts +49 -0
  186. package/src/boxes/iso-base-media/stsd/ctts.ts +55 -0
  187. package/src/boxes/iso-base-media/stsd/hvcc.ts +32 -0
  188. package/src/boxes/iso-base-media/stsd/keys.ts +2 -0
  189. package/src/boxes/iso-base-media/stsd/mebx.ts +8 -3
  190. package/src/boxes/iso-base-media/stsd/pasp.ts +32 -0
  191. package/src/boxes/iso-base-media/stsd/samples.ts +43 -16
  192. package/src/boxes/iso-base-media/stsd/stco.ts +50 -0
  193. package/src/boxes/iso-base-media/stsd/stsc.ts +61 -0
  194. package/src/boxes/iso-base-media/stsd/stsd.ts +10 -3
  195. package/src/boxes/iso-base-media/stsd/stss.ts +47 -0
  196. package/src/boxes/iso-base-media/stsd/stsz.ts +75 -0
  197. package/src/boxes/iso-base-media/tkhd.ts +63 -16
  198. package/src/boxes/iso-base-media/trak/trak.ts +8 -3
  199. package/src/boxes/iso-base-media/void-box.ts +4 -0
  200. package/src/boxes/webm/allowed-partial-segments.ts +1 -0
  201. package/src/boxes/webm/av1-codec-private.ts +113 -0
  202. package/src/boxes/webm/description.ts +101 -0
  203. package/src/boxes/webm/get-ready-tracks.ts +36 -0
  204. package/src/boxes/webm/get-track.ts +250 -0
  205. package/src/boxes/webm/parse-webm-header.ts +6 -2
  206. package/src/boxes/webm/segments/all-segments.ts +285 -0
  207. package/src/boxes/webm/segments/duration.ts +15 -8
  208. package/src/boxes/webm/segments/info.ts +18 -4
  209. package/src/boxes/webm/segments/main.ts +0 -13
  210. package/src/boxes/webm/segments/muxing.ts +1 -1
  211. package/src/boxes/webm/segments/parse-children.ts +132 -9
  212. package/src/boxes/webm/segments/seek-head.ts +17 -4
  213. package/src/boxes/webm/segments/seek-position.ts +1 -2
  214. package/src/boxes/webm/segments/seek.ts +31 -9
  215. package/src/boxes/webm/segments/track-entry.ts +475 -65
  216. package/src/boxes/webm/segments/tracks.ts +17 -7
  217. package/src/boxes/webm/segments/void.ts +4 -2
  218. package/src/boxes/webm/segments/writing.ts +1 -1
  219. package/src/boxes/webm/segments.ts +266 -42
  220. package/src/boxes/webm/traversal.ts +32 -0
  221. package/src/buffer-iterator.ts +155 -40
  222. package/src/combine-uint8array.ts +13 -0
  223. package/src/{from-web.ts → from-fetch.ts} +18 -7
  224. package/src/from-node.ts +15 -2
  225. package/src/from-web-file.ts +39 -0
  226. package/src/get-audio-codec.ts +213 -84
  227. package/src/get-dimensions.ts +25 -132
  228. package/src/get-duration.ts +4 -8
  229. package/src/get-fps.ts +27 -172
  230. package/src/get-sample-aspect-ratio.ts +204 -0
  231. package/src/get-sample-positions.ts +93 -0
  232. package/src/get-tracks.ts +147 -0
  233. package/src/get-video-codec.ts +62 -47
  234. package/src/has-all-info.ts +35 -5
  235. package/src/index.ts +8 -0
  236. package/src/make-hvc1-codec-strings.ts +55 -0
  237. package/src/options.ts +48 -9
  238. package/src/parse-media.ts +112 -25
  239. package/src/parse-result.ts +29 -4
  240. package/src/parse-video.ts +32 -7
  241. package/src/parser-context.ts +9 -0
  242. package/src/parser-state.ts +151 -0
  243. package/src/reader.ts +3 -3
  244. package/src/test/aspect-ratio.test.ts +42 -0
  245. package/src/test/av1.test.ts +108 -0
  246. package/src/test/duration.test.ts +5 -21
  247. package/src/test/matroska.test.ts +350 -31
  248. package/src/test/mvhd.test.ts +6 -1
  249. package/src/test/parse-esds.test.ts +29 -6
  250. package/src/test/parse-stco.test.ts +59 -0
  251. package/src/test/parse-stsc.test.ts +104 -0
  252. package/src/test/parse-stsz.test.ts +57 -0
  253. package/src/test/parse-stts.test.ts +1 -1
  254. package/src/test/parse-video.test.ts +23 -35
  255. package/src/test/parse-webm.test.ts +5 -5
  256. package/src/test/stream-local.test.ts +543 -47
  257. package/src/test/stream-remote.test.ts +15 -13
  258. package/src/test/stream-samples.test.ts +259 -0
  259. package/src/test/stsd.test.ts +60 -8
  260. package/src/test/tkhd.test.ts +4 -1
  261. package/src/traversal.ts +496 -0
  262. package/src/webcodec-sample-types.ts +30 -0
  263. package/tsconfig.json +5 -1
  264. package/tsconfig.tsbuildinfo +1 -1
  265. package/boxes.json +0 -1
  266. /package/src/boxes/iso-base-media/{stts → stsd}/stts.ts +0 -0
@@ -1,7 +1,13 @@
1
1
  import type { AnySegment } from './parse-result';
2
+ import type { ParserState } from './parser-state';
2
3
  export type Dimensions = {
3
4
  width: number;
4
5
  height: number;
5
6
  };
6
- export declare const getDimensions: (boxes: AnySegment[]) => Dimensions;
7
- export declare const hasDimensions: (boxes: AnySegment[]) => boolean;
7
+ export type ExpandedDimensions = Dimensions & {
8
+ rotation: number;
9
+ unrotatedWidth: number;
10
+ unrotatedHeight: number;
11
+ };
12
+ export declare const getDimensions: (boxes: AnySegment[], state: ParserState) => ExpandedDimensions;
13
+ export declare const hasDimensions: (boxes: AnySegment[], state: ParserState) => boolean;
@@ -1,105 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasDimensions = exports.getDimensions = void 0;
4
- const getDimensionsFromMatroska = (segments) => {
5
- const tracksSegment = segments.children.find((b) => b.type === 'tracks-segment');
6
- if (!tracksSegment || tracksSegment.type !== 'tracks-segment') {
7
- throw new Error('No tracks segment');
8
- }
9
- const trackEntrySegment = tracksSegment.children.find((b) => {
10
- if (b.type !== 'track-entry-segment') {
11
- return false;
12
- }
13
- return (b.children.find((c) => c.type === 'codec-segment' && c.codec.startsWith('V_')) !== undefined);
14
- });
15
- if (!trackEntrySegment || trackEntrySegment.type !== 'track-entry-segment') {
16
- throw new Error('No track entry segment');
17
- }
18
- const videoSegment = trackEntrySegment.children.find((b) => b.type === 'video-segment');
19
- if (!videoSegment || videoSegment.type !== 'video-segment') {
20
- throw new Error('No video segment');
21
- }
22
- const widthSegment = videoSegment.children.find((b) => b.type === 'width-segment');
23
- if (!widthSegment || widthSegment.type !== 'width-segment') {
24
- throw new Error('No width segment');
25
- }
26
- const heightSegment = videoSegment.children.find((b) => b.type === 'height-segment');
27
- if (!heightSegment || heightSegment.type !== 'height-segment') {
28
- throw new Error('No height segment');
4
+ const get_tracks_1 = require("./get-tracks");
5
+ const getDimensions = (boxes, state) => {
6
+ const { videoTracks } = (0, get_tracks_1.getTracks)(boxes, state);
7
+ if (!videoTracks.length) {
8
+ throw new Error('Expected video track');
29
9
  }
10
+ const firstVideoTrack = videoTracks[0];
30
11
  return {
31
- width: widthSegment.width,
32
- height: heightSegment.height,
12
+ width: firstVideoTrack.width,
13
+ height: firstVideoTrack.height,
14
+ rotation: firstVideoTrack.rotation,
15
+ unrotatedHeight: firstVideoTrack.displayAspectHeight,
16
+ unrotatedWidth: firstVideoTrack.displayAspectWidth,
33
17
  };
34
18
  };
35
- const getDimensions = (boxes) => {
36
- const matroskaBox = boxes.find((b) => b.type === 'main-segment');
37
- if (matroskaBox && matroskaBox.type === 'main-segment') {
38
- return getDimensionsFromMatroska(matroskaBox);
39
- }
40
- const moovBox = boxes.find((b) => b.type === 'moov-box');
41
- if (!moovBox || moovBox.type !== 'moov-box') {
42
- throw new Error('Expected moov box');
43
- }
44
- const { children } = moovBox;
45
- if (!children) {
46
- throw new Error('Expected moov box children');
47
- }
48
- const t = children.find((b) => b.type === 'trak-box');
49
- if (!t || t.type !== 'trak-box') {
50
- throw new Error('Expected trak box');
51
- }
52
- const mdiaBox = t.children.find((c) => c.type === 'regular-box' && c.boxType === 'mdia');
53
- const tkhdBox = t.children.find((c) => c.type === 'tkhd-box');
54
- if (tkhdBox && tkhdBox.type === 'tkhd-box') {
55
- return {
56
- width: tkhdBox.width,
57
- height: tkhdBox.height,
58
- };
59
- }
60
- if (!mdiaBox) {
61
- throw new Error('Expected mdia box');
62
- }
63
- if (mdiaBox.type !== 'regular-box') {
64
- throw new Error('Expected mdia box');
65
- }
66
- const minfBox = mdiaBox.children.find((c) => c.type === 'regular-box' && c.boxType === 'minf');
67
- if (!minfBox) {
68
- throw new Error('Expected minf box');
69
- }
70
- if (minfBox.type !== 'regular-box') {
71
- throw new Error('Expected minf box');
72
- }
73
- const stblBox = minfBox.children.find((c) => c.type === 'regular-box' && c.boxType === 'stbl');
74
- if (!stblBox) {
75
- throw new Error('Expected stbl box');
76
- }
77
- if (stblBox.type !== 'regular-box') {
78
- throw new Error('Expected stbl box');
79
- }
80
- const stsdBox = stblBox.children.find((c) => c.type === 'stsd-box');
81
- if (!stsdBox) {
82
- throw new Error('Expected stsd box');
83
- }
84
- if (stsdBox.type !== 'stsd-box') {
85
- throw new Error('Expected stsd box');
86
- }
87
- const videoSamples = stsdBox.samples.filter((s) => s.type === 'video');
88
- if (videoSamples.length === 0) {
89
- throw new Error('Has no video stream');
90
- }
91
- const [firstTrack] = videoSamples;
92
- if (firstTrack.type !== 'video') {
93
- throw new Error('Expected video track');
94
- }
95
- return { width: firstTrack.width, height: firstTrack.height };
96
- };
97
19
  exports.getDimensions = getDimensions;
98
20
  // TODO: An audio track should return 'hasDimensions' = true on an audio file
99
21
  // and stop parsing
100
- const hasDimensions = (boxes) => {
22
+ const hasDimensions = (boxes, state) => {
101
23
  try {
102
- return (0, exports.getDimensions)(boxes) !== null;
24
+ return (0, exports.getDimensions)(boxes, state) !== null;
103
25
  }
104
26
  catch (err) {
105
27
  return false;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasDuration = exports.getDuration = void 0;
4
+ const traversal_1 = require("./traversal");
4
5
  const getDurationFromMatroska = (segments) => {
5
6
  const mainSegment = segments.find((s) => s.type === 'main-segment');
6
7
  if (!mainSegment || mainSegment.type !== 'main-segment') {
@@ -32,15 +33,11 @@ const getDuration = (boxes) => {
32
33
  if (matroskaBox) {
33
34
  return getDurationFromMatroska(boxes);
34
35
  }
35
- const moovBox = boxes.find((b) => b.type === 'moov-box');
36
- if (!moovBox || moovBox.type !== 'moov-box') {
36
+ const moovBox = (0, traversal_1.getMoovBox)(boxes);
37
+ if (!moovBox) {
37
38
  return null;
38
39
  }
39
- const { children } = moovBox;
40
- if (!children) {
41
- return null;
42
- }
43
- const mvhdBox = children.find((b) => b.type === 'mvhd-box');
40
+ const mvhdBox = (0, traversal_1.getMvhdBox)(moovBox);
44
41
  if (!mvhdBox) {
45
42
  return null;
46
43
  }
package/dist/get-fps.d.ts CHANGED
@@ -1,11 +1,12 @@
1
+ import type { TrakBox } from './boxes/iso-base-media/trak/trak';
1
2
  import type { AnySegment } from './parse-result';
2
3
  type TimescaleAndDuration = {
3
4
  timescale: number;
4
5
  duration: number;
5
6
  };
6
- export declare const trakBoxContainsAudio: (trakBox: AnySegment) => boolean;
7
- export declare const trakBoxContainsVideo: (trakBox: AnySegment) => boolean;
8
- export declare const getTimescaleAndDuration: (boxes: AnySegment[]) => TimescaleAndDuration | null;
7
+ export declare const trakBoxContainsAudio: (trakBox: TrakBox) => boolean;
8
+ export declare const trakBoxContainsVideo: (trakBox: TrakBox) => boolean;
9
+ export declare const getTimescaleAndDuration: (trakBox: TrakBox) => TimescaleAndDuration | null;
9
10
  export declare const getFps: (segments: AnySegment[]) => number | null;
10
11
  export declare const hasFps: (boxes: AnySegment[]) => boolean;
11
12
  export {};
package/dist/get-fps.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hasFps = exports.getFps = exports.getTimescaleAndDuration = exports.trakBoxContainsVideo = exports.trakBoxContainsAudio = void 0;
4
+ const traversal_1 = require("./traversal");
4
5
  const calculateFps = ({ sttsBox, timeScale, durationInSamples, }) => {
5
6
  let totalSamples = 0;
6
7
  for (const sample of sttsBox.sampleDistribution) {
@@ -11,29 +12,8 @@ const calculateFps = ({ sttsBox, timeScale, durationInSamples, }) => {
11
12
  return fps;
12
13
  };
13
14
  const trakBoxContainsAudio = (trakBox) => {
14
- if (trakBox.type !== 'trak-box') {
15
- return false;
16
- }
17
- const { children } = trakBox;
18
- const mediaBoxes = children.filter((c) => c.type === 'regular-box' && c.boxType === 'mdia');
19
- if (!mediaBoxes || mediaBoxes.length === 0) {
20
- return false;
21
- }
22
- const firstMediaBox = mediaBoxes[0];
23
- if (firstMediaBox.type !== 'regular-box' ||
24
- firstMediaBox.boxType !== 'mdia') {
25
- return false;
26
- }
27
- const minf = firstMediaBox.children.find((c) => c.type === 'regular-box' && c.boxType === 'minf');
28
- if (!minf || minf.type !== 'regular-box' || minf.boxType !== 'minf') {
29
- return false;
30
- }
31
- const stbl = minf.children.find((c) => c.type === 'regular-box' && c.boxType === 'stbl');
32
- if (!stbl || stbl.type !== 'regular-box' || stbl.boxType !== 'stbl') {
33
- return false;
34
- }
35
- const stsd = stbl.children.find((c) => c.type === 'stsd-box');
36
- if (!stsd || stsd.type !== 'stsd-box') {
15
+ const stsd = (0, traversal_1.getStsdBox)(trakBox);
16
+ if (!stsd) {
37
17
  return false;
38
18
  }
39
19
  const videoSample = stsd.samples.find((s) => s.type === 'audio');
@@ -44,29 +24,8 @@ const trakBoxContainsAudio = (trakBox) => {
44
24
  };
45
25
  exports.trakBoxContainsAudio = trakBoxContainsAudio;
46
26
  const trakBoxContainsVideo = (trakBox) => {
47
- if (trakBox.type !== 'trak-box') {
48
- return false;
49
- }
50
- const { children } = trakBox;
51
- const mediaBoxes = children.filter((c) => c.type === 'regular-box' && c.boxType === 'mdia');
52
- if (!mediaBoxes || mediaBoxes.length === 0) {
53
- return false;
54
- }
55
- const firstMediaBox = mediaBoxes[0];
56
- if (firstMediaBox.type !== 'regular-box' ||
57
- firstMediaBox.boxType !== 'mdia') {
58
- return false;
59
- }
60
- const minf = firstMediaBox.children.find((c) => c.type === 'regular-box' && c.boxType === 'minf');
61
- if (!minf || minf.type !== 'regular-box' || minf.boxType !== 'minf') {
62
- return false;
63
- }
64
- const stbl = minf.children.find((c) => c.type === 'regular-box' && c.boxType === 'stbl');
65
- if (!stbl || stbl.type !== 'regular-box' || stbl.boxType !== 'stbl') {
66
- return false;
67
- }
68
- const stsd = stbl.children.find((c) => c.type === 'stsd-box');
69
- if (!stsd || stsd.type !== 'stsd-box') {
27
+ const stsd = (0, traversal_1.getStsdBox)(trakBox);
28
+ if (!stsd) {
70
29
  return false;
71
30
  }
72
31
  const videoSample = stsd.samples.find((s) => s.type === 'video');
@@ -76,88 +35,30 @@ const trakBoxContainsVideo = (trakBox) => {
76
35
  return true;
77
36
  };
78
37
  exports.trakBoxContainsVideo = trakBoxContainsVideo;
79
- const getTimescaleAndDuration = (boxes) => {
80
- const moovBox = boxes.find((s) => s.type === 'moov-box');
81
- if (!moovBox || moovBox.type !== 'moov-box') {
82
- return null;
83
- }
84
- const { children } = moovBox;
85
- const trackBoxes = children.filter((c) => c.type === 'trak-box');
86
- if (!trackBoxes || trackBoxes.length === 0) {
87
- return null;
88
- }
89
- const trackBox = trackBoxes.find(exports.trakBoxContainsVideo);
90
- if (!trackBox || trackBox.type !== 'trak-box') {
91
- return null;
92
- }
93
- const trackBoxChildren = trackBox.children;
94
- if (!trackBoxChildren || trackBoxChildren.length === 0) {
95
- return null;
96
- }
97
- const mdiaBox = trackBoxChildren.find((c) => c.type === 'regular-box' && c.boxType === 'mdia');
98
- if (!mdiaBox ||
99
- mdiaBox.type !== 'regular-box' ||
100
- mdiaBox.boxType !== 'mdia') {
101
- return null;
102
- }
103
- const mdhdBox = mdiaBox === null || mdiaBox === void 0 ? void 0 : mdiaBox.children.find((c) => c.type === 'mdhd-box');
104
- if (mdhdBox && mdhdBox.type === 'mdhd-box') {
38
+ const getTimescaleAndDuration = (trakBox) => {
39
+ const mdhdBox = (0, traversal_1.getMdhdBox)(trakBox);
40
+ if (mdhdBox) {
105
41
  return { timescale: mdhdBox.timescale, duration: mdhdBox.duration };
106
42
  }
107
- const mvhdBox = moovBox.children.find((c) => c.type === 'mvhd-box');
108
- if (!mvhdBox || mvhdBox.type !== 'mvhd-box') {
109
- return null;
110
- }
111
- const { timeScale, durationInUnits } = mvhdBox;
112
- return { timescale: timeScale, duration: durationInUnits };
43
+ return null;
113
44
  };
114
45
  exports.getTimescaleAndDuration = getTimescaleAndDuration;
115
46
  const getFps = (segments) => {
116
- const timescaleAndDuration = (0, exports.getTimescaleAndDuration)(segments);
117
- if (!timescaleAndDuration) {
118
- return null;
119
- }
120
- const moovBox = segments.find((s) => s.type === 'moov-box');
121
- if (!moovBox || moovBox.type !== 'moov-box') {
122
- return null;
123
- }
124
- const mvhdBox = moovBox.children.find((c) => c.type === 'mvhd-box');
125
- if (!mvhdBox || mvhdBox.type !== 'mvhd-box') {
126
- return null;
127
- }
128
- const { children } = moovBox;
129
- const trackBoxes = children.filter((c) => c.type === 'trak-box');
130
- if (!trackBoxes || trackBoxes.length === 0) {
47
+ const moovBox = (0, traversal_1.getMoovBox)(segments);
48
+ if (!moovBox) {
131
49
  return null;
132
50
  }
51
+ const trackBoxes = (0, traversal_1.getTraks)(moovBox);
133
52
  const trackBox = trackBoxes.find(exports.trakBoxContainsVideo);
134
- if (!trackBox || trackBox.type !== 'trak-box') {
135
- return null;
136
- }
137
- const trackBoxChildren = trackBox.children;
138
- if (!trackBoxChildren || trackBoxChildren.length === 0) {
53
+ if (!trackBox) {
139
54
  return null;
140
55
  }
141
- const mdiaBox = trackBoxChildren.find((c) => c.type === 'regular-box' && c.boxType === 'mdia');
142
- if (!mdiaBox ||
143
- mdiaBox.type !== 'regular-box' ||
144
- mdiaBox.boxType !== 'mdia') {
145
- return null;
146
- }
147
- const minfBox = mdiaBox.children.find((c) => c.type === 'regular-box' && c.boxType === 'minf');
148
- if (!minfBox ||
149
- minfBox.type !== 'regular-box' ||
150
- minfBox.boxType !== 'minf') {
151
- return null;
152
- }
153
- const stblBox = minfBox.children.find((c) => c.type === 'regular-box' && c.boxType === 'stbl');
154
- if (!stblBox ||
155
- stblBox.type !== 'regular-box' ||
156
- stblBox.boxType !== 'stbl') {
56
+ const timescaleAndDuration = (0, exports.getTimescaleAndDuration)(trackBox);
57
+ if (!timescaleAndDuration) {
157
58
  return null;
158
59
  }
159
- const sttsBox = stblBox.children.find((c) => c.type === 'stts-box');
160
- if (!sttsBox || sttsBox.type !== 'stts-box') {
60
+ const sttsBox = (0, traversal_1.getSttsBox)(trackBox);
61
+ if (!sttsBox) {
161
62
  return null;
162
63
  }
163
64
  return calculateFps({
@@ -0,0 +1,37 @@
1
+ import type { Av1CBox } from './boxes/iso-base-media/stsd/av1c';
2
+ import type { AvccBox } from './boxes/iso-base-media/stsd/avcc';
3
+ import type { ColorParameterBox } from './boxes/iso-base-media/stsd/colr';
4
+ import type { HvccBox } from './boxes/iso-base-media/stsd/hvcc';
5
+ import type { PaspBox } from './boxes/iso-base-media/stsd/pasp';
6
+ import type { VideoSample } from './boxes/iso-base-media/stsd/samples';
7
+ import type { TkhdBox } from './boxes/iso-base-media/tkhd';
8
+ import type { TrakBox } from './boxes/iso-base-media/trak/trak';
9
+ import type { Dimensions } from './get-dimensions';
10
+ type AspectRatio = {
11
+ numerator: number;
12
+ denominator: number;
13
+ };
14
+ export declare const getVideoSample: (trakBox: TrakBox) => VideoSample | null;
15
+ export declare const getAvccBox: (trakBox: TrakBox) => AvccBox | null;
16
+ export declare const getAv1CBox: (trakBox: TrakBox) => Av1CBox | null;
17
+ export declare const getPaspBox: (trakBox: TrakBox) => PaspBox | null;
18
+ export declare const getHvccBox: (trakBox: TrakBox) => HvccBox | null;
19
+ export declare const getSampleAspectRatio: (trakBox: TrakBox) => AspectRatio;
20
+ export declare const getColrBox: (videoSample: VideoSample) => ColorParameterBox | null;
21
+ export declare const applyTkhdBox: (aspectRatioApplied: Dimensions, tkhdBox: TkhdBox) => {
22
+ displayAspectWidth: number;
23
+ displayAspectHeight: number;
24
+ width: number;
25
+ height: number;
26
+ rotation: number;
27
+ };
28
+ export declare const applyAspectRatios: ({ dimensions, sampleAspectRatio, displayAspectRatio, }: {
29
+ dimensions: Dimensions;
30
+ sampleAspectRatio: AspectRatio;
31
+ displayAspectRatio: AspectRatio;
32
+ }) => Dimensions;
33
+ export declare const getDisplayAspectRatio: ({ sampleAspectRatio, nativeDimensions, }: {
34
+ sampleAspectRatio: AspectRatio;
35
+ nativeDimensions: Dimensions;
36
+ }) => AspectRatio;
37
+ export {};
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDisplayAspectRatio = exports.applyAspectRatios = exports.applyTkhdBox = exports.getColrBox = exports.getSampleAspectRatio = exports.getHvccBox = exports.getPaspBox = exports.getAv1CBox = exports.getAvccBox = exports.getVideoSample = void 0;
4
+ const traversal_1 = require("./traversal");
5
+ const getVideoSample = (trakBox) => {
6
+ const stsdBox = (0, traversal_1.getStsdBox)(trakBox);
7
+ if (!stsdBox) {
8
+ return null;
9
+ }
10
+ const videoSample = stsdBox.samples.find((s) => s.type === 'video');
11
+ if (!videoSample || videoSample.type !== 'video') {
12
+ return null;
13
+ }
14
+ return videoSample;
15
+ };
16
+ exports.getVideoSample = getVideoSample;
17
+ const getAvccBox = (trakBox) => {
18
+ const videoSample = (0, exports.getVideoSample)(trakBox);
19
+ if (!videoSample) {
20
+ return null;
21
+ }
22
+ const avccBox = videoSample.descriptors.find((c) => c.type === 'avcc-box');
23
+ if (!avccBox || avccBox.type !== 'avcc-box') {
24
+ return null;
25
+ }
26
+ return avccBox;
27
+ };
28
+ exports.getAvccBox = getAvccBox;
29
+ const getAv1CBox = (trakBox) => {
30
+ const videoSample = (0, exports.getVideoSample)(trakBox);
31
+ if (!videoSample) {
32
+ return null;
33
+ }
34
+ const av1cBox = videoSample.descriptors.find((c) => c.type === 'av1C-box');
35
+ if (!av1cBox || av1cBox.type !== 'av1C-box') {
36
+ return null;
37
+ }
38
+ return av1cBox;
39
+ };
40
+ exports.getAv1CBox = getAv1CBox;
41
+ const getPaspBox = (trakBox) => {
42
+ const videoSample = (0, exports.getVideoSample)(trakBox);
43
+ if (!videoSample) {
44
+ return null;
45
+ }
46
+ const paspBox = videoSample.descriptors.find((c) => c.type === 'pasp-box');
47
+ if (!paspBox || paspBox.type !== 'pasp-box') {
48
+ return null;
49
+ }
50
+ return paspBox;
51
+ };
52
+ exports.getPaspBox = getPaspBox;
53
+ const getHvccBox = (trakBox) => {
54
+ const videoSample = (0, exports.getVideoSample)(trakBox);
55
+ if (!videoSample) {
56
+ return null;
57
+ }
58
+ const hvccBox = videoSample.descriptors.find((c) => c.type === 'hvcc-box');
59
+ if (!hvccBox || hvccBox.type !== 'hvcc-box') {
60
+ return null;
61
+ }
62
+ return hvccBox;
63
+ };
64
+ exports.getHvccBox = getHvccBox;
65
+ const getSampleAspectRatio = (trakBox) => {
66
+ const paspBox = (0, exports.getPaspBox)(trakBox);
67
+ if (!paspBox) {
68
+ return {
69
+ numerator: 1,
70
+ denominator: 1,
71
+ };
72
+ }
73
+ return {
74
+ numerator: paspBox.hSpacing,
75
+ denominator: paspBox.vSpacing,
76
+ };
77
+ };
78
+ exports.getSampleAspectRatio = getSampleAspectRatio;
79
+ const getColrBox = (videoSample) => {
80
+ const colrBox = videoSample.descriptors.find((c) => c.type === 'colr-box');
81
+ if (!colrBox || colrBox.type !== 'colr-box') {
82
+ return null;
83
+ }
84
+ return colrBox;
85
+ };
86
+ exports.getColrBox = getColrBox;
87
+ const applyTkhdBox = (aspectRatioApplied, tkhdBox) => {
88
+ if (tkhdBox === null || tkhdBox.rotation === 0) {
89
+ return {
90
+ displayAspectWidth: aspectRatioApplied.width,
91
+ displayAspectHeight: aspectRatioApplied.height,
92
+ width: aspectRatioApplied.width,
93
+ height: aspectRatioApplied.height,
94
+ rotation: 0,
95
+ };
96
+ }
97
+ return {
98
+ width: tkhdBox.width,
99
+ height: tkhdBox.height,
100
+ rotation: tkhdBox.rotation,
101
+ displayAspectWidth: aspectRatioApplied.width,
102
+ displayAspectHeight: aspectRatioApplied.height,
103
+ };
104
+ };
105
+ exports.applyTkhdBox = applyTkhdBox;
106
+ const applyAspectRatios = ({ dimensions, sampleAspectRatio, displayAspectRatio, }) => {
107
+ if (displayAspectRatio.numerator === 0) {
108
+ return dimensions;
109
+ }
110
+ if (displayAspectRatio.denominator === 0) {
111
+ return dimensions;
112
+ }
113
+ const newWidth = Math.round((dimensions.width * sampleAspectRatio.numerator) /
114
+ sampleAspectRatio.denominator);
115
+ const newHeight = Math.floor(newWidth / (displayAspectRatio.numerator / displayAspectRatio.denominator));
116
+ return {
117
+ width: Math.floor(newWidth),
118
+ height: newHeight,
119
+ };
120
+ };
121
+ exports.applyAspectRatios = applyAspectRatios;
122
+ function gcd(a, b) {
123
+ return b === 0 ? a : gcd(b, a % b);
124
+ }
125
+ function reduceFraction(numerator, denominator) {
126
+ const greatestCommonDivisor = gcd(Math.abs(numerator), Math.abs(denominator));
127
+ return {
128
+ numerator: numerator / greatestCommonDivisor,
129
+ denominator: denominator / greatestCommonDivisor,
130
+ };
131
+ }
132
+ const getDisplayAspectRatio = ({ sampleAspectRatio, nativeDimensions, }) => {
133
+ const num = Math.round(nativeDimensions.width * sampleAspectRatio.numerator);
134
+ const den = Math.round(nativeDimensions.height * sampleAspectRatio.denominator);
135
+ return reduceFraction(num, den);
136
+ };
137
+ exports.getDisplayAspectRatio = getDisplayAspectRatio;
@@ -0,0 +1,22 @@
1
+ import type { CttsBox } from './boxes/iso-base-media/stsd/ctts';
2
+ import type { StcoBox } from './boxes/iso-base-media/stsd/stco';
3
+ import type { StscBox } from './boxes/iso-base-media/stsd/stsc';
4
+ import type { StssBox } from './boxes/iso-base-media/stsd/stss';
5
+ import type { StszBox } from './boxes/iso-base-media/stsd/stsz';
6
+ import type { SttsBox } from './boxes/iso-base-media/stsd/stts';
7
+ export type SamplePosition = {
8
+ offset: number;
9
+ size: number;
10
+ isKeyframe: boolean;
11
+ dts: number;
12
+ cts: number;
13
+ duration: number;
14
+ };
15
+ export declare const getSamplePositions: ({ stcoBox, stszBox, stscBox, stssBox, sttsBox, cttsBox, }: {
16
+ stcoBox: StcoBox;
17
+ stszBox: StszBox;
18
+ stscBox: StscBox;
19
+ stssBox: StssBox | null;
20
+ sttsBox: SttsBox;
21
+ cttsBox: CttsBox | null;
22
+ }) => SamplePosition[];
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSamplePositions = void 0;
4
+ const getSamplePositions = ({ stcoBox, stszBox, stscBox, stssBox, sttsBox, cttsBox, }) => {
5
+ var _a;
6
+ const sttsDeltas = [];
7
+ for (const distribution of sttsBox.sampleDistribution) {
8
+ for (let i = 0; i < distribution.sampleCount; i++) {
9
+ sttsDeltas.push(distribution.sampleDelta);
10
+ }
11
+ }
12
+ const cttsEntries = [];
13
+ for (const entry of (_a = cttsBox === null || cttsBox === void 0 ? void 0 : cttsBox.entries) !== null && _a !== void 0 ? _a : [
14
+ { sampleCount: sttsDeltas.length, sampleOffset: 0 },
15
+ ]) {
16
+ for (let i = 0; i < entry.sampleCount; i++) {
17
+ cttsEntries.push(entry.sampleOffset);
18
+ }
19
+ }
20
+ let dts = 0;
21
+ const chunks = stcoBox.entries;
22
+ const samples = [];
23
+ let samplesPerChunk = 1;
24
+ for (let i = 0; i < chunks.length; i++) {
25
+ const hasEntry = stscBox.entries.find((entry) => entry.firstChunk === i + 1);
26
+ if (hasEntry) {
27
+ samplesPerChunk = hasEntry.samplesPerChunk;
28
+ }
29
+ let offsetInThisChunk = 0;
30
+ for (let j = 0; j < samplesPerChunk; j++) {
31
+ const size = stszBox.countType === 'fixed'
32
+ ? stszBox.sampleSize
33
+ : stszBox.entries[samples.length];
34
+ const isKeyframe = stssBox
35
+ ? stssBox.sampleNumber.includes(samples.length + 1)
36
+ : true;
37
+ const delta = sttsDeltas[samples.length];
38
+ const ctsOffset = cttsEntries[samples.length];
39
+ const cts = dts + ctsOffset;
40
+ samples.push({
41
+ offset: chunks[i] + offsetInThisChunk,
42
+ size,
43
+ isKeyframe,
44
+ dts,
45
+ cts,
46
+ duration: delta,
47
+ });
48
+ dts += delta;
49
+ offsetInThisChunk += size;
50
+ }
51
+ }
52
+ return samples;
53
+ };
54
+ exports.getSamplePositions = getSamplePositions;
@@ -0,0 +1,49 @@
1
+ import type { MoovBox } from './boxes/iso-base-media/moov/moov';
2
+ import type { SamplePosition } from './get-sample-positions';
3
+ import type { AnySegment } from './parse-result';
4
+ import type { ParserState } from './parser-state';
5
+ type SampleAspectRatio = {
6
+ numerator: number;
7
+ denominator: number;
8
+ };
9
+ export type VideoTrack = {
10
+ type: 'video';
11
+ samplePositions: SamplePosition[] | null;
12
+ trackId: number;
13
+ description: Uint8Array | undefined;
14
+ timescale: number;
15
+ codec: string;
16
+ sampleAspectRatio: SampleAspectRatio;
17
+ width: number;
18
+ height: number;
19
+ displayAspectWidth: number;
20
+ displayAspectHeight: number;
21
+ codedWidth: number;
22
+ codedHeight: number;
23
+ rotation: number;
24
+ };
25
+ export type AudioTrack = {
26
+ type: 'audio';
27
+ samplePositions: SamplePosition[] | null;
28
+ trackId: number;
29
+ timescale: number;
30
+ codec: string;
31
+ numberOfChannels: number;
32
+ sampleRate: number;
33
+ description: Uint8Array | undefined;
34
+ };
35
+ export type OtherTrack = {
36
+ type: 'other';
37
+ samplePositions: SamplePosition[] | null;
38
+ trackId: number;
39
+ timescale: number;
40
+ };
41
+ export type Track = VideoTrack | AudioTrack | OtherTrack;
42
+ export declare const getNumberOfTracks: (moovBox: MoovBox) => number;
43
+ export declare const hasTracks: (segments: AnySegment[]) => boolean;
44
+ export declare const getTracks: (segments: AnySegment[], state: ParserState) => {
45
+ videoTracks: VideoTrack[];
46
+ audioTracks: AudioTrack[];
47
+ otherTracks: OtherTrack[];
48
+ };
49
+ export {};