@remotion/media-parser 4.0.233 → 4.0.235
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/aac-codecprivate.d.ts +19 -0
- package/dist/aac-codecprivate.js +122 -0
- package/dist/add-avc-profile-to-track.d.ts +1 -1
- package/dist/boxes/iso-base-media/get-actual-number-of-channels.d.ts +13 -0
- package/dist/boxes/iso-base-media/get-actual-number-of-channels.js +22 -0
- package/dist/boxes/iso-base-media/make-track.js +16 -7
- package/dist/boxes/iso-base-media/meta/hdlr.d.ts +12 -0
- package/dist/boxes/iso-base-media/meta/hdlr.js +33 -0
- package/dist/boxes/iso-base-media/meta/ilst.d.ts +28 -0
- package/dist/boxes/iso-base-media/meta/ilst.js +86 -0
- package/dist/boxes/iso-base-media/meta/keys.d.ts +10 -0
- package/dist/boxes/iso-base-media/meta/keys.js +17 -0
- package/dist/boxes/iso-base-media/meta/list.d.ts +12 -0
- package/dist/boxes/iso-base-media/meta/list.js +33 -0
- package/dist/boxes/iso-base-media/moov/moov.d.ts +3 -1
- package/dist/boxes/iso-base-media/moov/moov.js +2 -1
- package/dist/boxes/iso-base-media/process-box.d.ts +5 -2
- package/dist/boxes/iso-base-media/process-box.js +66 -8
- package/dist/boxes/iso-base-media/stsd/keys.d.ts +15 -1
- package/dist/boxes/iso-base-media/stsd/keys.js +25 -12
- package/dist/boxes/iso-base-media/stsd/mebx.d.ts +3 -1
- package/dist/boxes/iso-base-media/stsd/mebx.js +2 -1
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +5 -2
- package/dist/boxes/iso-base-media/stsd/samples.js +7 -2
- package/dist/boxes/iso-base-media/stsd/stsd.d.ts +3 -1
- package/dist/boxes/iso-base-media/stsd/stsd.js +2 -1
- package/dist/boxes/iso-base-media/trak/trak.d.ts +3 -1
- package/dist/boxes/iso-base-media/trak/trak.js +2 -1
- package/dist/boxes/riff/expect-riff-box.d.ts +1 -0
- package/dist/boxes/riff/expect-riff-box.js +1 -1
- package/dist/boxes/riff/get-tracks-from-avi.d.ts +2 -1
- package/dist/boxes/riff/get-tracks-from-avi.js +14 -8
- package/dist/boxes/riff/parse-box.d.ts +3 -1
- package/dist/boxes/riff/parse-box.js +38 -5
- package/dist/boxes/riff/parse-isft.d.ts +6 -0
- package/dist/boxes/riff/parse-isft.js +17 -0
- package/dist/boxes/riff/parse-movi.js +31 -20
- package/dist/boxes/riff/parse-riff-box.js +4 -0
- package/dist/boxes/riff/riff-box.d.ts +5 -1
- package/dist/boxes/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/parse-ebml.js +2 -1
- package/dist/boxes/webm/parse-webm-header.d.ts +6 -1
- package/dist/boxes/webm/parse-webm-header.js +3 -1
- package/dist/boxes/webm/segments/all-segments.d.ts +42 -2
- package/dist/boxes/webm/segments/all-segments.js +28 -3
- package/dist/boxes/webm/segments/parse-children.d.ts +8 -3
- package/dist/boxes/webm/segments/parse-children.js +39 -4
- package/dist/boxes/webm/segments.d.ts +5 -2
- package/dist/boxes/webm/segments.js +23 -3
- package/dist/boxes/webm/traversal.d.ts +1 -0
- package/dist/boxes/webm/traversal.js +18 -2
- package/dist/buffer-iterator.d.ts +3 -0
- package/dist/buffer-iterator.js +23 -0
- package/dist/create/iso-base-media/codec-specific/mp4a.js +1 -17
- package/dist/create/iso-base-media/mp4-header.js +2 -1
- package/dist/emit-available-info.d.ts +1 -1
- package/dist/emit-available-info.js +17 -6
- package/dist/esm/index.mjs +992 -162
- package/dist/get-audio-codec.d.ts +1 -1
- package/dist/get-dimensions.d.ts +1 -1
- package/dist/get-duration.d.ts +1 -1
- package/dist/get-is-hdr.d.ts +1 -1
- package/dist/get-metadata.d.ts +7 -0
- package/dist/get-metadata.js +63 -0
- package/dist/get-tracks.d.ts +1 -1
- package/dist/get-tracks.js +1 -1
- package/dist/get-video-codec.d.ts +1 -1
- package/dist/has-all-info.d.ts +8 -3
- package/dist/has-all-info.js +21 -12
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/metadata/get-metadata.d.ts +7 -0
- package/dist/metadata/get-metadata.js +16 -0
- package/dist/metadata/metadata-from-iso.d.ts +4 -0
- package/dist/metadata/metadata-from-iso.js +148 -0
- package/dist/metadata/metadata-from-matroska.d.ts +3 -0
- package/dist/metadata/metadata-from-matroska.js +53 -0
- package/dist/metadata/metadata-from-riff.d.ts +3 -0
- package/dist/metadata/metadata-from-riff.js +24 -0
- package/dist/options.d.ts +9 -3
- package/dist/parse-media.js +32 -29
- package/dist/parse-result.d.ts +3 -1
- package/dist/parse-video.d.ts +3 -1
- package/dist/parse-video.js +5 -3
- package/dist/parser-context.d.ts +1 -2
- package/dist/register-track.d.ts +1 -1
- package/dist/state/can-skip-tracks.d.ts +9 -0
- package/dist/state/can-skip-tracks.js +33 -0
- package/dist/state/has-tracks-section.d.ts +6 -0
- package/dist/state/has-tracks-section.js +21 -0
- package/dist/state/parser-state.d.ts +51 -0
- package/dist/state/parser-state.js +170 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseIsoBaseMediaBoxes = exports.processBox = exports.parseMdatPartially = void 0;
|
|
4
4
|
const get_tracks_1 = require("../../get-tracks");
|
|
5
|
+
const has_all_info_1 = require("../../has-all-info");
|
|
5
6
|
const register_track_1 = require("../../register-track");
|
|
6
7
|
const esds_1 = require("./esds/esds");
|
|
7
8
|
const ftyp_1 = require("./ftyp");
|
|
8
9
|
const make_track_1 = require("./make-track");
|
|
9
10
|
const mdat_1 = require("./mdat/mdat");
|
|
10
11
|
const mdhd_1 = require("./mdhd");
|
|
12
|
+
const hdlr_1 = require("./meta/hdlr");
|
|
13
|
+
const ilst_1 = require("./meta/ilst");
|
|
11
14
|
const moov_1 = require("./moov/moov");
|
|
12
15
|
const mvhd_1 = require("./mvhd");
|
|
13
16
|
const av1c_1 = require("./stsd/av1c");
|
|
@@ -15,6 +18,7 @@ const avcc_1 = require("./stsd/avcc");
|
|
|
15
18
|
const colr_1 = require("./stsd/colr");
|
|
16
19
|
const ctts_1 = require("./stsd/ctts");
|
|
17
20
|
const hvcc_1 = require("./stsd/hvcc");
|
|
21
|
+
const keys_1 = require("./stsd/keys");
|
|
18
22
|
const mebx_1 = require("./stsd/mebx");
|
|
19
23
|
const pasp_1 = require("./stsd/pasp");
|
|
20
24
|
const stco_1 = require("./stsd/stco");
|
|
@@ -29,12 +33,14 @@ const tkhd_1 = require("./tkhd");
|
|
|
29
33
|
const trak_1 = require("./trak/trak");
|
|
30
34
|
const traversal_1 = require("./traversal");
|
|
31
35
|
const trun_1 = require("./trun");
|
|
32
|
-
const getChildren = async ({ boxType, iterator, bytesRemainingInBox, options, signal, logLevel, }) => {
|
|
36
|
+
const getChildren = async ({ boxType, iterator, bytesRemainingInBox, options, signal, logLevel, fields, }) => {
|
|
33
37
|
const parseChildren = boxType === 'mdia' ||
|
|
34
38
|
boxType === 'minf' ||
|
|
35
39
|
boxType === 'stbl' ||
|
|
40
|
+
boxType === 'udta' ||
|
|
36
41
|
boxType === 'moof' ||
|
|
37
42
|
boxType === 'dims' ||
|
|
43
|
+
boxType === 'meta' ||
|
|
38
44
|
boxType === 'wave' ||
|
|
39
45
|
boxType === 'traf' ||
|
|
40
46
|
boxType === 'stsb';
|
|
@@ -49,6 +55,7 @@ const getChildren = async ({ boxType, iterator, bytesRemainingInBox, options, si
|
|
|
49
55
|
continueMdat: false,
|
|
50
56
|
signal,
|
|
51
57
|
logLevel,
|
|
58
|
+
fields,
|
|
52
59
|
});
|
|
53
60
|
if (parsed.status === 'incomplete') {
|
|
54
61
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -87,7 +94,7 @@ const parseMdatPartially = async ({ iterator, boxSize, fileOffset, parsedBoxes,
|
|
|
87
94
|
};
|
|
88
95
|
};
|
|
89
96
|
exports.parseMdatPartially = parseMdatPartially;
|
|
90
|
-
const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options, signal, logLevel, }) => {
|
|
97
|
+
const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options, signal, logLevel, fields, }) => {
|
|
91
98
|
const fileOffset = iterator.counter.getOffset();
|
|
92
99
|
const bytesRemaining = iterator.bytesRemaining();
|
|
93
100
|
const boxSizeRaw = iterator.getFourByteNumber();
|
|
@@ -117,9 +124,10 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options
|
|
|
117
124
|
const boxSize = boxSizeRaw === 1 ? iterator.getEightByteNumber() : boxSizeRaw;
|
|
118
125
|
if (bytesRemaining < boxSize) {
|
|
119
126
|
if (boxType === 'mdat') {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
options.
|
|
127
|
+
// Check if the moov atom is at the end
|
|
128
|
+
const shouldSkip = options.parserState.maySkipVideoData() ||
|
|
129
|
+
(!(0, get_tracks_1.hasTracks)({ type: 'iso-base-media', boxes: parsedBoxes }, options.parserState) &&
|
|
130
|
+
options.supportsContentRange);
|
|
123
131
|
if (shouldSkip) {
|
|
124
132
|
const skipTo = fileOffset + boxSize;
|
|
125
133
|
const bytesToSkip = skipTo - iterator.counter.getOffset();
|
|
@@ -221,6 +229,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options
|
|
|
221
229
|
size: boxSize,
|
|
222
230
|
options,
|
|
223
231
|
signal,
|
|
232
|
+
fields,
|
|
224
233
|
});
|
|
225
234
|
return {
|
|
226
235
|
type: 'complete',
|
|
@@ -315,6 +324,38 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options
|
|
|
315
324
|
size: boxSize,
|
|
316
325
|
options,
|
|
317
326
|
signal,
|
|
327
|
+
fields,
|
|
328
|
+
});
|
|
329
|
+
return {
|
|
330
|
+
type: 'complete',
|
|
331
|
+
box,
|
|
332
|
+
size: boxSize,
|
|
333
|
+
skipTo: null,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
if (boxType === 'hdlr') {
|
|
337
|
+
const box = await (0, hdlr_1.parseHdlr)({ iterator, size: boxSize, offset: fileOffset });
|
|
338
|
+
return {
|
|
339
|
+
type: 'complete',
|
|
340
|
+
box,
|
|
341
|
+
size: boxSize,
|
|
342
|
+
skipTo: null,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
if (boxType === 'keys') {
|
|
346
|
+
const box = (0, keys_1.parseKeys)({ iterator, size: boxSize, offset: fileOffset });
|
|
347
|
+
return {
|
|
348
|
+
type: 'complete',
|
|
349
|
+
box,
|
|
350
|
+
size: boxSize,
|
|
351
|
+
skipTo: null,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
if (boxType === 'ilst') {
|
|
355
|
+
const box = (0, ilst_1.parseIlstBox)({
|
|
356
|
+
iterator,
|
|
357
|
+
offset: fileOffset,
|
|
358
|
+
size: boxSize,
|
|
318
359
|
});
|
|
319
360
|
return {
|
|
320
361
|
type: 'complete',
|
|
@@ -331,7 +372,9 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options
|
|
|
331
372
|
options,
|
|
332
373
|
signal,
|
|
333
374
|
logLevel,
|
|
375
|
+
fields,
|
|
334
376
|
});
|
|
377
|
+
options.parserState.tracks.setIsDone();
|
|
335
378
|
return {
|
|
336
379
|
type: 'complete',
|
|
337
380
|
box,
|
|
@@ -347,6 +390,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options
|
|
|
347
390
|
options,
|
|
348
391
|
signal,
|
|
349
392
|
logLevel,
|
|
393
|
+
fields,
|
|
350
394
|
});
|
|
351
395
|
const transformedTrack = (0, make_track_1.makeBaseMediaTrack)(box);
|
|
352
396
|
if (transformedTrack) {
|
|
@@ -480,6 +524,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options
|
|
|
480
524
|
options,
|
|
481
525
|
signal,
|
|
482
526
|
logLevel,
|
|
527
|
+
fields,
|
|
483
528
|
});
|
|
484
529
|
return {
|
|
485
530
|
type: 'complete',
|
|
@@ -495,7 +540,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, options
|
|
|
495
540
|
};
|
|
496
541
|
};
|
|
497
542
|
exports.processBox = processBox;
|
|
498
|
-
const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes, initialBoxes, options, continueMdat, signal, logLevel, }) => {
|
|
543
|
+
const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes, initialBoxes, options, continueMdat, signal, logLevel, fields, }) => {
|
|
499
544
|
const structure = {
|
|
500
545
|
type: 'iso-base-media',
|
|
501
546
|
boxes: initialBoxes,
|
|
@@ -520,6 +565,7 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
520
565
|
options,
|
|
521
566
|
signal,
|
|
522
567
|
logLevel,
|
|
568
|
+
fields,
|
|
523
569
|
});
|
|
524
570
|
if (result.type === 'incomplete') {
|
|
525
571
|
if (Number.isFinite(maxBytes)) {
|
|
@@ -538,6 +584,7 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
538
584
|
continueMdat: false,
|
|
539
585
|
signal,
|
|
540
586
|
logLevel,
|
|
587
|
+
fields,
|
|
541
588
|
});
|
|
542
589
|
},
|
|
543
590
|
skipTo: null,
|
|
@@ -557,6 +604,7 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
557
604
|
continueMdat: result,
|
|
558
605
|
signal,
|
|
559
606
|
logLevel,
|
|
607
|
+
fields,
|
|
560
608
|
}));
|
|
561
609
|
},
|
|
562
610
|
skipTo: null,
|
|
@@ -573,6 +621,12 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
573
621
|
}
|
|
574
622
|
else {
|
|
575
623
|
structure.boxes.push(result.box);
|
|
624
|
+
if ((0, has_all_info_1.hasAllInfo)({ fields, state: options.parserState, structure })) {
|
|
625
|
+
return {
|
|
626
|
+
status: 'done',
|
|
627
|
+
segments: structure,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
576
630
|
}
|
|
577
631
|
if (result.skipTo !== null) {
|
|
578
632
|
if (!options.supportsContentRange) {
|
|
@@ -591,6 +645,7 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
591
645
|
continueMdat: false,
|
|
592
646
|
signal,
|
|
593
647
|
logLevel,
|
|
648
|
+
fields,
|
|
594
649
|
});
|
|
595
650
|
},
|
|
596
651
|
skipTo: result.skipTo,
|
|
@@ -610,6 +665,7 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
610
665
|
continueMdat: false,
|
|
611
666
|
signal,
|
|
612
667
|
logLevel,
|
|
668
|
+
fields,
|
|
613
669
|
});
|
|
614
670
|
},
|
|
615
671
|
skipTo: null,
|
|
@@ -619,9 +675,10 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
619
675
|
}
|
|
620
676
|
const mdatState = (0, traversal_1.getMdatBox)(structure.boxes);
|
|
621
677
|
const skipped = (mdatState === null || mdatState === void 0 ? void 0 : mdatState.status) === 'samples-skipped' &&
|
|
622
|
-
!options.
|
|
678
|
+
!options.parserState.maySkipVideoData() &&
|
|
623
679
|
options.supportsContentRange;
|
|
624
|
-
const buffered = (mdatState === null || mdatState === void 0 ? void 0 : mdatState.status) === 'samples-buffered' &&
|
|
680
|
+
const buffered = (mdatState === null || mdatState === void 0 ? void 0 : mdatState.status) === 'samples-buffered' &&
|
|
681
|
+
!options.parserState.maySkipVideoData();
|
|
625
682
|
if (skipped || buffered) {
|
|
626
683
|
return {
|
|
627
684
|
status: 'incomplete',
|
|
@@ -639,6 +696,7 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
639
696
|
continueMdat: false,
|
|
640
697
|
signal,
|
|
641
698
|
logLevel,
|
|
699
|
+
fields,
|
|
642
700
|
});
|
|
643
701
|
},
|
|
644
702
|
skipTo: skipped ? mdatState.fileOffset : null,
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
1
2
|
import type { BaseBox } from '../base-type';
|
|
3
|
+
type KeysEntry = {
|
|
4
|
+
keySize: number;
|
|
5
|
+
namespace: string;
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
2
8
|
export interface KeysBox extends BaseBox {
|
|
3
9
|
type: 'keys-box';
|
|
10
|
+
version: number;
|
|
11
|
+
entryCount: number;
|
|
12
|
+
entries: KeysEntry[];
|
|
4
13
|
}
|
|
5
|
-
export declare const parseKeys: (
|
|
14
|
+
export declare const parseKeys: ({ iterator, offset, size, }: {
|
|
15
|
+
iterator: BufferIterator;
|
|
16
|
+
offset: number;
|
|
17
|
+
size: number;
|
|
18
|
+
}) => KeysBox;
|
|
19
|
+
export {};
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseKeys = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const parseKeys = ({ iterator, offset, size, }) => {
|
|
5
|
+
const box = iterator.startBox(size - 8);
|
|
6
|
+
const version = iterator.getUint8();
|
|
7
|
+
// flags
|
|
8
|
+
iterator.discard(3);
|
|
9
|
+
// entry_count
|
|
10
|
+
const entryCount = iterator.getUint32();
|
|
11
|
+
const entries = [];
|
|
12
|
+
for (let i = 0; i < entryCount; i++) {
|
|
13
|
+
// key_size
|
|
14
|
+
const keySize = iterator.getUint32();
|
|
15
|
+
const namespace = iterator.getAtom();
|
|
16
|
+
const value = iterator.getByteString(keySize - 8);
|
|
17
|
+
// data
|
|
18
|
+
const entry = {
|
|
19
|
+
keySize,
|
|
20
|
+
namespace,
|
|
21
|
+
value,
|
|
22
|
+
};
|
|
23
|
+
entries.push(entry);
|
|
10
24
|
}
|
|
11
|
-
|
|
12
|
-
if (atom !== 'keys') {
|
|
13
|
-
throw new Error(`Expected keys type of keys, got ${atom}`);
|
|
14
|
-
}
|
|
15
|
-
iterator.destroy();
|
|
25
|
+
box.discardRest();
|
|
16
26
|
return {
|
|
17
27
|
type: 'keys-box',
|
|
18
|
-
boxSize:
|
|
28
|
+
boxSize: size,
|
|
19
29
|
offset,
|
|
30
|
+
version,
|
|
31
|
+
entryCount,
|
|
32
|
+
entries,
|
|
20
33
|
};
|
|
21
34
|
};
|
|
22
35
|
exports.parseKeys = parseKeys;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { Options, ParseMediaFields } from '../../../options';
|
|
2
3
|
import type { AnySegment } from '../../../parse-result';
|
|
3
4
|
import type { ParserContext } from '../../../parser-context';
|
|
4
5
|
import type { BaseBox } from '../base-type';
|
|
@@ -8,10 +9,11 @@ export interface MebxBox extends BaseBox {
|
|
|
8
9
|
format: string;
|
|
9
10
|
children: AnySegment[];
|
|
10
11
|
}
|
|
11
|
-
export declare const parseMebx: ({ iterator, offset, size, options, signal, }: {
|
|
12
|
+
export declare const parseMebx: ({ iterator, offset, size, options, signal, fields, }: {
|
|
12
13
|
iterator: BufferIterator;
|
|
13
14
|
offset: number;
|
|
14
15
|
size: number;
|
|
15
16
|
options: ParserContext;
|
|
16
17
|
signal: AbortSignal | null;
|
|
18
|
+
fields: Options<ParseMediaFields>;
|
|
17
19
|
}) => Promise<MebxBox>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMebx = void 0;
|
|
4
4
|
const process_box_1 = require("../process-box");
|
|
5
|
-
const parseMebx = async ({ iterator, offset, size, options, signal, }) => {
|
|
5
|
+
const parseMebx = async ({ iterator, offset, size, options, signal, fields, }) => {
|
|
6
6
|
// reserved, 6 bit
|
|
7
7
|
iterator.discard(6);
|
|
8
8
|
const dataReferenceIndex = iterator.getUint16();
|
|
@@ -15,6 +15,7 @@ const parseMebx = async ({ iterator, offset, size, options, signal, }) => {
|
|
|
15
15
|
continueMdat: false,
|
|
16
16
|
signal,
|
|
17
17
|
logLevel: 'info',
|
|
18
|
+
fields,
|
|
18
19
|
});
|
|
19
20
|
if (children.status === 'incomplete') {
|
|
20
21
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
2
|
import type { LogLevel } from '../../../log';
|
|
3
|
+
import type { Options, ParseMediaFields } from '../../../options';
|
|
3
4
|
import type { AnySegment, IsoBaseMediaBox } from '../../../parse-result';
|
|
4
5
|
import type { ParserContext } from '../../../parser-context';
|
|
5
6
|
type SampleBase = {
|
|
@@ -49,17 +50,19 @@ export type Sample = AudioSample | VideoSample | UnknownSample;
|
|
|
49
50
|
type SampleAndNext = {
|
|
50
51
|
sample: Sample | null;
|
|
51
52
|
};
|
|
52
|
-
export declare const processSample: ({ iterator, options, signal, logLevel, }: {
|
|
53
|
+
export declare const processSample: ({ iterator, options, signal, logLevel, fields, }: {
|
|
53
54
|
iterator: BufferIterator;
|
|
54
55
|
options: ParserContext;
|
|
55
56
|
signal: AbortSignal | null;
|
|
56
57
|
logLevel: LogLevel;
|
|
58
|
+
fields: Options<ParseMediaFields>;
|
|
57
59
|
}) => Promise<SampleAndNext>;
|
|
58
|
-
export declare const parseSamples: ({ iterator, maxBytes, options, signal, logLevel, }: {
|
|
60
|
+
export declare const parseSamples: ({ iterator, maxBytes, options, signal, logLevel, fields, }: {
|
|
59
61
|
iterator: BufferIterator;
|
|
60
62
|
maxBytes: number;
|
|
61
63
|
options: ParserContext;
|
|
62
64
|
signal: AbortSignal | null;
|
|
63
65
|
logLevel: LogLevel;
|
|
66
|
+
fields: Options<ParseMediaFields>;
|
|
64
67
|
}) => Promise<Sample[]>;
|
|
65
68
|
export {};
|
|
@@ -62,7 +62,7 @@ const audioTags = [
|
|
|
62
62
|
'mp4a',
|
|
63
63
|
'ac-3',
|
|
64
64
|
];
|
|
65
|
-
const processSample = async ({ iterator, options, signal, logLevel, }) => {
|
|
65
|
+
const processSample = async ({ iterator, options, signal, logLevel, fields, }) => {
|
|
66
66
|
const fileOffset = iterator.counter.getOffset();
|
|
67
67
|
const bytesRemaining = iterator.bytesRemaining();
|
|
68
68
|
const boxSize = iterator.getUint32();
|
|
@@ -108,6 +108,7 @@ const processSample = async ({ iterator, options, signal, logLevel, }) => {
|
|
|
108
108
|
continueMdat: false,
|
|
109
109
|
signal,
|
|
110
110
|
logLevel,
|
|
111
|
+
fields,
|
|
111
112
|
});
|
|
112
113
|
if (children.status === 'incomplete') {
|
|
113
114
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -155,6 +156,7 @@ const processSample = async ({ iterator, options, signal, logLevel, }) => {
|
|
|
155
156
|
continueMdat: false,
|
|
156
157
|
signal,
|
|
157
158
|
logLevel,
|
|
159
|
+
fields,
|
|
158
160
|
});
|
|
159
161
|
if (children.status === 'incomplete') {
|
|
160
162
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -206,6 +208,7 @@ const processSample = async ({ iterator, options, signal, logLevel, }) => {
|
|
|
206
208
|
continueMdat: false,
|
|
207
209
|
signal,
|
|
208
210
|
logLevel,
|
|
211
|
+
fields,
|
|
209
212
|
});
|
|
210
213
|
if (children.status === 'incomplete') {
|
|
211
214
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -261,6 +264,7 @@ const processSample = async ({ iterator, options, signal, logLevel, }) => {
|
|
|
261
264
|
continueMdat: false,
|
|
262
265
|
signal,
|
|
263
266
|
logLevel,
|
|
267
|
+
fields,
|
|
264
268
|
})
|
|
265
269
|
: (iterator.discard(bytesRemainingInBox),
|
|
266
270
|
{ status: 'done', segments: { boxes: [], type: 'iso-base-media' } });
|
|
@@ -295,7 +299,7 @@ const processSample = async ({ iterator, options, signal, logLevel, }) => {
|
|
|
295
299
|
throw new Error(`Unknown sample format ${boxFormat}`);
|
|
296
300
|
};
|
|
297
301
|
exports.processSample = processSample;
|
|
298
|
-
const parseSamples = async ({ iterator, maxBytes, options, signal, logLevel, }) => {
|
|
302
|
+
const parseSamples = async ({ iterator, maxBytes, options, signal, logLevel, fields, }) => {
|
|
299
303
|
const samples = [];
|
|
300
304
|
const initialOffset = iterator.counter.getOffset();
|
|
301
305
|
while (iterator.bytesRemaining() > 0 &&
|
|
@@ -305,6 +309,7 @@ const parseSamples = async ({ iterator, maxBytes, options, signal, logLevel, })
|
|
|
305
309
|
options,
|
|
306
310
|
signal,
|
|
307
311
|
logLevel,
|
|
312
|
+
fields,
|
|
308
313
|
});
|
|
309
314
|
if (sample) {
|
|
310
315
|
samples.push(sample);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { Options, ParseMediaFields } from '../../../options';
|
|
2
3
|
import type { ParserContext } from '../../../parser-context';
|
|
3
4
|
import type { BaseBox } from '../base-type';
|
|
4
5
|
import type { Sample } from './samples';
|
|
@@ -7,10 +8,11 @@ export interface StsdBox extends BaseBox {
|
|
|
7
8
|
numberOfEntries: number;
|
|
8
9
|
samples: Sample[];
|
|
9
10
|
}
|
|
10
|
-
export declare const parseStsd: ({ iterator, offset, size, options, signal, }: {
|
|
11
|
+
export declare const parseStsd: ({ iterator, offset, size, options, signal, fields, }: {
|
|
11
12
|
iterator: BufferIterator;
|
|
12
13
|
offset: number;
|
|
13
14
|
size: number;
|
|
14
15
|
options: ParserContext;
|
|
15
16
|
signal: AbortSignal | null;
|
|
17
|
+
fields: Options<ParseMediaFields>;
|
|
16
18
|
}) => Promise<StsdBox>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseStsd = void 0;
|
|
4
4
|
const samples_1 = require("./samples");
|
|
5
|
-
const parseStsd = async ({ iterator, offset, size, options, signal, }) => {
|
|
5
|
+
const parseStsd = async ({ iterator, offset, size, options, signal, fields, }) => {
|
|
6
6
|
const version = iterator.getUint8();
|
|
7
7
|
if (version !== 0) {
|
|
8
8
|
throw new Error(`Unsupported STSD version ${version}`);
|
|
@@ -17,6 +17,7 @@ const parseStsd = async ({ iterator, offset, size, options, signal, }) => {
|
|
|
17
17
|
options,
|
|
18
18
|
signal,
|
|
19
19
|
logLevel: 'info',
|
|
20
|
+
fields,
|
|
20
21
|
});
|
|
21
22
|
if (boxes.length !== numberOfEntries) {
|
|
22
23
|
throw new Error(`Expected ${numberOfEntries} sample descriptions, got ${boxes.length}`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
2
|
import type { LogLevel } from '../../../log';
|
|
3
|
+
import type { Options, ParseMediaFields } from '../../../options';
|
|
3
4
|
import type { AnySegment } from '../../../parse-result';
|
|
4
5
|
import type { ParserContext } from '../../../parser-context';
|
|
5
6
|
import type { BaseBox } from '../base-type';
|
|
@@ -7,11 +8,12 @@ export interface TrakBox extends BaseBox {
|
|
|
7
8
|
type: 'trak-box';
|
|
8
9
|
children: AnySegment[];
|
|
9
10
|
}
|
|
10
|
-
export declare const parseTrak: ({ data, size, offsetAtStart, options, signal, logLevel, }: {
|
|
11
|
+
export declare const parseTrak: ({ data, size, offsetAtStart, options, signal, logLevel, fields, }: {
|
|
11
12
|
data: BufferIterator;
|
|
12
13
|
size: number;
|
|
13
14
|
offsetAtStart: number;
|
|
14
15
|
options: ParserContext;
|
|
15
16
|
signal: AbortSignal | null;
|
|
16
17
|
logLevel: LogLevel;
|
|
18
|
+
fields: Options<ParseMediaFields>;
|
|
17
19
|
}) => Promise<TrakBox>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseTrak = void 0;
|
|
4
4
|
const process_box_1 = require("../process-box");
|
|
5
|
-
const parseTrak = async ({ data, size, offsetAtStart, options, signal, logLevel, }) => {
|
|
5
|
+
const parseTrak = async ({ data, size, offsetAtStart, options, signal, logLevel, fields, }) => {
|
|
6
6
|
const children = await (0, process_box_1.parseIsoBaseMediaBoxes)({
|
|
7
7
|
iterator: data,
|
|
8
8
|
maxBytes: size - (data.counter.getOffset() - offsetAtStart),
|
|
@@ -12,6 +12,7 @@ const parseTrak = async ({ data, size, offsetAtStart, options, signal, logLevel,
|
|
|
12
12
|
continueMdat: false,
|
|
13
13
|
signal,
|
|
14
14
|
logLevel,
|
|
15
|
+
fields,
|
|
15
16
|
});
|
|
16
17
|
if (children.status === 'incomplete') {
|
|
17
18
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -25,7 +25,6 @@ const expectRiffBox = async ({ iterator, options, structure, }) => {
|
|
|
25
25
|
structure,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
// TODO: Add capability to read partially
|
|
29
28
|
if (iterator.bytesRemaining() < ckSize) {
|
|
30
29
|
iterator.counter.decrement(8);
|
|
31
30
|
return {
|
|
@@ -44,6 +43,7 @@ const expectRiffBox = async ({ iterator, options, structure, }) => {
|
|
|
44
43
|
boxes: structure.boxes,
|
|
45
44
|
options,
|
|
46
45
|
}),
|
|
46
|
+
skipTo: null,
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
exports.expectRiffBox = expectRiffBox;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { AudioTrack, OtherTrack, VideoTrack } from '../../get-tracks';
|
|
2
2
|
import type { RiffStructure } from '../../parse-result';
|
|
3
|
-
import type { ParserState } from '../../parser-state';
|
|
3
|
+
import type { ParserState } from '../../state/parser-state';
|
|
4
4
|
import type { StrfBoxAudio, StrfBoxVideo, StrhBox } from './riff-box';
|
|
5
5
|
export type AllTracks = {
|
|
6
6
|
videoTracks: VideoTrack[];
|
|
7
7
|
audioTracks: AudioTrack[];
|
|
8
8
|
otherTracks: OtherTrack[];
|
|
9
9
|
};
|
|
10
|
+
export declare const TO_BE_OVERRIDDEN_LATER = "to-be-overriden-later";
|
|
10
11
|
export declare const getNumberOfTracks: (structure: RiffStructure) => number;
|
|
11
12
|
export declare const makeAviAudioTrack: ({ strf, index, }: {
|
|
12
13
|
strf: StrfBoxAudio;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasAllTracksFromAvi = exports.getTracksFromAvi = exports.makeAviVideoTrack = exports.makeAviAudioTrack = exports.getNumberOfTracks = void 0;
|
|
3
|
+
exports.hasAllTracksFromAvi = exports.getTracksFromAvi = exports.makeAviVideoTrack = exports.makeAviAudioTrack = exports.getNumberOfTracks = exports.TO_BE_OVERRIDDEN_LATER = void 0;
|
|
4
4
|
const add_avc_profile_to_track_1 = require("../../add-avc-profile-to-track");
|
|
5
5
|
const timescale_1 = require("./timescale");
|
|
6
6
|
const traversal_1 = require("./traversal");
|
|
7
|
+
exports.TO_BE_OVERRIDDEN_LATER = 'to-be-overriden-later';
|
|
7
8
|
const getNumberOfTracks = (structure) => {
|
|
8
9
|
const avihBox = (0, traversal_1.getAvihBox)(structure);
|
|
9
10
|
if (avihBox) {
|
|
@@ -37,7 +38,7 @@ const makeAviVideoTrack = ({ strh, strf, index, }) => {
|
|
|
37
38
|
}
|
|
38
39
|
return {
|
|
39
40
|
codecPrivate: null,
|
|
40
|
-
codec:
|
|
41
|
+
codec: exports.TO_BE_OVERRIDDEN_LATER,
|
|
41
42
|
codecWithoutConfig: 'h264',
|
|
42
43
|
codedHeight: strf.height,
|
|
43
44
|
codedWidth: strf.width,
|
|
@@ -98,11 +99,16 @@ const hasAllTracksFromAvi = (structure, state) => {
|
|
|
98
99
|
if (!(0, traversal_1.isRiffAvi)(structure)) {
|
|
99
100
|
throw new Error('Not an AVI file');
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
tracks.
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
try {
|
|
103
|
+
const numberOfTracks = (0, exports.getNumberOfTracks)(structure);
|
|
104
|
+
const tracks = (0, exports.getTracksFromAvi)(structure, state);
|
|
105
|
+
return (tracks.videoTracks.length +
|
|
106
|
+
tracks.audioTracks.length +
|
|
107
|
+
tracks.otherTracks.length ===
|
|
108
|
+
numberOfTracks);
|
|
109
|
+
}
|
|
110
|
+
catch (_a) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
107
113
|
};
|
|
108
114
|
exports.hasAllTracksFromAvi = hasAllTracksFromAvi;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
+
import type { Options, ParseMediaFields } from '../../options';
|
|
2
3
|
import type { ParseResult, RiffStructure } from '../../parse-result';
|
|
3
4
|
import type { ParserContext } from '../../parser-context';
|
|
4
5
|
export declare const parseRiffBody: ({ iterator, structure, maxOffset, options, }: {
|
|
@@ -7,7 +8,8 @@ export declare const parseRiffBody: ({ iterator, structure, maxOffset, options,
|
|
|
7
8
|
maxOffset: number;
|
|
8
9
|
options: ParserContext;
|
|
9
10
|
}) => Promise<ParseResult<RiffStructure>>;
|
|
10
|
-
export declare const parseRiff: ({ iterator, options, }: {
|
|
11
|
+
export declare const parseRiff: ({ iterator, options, fields, }: {
|
|
11
12
|
iterator: BufferIterator;
|
|
12
13
|
options: ParserContext;
|
|
14
|
+
fields: Options<ParseMediaFields>;
|
|
13
15
|
}) => Promise<ParseResult<RiffStructure>>;
|