@remotion/media-parser 4.0.201 → 4.0.204

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 (144) hide show
  1. package/dist/av1-codec-string.d.ts +0 -5
  2. package/dist/av1-codec-string.js +1 -18
  3. package/dist/boxes/iso-base-media/ftype.d.ts +9 -0
  4. package/dist/boxes/iso-base-media/ftype.js +31 -0
  5. package/dist/boxes/iso-base-media/get-sample-positions-from-track.d.ts +4 -0
  6. package/dist/boxes/iso-base-media/get-sample-positions-from-track.js +48 -0
  7. package/dist/boxes/iso-base-media/mvhd.js +2 -2
  8. package/dist/boxes/iso-base-media/stsd/keys.js +1 -1
  9. package/dist/boxes/iso-base-media/tfdt.d.ts +12 -0
  10. package/dist/boxes/iso-base-media/tfdt.js +20 -0
  11. package/dist/boxes/iso-base-media/tfhd.d.ts +16 -0
  12. package/dist/boxes/iso-base-media/tfhd.js +41 -0
  13. package/dist/boxes/iso-base-media/trun.d.ts +21 -0
  14. package/dist/boxes/iso-base-media/trun.js +44 -0
  15. package/dist/boxes/webm/av1-codec-private.js +1 -1
  16. package/dist/boxes/webm/bitstream/av1.js +1 -10
  17. package/dist/boxes/webm/description.d.ts +2 -2
  18. package/dist/boxes/webm/description.js +2 -2
  19. package/dist/boxes/webm/ebml.d.ts +2 -2
  20. package/dist/boxes/webm/ebml.js +23 -1
  21. package/dist/boxes/webm/get-ready-tracks.d.ts +1 -1
  22. package/dist/boxes/webm/get-ready-tracks.js +3 -3
  23. package/dist/boxes/webm/get-sample-from-block.d.ts +17 -0
  24. package/dist/boxes/webm/get-sample-from-block.js +78 -0
  25. package/dist/boxes/webm/get-track.d.ts +2 -2
  26. package/dist/boxes/webm/get-track.js +26 -25
  27. package/dist/boxes/webm/make-header.d.ts +3 -8
  28. package/dist/boxes/webm/make-header.js +43 -20
  29. package/dist/boxes/webm/parse-ebml.d.ts +9 -4
  30. package/dist/boxes/webm/parse-ebml.js +122 -13
  31. package/dist/boxes/webm/segments/all-segments.d.ts +421 -107
  32. package/dist/boxes/webm/segments/all-segments.js +260 -33
  33. package/dist/boxes/webm/segments/track-entry.d.ts +3 -191
  34. package/dist/boxes/webm/segments/track-entry.js +2 -456
  35. package/dist/boxes/webm/segments.d.ts +3 -16
  36. package/dist/boxes/webm/segments.js +12 -196
  37. package/dist/boxes/webm/tracks.d.ts +8 -0
  38. package/dist/boxes/webm/tracks.js +21 -0
  39. package/dist/boxes/webm/traversal.d.ts +5 -6
  40. package/dist/boxes/webm/traversal.js +6 -6
  41. package/dist/buffer-iterator.d.ts +1 -1
  42. package/dist/buffer-iterator.js +3 -3
  43. package/dist/from-web.js +6 -15
  44. package/dist/get-audio-codec.d.ts +1 -1
  45. package/dist/get-audio-codec.js +13 -13
  46. package/dist/get-duration.js +12 -14
  47. package/dist/get-tracks.js +2 -2
  48. package/dist/get-video-codec.js +13 -13
  49. package/dist/get-video-metadata.d.ts +2 -0
  50. package/dist/get-video-metadata.js +44 -0
  51. package/dist/parse-media.js +4 -1
  52. package/dist/parser-context.d.ts +1 -0
  53. package/dist/parser-state.js +3 -2
  54. package/dist/read-and-increment-offset.d.ts +28 -0
  55. package/dist/read-and-increment-offset.js +177 -0
  56. package/dist/samples-from-moof.d.ts +6 -0
  57. package/dist/samples-from-moof.js +74 -0
  58. package/dist/traversal.d.ts +19 -17
  59. package/dist/traversal.js +38 -39
  60. package/dist/understand-vorbis.d.ts +1 -0
  61. package/dist/understand-vorbis.js +12 -0
  62. package/input.webm +0 -0
  63. package/package.json +2 -2
  64. package/src/boxes/iso-base-media/get-sample-positions-from-track.ts +69 -0
  65. package/src/boxes/iso-base-media/make-track.ts +4 -45
  66. package/src/boxes/iso-base-media/mdat/mdat.ts +33 -24
  67. package/src/boxes/iso-base-media/mdhd.ts +10 -7
  68. package/src/boxes/iso-base-media/mvhd.ts +17 -16
  69. package/src/boxes/iso-base-media/process-box.ts +42 -0
  70. package/src/boxes/iso-base-media/stsd/keys.ts +1 -1
  71. package/src/boxes/iso-base-media/tfdt.ts +37 -0
  72. package/src/boxes/iso-base-media/tfhd.ts +66 -0
  73. package/src/boxes/iso-base-media/tkhd.ts +11 -13
  74. package/src/boxes/iso-base-media/trun.ts +74 -0
  75. package/src/boxes/webm/av1-codec-private.ts +1 -1
  76. package/src/boxes/webm/description.ts +7 -4
  77. package/src/boxes/webm/ebml.ts +24 -4
  78. package/src/boxes/webm/get-ready-tracks.ts +4 -4
  79. package/src/boxes/webm/get-sample-from-block.ts +125 -0
  80. package/src/boxes/webm/get-track.ts +40 -33
  81. package/src/boxes/webm/make-header.ts +58 -51
  82. package/src/boxes/webm/parse-ebml.ts +170 -16
  83. package/src/boxes/webm/segments/all-segments.ts +379 -62
  84. package/src/boxes/webm/segments/track-entry.ts +3 -846
  85. package/src/boxes/webm/segments.ts +18 -410
  86. package/src/boxes/webm/traversal.ts +17 -17
  87. package/src/buffer-iterator.ts +8 -6
  88. package/src/get-audio-codec.ts +14 -16
  89. package/src/get-duration.ts +55 -21
  90. package/src/get-tracks.ts +6 -6
  91. package/src/get-video-codec.ts +13 -15
  92. package/src/has-all-info.ts +1 -1
  93. package/src/parse-media.ts +7 -2
  94. package/src/parse-result.ts +7 -1
  95. package/src/parser-context.ts +1 -0
  96. package/src/parser-state.ts +2 -2
  97. package/src/samples-from-moof.ts +101 -0
  98. package/src/test/create-matroska.test.ts +237 -23
  99. package/src/test/matroska.test.ts +283 -348
  100. package/src/test/mvhd.test.ts +1 -1
  101. package/src/test/parse-esds.test.ts +2 -2
  102. package/src/test/parse-stco.test.ts +2 -2
  103. package/src/test/parse-stsc.test.ts +2 -2
  104. package/src/test/parse-stsz.test.ts +2 -2
  105. package/src/test/parse-stts.test.ts +1 -1
  106. package/src/test/samples-from-moof.test.ts +2496 -0
  107. package/src/test/stream-local.test.ts +28 -30
  108. package/src/test/stream-samples.test.ts +153 -231
  109. package/src/test/stsd.test.ts +4 -2
  110. package/src/test/tkhd.test.ts +1 -1
  111. package/src/traversal.ts +118 -86
  112. package/tsconfig.tsbuildinfo +1 -1
  113. package/dist/bitstream/av1.d.ts +0 -2
  114. package/dist/bitstream/av1.js +0 -12
  115. package/dist/boxes/iso-base-media/avcc-hvcc.d.ts +0 -20
  116. package/dist/boxes/iso-base-media/avcc-hvcc.js +0 -73
  117. package/dist/boxes/iso-base-media/avcc.d.ts +0 -18
  118. package/dist/boxes/iso-base-media/avcc.js +0 -27
  119. package/dist/boxes/iso-base-media/esds-descriptors.d.ts +0 -21
  120. package/dist/boxes/iso-base-media/esds-descriptors.js +0 -62
  121. package/dist/boxes/iso-base-media/esds.d.ts +0 -15
  122. package/dist/boxes/iso-base-media/esds.js +0 -27
  123. package/dist/from-input-type-file.d.ts +0 -2
  124. package/dist/from-input-type-file.js +0 -37
  125. package/dist/get-codec.d.ts +0 -4
  126. package/dist/get-codec.js +0 -22
  127. package/dist/web-file.d.ts +0 -2
  128. package/dist/web-file.js +0 -37
  129. package/src/boxes/webm/segments/duration.ts +0 -29
  130. package/src/boxes/webm/segments/info.ts +0 -34
  131. package/src/boxes/webm/segments/main.ts +0 -6
  132. package/src/boxes/webm/segments/muxing.ts +0 -18
  133. package/src/boxes/webm/segments/seek-head.ts +0 -34
  134. package/src/boxes/webm/segments/seek-position.ts +0 -18
  135. package/src/boxes/webm/segments/seek.ts +0 -55
  136. package/src/boxes/webm/segments/timestamp-scale.ts +0 -17
  137. package/src/boxes/webm/segments/tracks.ts +0 -32
  138. package/src/boxes/webm/segments/void.ts +0 -18
  139. package/src/boxes/webm/segments/writing.ts +0 -18
  140. package/src/combine-uint8array.ts +0 -13
  141. /package/dist/{get-samples.d.ts → boxes/webm/bitstream/av1/frame.d.ts} +0 -0
  142. /package/dist/{get-samples.js → boxes/webm/bitstream/av1/frame.js} +0 -0
  143. /package/dist/{sample-aspect-ratio.d.ts → boxes/webm/bitstream/h264/get-h264-descriptor.d.ts} +0 -0
  144. /package/dist/{sample-aspect-ratio.js → boxes/webm/bitstream/h264/get-h264-descriptor.js} +0 -0
package/src/traversal.ts CHANGED
@@ -9,23 +9,26 @@ import type {StsdBox} from './boxes/iso-base-media/stsd/stsd';
9
9
  import type {StssBox} from './boxes/iso-base-media/stsd/stss';
10
10
  import type {StszBox} from './boxes/iso-base-media/stsd/stsz';
11
11
  import type {SttsBox} from './boxes/iso-base-media/stsd/stts';
12
+ import type {TfdtBox} from './boxes/iso-base-media/tfdt';
13
+ import type {TfhdBox} from './boxes/iso-base-media/tfhd';
12
14
  import type {TkhdBox} from './boxes/iso-base-media/tkhd';
13
15
  import type {TrakBox} from './boxes/iso-base-media/trak/trak';
14
- import type {MainSegment} from './boxes/webm/segments/main';
15
- import type {TimestampScaleSegment} from './boxes/webm/segments/timestamp-scale';
16
+ import type {TrunBox} from './boxes/iso-base-media/trun';
16
17
  import type {
17
18
  AudioSegment,
18
19
  ClusterSegment,
19
- CodecSegment,
20
+ CodecIdSegment,
20
21
  DisplayHeightSegment,
21
22
  DisplayWidthSegment,
22
23
  HeightSegment,
23
- TrackEntrySegment,
24
+ MainSegment,
25
+ TimestampScaleSegment,
26
+ TrackEntry,
24
27
  TrackTypeSegment,
25
28
  VideoSegment,
26
29
  WidthSegment,
27
- } from './boxes/webm/segments/track-entry';
28
- import type {AnySegment, RegularBox} from './parse-result';
30
+ } from './boxes/webm/segments/all-segments';
31
+ import type {AnySegment, IsoBaseMediaBox, RegularBox} from './parse-result';
29
32
 
30
33
  export const getFtypBox = (segments: AnySegment[]): FtypBox | null => {
31
34
  const ftypBox = segments.find((s) => s.type === 'ftyp-box');
@@ -45,6 +48,18 @@ export const getMoovBox = (segments: AnySegment[]): MoovBox | null => {
45
48
  return moovBox;
46
49
  };
47
50
 
51
+ export const getMoofBox = (main: AnySegment[]): IsoBaseMediaBox | null => {
52
+ const moofBox = main.find(
53
+ (s) => s.type === 'regular-box' && s.boxType === 'moof',
54
+ );
55
+
56
+ if (!moofBox || moofBox.type !== 'regular-box') {
57
+ return null;
58
+ }
59
+
60
+ return moofBox;
61
+ };
62
+
48
63
  export const getMvhdBox = (moovBox: MoovBox): MvhdBox | null => {
49
64
  const mvHdBox = moovBox.children.find((s) => s.type === 'mvhd-box');
50
65
 
@@ -239,21 +254,59 @@ export const getStssBox = (trakBox: TrakBox): StssBox | null => {
239
254
  return stssBox;
240
255
  };
241
256
 
257
+ export const getTfdtBox = (segment: IsoBaseMediaBox): TfdtBox | null => {
258
+ if (segment.type !== 'regular-box' || segment.boxType !== 'traf') {
259
+ throw new Error('Expected traf-box');
260
+ }
261
+
262
+ const tfhdBox = segment.children.find((c) => c.type === 'tfdt-box');
263
+
264
+ if (!tfhdBox || tfhdBox.type !== 'tfdt-box') {
265
+ throw new Error('Expected tfhd-box');
266
+ }
267
+
268
+ return tfhdBox;
269
+ };
270
+
271
+ export const getTfhdBox = (segment: IsoBaseMediaBox): TfhdBox | null => {
272
+ if (segment.type !== 'regular-box' || segment.boxType !== 'traf') {
273
+ throw new Error('Expected traf-box');
274
+ }
275
+
276
+ const tfhdBox = segment.children.find(
277
+ (c) => c.type === 'tfhd-box',
278
+ ) as TfhdBox;
279
+
280
+ if (!tfhdBox || tfhdBox.type !== 'tfhd-box') {
281
+ throw new Error('Expected tfhd-box');
282
+ }
283
+
284
+ return tfhdBox;
285
+ };
286
+
287
+ export const getTrunBoxes = (segment: IsoBaseMediaBox): TrunBox[] => {
288
+ if (segment.type !== 'regular-box' || segment.boxType !== 'traf') {
289
+ throw new Error('Expected traf-box');
290
+ }
291
+
292
+ const trunBoxes = segment.children.filter((c) => c.type === 'trun-box');
293
+
294
+ return trunBoxes as TrunBox[];
295
+ };
296
+
242
297
  export const getClusterSegment = (
243
298
  segment: MainSegment,
244
299
  ): ClusterSegment | null => {
245
- const clusterSegment = segment.children.find(
246
- (b) => b.type === 'cluster-segment',
247
- ) as ClusterSegment | undefined;
300
+ const clusterSegment = segment.value.find((b) => b.type === 'Cluster') as
301
+ | ClusterSegment
302
+ | undefined;
248
303
 
249
304
  return clusterSegment ?? null;
250
305
  };
251
306
 
252
307
  export const getTracksSegment = (segment: MainSegment) => {
253
- const tracksSegment = segment.children.find(
254
- (b) => b.type === 'tracks-segment',
255
- );
256
- if (!tracksSegment || tracksSegment.type !== 'tracks-segment') {
308
+ const tracksSegment = segment.value.find((b) => b.type === 'Tracks');
309
+ if (!tracksSegment || tracksSegment.type !== 'Tracks') {
257
310
  return null;
258
311
  }
259
312
 
@@ -263,139 +316,120 @@ export const getTracksSegment = (segment: MainSegment) => {
263
316
  export const getTimescaleSegment = (
264
317
  segment: MainSegment,
265
318
  ): TimestampScaleSegment | null => {
266
- const infoSegment = segment.children.find((b) => b.type === 'info-segment');
319
+ const infoSegment = segment.value.find((b) => b.type === 'Info');
267
320
 
268
- if (!infoSegment || infoSegment.type !== 'info-segment') {
321
+ if (!infoSegment || infoSegment.type !== 'Info') {
269
322
  return null;
270
323
  }
271
324
 
272
- const timescale = infoSegment.children.find(
273
- (b) => b.type === 'timestamp-scale-segment',
274
- );
325
+ const timescale = infoSegment.value.find((b) => b.type === 'TimestampScale');
275
326
 
276
- if (!timescale || timescale.type !== 'timestamp-scale-segment') {
327
+ if (!timescale || timescale.type !== 'TimestampScale') {
277
328
  return null;
278
329
  }
279
330
 
280
- return timescale;
331
+ return timescale as TimestampScaleSegment;
281
332
  };
282
333
 
283
- export const getVideoSegment = (
284
- track: TrackEntrySegment,
285
- ): VideoSegment | null => {
286
- const videoSegment = track.children.find((b) => b.type === 'video-segment');
287
- if (!videoSegment || videoSegment.type !== 'video-segment') {
334
+ export const getVideoSegment = (track: TrackEntry): VideoSegment | null => {
335
+ const videoSegment = track.value.find((b) => b.type === 'Video');
336
+ if (!videoSegment || videoSegment.type !== 'Video') {
288
337
  return null;
289
338
  }
290
339
 
291
340
  return videoSegment ?? null;
292
341
  };
293
342
 
294
- export const getAudioSegment = (
295
- track: TrackEntrySegment,
296
- ): AudioSegment | null => {
297
- const audioSegment = track.children.find((b) => b.type === 'audio-segment');
298
- if (!audioSegment || audioSegment.type !== 'audio-segment') {
343
+ export const getAudioSegment = (track: TrackEntry): AudioSegment | null => {
344
+ const audioSegment = track.value.find((b) => b.type === 'Audio');
345
+ if (!audioSegment || audioSegment.type !== 'Audio') {
299
346
  return null;
300
347
  }
301
348
 
302
349
  return audioSegment ?? null;
303
350
  };
304
351
 
305
- export const getSampleRate = (track: TrackEntrySegment): number | null => {
352
+ export const getSampleRate = (track: TrackEntry): number | null => {
306
353
  const audioSegment = getAudioSegment(track);
307
354
  if (!audioSegment) {
308
355
  return null;
309
356
  }
310
357
 
311
- const samplingFrequency = audioSegment.children.find(
312
- (b) => b.type === 'sampling-frequency-segment',
358
+ const samplingFrequency = audioSegment.value.find(
359
+ (b) => b.type === 'SamplingFrequency',
313
360
  );
314
361
 
315
- if (
316
- !samplingFrequency ||
317
- samplingFrequency.type !== 'sampling-frequency-segment'
318
- ) {
362
+ if (!samplingFrequency || samplingFrequency.type !== 'SamplingFrequency') {
319
363
  return null;
320
364
  }
321
365
 
322
- return samplingFrequency.samplingFrequency;
366
+ return samplingFrequency.value.value;
323
367
  };
324
368
 
325
- export const getNumberOfChannels = (track: TrackEntrySegment): number => {
369
+ export const getNumberOfChannels = (track: TrackEntry): number => {
326
370
  const audioSegment = getAudioSegment(track);
327
371
  if (!audioSegment) {
328
372
  throw new Error('Could not find audio segment');
329
373
  }
330
374
 
331
- const channels = audioSegment.children.find(
332
- (b) => b.type === 'channels-segment',
333
- );
375
+ const channels = audioSegment.value.find((b) => b.type === 'Channels');
334
376
 
335
- if (!channels || channels.type !== 'channels-segment') {
377
+ if (!channels || channels.type !== 'Channels') {
336
378
  return 1;
337
379
  }
338
380
 
339
- return channels.channels;
381
+ return channels.value.value;
340
382
  };
341
383
 
342
- export const getBitDepth = (track: TrackEntrySegment): number | null => {
384
+ export const getBitDepth = (track: TrackEntry): number | null => {
343
385
  const audioSegment = getAudioSegment(track);
344
386
  if (!audioSegment) {
345
387
  return null;
346
388
  }
347
389
 
348
- const bitDepth = audioSegment.children.find(
349
- (b) => b.type === 'bit-depth-segment',
350
- );
390
+ const bitDepth = audioSegment.value.find((b) => b.type === 'BitDepth');
351
391
 
352
- if (!bitDepth || bitDepth.type !== 'bit-depth-segment') {
392
+ if (!bitDepth || bitDepth.type !== 'BitDepth') {
353
393
  return null;
354
394
  }
355
395
 
356
- return bitDepth.bitDepth;
396
+ return bitDepth.value.value;
357
397
  };
358
398
 
359
- export const getPrivateData = (track: TrackEntrySegment): Uint8Array | null => {
360
- const privateData = track.children.find(
361
- (b) => b.type === 'codec-private-segment',
362
- );
399
+ export const getPrivateData = (track: TrackEntry): Uint8Array | null => {
400
+ const privateData = track.value.find((b) => b.type === 'CodecPrivate');
363
401
 
364
- if (!privateData || privateData.type !== 'codec-private-segment') {
402
+ if (!privateData || privateData.type !== 'CodecPrivate') {
365
403
  return null;
366
404
  }
367
405
 
368
- return privateData.codecPrivateData;
406
+ return privateData.value;
369
407
  };
370
408
 
371
- export const getWidthSegment = (
372
- track: TrackEntrySegment,
373
- ): WidthSegment | null => {
409
+ export const getWidthSegment = (track: TrackEntry): WidthSegment | null => {
374
410
  const videoSegment = getVideoSegment(track);
375
411
  if (!videoSegment) {
376
412
  return null;
377
413
  }
378
414
 
379
- const width = videoSegment.children.find((b) => b.type === 'width-segment');
415
+ const width = videoSegment.value.find((b) => b.type === 'PixelWidth');
380
416
 
381
- if (!width || width.type !== 'width-segment') {
417
+ if (!width || width.type !== 'PixelWidth') {
382
418
  return null;
383
419
  }
384
420
 
385
421
  return width;
386
422
  };
387
423
 
388
- export const getHeightSegment = (
389
- track: TrackEntrySegment,
390
- ): HeightSegment | null => {
424
+ export const getHeightSegment = (track: TrackEntry): HeightSegment | null => {
391
425
  const videoSegment = getVideoSegment(track);
392
426
  if (!videoSegment) {
393
427
  return null;
394
428
  }
395
429
 
396
- const height = videoSegment.children.find((b) => b.type === 'height-segment');
430
+ const height = videoSegment.value.find((b) => b.type === 'PixelHeight');
397
431
 
398
- if (!height || height.type !== 'height-segment') {
432
+ if (!height || height.type !== 'PixelHeight') {
399
433
  return null;
400
434
  }
401
435
 
@@ -403,18 +437,18 @@ export const getHeightSegment = (
403
437
  };
404
438
 
405
439
  export const getDisplayWidthSegment = (
406
- track: TrackEntrySegment,
440
+ track: TrackEntry,
407
441
  ): DisplayWidthSegment | null => {
408
442
  const videoSegment = getVideoSegment(track);
409
443
  if (!videoSegment) {
410
444
  return null;
411
445
  }
412
446
 
413
- const displayWidth = videoSegment.children.find(
414
- (b) => b.type === 'display-width-segment',
447
+ const displayWidth = videoSegment.value.find(
448
+ (b) => b.type === 'DisplayWidth',
415
449
  );
416
450
 
417
- if (!displayWidth || displayWidth.type !== 'display-width-segment') {
451
+ if (!displayWidth || displayWidth.type !== 'DisplayWidth') {
418
452
  return null;
419
453
  }
420
454
 
@@ -422,18 +456,18 @@ export const getDisplayWidthSegment = (
422
456
  };
423
457
 
424
458
  export const getDisplayHeightSegment = (
425
- track: TrackEntrySegment,
459
+ track: TrackEntry,
426
460
  ): DisplayHeightSegment | null => {
427
461
  const videoSegment = getVideoSegment(track);
428
462
  if (!videoSegment) {
429
463
  return null;
430
464
  }
431
465
 
432
- const displayHeight = videoSegment.children.find(
433
- (b) => b.type === 'display-height-segment',
466
+ const displayHeight = videoSegment.value.find(
467
+ (b) => b.type === 'DisplayHeight',
434
468
  );
435
469
 
436
- if (!displayHeight || displayHeight.type !== 'display-height-segment') {
470
+ if (!displayHeight || displayHeight.type !== 'DisplayHeight') {
437
471
  return null;
438
472
  }
439
473
 
@@ -441,30 +475,28 @@ export const getDisplayHeightSegment = (
441
475
  };
442
476
 
443
477
  export const getTrackTypeSegment = (
444
- track: TrackEntrySegment,
478
+ track: TrackEntry,
445
479
  ): TrackTypeSegment | null => {
446
- const trackType = track.children.find((b) => b.type === 'track-type-segment');
447
- if (!trackType || trackType.type !== 'track-type-segment') {
480
+ const trackType = track.value.find((b) => b.type === 'TrackType');
481
+ if (!trackType || trackType.type !== 'TrackType') {
448
482
  return null;
449
483
  }
450
484
 
451
485
  return trackType;
452
486
  };
453
487
 
454
- export const getTrackId = (track: TrackEntrySegment): number => {
455
- const trackId = track.children.find((b) => b.type === 'track-number-segment');
456
- if (!trackId || trackId.type !== 'track-number-segment') {
488
+ export const getTrackId = (track: TrackEntry): number => {
489
+ const trackId = track.value.find((b) => b.type === 'TrackNumber');
490
+ if (!trackId || trackId.type !== 'TrackNumber') {
457
491
  throw new Error('Expected track number segment');
458
492
  }
459
493
 
460
- return trackId.trackNumber;
494
+ return trackId.value.value;
461
495
  };
462
496
 
463
- export const getCodecSegment = (
464
- track: TrackEntrySegment,
465
- ): CodecSegment | null => {
466
- const codec = track.children.find((b) => b.type === 'codec-segment');
467
- if (!codec || codec.type !== 'codec-segment') {
497
+ export const getCodecSegment = (track: TrackEntry): CodecIdSegment | null => {
498
+ const codec = track.value.find((b) => b.type === 'CodecID');
499
+ if (!codec || codec.type !== 'CodecID') {
468
500
  return null;
469
501
  }
470
502