@remotion/media-parser 4.0.209 → 4.0.210

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 (213) hide show
  1. package/buffer.js +2 -0
  2. package/dist/boxes/iso-base-media/get-sample-positions-from-track.js +1 -1
  3. package/dist/boxes/iso-base-media/make-track.js +14 -2
  4. package/dist/boxes/iso-base-media/mdat/mdat.d.ts +2 -1
  5. package/dist/boxes/iso-base-media/mdat/mdat.js +8 -3
  6. package/dist/boxes/iso-base-media/moov/moov.d.ts +2 -1
  7. package/dist/boxes/iso-base-media/moov/moov.js +2 -1
  8. package/dist/boxes/iso-base-media/process-box.d.ts +6 -3
  9. package/dist/boxes/iso-base-media/process-box.js +20 -5
  10. package/dist/boxes/iso-base-media/stsd/avcc.d.ts +1 -1
  11. package/dist/boxes/iso-base-media/stsd/avcc.js +2 -2
  12. package/dist/boxes/iso-base-media/stsd/ctts.js +2 -5
  13. package/dist/boxes/iso-base-media/stsd/hvcc.d.ts +1 -1
  14. package/dist/boxes/iso-base-media/stsd/hvcc.js +2 -2
  15. package/dist/boxes/iso-base-media/stsd/mebx.d.ts +2 -1
  16. package/dist/boxes/iso-base-media/stsd/mebx.js +2 -1
  17. package/dist/boxes/iso-base-media/stsd/samples.d.ts +4 -2
  18. package/dist/boxes/iso-base-media/stsd/samples.js +69 -11
  19. package/dist/boxes/iso-base-media/stsd/stsd.d.ts +2 -1
  20. package/dist/boxes/iso-base-media/stsd/stsd.js +2 -1
  21. package/dist/boxes/iso-base-media/trak/trak.d.ts +2 -1
  22. package/dist/boxes/iso-base-media/trak/trak.js +2 -1
  23. package/dist/boxes/iso-base-media/traversal.d.ts +44 -0
  24. package/dist/boxes/iso-base-media/traversal.js +211 -0
  25. package/dist/boxes/webm/color.d.ts +4 -0
  26. package/dist/boxes/webm/color.js +120 -0
  27. package/dist/boxes/webm/description.js +1 -1
  28. package/dist/boxes/webm/get-ready-tracks.js +3 -3
  29. package/dist/boxes/webm/get-sample-from-block.js +1 -1
  30. package/dist/boxes/webm/get-track.js +16 -1
  31. package/dist/boxes/webm/make-track.d.ts +9 -0
  32. package/dist/boxes/webm/make-track.js +260 -0
  33. package/dist/boxes/webm/parse-ebml.js +2 -2
  34. package/dist/boxes/webm/segments/all-segments.d.ts +36 -3
  35. package/dist/boxes/webm/segments/all-segments.js +34 -6
  36. package/dist/boxes/webm/traversal.d.ts +26 -1
  37. package/dist/boxes/webm/traversal.js +214 -1
  38. package/dist/create/cluster-segment.js +0 -2
  39. package/dist/create/cluster.d.ts +10 -2
  40. package/dist/create/cluster.js +16 -10
  41. package/dist/create/create-media.d.ts +4 -2
  42. package/dist/create/create-media.js +76 -14
  43. package/dist/create/cues.d.ts +0 -0
  44. package/dist/create/cues.js +1 -0
  45. package/dist/create/make-duration-with-padding.d.ts +1 -1
  46. package/dist/create/make-duration-with-padding.js +3 -3
  47. package/dist/create/matroska-cues.d.ts +6 -0
  48. package/dist/create/matroska-cues.js +50 -0
  49. package/dist/create/matroska-info.js +1 -1
  50. package/dist/create/matroska-seek.d.ts +6 -0
  51. package/dist/create/matroska-seek.js +32 -0
  52. package/dist/create/matroska-segment.d.ts +1 -0
  53. package/dist/create/matroska-segment.js +3 -2
  54. package/dist/create/matroska-trackentry.d.ts +9 -14
  55. package/dist/create/matroska-trackentry.js +79 -94
  56. package/dist/emit-available-info.d.ts +12 -0
  57. package/dist/emit-available-info.js +133 -0
  58. package/dist/esm/buffer.mjs +57 -0
  59. package/dist/esm/from-fetch.mjs +72 -0
  60. package/dist/esm/from-node.mjs +48 -0
  61. package/dist/esm/from-web-file.mjs +48 -0
  62. package/dist/esm/index.mjs +6689 -0
  63. package/dist/esm/web-fs.mjs +67 -0
  64. package/dist/get-audio-codec.d.ts +5 -5
  65. package/dist/get-audio-codec.js +41 -57
  66. package/dist/get-container.d.ts +4 -0
  67. package/dist/get-container.js +26 -0
  68. package/dist/get-duration.js +1 -1
  69. package/dist/get-fps.js +1 -1
  70. package/dist/get-sample-aspect-ratio.d.ts +1 -1
  71. package/dist/get-sample-aspect-ratio.js +19 -19
  72. package/dist/get-tracks.d.ts +13 -0
  73. package/dist/get-tracks.js +8 -8
  74. package/dist/get-video-codec.d.ts +5 -2
  75. package/dist/get-video-codec.js +111 -21
  76. package/dist/has-all-info.d.ts +2 -2
  77. package/dist/has-all-info.js +23 -9
  78. package/dist/index.d.ts +3 -1
  79. package/dist/options.d.ts +97 -30
  80. package/dist/parse-media.js +43 -62
  81. package/dist/parse-video.d.ts +2 -1
  82. package/dist/parse-video.js +3 -1
  83. package/dist/parser-state.js +1 -2
  84. package/dist/readers/from-fetch.js +24 -4
  85. package/dist/readers/from-node.js +13 -3
  86. package/dist/readers/from-web-file.js +14 -2
  87. package/dist/readers/reader.d.ts +6 -1
  88. package/dist/samples-from-moof.js +1 -1
  89. package/dist/traversal.d.ts +0 -21
  90. package/dist/traversal.js +1 -158
  91. package/dist/truthy.d.ts +3 -0
  92. package/dist/truthy.js +7 -0
  93. package/dist/writers/buffer.d.ts +2 -0
  94. package/dist/writers/buffer.js +58 -0
  95. package/dist/writers/web-fs.d.ts +1 -0
  96. package/dist/writers/web-fs.js +42 -18
  97. package/dist/writers/writer.d.ts +4 -2
  98. package/fetch.js +2 -0
  99. package/node.js +2 -0
  100. package/package.json +43 -8
  101. package/web-file.js +2 -0
  102. package/web-fs.js +2 -0
  103. package/.eslintrc +0 -8
  104. package/input.webm +0 -0
  105. package/src/add-new-matroska-tracks.ts +0 -23
  106. package/src/boxes/iso-base-media/base-type.ts +0 -4
  107. package/src/boxes/iso-base-media/esds/decoder-specific-config.ts +0 -68
  108. package/src/boxes/iso-base-media/esds/esds-descriptors.ts +0 -135
  109. package/src/boxes/iso-base-media/esds/esds.ts +0 -49
  110. package/src/boxes/iso-base-media/ftyp.ts +0 -39
  111. package/src/boxes/iso-base-media/get-sample-positions-from-track.ts +0 -69
  112. package/src/boxes/iso-base-media/make-track.ts +0 -116
  113. package/src/boxes/iso-base-media/mdat/mdat.ts +0 -140
  114. package/src/boxes/iso-base-media/mdhd.ts +0 -59
  115. package/src/boxes/iso-base-media/moov/moov.ts +0 -43
  116. package/src/boxes/iso-base-media/mvhd.ts +0 -114
  117. package/src/boxes/iso-base-media/process-box.ts +0 -748
  118. package/src/boxes/iso-base-media/stsd/av1c.ts +0 -19
  119. package/src/boxes/iso-base-media/stsd/avcc.ts +0 -36
  120. package/src/boxes/iso-base-media/stsd/colr.ts +0 -49
  121. package/src/boxes/iso-base-media/stsd/ctts.ts +0 -64
  122. package/src/boxes/iso-base-media/stsd/hvcc.ts +0 -32
  123. package/src/boxes/iso-base-media/stsd/keys.ts +0 -27
  124. package/src/boxes/iso-base-media/stsd/mebx.ts +0 -54
  125. package/src/boxes/iso-base-media/stsd/pasp.ts +0 -32
  126. package/src/boxes/iso-base-media/stsd/samples.ts +0 -359
  127. package/src/boxes/iso-base-media/stsd/stco.ts +0 -52
  128. package/src/boxes/iso-base-media/stsd/stsc.ts +0 -61
  129. package/src/boxes/iso-base-media/stsd/stsd.ts +0 -55
  130. package/src/boxes/iso-base-media/stsd/stss.ts +0 -47
  131. package/src/boxes/iso-base-media/stsd/stsz.ts +0 -75
  132. package/src/boxes/iso-base-media/stsd/stts.ts +0 -62
  133. package/src/boxes/iso-base-media/tfdt.ts +0 -37
  134. package/src/boxes/iso-base-media/tfhd.ts +0 -66
  135. package/src/boxes/iso-base-media/tkhd.ts +0 -150
  136. package/src/boxes/iso-base-media/to-date.ts +0 -9
  137. package/src/boxes/iso-base-media/trak/trak.ts +0 -43
  138. package/src/boxes/iso-base-media/trun.ts +0 -74
  139. package/src/boxes/iso-base-media/void-box.ts +0 -4
  140. package/src/boxes/webm/allowed-partial-segments.ts +0 -1
  141. package/src/boxes/webm/av1-codec-private.ts +0 -113
  142. package/src/boxes/webm/description.ts +0 -104
  143. package/src/boxes/webm/ebml.ts +0 -98
  144. package/src/boxes/webm/get-ready-tracks.ts +0 -36
  145. package/src/boxes/webm/get-sample-from-block.ts +0 -125
  146. package/src/boxes/webm/get-track.ts +0 -257
  147. package/src/boxes/webm/make-header.ts +0 -253
  148. package/src/boxes/webm/parse-ebml.ts +0 -259
  149. package/src/boxes/webm/parse-webm-header.ts +0 -18
  150. package/src/boxes/webm/segments/all-segments.ts +0 -888
  151. package/src/boxes/webm/segments/block-simple-block-flags.ts +0 -52
  152. package/src/boxes/webm/segments/parse-children.ts +0 -144
  153. package/src/boxes/webm/segments/track-entry.ts +0 -38
  154. package/src/boxes/webm/segments.ts +0 -147
  155. package/src/boxes/webm/traversal.ts +0 -45
  156. package/src/buffer-iterator.ts +0 -555
  157. package/src/create/cluster-segment.ts +0 -62
  158. package/src/create/cluster.ts +0 -64
  159. package/src/create/create-media.ts +0 -136
  160. package/src/create/make-duration-with-padding.ts +0 -15
  161. package/src/create/matroska-header.ts +0 -63
  162. package/src/create/matroska-info.ts +0 -30
  163. package/src/create/matroska-segment.ts +0 -10
  164. package/src/create/matroska-trackentry.ts +0 -325
  165. package/src/create/timescale.ts +0 -1
  166. package/src/get-audio-codec.ts +0 -270
  167. package/src/get-dimensions.ts +0 -47
  168. package/src/get-duration.ts +0 -103
  169. package/src/get-fps.ts +0 -113
  170. package/src/get-sample-aspect-ratio.ts +0 -204
  171. package/src/get-sample-positions.ts +0 -93
  172. package/src/get-tracks.ts +0 -147
  173. package/src/get-video-codec.ts +0 -117
  174. package/src/has-all-info.ts +0 -81
  175. package/src/index.ts +0 -18
  176. package/src/make-hvc1-codec-strings.ts +0 -55
  177. package/src/options.ts +0 -118
  178. package/src/parse-media.ts +0 -183
  179. package/src/parse-result.ts +0 -79
  180. package/src/parse-video.ts +0 -83
  181. package/src/parser-context.ts +0 -10
  182. package/src/parser-state.ts +0 -178
  183. package/src/readers/from-fetch.ts +0 -90
  184. package/src/readers/from-node.ts +0 -51
  185. package/src/readers/from-web-file.ts +0 -49
  186. package/src/readers/reader.ts +0 -15
  187. package/src/samples-from-moof.ts +0 -102
  188. package/src/test/aspect-ratio.test.ts +0 -42
  189. package/src/test/av1.test.ts +0 -108
  190. package/src/test/create-matroska.test.ts +0 -287
  191. package/src/test/duration.test.ts +0 -18
  192. package/src/test/keys.test.ts +0 -47
  193. package/src/test/matroska.test.ts +0 -463
  194. package/src/test/mvhd.test.ts +0 -94
  195. package/src/test/parse-esds.test.ts +0 -98
  196. package/src/test/parse-stco.test.ts +0 -61
  197. package/src/test/parse-stsc.test.ts +0 -104
  198. package/src/test/parse-stsz.test.ts +0 -57
  199. package/src/test/parse-stts.test.ts +0 -38
  200. package/src/test/parse-video.test.ts +0 -101
  201. package/src/test/parse-webm.test.ts +0 -17
  202. package/src/test/samples-from-moof.test.ts +0 -2496
  203. package/src/test/stream-local.test.ts +0 -743
  204. package/src/test/stream-remote.test.ts +0 -59
  205. package/src/test/stream-samples.test.ts +0 -181
  206. package/src/test/stsd.test.ts +0 -265
  207. package/src/test/tkhd.test.ts +0 -87
  208. package/src/traversal.ts +0 -528
  209. package/src/webcodec-sample-types.ts +0 -29
  210. package/src/writers/web-fs.ts +0 -50
  211. package/src/writers/writer.ts +0 -12
  212. package/tsconfig.json +0 -14
  213. package/tsconfig.tsbuildinfo +0 -1
@@ -1,463 +0,0 @@
1
- import {RenderInternals} from '@remotion/renderer';
2
- import {expect, test} from 'bun:test';
3
- import {parseMedia} from '../parse-media';
4
- import {nodeReader} from '../readers/from-node';
5
-
6
- test('Should get duration of AV1 video', async () => {
7
- const parsed = await parseMedia({
8
- src: RenderInternals.exampleVideos.av1,
9
- fields: {
10
- durationInSeconds: true,
11
- boxes: true,
12
- dimensions: true,
13
- fps: true,
14
- },
15
- reader: nodeReader,
16
- });
17
-
18
- expect(parsed.durationInSeconds).toBe(1);
19
- expect(parsed.fps).toBe(null);
20
- expect(parsed.dimensions).toEqual({
21
- width: 1920,
22
- height: 1080,
23
- });
24
-
25
- expect(parsed.boxes).toEqual([
26
- {
27
- type: 'Header',
28
- value: [
29
- {
30
- type: 'EBMLVersion',
31
- value: {value: 1, byteLength: 1},
32
- minVintWidth: 1,
33
- },
34
- {
35
- type: 'EBMLReadVersion',
36
- value: {value: 1, byteLength: 1},
37
- minVintWidth: 1,
38
- },
39
- {
40
- type: 'EBMLMaxIDLength',
41
- value: {value: 4, byteLength: 1},
42
- minVintWidth: 1,
43
- },
44
- {
45
- type: 'EBMLMaxSizeLength',
46
- value: {value: 8, byteLength: 1},
47
- minVintWidth: 1,
48
- },
49
- {
50
- type: 'DocType',
51
- value: 'webm',
52
- minVintWidth: 1,
53
- },
54
- {
55
- type: 'DocTypeVersion',
56
- value: {value: 2, byteLength: 1},
57
- minVintWidth: 1,
58
- },
59
- {
60
- type: 'DocTypeReadVersion',
61
- value: {value: 2, byteLength: 1},
62
- minVintWidth: 1,
63
- },
64
- ],
65
- minVintWidth: 1,
66
- },
67
- {
68
- type: 'Segment',
69
- minVintWidth: 8,
70
- value: [
71
- {
72
- type: 'SeekHead',
73
- value: [
74
- {
75
- type: 'Seek',
76
- value: [
77
- {
78
- type: 'SeekID',
79
- value: '0x1549a966',
80
- minVintWidth: 1,
81
- },
82
- {
83
- type: 'SeekPosition',
84
- value: {value: 161, byteLength: 1},
85
- minVintWidth: 1,
86
- },
87
- ],
88
- minVintWidth: 1,
89
- },
90
- {
91
- type: 'Seek',
92
- value: [
93
- {
94
- type: 'SeekID',
95
- value: '0x1654ae6b',
96
- minVintWidth: 1,
97
- },
98
- {
99
- type: 'SeekPosition',
100
- value: {value: 214, byteLength: 1},
101
- minVintWidth: 1,
102
- },
103
- ],
104
- minVintWidth: 1,
105
- },
106
- {
107
- type: 'Seek',
108
- value: [
109
- {
110
- type: 'SeekID',
111
- value: '0x1254c367',
112
- minVintWidth: 1,
113
- },
114
- {
115
- type: 'SeekPosition',
116
- value: {value: 322, byteLength: 2},
117
- minVintWidth: 1,
118
- },
119
- ],
120
- minVintWidth: 1,
121
- },
122
- {
123
- type: 'Seek',
124
- value: [
125
- {
126
- type: 'SeekID',
127
- value: '0x1c53bb6b',
128
- minVintWidth: 1,
129
- },
130
- {
131
- type: 'SeekPosition',
132
- value: {value: 347329, byteLength: 3},
133
- minVintWidth: 1,
134
- },
135
- ],
136
- minVintWidth: 1,
137
- },
138
- ],
139
- minVintWidth: 1,
140
- },
141
- {
142
- type: 'Void',
143
- value: new Uint8Array([
144
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
145
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
146
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
147
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
148
- ]),
149
- minVintWidth: 8,
150
- },
151
- {
152
- type: 'Info',
153
- value: [
154
- {
155
- type: 'TimestampScale',
156
- value: {value: 1000000, byteLength: 3},
157
- minVintWidth: 1,
158
- },
159
- {
160
- type: 'MuxingApp',
161
- value: 'Lavf60.3.100',
162
- minVintWidth: 1,
163
- },
164
- {
165
- type: 'WritingApp',
166
- value: 'Lavf60.3.100',
167
- minVintWidth: 1,
168
- },
169
- {
170
- type: 'Duration',
171
- value: {
172
- value: 1000,
173
- size: '64',
174
- },
175
- minVintWidth: 1,
176
- },
177
- ],
178
- minVintWidth: 1,
179
- },
180
- {
181
- type: 'Tracks',
182
- value: [
183
- {
184
- type: 'TrackEntry',
185
- value: [
186
- {
187
- type: 'TrackNumber',
188
- value: {value: 1, byteLength: 1},
189
- minVintWidth: 1,
190
- },
191
- {
192
- type: 'TrackUID',
193
- value: '0xab2171012bb9020a',
194
- minVintWidth: 1,
195
- },
196
- {
197
- type: 'FlagLacing',
198
- value: {value: 0, byteLength: 1},
199
- minVintWidth: 1,
200
- },
201
- {
202
- type: 'Language',
203
- value: 'und',
204
- minVintWidth: 1,
205
- },
206
- {
207
- type: 'CodecID',
208
- value: 'V_AV1',
209
- minVintWidth: 1,
210
- },
211
- {
212
- type: 'TrackType',
213
- value: {value: 1, byteLength: 1},
214
- minVintWidth: 1,
215
- },
216
- {
217
- type: 'DefaultDuration',
218
- value: {value: 40000000, byteLength: 4},
219
- minVintWidth: 1,
220
- },
221
- {
222
- type: 'Video',
223
- value: [
224
- {
225
- type: 'PixelWidth',
226
- value: {value: 1920, byteLength: 2},
227
- minVintWidth: 1,
228
- },
229
- {
230
- type: 'PixelHeight',
231
- value: {value: 1080, byteLength: 2},
232
- minVintWidth: 1,
233
- },
234
- {
235
- type: 'Colour',
236
- value: [
237
- {
238
- minVintWidth: 1,
239
- type: 'TransferCharacteristics',
240
- value: {
241
- byteLength: 1,
242
- value: 1,
243
- },
244
- },
245
- {
246
- minVintWidth: 1,
247
- type: 'MatrixCoefficients',
248
- value: {
249
- byteLength: 1,
250
- value: 1,
251
- },
252
- },
253
- {
254
- minVintWidth: 1,
255
- type: 'Primaries',
256
- value: {
257
- byteLength: 1,
258
- value: 1,
259
- },
260
- },
261
- {
262
- minVintWidth: 1,
263
- type: 'Range',
264
- value: {
265
- byteLength: 1,
266
- value: 1,
267
- },
268
- },
269
- ],
270
- minVintWidth: 1,
271
- },
272
- ],
273
- minVintWidth: 1,
274
- },
275
- {
276
- type: 'CodecPrivate',
277
- value: new Uint8Array([
278
- 129, 8, 12, 0, 10, 14, 0, 0, 0, 66, 171, 191, 195, 118, 0,
279
- 8, 8, 8, 8, 32,
280
- ]),
281
- minVintWidth: 1,
282
- },
283
- ],
284
- minVintWidth: 8,
285
- },
286
- ],
287
- minVintWidth: 1,
288
- },
289
- {
290
- type: 'Tags',
291
- value: [
292
- {
293
- type: 'Tag',
294
- value: new Uint8Array([
295
- 99, 192, 128, 103, 200, 153, 69, 163, 135, 69, 78, 67, 79, 68,
296
- 69, 82, 68, 135, 140, 76, 97, 118, 102, 54, 48, 46, 51, 46, 49,
297
- 48, 48,
298
- ]),
299
- minVintWidth: 1,
300
- },
301
- {
302
- type: 'Tag',
303
- value: new Uint8Array([
304
- 99, 192, 139, 99, 197, 136, 171, 33, 113, 1, 43, 185, 2, 10,
305
- 103, 200, 162, 69, 163, 136, 68, 85, 82, 65, 84, 73, 79, 78, 68,
306
- 135, 148, 48, 48, 58, 48, 48, 58, 48, 49, 46, 48, 48, 48, 48,
307
- 48, 48, 48, 48, 48, 0, 0,
308
- ]),
309
- minVintWidth: 1,
310
- },
311
- ],
312
- minVintWidth: 1,
313
- },
314
- {
315
- value: [
316
- {
317
- type: 'Timestamp',
318
- value: {value: 0, byteLength: 1},
319
- minVintWidth: 1,
320
- },
321
- {
322
- type: 'Block',
323
- value: new Uint8Array(),
324
- minVintWidth: 3,
325
- },
326
- {
327
- type: 'Block',
328
- value: new Uint8Array(),
329
- minVintWidth: 1,
330
- },
331
- {
332
- type: 'Block',
333
- value: new Uint8Array(),
334
- minVintWidth: 2,
335
- },
336
- {
337
- type: 'Block',
338
- value: new Uint8Array(),
339
- minVintWidth: 2,
340
- },
341
- {
342
- type: 'Block',
343
- value: new Uint8Array(),
344
- minVintWidth: 2,
345
- },
346
- {
347
- type: 'Block',
348
- value: new Uint8Array(),
349
- minVintWidth: 2,
350
- },
351
- {
352
- type: 'Block',
353
- value: new Uint8Array(),
354
- minVintWidth: 2,
355
- },
356
- {
357
- type: 'Block',
358
- value: new Uint8Array(),
359
- minVintWidth: 2,
360
- },
361
- {
362
- type: 'Block',
363
- value: new Uint8Array(),
364
- minVintWidth: 2,
365
- },
366
- {
367
- type: 'Block',
368
- value: new Uint8Array(),
369
- minVintWidth: 2,
370
- },
371
- {
372
- type: 'Block',
373
- value: new Uint8Array(),
374
- minVintWidth: 2,
375
- },
376
- {
377
- type: 'Block',
378
- value: new Uint8Array(),
379
- minVintWidth: 2,
380
- },
381
- {
382
- type: 'Block',
383
- value: new Uint8Array(),
384
- minVintWidth: 2,
385
- },
386
- {
387
- type: 'Block',
388
- value: new Uint8Array(),
389
- minVintWidth: 2,
390
- },
391
- {
392
- type: 'Block',
393
- value: new Uint8Array(),
394
- minVintWidth: 2,
395
- },
396
- {
397
- type: 'Block',
398
- value: new Uint8Array(),
399
- minVintWidth: 2,
400
- },
401
- {
402
- type: 'Block',
403
- value: new Uint8Array(),
404
- minVintWidth: 2,
405
- },
406
- {
407
- type: 'Block',
408
- value: new Uint8Array(),
409
- minVintWidth: 2,
410
- },
411
- {
412
- type: 'Block',
413
- value: new Uint8Array(),
414
- minVintWidth: 2,
415
- },
416
- {
417
- type: 'Block',
418
- value: new Uint8Array(),
419
- minVintWidth: 2,
420
- },
421
- {
422
- type: 'Block',
423
- value: new Uint8Array(),
424
- minVintWidth: 2,
425
- },
426
- {
427
- type: 'Block',
428
- value: new Uint8Array(),
429
- minVintWidth: 2,
430
- },
431
- {
432
- type: 'Block',
433
- value: new Uint8Array(),
434
- minVintWidth: 2,
435
- },
436
- {
437
- type: 'Block',
438
- value: new Uint8Array(),
439
- minVintWidth: 2,
440
- },
441
- {
442
- type: 'Block',
443
- value: new Uint8Array(),
444
- minVintWidth: 2,
445
- },
446
- ],
447
- type: 'Cluster',
448
- minVintWidth: 3,
449
- },
450
- {
451
- type: 'Cues',
452
- value: new Uint8Array([
453
- 187, 143, 179, 129, 0, 183, 138, 247, 129, 1, 241, 130, 1, 159, 240,
454
- 129, 3,
455
- ]),
456
- minVintWidth: 1,
457
- },
458
- ],
459
- },
460
- ]);
461
-
462
- expect(parsed.durationInSeconds).toBe(1);
463
- });
@@ -1,94 +0,0 @@
1
- import {expect, test} from 'bun:test';
2
- import {parseMvhd} from '../boxes/iso-base-media/mvhd';
3
- import {getArrayBufferIterator} from '../buffer-iterator';
4
-
5
- test('Should be able to parse a MVHD box correctly', () => {
6
- const buffer = Uint8Array.from([
7
- // size, 32 bit
8
- 0, 0, 0, 108,
9
- // mvhd atom, 32 bit
10
- 109, 118, 104, 100,
11
- // version, 8 unsigned bit
12
- 0,
13
- // flags, 24 bit
14
- 0, 0, 0,
15
- // creation time, 32 bit
16
- 0, 0, 0, 0,
17
- // modification time, 32 bit
18
- 0, 0, 0, 0,
19
- // time scale
20
- 0, 0, 3, 232,
21
- // duration
22
- 0, 0, 16, 71,
23
- // rate
24
- 0, 1, 0, 0,
25
- // volume
26
- 1, 0,
27
- // reserved 16 bit
28
- 0, 0,
29
- // reserved 32 bit [0]
30
- 0, 0, 0, 0,
31
- // reserved 32 bit [1]
32
- 0, 0, 0, 0,
33
- // matrix [0]
34
- 0, 1, 0, 0,
35
- // matrix [1]
36
- 0, 0, 0, 0,
37
- // matrix [2]
38
- 0, 0, 0, 0,
39
- // matrix [3]
40
- 0, 0, 0, 0,
41
- // matrix [4]
42
- 0, 1, 0, 0,
43
- // matrix [5]
44
- 0, 0, 0, 0,
45
- // matrix [6]
46
- 0, 0, 0, 0,
47
- // matrix [7]
48
- 0, 0, 0, 0,
49
- // matrix [8]
50
- 64, 0, 0, 0,
51
- // predefined [0]
52
- 0, 0, 0, 0,
53
- // predefined [1]
54
- 0, 0, 0, 0,
55
- // predefined [2]
56
- 0, 0, 0, 0,
57
- // predefined [3]
58
- 0, 0, 0, 0,
59
- // predefined [4]
60
- 0, 0, 0, 0,
61
- // predefined [5]
62
- 0, 0, 0, 0,
63
- // next track id
64
- 0, 0, 0, 2,
65
- ]);
66
-
67
- const iterator = getArrayBufferIterator(buffer, null);
68
- iterator.discard(8);
69
-
70
- const mvhd = parseMvhd({
71
- offset: 0,
72
- size: 108,
73
- iterator,
74
- });
75
- expect(mvhd).toEqual({
76
- creationTime: null,
77
- modificationTime: null,
78
- timeScale: 1000,
79
- durationInUnits: 4167,
80
- durationInSeconds: 4.167,
81
- rate: 1,
82
- volume: 1,
83
- // prettier-ignore
84
- matrix: [
85
- 1, 0, 0,
86
- 0, 1, 0,
87
- 0, 0, 1
88
- ],
89
- nextTrackId: 2,
90
- type: 'mvhd-box',
91
- boxSize: 108,
92
- offset: 0,
93
- });
94
- });
@@ -1,98 +0,0 @@
1
- import {expect, test} from 'bun:test';
2
- import {parseEsds} from '../boxes/iso-base-media/esds/esds';
3
- import {getArrayBufferIterator} from '../buffer-iterator';
4
-
5
- test('Parse ESDS box', () => {
6
- const buf = new Uint8Array([
7
- // mock header
8
- 0, 0, 0, 0, 0, 0, 0, 0,
9
- // actual box
10
- 0, 0, 0, 0, 3, 128, 128, 128, 27, 0, 2, 0, 4, 128, 128, 128, 13, 107, 21, 0,
11
- 0, 0, 0, 4, 226, 0, 0, 4, 226, 0, 6, 128, 128, 128, 1, 2,
12
- ]);
13
-
14
- const iter = getArrayBufferIterator(buf, null);
15
- iter.counter.increment(8);
16
-
17
- expect(
18
- parseEsds({
19
- data: iter,
20
- fileOffset: 8,
21
- size: buf.length - 8,
22
- }),
23
- ).toEqual({
24
- type: 'esds-box',
25
- version: 0,
26
- tag: 3,
27
- sizeOfInstance: 27,
28
- esId: 2,
29
- descriptors: [
30
- {
31
- type: 'decoder-config-descriptor',
32
- objectTypeIndication: 'mp3',
33
- asNumber: 107,
34
- bufferSizeDB: 0,
35
- streamType: 5,
36
- upStream: 0,
37
- avgBitrate: 320000,
38
- maxBitrate: 320000,
39
- decoderSpecificConfigs: [
40
- {
41
- type: 'unknown-decoder-specific-config',
42
- },
43
- ],
44
- },
45
- ],
46
- });
47
- });
48
-
49
- test('Parse two ESDS', () => {
50
- const buf = new Uint8Array([
51
- // mock header
52
- 0, 0, 0, 0, 0, 0, 0, 0,
53
- // actual box
54
- 0, 0, 0, 0, 3, 25, 0, 0, 0, 4, 17, 64, 21, 0, 24, 0, 0, 4, 226, 0, 0, 4,
55
- 226, 0, 5, 2, 17, 144, 6, 1, 2, 0, 0, 0, 24, 115, 116, 116, 115,
56
- ]);
57
-
58
- const iter = getArrayBufferIterator(buf, null);
59
- iter.counter.increment(8);
60
-
61
- expect(
62
- parseEsds({
63
- data: iter,
64
- fileOffset: 8,
65
- size: buf.length - 8,
66
- }),
67
- ).toEqual({
68
- type: 'esds-box',
69
- version: 0,
70
- tag: 3,
71
- sizeOfInstance: 25,
72
- esId: 0,
73
- descriptors: [
74
- {
75
- objectTypeIndication: 'aac',
76
- type: 'decoder-config-descriptor',
77
- asNumber: 64,
78
- bufferSizeDB: 6144,
79
- streamType: 5,
80
- upStream: 0,
81
- avgBitrate: 320000,
82
- maxBitrate: 320000,
83
- decoderSpecificConfigs: [
84
- {
85
- audioObjectType: 2,
86
- channelConfiguration: 2,
87
- samplingFrequencyIndex: 3,
88
- type: 'audio-specific-config',
89
- asBytes: new Uint8Array([17, 144]),
90
- },
91
- {
92
- type: 'unknown-decoder-specific-config',
93
- },
94
- ],
95
- },
96
- ],
97
- });
98
- });
@@ -1,61 +0,0 @@
1
- import {expect, test} from 'bun:test';
2
- import {parseStco} from '../boxes/iso-base-media/stsd/stco';
3
- import {getArrayBufferIterator} from '../buffer-iterator';
4
-
5
- test('Parse stco box', () => {
6
- const buf = new Uint8Array([
7
- // mock header
8
- 0, 0, 0, 0, 0, 0, 0, 0,
9
- // actual box
10
- 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 26, 252, 0, 0, 33, 118, 0, 0, 43, 73, 0, 0,
11
- 49, 45, 0, 0, 59, 16, 0, 0, 65, 141, 0, 0, 71, 100, 0, 0, 81, 236, 0, 0, 87,
12
- 246,
13
- ]);
14
-
15
- const iterator = getArrayBufferIterator(buf, null);
16
- iterator.counter.increment(8);
17
- const result = parseStco({
18
- iterator,
19
- size: buf.length - 8,
20
- offset: 0,
21
- mode64Bit: false,
22
- });
23
- expect(result).toEqual({
24
- type: 'stco-box',
25
- boxSize: 44,
26
- offset: 0,
27
- version: 0,
28
- flags: [0, 0, 0],
29
- entryCount: 9,
30
- entries: [6908, 8566, 11081, 12589, 15120, 16781, 18276],
31
- });
32
- });
33
-
34
- test('Parse stco box with empty chunk', () => {
35
- const buf = new Uint8Array([
36
- // mock header
37
- 0, 0, 0, 0, 0, 0, 0, 0,
38
- // actual box
39
- 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 6, 101, 0, 0, 30, 188, 0, 0, 40, 246, 0, 0,
40
- 47, 9, 0, 0, 56, 173, 0, 0, 62, 208, 0, 0, 69, 77, 0, 0, 78, 228, 0, 0, 85,
41
- 172,
42
- ]);
43
-
44
- const iterator = getArrayBufferIterator(buf, null);
45
- iterator.counter.increment(8);
46
- const result = parseStco({
47
- iterator,
48
- size: buf.length - 8,
49
- offset: 0,
50
- mode64Bit: false,
51
- });
52
- expect(result).toEqual({
53
- type: 'stco-box',
54
- boxSize: 44,
55
- offset: 0,
56
- version: 0,
57
- flags: [0, 0, 0],
58
- entryCount: 9,
59
- entries: [1637, 7868, 10486, 12041, 14509, 16080, 17741],
60
- });
61
- });