@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.
- package/dist/av1-codec-string.d.ts +0 -5
- package/dist/av1-codec-string.js +1 -18
- package/dist/boxes/iso-base-media/ftype.d.ts +9 -0
- package/dist/boxes/iso-base-media/ftype.js +31 -0
- package/dist/boxes/iso-base-media/get-sample-positions-from-track.d.ts +4 -0
- package/dist/boxes/iso-base-media/get-sample-positions-from-track.js +48 -0
- package/dist/boxes/iso-base-media/mvhd.js +2 -2
- package/dist/boxes/iso-base-media/stsd/keys.js +1 -1
- package/dist/boxes/iso-base-media/tfdt.d.ts +12 -0
- package/dist/boxes/iso-base-media/tfdt.js +20 -0
- package/dist/boxes/iso-base-media/tfhd.d.ts +16 -0
- package/dist/boxes/iso-base-media/tfhd.js +41 -0
- package/dist/boxes/iso-base-media/trun.d.ts +21 -0
- package/dist/boxes/iso-base-media/trun.js +44 -0
- package/dist/boxes/webm/av1-codec-private.js +1 -1
- package/dist/boxes/webm/bitstream/av1.js +1 -10
- package/dist/boxes/webm/description.d.ts +2 -2
- package/dist/boxes/webm/description.js +2 -2
- package/dist/boxes/webm/ebml.d.ts +2 -2
- package/dist/boxes/webm/ebml.js +23 -1
- package/dist/boxes/webm/get-ready-tracks.d.ts +1 -1
- package/dist/boxes/webm/get-ready-tracks.js +3 -3
- package/dist/boxes/webm/get-sample-from-block.d.ts +17 -0
- package/dist/boxes/webm/get-sample-from-block.js +78 -0
- package/dist/boxes/webm/get-track.d.ts +2 -2
- package/dist/boxes/webm/get-track.js +26 -25
- package/dist/boxes/webm/make-header.d.ts +3 -8
- package/dist/boxes/webm/make-header.js +43 -20
- package/dist/boxes/webm/parse-ebml.d.ts +9 -4
- package/dist/boxes/webm/parse-ebml.js +122 -13
- package/dist/boxes/webm/segments/all-segments.d.ts +421 -107
- package/dist/boxes/webm/segments/all-segments.js +260 -33
- package/dist/boxes/webm/segments/track-entry.d.ts +3 -191
- package/dist/boxes/webm/segments/track-entry.js +2 -456
- package/dist/boxes/webm/segments.d.ts +3 -16
- package/dist/boxes/webm/segments.js +12 -196
- package/dist/boxes/webm/tracks.d.ts +8 -0
- package/dist/boxes/webm/tracks.js +21 -0
- package/dist/boxes/webm/traversal.d.ts +5 -6
- package/dist/boxes/webm/traversal.js +6 -6
- package/dist/buffer-iterator.d.ts +1 -1
- package/dist/buffer-iterator.js +3 -3
- package/dist/from-web.js +6 -15
- package/dist/get-audio-codec.d.ts +1 -1
- package/dist/get-audio-codec.js +13 -13
- package/dist/get-duration.js +12 -14
- package/dist/get-tracks.js +2 -2
- package/dist/get-video-codec.js +13 -13
- package/dist/get-video-metadata.d.ts +2 -0
- package/dist/get-video-metadata.js +44 -0
- package/dist/parse-media.js +4 -1
- package/dist/parser-context.d.ts +1 -0
- package/dist/parser-state.js +3 -2
- package/dist/read-and-increment-offset.d.ts +28 -0
- package/dist/read-and-increment-offset.js +177 -0
- package/dist/samples-from-moof.d.ts +6 -0
- package/dist/samples-from-moof.js +74 -0
- package/dist/traversal.d.ts +19 -17
- package/dist/traversal.js +38 -39
- package/dist/understand-vorbis.d.ts +1 -0
- package/dist/understand-vorbis.js +12 -0
- package/input.webm +0 -0
- package/package.json +2 -2
- package/src/boxes/iso-base-media/get-sample-positions-from-track.ts +69 -0
- package/src/boxes/iso-base-media/make-track.ts +4 -45
- package/src/boxes/iso-base-media/mdat/mdat.ts +33 -24
- package/src/boxes/iso-base-media/mdhd.ts +10 -7
- package/src/boxes/iso-base-media/mvhd.ts +17 -16
- package/src/boxes/iso-base-media/process-box.ts +42 -0
- package/src/boxes/iso-base-media/stsd/keys.ts +1 -1
- package/src/boxes/iso-base-media/tfdt.ts +37 -0
- package/src/boxes/iso-base-media/tfhd.ts +66 -0
- package/src/boxes/iso-base-media/tkhd.ts +11 -13
- package/src/boxes/iso-base-media/trun.ts +74 -0
- package/src/boxes/webm/av1-codec-private.ts +1 -1
- package/src/boxes/webm/description.ts +7 -4
- package/src/boxes/webm/ebml.ts +24 -4
- package/src/boxes/webm/get-ready-tracks.ts +4 -4
- package/src/boxes/webm/get-sample-from-block.ts +125 -0
- package/src/boxes/webm/get-track.ts +40 -33
- package/src/boxes/webm/make-header.ts +58 -51
- package/src/boxes/webm/parse-ebml.ts +170 -16
- package/src/boxes/webm/segments/all-segments.ts +379 -62
- package/src/boxes/webm/segments/track-entry.ts +3 -846
- package/src/boxes/webm/segments.ts +18 -410
- package/src/boxes/webm/traversal.ts +17 -17
- package/src/buffer-iterator.ts +8 -6
- package/src/get-audio-codec.ts +14 -16
- package/src/get-duration.ts +55 -21
- package/src/get-tracks.ts +6 -6
- package/src/get-video-codec.ts +13 -15
- package/src/has-all-info.ts +1 -1
- package/src/parse-media.ts +7 -2
- package/src/parse-result.ts +7 -1
- package/src/parser-context.ts +1 -0
- package/src/parser-state.ts +2 -2
- package/src/samples-from-moof.ts +101 -0
- package/src/test/create-matroska.test.ts +237 -23
- package/src/test/matroska.test.ts +283 -348
- package/src/test/mvhd.test.ts +1 -1
- package/src/test/parse-esds.test.ts +2 -2
- package/src/test/parse-stco.test.ts +2 -2
- package/src/test/parse-stsc.test.ts +2 -2
- package/src/test/parse-stsz.test.ts +2 -2
- package/src/test/parse-stts.test.ts +1 -1
- package/src/test/samples-from-moof.test.ts +2496 -0
- package/src/test/stream-local.test.ts +28 -30
- package/src/test/stream-samples.test.ts +153 -231
- package/src/test/stsd.test.ts +4 -2
- package/src/test/tkhd.test.ts +1 -1
- package/src/traversal.ts +118 -86
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/bitstream/av1.d.ts +0 -2
- package/dist/bitstream/av1.js +0 -12
- package/dist/boxes/iso-base-media/avcc-hvcc.d.ts +0 -20
- package/dist/boxes/iso-base-media/avcc-hvcc.js +0 -73
- package/dist/boxes/iso-base-media/avcc.d.ts +0 -18
- package/dist/boxes/iso-base-media/avcc.js +0 -27
- package/dist/boxes/iso-base-media/esds-descriptors.d.ts +0 -21
- package/dist/boxes/iso-base-media/esds-descriptors.js +0 -62
- package/dist/boxes/iso-base-media/esds.d.ts +0 -15
- package/dist/boxes/iso-base-media/esds.js +0 -27
- package/dist/from-input-type-file.d.ts +0 -2
- package/dist/from-input-type-file.js +0 -37
- package/dist/get-codec.d.ts +0 -4
- package/dist/get-codec.js +0 -22
- package/dist/web-file.d.ts +0 -2
- package/dist/web-file.js +0 -37
- package/src/boxes/webm/segments/duration.ts +0 -29
- package/src/boxes/webm/segments/info.ts +0 -34
- package/src/boxes/webm/segments/main.ts +0 -6
- package/src/boxes/webm/segments/muxing.ts +0 -18
- package/src/boxes/webm/segments/seek-head.ts +0 -34
- package/src/boxes/webm/segments/seek-position.ts +0 -18
- package/src/boxes/webm/segments/seek.ts +0 -55
- package/src/boxes/webm/segments/timestamp-scale.ts +0 -17
- package/src/boxes/webm/segments/tracks.ts +0 -32
- package/src/boxes/webm/segments/void.ts +0 -18
- package/src/boxes/webm/segments/writing.ts +0 -18
- package/src/combine-uint8array.ts +0 -13
- /package/dist/{get-samples.d.ts → boxes/webm/bitstream/av1/frame.d.ts} +0 -0
- /package/dist/{get-samples.js → boxes/webm/bitstream/av1/frame.js} +0 -0
- /package/dist/{sample-aspect-ratio.d.ts → boxes/webm/bitstream/h264/get-h264-descriptor.d.ts} +0 -0
- /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 {
|
|
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
|
-
|
|
20
|
+
CodecIdSegment,
|
|
20
21
|
DisplayHeightSegment,
|
|
21
22
|
DisplayWidthSegment,
|
|
22
23
|
HeightSegment,
|
|
23
|
-
|
|
24
|
+
MainSegment,
|
|
25
|
+
TimestampScaleSegment,
|
|
26
|
+
TrackEntry,
|
|
24
27
|
TrackTypeSegment,
|
|
25
28
|
VideoSegment,
|
|
26
29
|
WidthSegment,
|
|
27
|
-
} from './boxes/webm/segments/
|
|
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.
|
|
246
|
-
|
|
247
|
-
|
|
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.
|
|
254
|
-
|
|
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.
|
|
319
|
+
const infoSegment = segment.value.find((b) => b.type === 'Info');
|
|
267
320
|
|
|
268
|
-
if (!infoSegment || infoSegment.type !== '
|
|
321
|
+
if (!infoSegment || infoSegment.type !== 'Info') {
|
|
269
322
|
return null;
|
|
270
323
|
}
|
|
271
324
|
|
|
272
|
-
const timescale = infoSegment.
|
|
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 !== '
|
|
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
|
|
285
|
-
|
|
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
|
|
296
|
-
|
|
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:
|
|
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.
|
|
312
|
-
(b) => b.type === '
|
|
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.
|
|
366
|
+
return samplingFrequency.value.value;
|
|
323
367
|
};
|
|
324
368
|
|
|
325
|
-
export const getNumberOfChannels = (track:
|
|
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.
|
|
332
|
-
(b) => b.type === 'channels-segment',
|
|
333
|
-
);
|
|
375
|
+
const channels = audioSegment.value.find((b) => b.type === 'Channels');
|
|
334
376
|
|
|
335
|
-
if (!channels || channels.type !== '
|
|
377
|
+
if (!channels || channels.type !== 'Channels') {
|
|
336
378
|
return 1;
|
|
337
379
|
}
|
|
338
380
|
|
|
339
|
-
return channels.
|
|
381
|
+
return channels.value.value;
|
|
340
382
|
};
|
|
341
383
|
|
|
342
|
-
export const getBitDepth = (track:
|
|
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.
|
|
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 !== '
|
|
392
|
+
if (!bitDepth || bitDepth.type !== 'BitDepth') {
|
|
353
393
|
return null;
|
|
354
394
|
}
|
|
355
395
|
|
|
356
|
-
return bitDepth.
|
|
396
|
+
return bitDepth.value.value;
|
|
357
397
|
};
|
|
358
398
|
|
|
359
|
-
export const getPrivateData = (track:
|
|
360
|
-
const privateData = track.
|
|
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 !== '
|
|
402
|
+
if (!privateData || privateData.type !== 'CodecPrivate') {
|
|
365
403
|
return null;
|
|
366
404
|
}
|
|
367
405
|
|
|
368
|
-
return privateData.
|
|
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.
|
|
415
|
+
const width = videoSegment.value.find((b) => b.type === 'PixelWidth');
|
|
380
416
|
|
|
381
|
-
if (!width || width.type !== '
|
|
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.
|
|
430
|
+
const height = videoSegment.value.find((b) => b.type === 'PixelHeight');
|
|
397
431
|
|
|
398
|
-
if (!height || height.type !== '
|
|
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:
|
|
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.
|
|
414
|
-
(b) => b.type === '
|
|
447
|
+
const displayWidth = videoSegment.value.find(
|
|
448
|
+
(b) => b.type === 'DisplayWidth',
|
|
415
449
|
);
|
|
416
450
|
|
|
417
|
-
if (!displayWidth || displayWidth.type !== '
|
|
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:
|
|
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.
|
|
433
|
-
(b) => b.type === '
|
|
466
|
+
const displayHeight = videoSegment.value.find(
|
|
467
|
+
(b) => b.type === 'DisplayHeight',
|
|
434
468
|
);
|
|
435
469
|
|
|
436
|
-
if (!displayHeight || displayHeight.type !== '
|
|
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:
|
|
478
|
+
track: TrackEntry,
|
|
445
479
|
): TrackTypeSegment | null => {
|
|
446
|
-
const trackType = track.
|
|
447
|
-
if (!trackType || trackType.type !== '
|
|
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:
|
|
455
|
-
const trackId = track.
|
|
456
|
-
if (!trackId || trackId.type !== '
|
|
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.
|
|
494
|
+
return trackId.value.value;
|
|
461
495
|
};
|
|
462
496
|
|
|
463
|
-
export const getCodecSegment = (
|
|
464
|
-
track
|
|
465
|
-
|
|
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
|
|