@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {Prettify} from '../parse-ebml';
|
|
2
|
+
|
|
1
3
|
export const matroskaElements = {
|
|
2
4
|
Header: '0x1a45dfa3',
|
|
3
5
|
EBMLMaxIDLength: '0x42f2',
|
|
@@ -290,7 +292,7 @@ export const getSegmentName = (id: string) => {
|
|
|
290
292
|
)?.[0];
|
|
291
293
|
};
|
|
292
294
|
|
|
293
|
-
export const getIdForName = (name: string) => {
|
|
295
|
+
export const getIdForName = (name: string): EbmlMapKey => {
|
|
294
296
|
const value = Object.entries(matroskaElements).find(
|
|
295
297
|
([key]) => key === name,
|
|
296
298
|
)?.[1];
|
|
@@ -298,7 +300,7 @@ export const getIdForName = (name: string) => {
|
|
|
298
300
|
throw new Error(`Could not find id for name ${name}`);
|
|
299
301
|
}
|
|
300
302
|
|
|
301
|
-
return value;
|
|
303
|
+
return value as EbmlMapKey;
|
|
302
304
|
};
|
|
303
305
|
|
|
304
306
|
export type MatroskaKey = keyof typeof matroskaElements;
|
|
@@ -310,10 +312,9 @@ type EbmlType = 'string';
|
|
|
310
312
|
export type EbmlWithChildren = {
|
|
311
313
|
name: MatroskaKey;
|
|
312
314
|
type: 'children';
|
|
313
|
-
children: HeaderStructure;
|
|
314
315
|
};
|
|
315
316
|
|
|
316
|
-
export type
|
|
317
|
+
export type EbmlWithUint = {
|
|
317
318
|
name: MatroskaKey;
|
|
318
319
|
type: 'uint';
|
|
319
320
|
};
|
|
@@ -328,23 +329,23 @@ export type EbmlWithString = {
|
|
|
328
329
|
type: EbmlType;
|
|
329
330
|
};
|
|
330
331
|
|
|
331
|
-
export type
|
|
332
|
+
export type EbmlWithFloat = {
|
|
332
333
|
name: MatroskaKey;
|
|
333
|
-
type: '
|
|
334
|
+
type: 'float';
|
|
334
335
|
};
|
|
335
336
|
|
|
336
|
-
export type
|
|
337
|
+
export type EbmlWithUint8Array = {
|
|
337
338
|
name: MatroskaKey;
|
|
338
|
-
type: '
|
|
339
|
+
type: 'uint8array';
|
|
339
340
|
};
|
|
340
341
|
|
|
341
342
|
export type Ebml =
|
|
342
343
|
| EbmlWithString
|
|
343
|
-
|
|
|
344
|
+
| EbmlWithUint
|
|
344
345
|
| EbmlWithChildren
|
|
345
|
-
| EbmlWithVoid
|
|
346
346
|
| EbmlWithFloat
|
|
347
|
-
| EbmlWithHexString
|
|
347
|
+
| EbmlWithHexString
|
|
348
|
+
| EbmlWithUint8Array;
|
|
348
349
|
|
|
349
350
|
export const ebmlVersion = {
|
|
350
351
|
name: 'EBMLVersion',
|
|
@@ -381,36 +382,24 @@ export const docTypeReadVersion = {
|
|
|
381
382
|
type: 'uint',
|
|
382
383
|
} satisfies Ebml;
|
|
383
384
|
|
|
384
|
-
|
|
385
|
+
const voidEbml = {
|
|
385
386
|
name: 'Void',
|
|
386
|
-
type: '
|
|
387
|
+
type: 'uint8array',
|
|
387
388
|
} satisfies Ebml;
|
|
388
389
|
|
|
389
390
|
export type EmblTypes = {
|
|
390
391
|
uint: number;
|
|
391
392
|
float: number;
|
|
392
393
|
string: string;
|
|
393
|
-
children:
|
|
394
|
+
children: Ebml[];
|
|
394
395
|
void: undefined;
|
|
395
396
|
'hex-string': string;
|
|
397
|
+
uint8array: Uint8Array;
|
|
396
398
|
};
|
|
397
399
|
|
|
398
|
-
export type HeaderStructure = Ebml[];
|
|
399
|
-
|
|
400
|
-
export const matroskaHeaderStructure = [
|
|
401
|
-
ebmlVersion,
|
|
402
|
-
ebmlReadVersion,
|
|
403
|
-
ebmlMaxIdLength,
|
|
404
|
-
ebmlMaxSizeLength,
|
|
405
|
-
docType,
|
|
406
|
-
docTypeVersion,
|
|
407
|
-
docTypeReadVersion,
|
|
408
|
-
] as const satisfies HeaderStructure;
|
|
409
|
-
|
|
410
400
|
export const matroskaHeader = {
|
|
411
401
|
name: 'Header',
|
|
412
402
|
type: 'children',
|
|
413
|
-
children: matroskaHeaderStructure,
|
|
414
403
|
} as const satisfies Ebml;
|
|
415
404
|
|
|
416
405
|
export const seekId = {
|
|
@@ -426,28 +415,285 @@ export const seekPosition = {
|
|
|
426
415
|
export const seek = {
|
|
427
416
|
name: 'Seek',
|
|
428
417
|
type: 'children',
|
|
429
|
-
|
|
418
|
+
} as const satisfies Ebml;
|
|
419
|
+
|
|
420
|
+
export const seekHead = {
|
|
421
|
+
name: 'SeekHead',
|
|
422
|
+
type: 'children',
|
|
430
423
|
} as const satisfies Ebml;
|
|
431
424
|
|
|
432
425
|
export const voidHeader = {
|
|
433
426
|
name: 'Void',
|
|
434
|
-
type: '
|
|
427
|
+
type: 'uint8array',
|
|
428
|
+
} as const satisfies Ebml;
|
|
429
|
+
|
|
430
|
+
export const codecID = {
|
|
431
|
+
name: 'CodecID',
|
|
432
|
+
type: 'string',
|
|
433
|
+
} as const satisfies Ebml;
|
|
434
|
+
|
|
435
|
+
export const trackType = {
|
|
436
|
+
name: 'TrackType',
|
|
437
|
+
type: 'uint',
|
|
438
|
+
} as const satisfies Ebml;
|
|
439
|
+
|
|
440
|
+
export const widthType = {
|
|
441
|
+
name: 'PixelWidth',
|
|
442
|
+
type: 'uint',
|
|
443
|
+
} as const satisfies Ebml;
|
|
444
|
+
|
|
445
|
+
export const heightType = {
|
|
446
|
+
name: 'PixelHeight',
|
|
447
|
+
type: 'uint',
|
|
448
|
+
} as const satisfies Ebml;
|
|
449
|
+
|
|
450
|
+
export const muxingApp = {
|
|
451
|
+
name: 'MuxingApp',
|
|
452
|
+
type: 'string',
|
|
453
|
+
} as const satisfies Ebml;
|
|
454
|
+
|
|
455
|
+
export const duration = {
|
|
456
|
+
name: 'Duration',
|
|
457
|
+
type: 'float',
|
|
458
|
+
} as const satisfies Ebml;
|
|
459
|
+
|
|
460
|
+
export const timestampScale = {
|
|
461
|
+
name: 'TimestampScale',
|
|
462
|
+
type: 'uint',
|
|
463
|
+
} as const satisfies Ebml;
|
|
464
|
+
|
|
465
|
+
export const writingApp = {
|
|
466
|
+
name: 'WritingApp',
|
|
467
|
+
type: 'string',
|
|
468
|
+
} as const satisfies Ebml;
|
|
469
|
+
|
|
470
|
+
export const infoType = {
|
|
471
|
+
name: 'Info',
|
|
472
|
+
type: 'children',
|
|
473
|
+
} as const satisfies Ebml;
|
|
474
|
+
|
|
475
|
+
export const titleType = {
|
|
476
|
+
name: 'Title',
|
|
477
|
+
type: 'string',
|
|
478
|
+
} as const satisfies Ebml;
|
|
479
|
+
|
|
480
|
+
export const samplingFrequency = {
|
|
481
|
+
name: 'SamplingFrequency',
|
|
482
|
+
type: 'float',
|
|
483
|
+
} as const satisfies Ebml;
|
|
484
|
+
|
|
485
|
+
export const channels = {
|
|
486
|
+
name: 'Channels',
|
|
487
|
+
type: 'uint',
|
|
488
|
+
} as const satisfies Ebml;
|
|
489
|
+
|
|
490
|
+
export const alphaMode = {
|
|
491
|
+
name: 'AlphaMode',
|
|
492
|
+
type: 'uint',
|
|
493
|
+
} as const satisfies Ebml;
|
|
494
|
+
|
|
495
|
+
export const interlaced = {
|
|
496
|
+
name: 'FlagInterlaced',
|
|
497
|
+
type: 'uint',
|
|
498
|
+
} as const satisfies Ebml;
|
|
499
|
+
|
|
500
|
+
export const bitDepth = {
|
|
501
|
+
name: 'BitDepth',
|
|
502
|
+
type: 'uint',
|
|
503
|
+
} as const satisfies Ebml;
|
|
504
|
+
|
|
505
|
+
export const displayWidth = {
|
|
506
|
+
name: 'DisplayWidth',
|
|
507
|
+
type: 'uint',
|
|
508
|
+
} as const satisfies Ebml;
|
|
509
|
+
|
|
510
|
+
export const displayHeight = {
|
|
511
|
+
name: 'DisplayHeight',
|
|
512
|
+
type: 'uint',
|
|
513
|
+
} as const satisfies Ebml;
|
|
514
|
+
|
|
515
|
+
export const flagLacing = {
|
|
516
|
+
name: 'FlagLacing',
|
|
517
|
+
type: 'uint',
|
|
518
|
+
} as const satisfies Ebml;
|
|
519
|
+
|
|
520
|
+
export const tagSegment = {
|
|
521
|
+
name: 'Tag',
|
|
522
|
+
type: 'uint8array',
|
|
523
|
+
} as const satisfies Ebml;
|
|
524
|
+
|
|
525
|
+
export const tags = {
|
|
526
|
+
name: 'Tags',
|
|
527
|
+
type: 'children',
|
|
528
|
+
} as const satisfies Ebml;
|
|
529
|
+
|
|
530
|
+
export const trackNumber = {
|
|
531
|
+
name: 'TrackNumber',
|
|
532
|
+
type: 'uint',
|
|
435
533
|
} as const satisfies Ebml;
|
|
436
534
|
|
|
437
|
-
export
|
|
438
|
-
|
|
439
|
-
:
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
535
|
+
export const trackUID = {
|
|
536
|
+
name: 'TrackUID',
|
|
537
|
+
type: 'hex-string',
|
|
538
|
+
} as const satisfies Ebml;
|
|
539
|
+
|
|
540
|
+
export const color = {
|
|
541
|
+
name: 'Colour',
|
|
542
|
+
type: 'uint8array',
|
|
543
|
+
} as const satisfies Ebml;
|
|
544
|
+
|
|
545
|
+
export const language = {
|
|
546
|
+
name: 'Language',
|
|
547
|
+
type: 'string',
|
|
548
|
+
} as const satisfies Ebml;
|
|
549
|
+
|
|
550
|
+
export const defaultDuration = {
|
|
551
|
+
name: 'DefaultDuration',
|
|
552
|
+
type: 'uint',
|
|
553
|
+
} as const satisfies Ebml;
|
|
554
|
+
|
|
555
|
+
export const codecPrivate = {
|
|
556
|
+
name: 'CodecPrivate',
|
|
557
|
+
type: 'uint8array',
|
|
558
|
+
} as const satisfies Ebml;
|
|
559
|
+
|
|
560
|
+
export const blockAdditionsSegment = {
|
|
561
|
+
name: 'BlockAdditions',
|
|
562
|
+
type: 'uint8array',
|
|
563
|
+
} as const satisfies Ebml;
|
|
564
|
+
|
|
565
|
+
export const maxBlockAdditionIdSegment = {
|
|
566
|
+
name: 'MaxBlockAdditionID',
|
|
567
|
+
type: 'uint',
|
|
568
|
+
} as const satisfies Ebml;
|
|
569
|
+
|
|
570
|
+
export const audioSegment = {
|
|
571
|
+
name: 'Audio',
|
|
572
|
+
type: 'children',
|
|
573
|
+
} as const satisfies Ebml;
|
|
574
|
+
|
|
575
|
+
export const videoSegment = {
|
|
576
|
+
name: 'Video',
|
|
577
|
+
type: 'children',
|
|
578
|
+
} as const satisfies Ebml;
|
|
579
|
+
|
|
580
|
+
export const flagDefault = {
|
|
581
|
+
name: 'FlagDefault',
|
|
582
|
+
type: 'uint8array',
|
|
583
|
+
} as const satisfies Ebml;
|
|
584
|
+
|
|
585
|
+
export const referenceBlock = {
|
|
586
|
+
name: 'ReferenceBlock',
|
|
587
|
+
type: 'uint',
|
|
588
|
+
} as const satisfies Ebml;
|
|
589
|
+
|
|
590
|
+
export const blockElement = {
|
|
591
|
+
name: 'Block',
|
|
592
|
+
type: 'uint8array',
|
|
593
|
+
} as const satisfies Ebml;
|
|
594
|
+
|
|
595
|
+
export const codecName = {
|
|
596
|
+
name: 'CodecName',
|
|
597
|
+
type: 'string',
|
|
598
|
+
} as const satisfies Ebml;
|
|
599
|
+
|
|
600
|
+
export const trackTimestampScale = {
|
|
601
|
+
name: 'TrackTimestampScale',
|
|
602
|
+
type: 'float',
|
|
603
|
+
} as const satisfies Ebml;
|
|
604
|
+
|
|
605
|
+
export const trackEntry = {
|
|
606
|
+
name: 'TrackEntry',
|
|
607
|
+
type: 'children',
|
|
608
|
+
} as const satisfies Ebml;
|
|
609
|
+
|
|
610
|
+
export const tracks = {
|
|
611
|
+
name: 'Tracks',
|
|
612
|
+
type: 'children',
|
|
613
|
+
} as const satisfies Ebml;
|
|
614
|
+
|
|
615
|
+
export const timestampEntry = {
|
|
616
|
+
name: 'Timestamp',
|
|
617
|
+
type: 'uint',
|
|
618
|
+
} as const satisfies Ebml;
|
|
619
|
+
|
|
620
|
+
export const block = {
|
|
621
|
+
name: 'Block',
|
|
622
|
+
type: 'uint8array',
|
|
623
|
+
} as const satisfies Ebml;
|
|
624
|
+
|
|
625
|
+
export const simpleBlock = {
|
|
626
|
+
name: 'SimpleBlock',
|
|
627
|
+
type: 'uint8array',
|
|
628
|
+
} as const satisfies Ebml;
|
|
629
|
+
|
|
630
|
+
export const blockGroup = {
|
|
631
|
+
name: 'BlockGroup',
|
|
632
|
+
type: 'children',
|
|
633
|
+
} as const satisfies Ebml;
|
|
634
|
+
|
|
635
|
+
export const segment = {
|
|
636
|
+
name: 'Segment',
|
|
637
|
+
type: 'children',
|
|
638
|
+
} as const satisfies Ebml;
|
|
639
|
+
|
|
640
|
+
export const cluster = {
|
|
641
|
+
name: 'Cluster',
|
|
642
|
+
type: 'children',
|
|
643
|
+
} as const satisfies Ebml;
|
|
644
|
+
|
|
645
|
+
export type CodecIdSegment = EbmlParsed<typeof codecID>;
|
|
646
|
+
export type TrackTypeSegment = EbmlParsed<typeof trackType>;
|
|
647
|
+
export type WidthSegment = EbmlParsed<typeof widthType>;
|
|
648
|
+
export type HeightSegment = EbmlParsed<typeof heightType>;
|
|
649
|
+
export type TimestampScaleSegment = EbmlParsed<typeof timestampScale>;
|
|
650
|
+
export type DurationSegment = EbmlParsed<typeof duration>;
|
|
651
|
+
export type DisplayWidthSegment = EbmlParsed<typeof displayWidth>;
|
|
652
|
+
export type DisplayHeightSegment = EbmlParsed<typeof displayHeight>;
|
|
653
|
+
export type TrackNumberSegment = EbmlParsed<typeof trackNumber>;
|
|
654
|
+
export type AudioSegment = EbmlParsed<typeof audioSegment>;
|
|
655
|
+
export type VideoSegment = EbmlParsed<typeof videoSegment>;
|
|
656
|
+
export type TrackEntry = EbmlParsed<typeof trackEntry>;
|
|
657
|
+
export type BlockSegment = EbmlParsed<typeof block>;
|
|
658
|
+
export type SimpleBlockSegment = EbmlParsed<typeof simpleBlock>;
|
|
659
|
+
export type MainSegment = EbmlParsed<typeof segment>;
|
|
660
|
+
export type ClusterSegment = EbmlParsed<typeof cluster>;
|
|
661
|
+
export type Tracks = EbmlParsed<typeof tracks>;
|
|
662
|
+
|
|
663
|
+
export type FloatWithSize = {value: number; size: '32' | '64'};
|
|
664
|
+
export type UintWithSize = {value: number; byteLength: number};
|
|
665
|
+
|
|
666
|
+
export type EbmlValue<
|
|
667
|
+
T extends Ebml,
|
|
668
|
+
Child = PossibleEbml,
|
|
669
|
+
> = T extends EbmlWithUint
|
|
670
|
+
? UintWithSize
|
|
671
|
+
: T extends EbmlWithString
|
|
672
|
+
? string
|
|
673
|
+
: T extends EbmlWithFloat
|
|
674
|
+
? FloatWithSize
|
|
675
|
+
: T extends EbmlWithHexString
|
|
676
|
+
? string
|
|
677
|
+
: T extends EbmlWithUint8Array
|
|
678
|
+
? Uint8Array
|
|
679
|
+
: T extends EbmlWithChildren
|
|
680
|
+
? Child[]
|
|
681
|
+
: never;
|
|
682
|
+
|
|
683
|
+
export type EbmlValueOrUint8Array<T extends Ebml> =
|
|
684
|
+
| Uint8Array
|
|
685
|
+
| EbmlValue<T, PossibleEbmlOrUint8Array>;
|
|
446
686
|
|
|
447
687
|
export type EbmlParsed<T extends Ebml> = {
|
|
448
688
|
type: T['name'];
|
|
449
689
|
value: EbmlValue<T>;
|
|
450
|
-
|
|
690
|
+
minVintWidth: number;
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
export type EbmlParsedOrUint8Array<T extends Ebml> = {
|
|
694
|
+
type: T['name'];
|
|
695
|
+
value: EbmlValueOrUint8Array<T>;
|
|
696
|
+
minVintWidth: number;
|
|
451
697
|
};
|
|
452
698
|
|
|
453
699
|
export const ebmlMap = {
|
|
@@ -462,50 +708,121 @@ export const ebmlMap = {
|
|
|
462
708
|
[matroskaElements.Void]: voidEbml,
|
|
463
709
|
[matroskaElements.Cues]: {
|
|
464
710
|
name: 'Cues',
|
|
465
|
-
type: '
|
|
711
|
+
type: 'uint8array',
|
|
466
712
|
},
|
|
467
713
|
[matroskaElements.DateUTC]: {
|
|
468
714
|
name: 'DateUTC',
|
|
469
|
-
type: '
|
|
470
|
-
},
|
|
471
|
-
[matroskaElements.TrackTimestampScale]: {
|
|
472
|
-
name: 'TrackTimestampScale',
|
|
473
|
-
type: 'float',
|
|
715
|
+
type: 'uint8array',
|
|
474
716
|
},
|
|
717
|
+
[matroskaElements.TrackTimestampScale]: trackTimestampScale,
|
|
475
718
|
[matroskaElements.CodecDelay]: {
|
|
476
719
|
name: 'CodecDelay',
|
|
477
|
-
type: '
|
|
720
|
+
type: 'uint8array',
|
|
478
721
|
},
|
|
479
722
|
[matroskaElements.SeekPreRoll]: {
|
|
480
723
|
name: 'SeekPreRoll',
|
|
481
|
-
type: '
|
|
724
|
+
type: 'uint8array',
|
|
482
725
|
},
|
|
483
726
|
[matroskaElements.DiscardPadding]: {
|
|
484
727
|
name: 'DiscardPadding',
|
|
485
|
-
type: '
|
|
728
|
+
type: 'uint8array',
|
|
486
729
|
},
|
|
487
730
|
[matroskaElements.OutputSamplingFrequency]: {
|
|
488
731
|
name: 'OutputSamplingFrequency',
|
|
489
|
-
type: '
|
|
490
|
-
},
|
|
491
|
-
[matroskaElements.CodecName]: {
|
|
492
|
-
name: 'CodecName',
|
|
493
|
-
type: 'void',
|
|
732
|
+
type: 'uint8array',
|
|
494
733
|
},
|
|
734
|
+
[matroskaElements.CodecName]: codecName,
|
|
495
735
|
[matroskaElements.Position]: {
|
|
496
736
|
name: 'Position',
|
|
497
|
-
type: '
|
|
737
|
+
type: 'uint8array',
|
|
498
738
|
},
|
|
499
739
|
[matroskaElements.SliceDuration]: {
|
|
500
740
|
name: 'SliceDuration',
|
|
501
|
-
type: '
|
|
741
|
+
type: 'uint8array',
|
|
742
|
+
},
|
|
743
|
+
[matroskaElements.SeekHead]: seekHead,
|
|
744
|
+
[matroskaElements.Seek]: seek,
|
|
745
|
+
[matroskaElements.SeekID]: seekId,
|
|
746
|
+
[matroskaElements.SeekPosition]: seekPosition,
|
|
747
|
+
[matroskaElements.Crc32]: {
|
|
748
|
+
name: 'Crc32',
|
|
749
|
+
type: 'uint8array',
|
|
750
|
+
},
|
|
751
|
+
[matroskaElements.MuxingApp]: muxingApp,
|
|
752
|
+
[matroskaElements.WritingApp]: {
|
|
753
|
+
name: 'WritingApp',
|
|
754
|
+
type: 'string',
|
|
755
|
+
},
|
|
756
|
+
[matroskaElements.SegmentUUID]: {
|
|
757
|
+
name: 'SegmentUUID',
|
|
758
|
+
type: 'string',
|
|
759
|
+
},
|
|
760
|
+
[matroskaElements.Duration]: duration,
|
|
761
|
+
[matroskaElements.CodecID]: {
|
|
762
|
+
name: 'CodecID',
|
|
763
|
+
type: 'string',
|
|
764
|
+
},
|
|
765
|
+
[matroskaElements.TrackType]: trackType,
|
|
766
|
+
[matroskaElements.PixelWidth]: widthType,
|
|
767
|
+
[matroskaElements.PixelHeight]: heightType,
|
|
768
|
+
[matroskaElements.TimestampScale]: timestampScale,
|
|
769
|
+
[matroskaElements.Info]: infoType,
|
|
770
|
+
[matroskaElements.Title]: titleType,
|
|
771
|
+
[matroskaElements.SamplingFrequency]: samplingFrequency,
|
|
772
|
+
[matroskaElements.Channels]: channels,
|
|
773
|
+
[matroskaElements.AlphaMode]: alphaMode,
|
|
774
|
+
[matroskaElements.FlagInterlaced]: interlaced,
|
|
775
|
+
[matroskaElements.BitDepth]: bitDepth,
|
|
776
|
+
[matroskaElements.DisplayHeight]: displayHeight,
|
|
777
|
+
[matroskaElements.DisplayWidth]: displayWidth,
|
|
778
|
+
[matroskaElements.FlagLacing]: flagLacing,
|
|
779
|
+
[matroskaElements.Tags]: tags,
|
|
780
|
+
[matroskaElements.Tag]: tagSegment,
|
|
781
|
+
[matroskaElements.TrackNumber]: trackNumber,
|
|
782
|
+
[matroskaElements.TrackUID]: trackUID,
|
|
783
|
+
[matroskaElements.Colour]: color,
|
|
784
|
+
[matroskaElements.Language]: language,
|
|
785
|
+
[matroskaElements.DefaultDuration]: defaultDuration,
|
|
786
|
+
[matroskaElements.CodecPrivate]: codecPrivate,
|
|
787
|
+
[matroskaElements.BlockAdditions]: blockAdditionsSegment,
|
|
788
|
+
[matroskaElements.MaxBlockAdditionID]: maxBlockAdditionIdSegment,
|
|
789
|
+
[matroskaElements.Audio]: audioSegment,
|
|
790
|
+
[matroskaElements.Video]: videoSegment,
|
|
791
|
+
[matroskaElements.FlagDefault]: flagDefault,
|
|
792
|
+
[matroskaElements.ReferenceBlock]: referenceBlock,
|
|
793
|
+
[matroskaElements.TrackEntry]: trackEntry,
|
|
794
|
+
[matroskaElements.Timestamp]: {
|
|
795
|
+
name: 'Timestamp',
|
|
796
|
+
type: 'uint',
|
|
797
|
+
},
|
|
798
|
+
[matroskaElements.Tracks]: tracks,
|
|
799
|
+
[matroskaElements.Block]: block,
|
|
800
|
+
[matroskaElements.SimpleBlock]: simpleBlock,
|
|
801
|
+
[matroskaElements.BlockGroup]: blockGroup,
|
|
802
|
+
[matroskaElements.Segment]: {
|
|
803
|
+
name: 'Segment',
|
|
804
|
+
type: 'children',
|
|
805
|
+
},
|
|
806
|
+
[matroskaElements.Cluster]: {
|
|
807
|
+
name: 'Cluster',
|
|
808
|
+
type: 'children',
|
|
502
809
|
},
|
|
503
810
|
} as const satisfies Partial<Record<MatroskaElement, Ebml>>;
|
|
504
811
|
|
|
505
|
-
export type PossibleEbml =
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
812
|
+
export type PossibleEbml = Prettify<
|
|
813
|
+
{
|
|
814
|
+
[key in keyof typeof ebmlMap]: EbmlParsed<(typeof ebmlMap)[key]>;
|
|
815
|
+
}[keyof typeof ebmlMap]
|
|
816
|
+
>;
|
|
817
|
+
|
|
818
|
+
export type PossibleEbmlOrUint8Array =
|
|
819
|
+
| Prettify<
|
|
820
|
+
{
|
|
821
|
+
[key in keyof typeof ebmlMap]: EbmlParsedOrUint8Array<
|
|
822
|
+
(typeof ebmlMap)[key]
|
|
823
|
+
>;
|
|
824
|
+
}[keyof typeof ebmlMap]
|
|
825
|
+
>
|
|
826
|
+
| Uint8Array;
|
|
827
|
+
|
|
828
|
+
export type EbmlMapKey = keyof typeof ebmlMap;
|