@remotion/media-parser 4.0.248 → 4.0.250
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/boxes/avc/key.d.ts +1 -1
- package/dist/boxes/iso-base-media/continue-mdat-routine.d.ts +14 -0
- package/dist/boxes/iso-base-media/continue-mdat-routine.js +74 -0
- package/dist/boxes/iso-base-media/get-children.d.ts +8 -0
- package/dist/boxes/iso-base-media/get-children.js +23 -0
- package/dist/boxes/iso-base-media/mdat/mdat.d.ts +3 -22
- package/dist/boxes/iso-base-media/mdat/mdat.js +80 -121
- package/dist/boxes/iso-base-media/moov/moov.d.ts +1 -6
- package/dist/boxes/iso-base-media/moov/moov.js +5 -15
- package/dist/boxes/iso-base-media/parse-all-children.d.ts +8 -0
- package/dist/boxes/iso-base-media/parse-all-children.js +20 -0
- package/dist/boxes/iso-base-media/parse-boxes.d.ts +7 -0
- package/dist/boxes/iso-base-media/parse-boxes.js +46 -0
- package/dist/boxes/iso-base-media/parse-mdat-partially.d.ts +9 -0
- package/dist/boxes/iso-base-media/parse-mdat-partially.js +24 -0
- package/dist/boxes/iso-base-media/process-box.d.ts +2 -29
- package/dist/boxes/iso-base-media/process-box.js +56 -367
- package/dist/boxes/iso-base-media/stsd/mebx.d.ts +1 -4
- package/dist/boxes/iso-base-media/stsd/mebx.js +5 -15
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +4 -12
- package/dist/boxes/iso-base-media/stsd/samples.js +24 -70
- package/dist/boxes/iso-base-media/stsd/stsd.d.ts +1 -4
- package/dist/boxes/iso-base-media/stsd/stsd.js +2 -5
- package/dist/boxes/iso-base-media/trak/trak.d.ts +1 -6
- package/dist/boxes/iso-base-media/trak/trak.js +5 -15
- package/dist/boxes/iso-base-media/traversal.d.ts +0 -2
- package/dist/boxes/iso-base-media/traversal.js +1 -12
- package/dist/boxes/mp3/get-duration.d.ts +2 -0
- package/dist/boxes/mp3/get-duration.js +30 -0
- package/dist/boxes/mp3/get-frame-length.d.ts +13 -0
- package/dist/boxes/mp3/get-frame-length.js +33 -0
- package/dist/boxes/mp3/get-metadata-from-mp3.d.ts +3 -0
- package/dist/boxes/mp3/get-metadata-from-mp3.js +8 -0
- package/dist/boxes/mp3/get-tracks-from-mp3.d.ts +4 -0
- package/dist/boxes/mp3/get-tracks-from-mp3.js +25 -0
- package/dist/boxes/mp3/id3-v1.d.ts +2 -0
- package/dist/boxes/mp3/id3-v1.js +12 -0
- package/dist/boxes/mp3/id3-v2.d.ts +0 -0
- package/dist/boxes/mp3/id3-v2.js +1 -0
- package/dist/boxes/mp3/id3.d.ts +6 -0
- package/dist/boxes/mp3/id3.js +80 -0
- package/dist/boxes/mp3/parse-mp3.d.ts +7 -0
- package/dist/boxes/mp3/parse-mp3.js +41 -0
- package/dist/boxes/mp3/parse-mpeg-header.d.ts +6 -0
- package/dist/boxes/mp3/parse-mpeg-header.js +274 -0
- package/dist/boxes/mp3/samples-per-mpeg-file.d.ts +4 -0
- package/dist/boxes/mp3/samples-per-mpeg-file.js +26 -0
- package/dist/boxes/riff/continue-after-riff-result.d.ts +13 -0
- package/dist/boxes/riff/continue-after-riff-result.js +34 -0
- package/dist/boxes/riff/expect-riff-box.d.ts +1 -7
- package/dist/boxes/riff/expect-riff-box.js +47 -24
- package/dist/boxes/riff/get-tracks-from-avi.d.ts +1 -1
- package/dist/boxes/riff/get-tracks-from-avi.js +6 -10
- package/dist/boxes/riff/parse-box.d.ts +1 -7
- package/dist/boxes/riff/parse-box.js +4 -120
- package/dist/boxes/riff/parse-fmt-box.d.ts +3 -2
- package/dist/boxes/riff/parse-fmt-box.js +7 -5
- package/dist/boxes/riff/parse-list-box.js +15 -14
- package/dist/boxes/riff/parse-movi.d.ts +2 -5
- package/dist/boxes/riff/parse-movi.js +34 -56
- package/dist/boxes/riff/parse-riff-body.d.ts +7 -0
- package/dist/boxes/riff/parse-riff-body.js +25 -0
- package/dist/boxes/riff/parse-riff-box.d.ts +1 -2
- package/dist/boxes/riff/parse-riff-box.js +2 -6
- package/dist/boxes/riff/parse-riff-header.d.ts +7 -0
- package/dist/boxes/riff/parse-riff-header.js +23 -0
- package/dist/boxes/riff/parse-riff.d.ts +7 -0
- package/dist/boxes/riff/parse-riff.js +15 -0
- package/dist/boxes/riff/parse-strf.d.ts +4 -4
- package/dist/boxes/riff/parse-strf.js +4 -8
- package/dist/boxes/riff/parse-strh.js +11 -0
- package/dist/boxes/riff/parse-video-section.d.ts +6 -0
- package/dist/boxes/riff/parse-video-section.js +20 -0
- package/dist/boxes/riff/riff-box.d.ts +4 -5
- package/dist/boxes/riff/traversal.d.ts +1 -2
- package/dist/boxes/riff/traversal.js +1 -6
- package/dist/boxes/transport-stream/get-tracks.d.ts +2 -3
- package/dist/boxes/transport-stream/get-tracks.js +4 -3
- package/dist/boxes/transport-stream/parse-packet.d.ts +1 -7
- package/dist/boxes/transport-stream/parse-packet.js +3 -4
- package/dist/boxes/transport-stream/parse-stream-packet.d.ts +1 -5
- package/dist/boxes/transport-stream/parse-stream-packet.js +10 -12
- package/dist/boxes/transport-stream/parse-transport-stream.d.ts +1 -7
- package/dist/boxes/transport-stream/parse-transport-stream.js +19 -49
- package/dist/boxes/transport-stream/process-stream-buffers.d.ts +1 -2
- package/dist/boxes/transport-stream/process-stream-buffers.js +3 -3
- package/dist/boxes/webm/parse-ebml.js +3 -0
- package/dist/boxes/webm/parse-webm-header.d.ts +2 -4
- package/dist/boxes/webm/parse-webm-header.js +41 -25
- package/dist/boxes/webm/segments/parse-children.d.ts +2 -16
- package/dist/boxes/webm/segments/parse-children.js +7 -130
- package/dist/boxes/webm/segments.d.ts +4 -8
- package/dist/boxes/webm/segments.js +41 -123
- package/dist/buffer-iterator.d.ts +6 -3
- package/dist/buffer-iterator.js +27 -16
- package/dist/bun-reader.d.ts +1 -0
- package/dist/bun-reader.js +17 -0
- package/dist/continue-mdat-routine.d.ts +17 -0
- package/dist/continue-mdat-routine.js +92 -0
- package/dist/emit-available-info.js +42 -28
- package/dist/esm/from-node.mjs +8 -9
- package/dist/esm/index.mjs +5133 -5085
- package/dist/file-types/detect-file-type.js +6 -2
- package/dist/get-audio-codec.d.ts +1 -1
- package/dist/get-audio-codec.js +3 -3
- package/dist/get-container.js +5 -1
- package/dist/get-dimensions.d.ts +1 -1
- package/dist/get-dimensions.js +4 -1
- package/dist/get-duration.js +6 -2
- package/dist/get-fields-from-callbacks.js +1 -0
- package/dist/get-fps.js +3 -0
- package/dist/get-is-hdr.d.ts +1 -1
- package/dist/get-is-hdr.js +3 -3
- package/dist/get-keyframes.js +1 -1
- package/dist/get-tracks.d.ts +2 -2
- package/dist/get-tracks.js +23 -15
- package/dist/get-video-codec.d.ts +1 -1
- package/dist/get-video-codec.js +3 -3
- package/dist/has-all-info.js +4 -3
- package/dist/index.d.ts +65 -21
- package/dist/index.js +1 -1
- package/dist/may-skip-video-data/may-skip-video-data.js +6 -2
- package/dist/may-skip-video-data/need-samples-for-fields.js +1 -0
- package/dist/metadata/get-metadata.d.ts +1 -0
- package/dist/metadata/get-metadata.js +16 -1
- package/dist/options.d.ts +12 -5
- package/dist/parse-media.js +88 -68
- package/dist/parse-result.d.ts +17 -19
- package/dist/parse-video.d.ts +3 -17
- package/dist/parse-video.js +52 -40
- package/dist/readers/from-node.js +7 -8
- package/dist/state/can-skip-tracks.d.ts +8 -1
- package/dist/state/can-skip-tracks.js +38 -26
- package/dist/state/emitted-fields.js +1 -0
- package/dist/state/images.d.ts +9 -0
- package/dist/state/images.js +14 -0
- package/dist/state/iso-base-media/cached-sample-positions.d.ts +15 -0
- package/dist/state/iso-base-media/cached-sample-positions.js +42 -0
- package/dist/state/iso-base-media/iso-state.d.ts +8 -0
- package/dist/state/iso-base-media/iso-state.js +15 -0
- package/dist/state/iso-state.d.ts +4 -0
- package/dist/state/iso-state.js +13 -0
- package/dist/state/mp3.d.ts +11 -0
- package/dist/state/mp3.js +13 -0
- package/dist/state/parser-state.d.ts +57 -11
- package/dist/state/parser-state.js +17 -2
- package/dist/state/sample-callbacks.d.ts +5 -1
- package/dist/state/sample-callbacks.js +8 -2
- package/dist/state/slow-duration-fps.d.ts +2 -1
- package/dist/state/slow-duration-fps.js +52 -18
- package/dist/state/transport-stream.d.ts +8 -0
- package/dist/state/transport-stream.js +11 -0
- package/dist/state/video-section.d.ts +16 -0
- package/dist/state/video-section.js +37 -0
- package/dist/state/webm.d.ts +15 -0
- package/dist/state/webm.js +32 -0
- package/dist/throttled-progress.d.ts +14 -0
- package/dist/throttled-progress.js +44 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/test.json +663 -0
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const has_all_info_1 = require("../../has-all-info");
|
|
6
|
-
const may_skip_video_data_1 = require("../../may-skip-video-data/may-skip-video-data");
|
|
3
|
+
exports.processBox = void 0;
|
|
4
|
+
const log_1 = require("../../log");
|
|
7
5
|
const register_track_1 = require("../../register-track");
|
|
8
6
|
const esds_1 = require("./esds/esds");
|
|
9
7
|
const ftyp_1 = require("./ftyp");
|
|
8
|
+
const get_children_1 = require("./get-children");
|
|
10
9
|
const make_track_1 = require("./make-track");
|
|
11
|
-
const mdat_1 = require("./mdat/mdat");
|
|
12
10
|
const mdhd_1 = require("./mdhd");
|
|
13
11
|
const hdlr_1 = require("./meta/hdlr");
|
|
14
12
|
const ilst_1 = require("./meta/ilst");
|
|
@@ -32,147 +30,51 @@ const tfdt_1 = require("./tfdt");
|
|
|
32
30
|
const tfhd_1 = require("./tfhd");
|
|
33
31
|
const tkhd_1 = require("./tkhd");
|
|
34
32
|
const trak_1 = require("./trak/trak");
|
|
35
|
-
const traversal_1 = require("./traversal");
|
|
36
33
|
const trun_1 = require("./trun");
|
|
37
|
-
const
|
|
38
|
-
const parseChildren = boxType === 'mdia' ||
|
|
39
|
-
boxType === 'minf' ||
|
|
40
|
-
boxType === 'stbl' ||
|
|
41
|
-
boxType === 'udta' ||
|
|
42
|
-
boxType === 'moof' ||
|
|
43
|
-
boxType === 'dims' ||
|
|
44
|
-
boxType === 'meta' ||
|
|
45
|
-
boxType === 'wave' ||
|
|
46
|
-
boxType === 'traf' ||
|
|
47
|
-
boxType === 'stsb';
|
|
48
|
-
if (parseChildren) {
|
|
49
|
-
const boxes = [];
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
51
|
-
const parsed = await (0, exports.parseIsoBaseMediaBoxes)({
|
|
52
|
-
iterator,
|
|
53
|
-
maxBytes: bytesRemainingInBox,
|
|
54
|
-
allowIncompleteBoxes: false,
|
|
55
|
-
initialBoxes: boxes,
|
|
56
|
-
state,
|
|
57
|
-
continueMdat: false,
|
|
58
|
-
signal,
|
|
59
|
-
logLevel,
|
|
60
|
-
fields,
|
|
61
|
-
});
|
|
62
|
-
if (parsed.status === 'incomplete') {
|
|
63
|
-
throw new Error('Incomplete boxes are not allowed');
|
|
64
|
-
}
|
|
65
|
-
return boxes;
|
|
66
|
-
}
|
|
67
|
-
if (bytesRemainingInBox < 0) {
|
|
68
|
-
throw new Error('Box size is too big ' + JSON.stringify({ boxType }));
|
|
69
|
-
}
|
|
70
|
-
iterator.discard(bytesRemainingInBox);
|
|
71
|
-
return [];
|
|
72
|
-
};
|
|
73
|
-
const parseMdatPartially = async ({ iterator, boxSize, fileOffset, parsedBoxes, state, signal, }) => {
|
|
74
|
-
const box = await (0, mdat_1.parseMdat)({
|
|
75
|
-
data: iterator,
|
|
76
|
-
size: boxSize,
|
|
77
|
-
fileOffset,
|
|
78
|
-
existingBoxes: parsedBoxes,
|
|
79
|
-
state,
|
|
80
|
-
signal,
|
|
81
|
-
maySkipSampleProcessing: state.supportsContentRange,
|
|
82
|
-
});
|
|
83
|
-
if ((box.status === 'samples-processed' || box.status === 'samples-buffered') &&
|
|
84
|
-
box.fileOffset + boxSize === iterator.counter.getOffset()) {
|
|
85
|
-
return {
|
|
86
|
-
type: 'complete',
|
|
87
|
-
box,
|
|
88
|
-
size: boxSize,
|
|
89
|
-
skipTo: null,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
type: 'partial-mdat-box',
|
|
94
|
-
boxSize,
|
|
95
|
-
fileOffset,
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
exports.parseMdatPartially = parseMdatPartially;
|
|
99
|
-
const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state, signal, logLevel, fields, }) => {
|
|
34
|
+
const processBox = async ({ iterator, state, }) => {
|
|
100
35
|
const fileOffset = iterator.counter.getOffset();
|
|
36
|
+
const { returnToCheckpoint } = iterator.startCheckpoint();
|
|
101
37
|
const bytesRemaining = iterator.bytesRemaining();
|
|
102
38
|
const boxSizeRaw = iterator.getFourByteNumber();
|
|
103
|
-
// If `boxSize === 1`, the 8 bytes after the box type are the size of the box.
|
|
104
|
-
if ((boxSizeRaw === 1 && iterator.bytesRemaining() < 12) ||
|
|
105
|
-
iterator.bytesRemaining() < 4) {
|
|
106
|
-
iterator.counter.decrement(iterator.counter.getOffset() - fileOffset);
|
|
107
|
-
if (allowIncompleteBoxes) {
|
|
108
|
-
return {
|
|
109
|
-
type: 'incomplete',
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
throw new Error(`Expected box size of ${bytesRemaining}, got ${boxSizeRaw}. Incomplete boxes are not allowed.`);
|
|
113
|
-
}
|
|
114
39
|
if (boxSizeRaw === 0) {
|
|
115
40
|
return {
|
|
116
|
-
type: 'complete',
|
|
117
41
|
box: {
|
|
118
42
|
type: 'void-box',
|
|
119
43
|
boxSize: 0,
|
|
120
44
|
},
|
|
121
|
-
size: 4,
|
|
122
45
|
skipTo: null,
|
|
123
46
|
};
|
|
124
47
|
}
|
|
48
|
+
// If `boxSize === 1`, the 8 bytes after the box type are the size of the box.
|
|
49
|
+
if ((boxSizeRaw === 1 && iterator.bytesRemaining() < 12) ||
|
|
50
|
+
iterator.bytesRemaining() < 4) {
|
|
51
|
+
iterator.counter.decrement(iterator.counter.getOffset() - fileOffset);
|
|
52
|
+
throw new Error(`Expected box size of ${bytesRemaining}, got ${boxSizeRaw}. Incomplete boxes are not allowed.`);
|
|
53
|
+
}
|
|
125
54
|
const boxType = iterator.getByteString(4, false);
|
|
126
55
|
const boxSize = boxSizeRaw === 1 ? iterator.getEightByteNumber() : boxSizeRaw;
|
|
56
|
+
log_1.Log.trace(state.logLevel, 'Found box', boxType, boxSize);
|
|
57
|
+
if (boxType === 'mdat') {
|
|
58
|
+
state.videoSection.setVideoSection({
|
|
59
|
+
size: boxSize - 8,
|
|
60
|
+
start: iterator.counter.getOffset(),
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
box: null,
|
|
64
|
+
skipTo: null,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
127
67
|
if (bytesRemaining < boxSize) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (shouldSkip) {
|
|
134
|
-
const skipTo = fileOffset + boxSize;
|
|
135
|
-
const bytesToSkip = skipTo - iterator.counter.getOffset();
|
|
136
|
-
// If there is a huge mdat chunk, we can skip it because we don't need it for the metadata
|
|
137
|
-
if (bytesToSkip > 1000000) {
|
|
138
|
-
return {
|
|
139
|
-
type: 'complete',
|
|
140
|
-
box: {
|
|
141
|
-
type: 'mdat-box',
|
|
142
|
-
boxSize,
|
|
143
|
-
fileOffset,
|
|
144
|
-
status: 'samples-skipped',
|
|
145
|
-
},
|
|
146
|
-
size: boxSize,
|
|
147
|
-
skipTo: fileOffset + boxSize,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
return (0, exports.parseMdatPartially)({
|
|
153
|
-
iterator,
|
|
154
|
-
boxSize,
|
|
155
|
-
fileOffset,
|
|
156
|
-
parsedBoxes,
|
|
157
|
-
state,
|
|
158
|
-
signal,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
iterator.counter.decrement(iterator.counter.getOffset() - fileOffset);
|
|
163
|
-
if (allowIncompleteBoxes) {
|
|
164
|
-
return {
|
|
165
|
-
type: 'incomplete',
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
throw new Error(`Expected box size of ${bytesRemaining}, got ${boxSize}. Incomplete boxes are not allowed.`);
|
|
68
|
+
returnToCheckpoint();
|
|
69
|
+
return {
|
|
70
|
+
box: null,
|
|
71
|
+
skipTo: null,
|
|
72
|
+
};
|
|
169
73
|
}
|
|
170
74
|
if (boxType === 'ftyp') {
|
|
171
75
|
const box = (0, ftyp_1.parseFtyp)({ iterator, size: boxSize, offset: fileOffset });
|
|
172
76
|
return {
|
|
173
|
-
type: 'complete',
|
|
174
77
|
box,
|
|
175
|
-
size: boxSize,
|
|
176
78
|
skipTo: null,
|
|
177
79
|
};
|
|
178
80
|
}
|
|
@@ -182,45 +84,35 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
182
84
|
size: boxSize,
|
|
183
85
|
});
|
|
184
86
|
return {
|
|
185
|
-
type: 'complete',
|
|
186
87
|
box,
|
|
187
|
-
size: boxSize,
|
|
188
88
|
skipTo: null,
|
|
189
89
|
};
|
|
190
90
|
}
|
|
191
91
|
if (boxType === 'mvhd') {
|
|
192
92
|
const box = (0, mvhd_1.parseMvhd)({ iterator, offset: fileOffset, size: boxSize });
|
|
193
93
|
return {
|
|
194
|
-
type: 'complete',
|
|
195
94
|
box,
|
|
196
|
-
size: boxSize,
|
|
197
95
|
skipTo: null,
|
|
198
96
|
};
|
|
199
97
|
}
|
|
200
98
|
if (boxType === 'tkhd') {
|
|
201
99
|
const box = (0, tkhd_1.parseTkhd)({ iterator, offset: fileOffset, size: boxSize });
|
|
202
100
|
return {
|
|
203
|
-
type: 'complete',
|
|
204
101
|
box,
|
|
205
|
-
size: boxSize,
|
|
206
102
|
skipTo: null,
|
|
207
103
|
};
|
|
208
104
|
}
|
|
209
105
|
if (boxType === 'trun') {
|
|
210
106
|
const box = (0, trun_1.parseTrun)({ iterator, offset: fileOffset, size: boxSize });
|
|
211
107
|
return {
|
|
212
|
-
type: 'complete',
|
|
213
108
|
box,
|
|
214
|
-
size: boxSize,
|
|
215
109
|
skipTo: null,
|
|
216
110
|
};
|
|
217
111
|
}
|
|
218
112
|
if (boxType === 'tfdt') {
|
|
219
113
|
const box = (0, tfdt_1.parseTfdt)({ iterator, size: boxSize, offset: fileOffset });
|
|
220
114
|
return {
|
|
221
|
-
type: 'complete',
|
|
222
115
|
box,
|
|
223
|
-
size: boxSize,
|
|
224
116
|
skipTo: null,
|
|
225
117
|
};
|
|
226
118
|
}
|
|
@@ -230,13 +122,9 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
230
122
|
offset: fileOffset,
|
|
231
123
|
size: boxSize,
|
|
232
124
|
state,
|
|
233
|
-
signal,
|
|
234
|
-
fields,
|
|
235
125
|
});
|
|
236
126
|
return {
|
|
237
|
-
type: 'complete',
|
|
238
127
|
box,
|
|
239
|
-
size: boxSize,
|
|
240
128
|
skipTo: null,
|
|
241
129
|
};
|
|
242
130
|
}
|
|
@@ -247,9 +135,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
247
135
|
size: boxSize,
|
|
248
136
|
});
|
|
249
137
|
return {
|
|
250
|
-
type: 'complete',
|
|
251
138
|
box,
|
|
252
|
-
size: boxSize,
|
|
253
139
|
skipTo: null,
|
|
254
140
|
};
|
|
255
141
|
}
|
|
@@ -261,9 +147,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
261
147
|
mode64Bit: boxType === 'co64',
|
|
262
148
|
});
|
|
263
149
|
return {
|
|
264
|
-
type: 'complete',
|
|
265
150
|
box,
|
|
266
|
-
size: boxSize,
|
|
267
151
|
skipTo: null,
|
|
268
152
|
};
|
|
269
153
|
}
|
|
@@ -274,9 +158,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
274
158
|
size: boxSize,
|
|
275
159
|
});
|
|
276
160
|
return {
|
|
277
|
-
type: 'complete',
|
|
278
161
|
box,
|
|
279
|
-
size: boxSize,
|
|
280
162
|
skipTo: null,
|
|
281
163
|
};
|
|
282
164
|
}
|
|
@@ -287,9 +169,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
287
169
|
boxSize,
|
|
288
170
|
});
|
|
289
171
|
return {
|
|
290
|
-
type: 'complete',
|
|
291
172
|
box,
|
|
292
|
-
size: boxSize,
|
|
293
173
|
skipTo: null,
|
|
294
174
|
};
|
|
295
175
|
}
|
|
@@ -300,9 +180,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
300
180
|
size: boxSize,
|
|
301
181
|
});
|
|
302
182
|
return {
|
|
303
|
-
type: 'complete',
|
|
304
183
|
box,
|
|
305
|
-
size: boxSize,
|
|
306
184
|
skipTo: null,
|
|
307
185
|
};
|
|
308
186
|
}
|
|
@@ -313,9 +191,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
313
191
|
size: boxSize,
|
|
314
192
|
});
|
|
315
193
|
return {
|
|
316
|
-
type: 'complete',
|
|
317
194
|
box,
|
|
318
|
-
size: boxSize,
|
|
319
195
|
skipTo: null,
|
|
320
196
|
};
|
|
321
197
|
}
|
|
@@ -325,31 +201,23 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
325
201
|
offset: fileOffset,
|
|
326
202
|
size: boxSize,
|
|
327
203
|
state,
|
|
328
|
-
signal,
|
|
329
|
-
fields,
|
|
330
204
|
});
|
|
331
205
|
return {
|
|
332
|
-
type: 'complete',
|
|
333
206
|
box,
|
|
334
|
-
size: boxSize,
|
|
335
207
|
skipTo: null,
|
|
336
208
|
};
|
|
337
209
|
}
|
|
338
210
|
if (boxType === 'hdlr') {
|
|
339
211
|
const box = await (0, hdlr_1.parseHdlr)({ iterator, size: boxSize, offset: fileOffset });
|
|
340
212
|
return {
|
|
341
|
-
type: 'complete',
|
|
342
213
|
box,
|
|
343
|
-
size: boxSize,
|
|
344
214
|
skipTo: null,
|
|
345
215
|
};
|
|
346
216
|
}
|
|
347
217
|
if (boxType === 'keys') {
|
|
348
218
|
const box = (0, keys_1.parseKeys)({ iterator, size: boxSize, offset: fileOffset });
|
|
349
219
|
return {
|
|
350
|
-
type: 'complete',
|
|
351
220
|
box,
|
|
352
|
-
size: boxSize,
|
|
353
221
|
skipTo: null,
|
|
354
222
|
};
|
|
355
223
|
}
|
|
@@ -360,27 +228,27 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
360
228
|
size: boxSize,
|
|
361
229
|
});
|
|
362
230
|
return {
|
|
363
|
-
type: 'complete',
|
|
364
231
|
box,
|
|
365
|
-
size: boxSize,
|
|
366
232
|
skipTo: null,
|
|
367
233
|
};
|
|
368
234
|
}
|
|
369
235
|
if (boxType === 'moov') {
|
|
236
|
+
if (state.callbacks.tracks.hasAllTracks()) {
|
|
237
|
+
iterator.discard(boxSize - 8);
|
|
238
|
+
return {
|
|
239
|
+
box: null,
|
|
240
|
+
skipTo: null,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
370
243
|
const box = await (0, moov_1.parseMoov)({
|
|
371
244
|
iterator,
|
|
372
245
|
offset: fileOffset,
|
|
373
246
|
size: boxSize,
|
|
374
247
|
state,
|
|
375
|
-
signal,
|
|
376
|
-
logLevel,
|
|
377
|
-
fields,
|
|
378
248
|
});
|
|
379
249
|
state.callbacks.tracks.setIsDone();
|
|
380
250
|
return {
|
|
381
|
-
type: 'complete',
|
|
382
251
|
box,
|
|
383
|
-
size: boxSize,
|
|
384
252
|
skipTo: null,
|
|
385
253
|
};
|
|
386
254
|
}
|
|
@@ -390,9 +258,6 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
390
258
|
size: boxSize,
|
|
391
259
|
offsetAtStart: fileOffset,
|
|
392
260
|
state,
|
|
393
|
-
signal,
|
|
394
|
-
logLevel,
|
|
395
|
-
fields,
|
|
396
261
|
});
|
|
397
262
|
const transformedTrack = (0, make_track_1.makeBaseMediaTrack)(box);
|
|
398
263
|
if (transformedTrack) {
|
|
@@ -403,9 +268,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
403
268
|
});
|
|
404
269
|
}
|
|
405
270
|
return {
|
|
406
|
-
type: 'complete',
|
|
407
271
|
box,
|
|
408
|
-
size: boxSize,
|
|
409
272
|
skipTo: null,
|
|
410
273
|
};
|
|
411
274
|
}
|
|
@@ -416,9 +279,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
416
279
|
fileOffset,
|
|
417
280
|
});
|
|
418
281
|
return {
|
|
419
|
-
type: 'complete',
|
|
420
282
|
box,
|
|
421
|
-
size: boxSize,
|
|
422
283
|
skipTo: null,
|
|
423
284
|
};
|
|
424
285
|
}
|
|
@@ -428,9 +289,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
428
289
|
size: boxSize,
|
|
429
290
|
});
|
|
430
291
|
return {
|
|
431
|
-
type: 'complete',
|
|
432
292
|
box,
|
|
433
|
-
size: boxSize,
|
|
434
293
|
skipTo: null,
|
|
435
294
|
};
|
|
436
295
|
}
|
|
@@ -440,9 +299,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
440
299
|
size: boxSize,
|
|
441
300
|
});
|
|
442
301
|
return {
|
|
443
|
-
type: 'complete',
|
|
444
302
|
box,
|
|
445
|
-
size: boxSize,
|
|
446
303
|
skipTo: null,
|
|
447
304
|
};
|
|
448
305
|
}
|
|
@@ -453,9 +310,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
453
310
|
offset: fileOffset,
|
|
454
311
|
});
|
|
455
312
|
return {
|
|
456
|
-
type: 'complete',
|
|
457
313
|
box,
|
|
458
|
-
size: boxSize,
|
|
459
314
|
skipTo: null,
|
|
460
315
|
};
|
|
461
316
|
}
|
|
@@ -466,9 +321,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
466
321
|
size: boxSize,
|
|
467
322
|
});
|
|
468
323
|
return {
|
|
469
|
-
type: 'complete',
|
|
470
324
|
box,
|
|
471
|
-
size: boxSize,
|
|
472
325
|
skipTo: null,
|
|
473
326
|
};
|
|
474
327
|
}
|
|
@@ -479,9 +332,7 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
479
332
|
fileOffset,
|
|
480
333
|
});
|
|
481
334
|
return {
|
|
482
|
-
type: 'complete',
|
|
483
335
|
box,
|
|
484
|
-
size: boxSize,
|
|
485
336
|
skipTo: null,
|
|
486
337
|
};
|
|
487
338
|
}
|
|
@@ -492,208 +343,46 @@ const processBox = async ({ iterator, allowIncompleteBoxes, parsedBoxes, state,
|
|
|
492
343
|
fileOffset,
|
|
493
344
|
});
|
|
494
345
|
return {
|
|
495
|
-
type: 'complete',
|
|
496
346
|
box,
|
|
497
|
-
size: boxSize,
|
|
498
347
|
skipTo: null,
|
|
499
348
|
};
|
|
500
349
|
}
|
|
501
|
-
if (boxType === '
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
350
|
+
if (boxType === 'mdia' ||
|
|
351
|
+
boxType === 'minf' ||
|
|
352
|
+
boxType === 'stbl' ||
|
|
353
|
+
boxType === 'udta' ||
|
|
354
|
+
boxType === 'moof' ||
|
|
355
|
+
boxType === 'dims' ||
|
|
356
|
+
boxType === 'meta' ||
|
|
357
|
+
boxType === 'wave' ||
|
|
358
|
+
boxType === 'traf' ||
|
|
359
|
+
boxType === 'stsb') {
|
|
360
|
+
const children = await (0, get_children_1.getIsoBaseMediaChildren)({
|
|
361
|
+
iterator,
|
|
507
362
|
state,
|
|
508
|
-
|
|
509
|
-
maySkipSampleProcessing: state.supportsContentRange,
|
|
363
|
+
size: boxSize - 8,
|
|
510
364
|
});
|
|
511
|
-
if (box === null) {
|
|
512
|
-
throw new Error('Unexpected null');
|
|
513
|
-
}
|
|
514
365
|
return {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
366
|
+
box: {
|
|
367
|
+
type: 'regular-box',
|
|
368
|
+
boxType,
|
|
369
|
+
boxSize,
|
|
370
|
+
children,
|
|
371
|
+
offset: fileOffset,
|
|
372
|
+
},
|
|
518
373
|
skipTo: null,
|
|
519
374
|
};
|
|
520
375
|
}
|
|
521
|
-
|
|
522
|
-
const children = await getChildren({
|
|
523
|
-
boxType,
|
|
524
|
-
iterator,
|
|
525
|
-
bytesRemainingInBox,
|
|
526
|
-
state,
|
|
527
|
-
signal,
|
|
528
|
-
logLevel,
|
|
529
|
-
fields,
|
|
530
|
-
});
|
|
376
|
+
iterator.discard(boxSize - 8);
|
|
531
377
|
return {
|
|
532
|
-
type: 'complete',
|
|
533
378
|
box: {
|
|
534
379
|
type: 'regular-box',
|
|
535
380
|
boxType,
|
|
536
381
|
boxSize,
|
|
537
|
-
children,
|
|
382
|
+
children: [],
|
|
538
383
|
offset: fileOffset,
|
|
539
384
|
},
|
|
540
|
-
size: boxSize,
|
|
541
385
|
skipTo: null,
|
|
542
386
|
};
|
|
543
387
|
};
|
|
544
388
|
exports.processBox = processBox;
|
|
545
|
-
const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes, initialBoxes, state, continueMdat, signal, logLevel, fields, }) => {
|
|
546
|
-
var _a;
|
|
547
|
-
const initialOffset = iterator.counter.getOffset();
|
|
548
|
-
const alreadyHasMdat = (_a = state.structure
|
|
549
|
-
.getStructureOrNull()) === null || _a === void 0 ? void 0 : _a.boxes.find((b) => b.type === 'mdat-box');
|
|
550
|
-
while (iterator.bytesRemaining() > 0 &&
|
|
551
|
-
iterator.counter.getOffset() - initialOffset < maxBytes) {
|
|
552
|
-
const result = continueMdat
|
|
553
|
-
? await (0, exports.parseMdatPartially)({
|
|
554
|
-
iterator,
|
|
555
|
-
boxSize: continueMdat.boxSize,
|
|
556
|
-
fileOffset: continueMdat.fileOffset,
|
|
557
|
-
parsedBoxes: initialBoxes,
|
|
558
|
-
state,
|
|
559
|
-
signal,
|
|
560
|
-
})
|
|
561
|
-
: await (0, exports.processBox)({
|
|
562
|
-
iterator,
|
|
563
|
-
allowIncompleteBoxes,
|
|
564
|
-
parsedBoxes: initialBoxes,
|
|
565
|
-
state,
|
|
566
|
-
signal,
|
|
567
|
-
logLevel,
|
|
568
|
-
fields,
|
|
569
|
-
});
|
|
570
|
-
if (result.type === 'incomplete') {
|
|
571
|
-
if (Number.isFinite(maxBytes)) {
|
|
572
|
-
throw new Error('maxBytes must be Infinity for top-level boxes');
|
|
573
|
-
}
|
|
574
|
-
return {
|
|
575
|
-
status: 'incomplete',
|
|
576
|
-
continueParsing: () => {
|
|
577
|
-
return (0, exports.parseIsoBaseMediaBoxes)({
|
|
578
|
-
iterator,
|
|
579
|
-
maxBytes,
|
|
580
|
-
allowIncompleteBoxes,
|
|
581
|
-
initialBoxes,
|
|
582
|
-
state,
|
|
583
|
-
continueMdat: false,
|
|
584
|
-
signal,
|
|
585
|
-
logLevel,
|
|
586
|
-
fields,
|
|
587
|
-
});
|
|
588
|
-
},
|
|
589
|
-
skipTo: null,
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
if (result.type === 'partial-mdat-box') {
|
|
593
|
-
return {
|
|
594
|
-
status: 'incomplete',
|
|
595
|
-
continueParsing: () => {
|
|
596
|
-
return Promise.resolve((0, exports.parseIsoBaseMediaBoxes)({
|
|
597
|
-
iterator,
|
|
598
|
-
maxBytes,
|
|
599
|
-
allowIncompleteBoxes,
|
|
600
|
-
initialBoxes,
|
|
601
|
-
state,
|
|
602
|
-
continueMdat: result,
|
|
603
|
-
signal,
|
|
604
|
-
logLevel,
|
|
605
|
-
fields,
|
|
606
|
-
}));
|
|
607
|
-
},
|
|
608
|
-
skipTo: null,
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
if (result.box.type === 'mdat-box' && alreadyHasMdat) {
|
|
612
|
-
initialBoxes = initialBoxes.filter((b) => b.type !== 'mdat-box');
|
|
613
|
-
initialBoxes.push(result.box);
|
|
614
|
-
iterator.allowDiscard();
|
|
615
|
-
break;
|
|
616
|
-
}
|
|
617
|
-
else {
|
|
618
|
-
initialBoxes.push(result.box);
|
|
619
|
-
if ((0, has_all_info_1.hasAllInfo)({ fields, state })) {
|
|
620
|
-
return {
|
|
621
|
-
status: 'done',
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (result.skipTo !== null) {
|
|
626
|
-
if (!state.supportsContentRange) {
|
|
627
|
-
throw new Error('Content-Range header is not supported by the reader, but was asked to seek');
|
|
628
|
-
}
|
|
629
|
-
return {
|
|
630
|
-
status: 'incomplete',
|
|
631
|
-
continueParsing: () => {
|
|
632
|
-
return (0, exports.parseIsoBaseMediaBoxes)({
|
|
633
|
-
iterator,
|
|
634
|
-
maxBytes,
|
|
635
|
-
allowIncompleteBoxes,
|
|
636
|
-
initialBoxes,
|
|
637
|
-
state,
|
|
638
|
-
continueMdat: false,
|
|
639
|
-
signal,
|
|
640
|
-
logLevel,
|
|
641
|
-
fields,
|
|
642
|
-
});
|
|
643
|
-
},
|
|
644
|
-
skipTo: result.skipTo,
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
if (iterator.bytesRemaining() < 0) {
|
|
648
|
-
return {
|
|
649
|
-
status: 'incomplete',
|
|
650
|
-
continueParsing: () => {
|
|
651
|
-
return (0, exports.parseIsoBaseMediaBoxes)({
|
|
652
|
-
iterator,
|
|
653
|
-
maxBytes,
|
|
654
|
-
allowIncompleteBoxes,
|
|
655
|
-
initialBoxes,
|
|
656
|
-
state,
|
|
657
|
-
continueMdat: false,
|
|
658
|
-
signal,
|
|
659
|
-
logLevel,
|
|
660
|
-
fields,
|
|
661
|
-
});
|
|
662
|
-
},
|
|
663
|
-
skipTo: null,
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
|
-
iterator.removeBytesRead();
|
|
667
|
-
}
|
|
668
|
-
const mdatState = (0, traversal_1.getMdatBox)(initialBoxes);
|
|
669
|
-
const skipped = (mdatState === null || mdatState === void 0 ? void 0 : mdatState.status) === 'samples-skipped' &&
|
|
670
|
-
!(0, may_skip_video_data_1.maySkipVideoData)({ state }) &&
|
|
671
|
-
state.supportsContentRange;
|
|
672
|
-
const buffered = (mdatState === null || mdatState === void 0 ? void 0 : mdatState.status) === 'samples-buffered' && !(0, may_skip_video_data_1.maySkipVideoData)({ state });
|
|
673
|
-
if (skipped || buffered) {
|
|
674
|
-
return {
|
|
675
|
-
status: 'incomplete',
|
|
676
|
-
continueParsing: () => {
|
|
677
|
-
if (buffered) {
|
|
678
|
-
iterator.skipTo(mdatState.fileOffset, false);
|
|
679
|
-
}
|
|
680
|
-
return (0, exports.parseIsoBaseMediaBoxes)({
|
|
681
|
-
iterator,
|
|
682
|
-
maxBytes,
|
|
683
|
-
allowIncompleteBoxes: false,
|
|
684
|
-
initialBoxes,
|
|
685
|
-
state,
|
|
686
|
-
continueMdat: false,
|
|
687
|
-
signal,
|
|
688
|
-
logLevel,
|
|
689
|
-
fields,
|
|
690
|
-
});
|
|
691
|
-
},
|
|
692
|
-
skipTo: skipped ? mdatState.fileOffset : null,
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
return {
|
|
696
|
-
status: 'done',
|
|
697
|
-
};
|
|
698
|
-
};
|
|
699
|
-
exports.parseIsoBaseMediaBoxes = parseIsoBaseMediaBoxes;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
-
import type { Options, ParseMediaFields } from '../../../options';
|
|
3
2
|
import type { AnySegment } from '../../../parse-result';
|
|
4
3
|
import type { ParserState } from '../../../state/parser-state';
|
|
5
4
|
import type { BaseBox } from '../base-type';
|
|
@@ -9,11 +8,9 @@ export interface MebxBox extends BaseBox {
|
|
|
9
8
|
format: string;
|
|
10
9
|
children: AnySegment[];
|
|
11
10
|
}
|
|
12
|
-
export declare const parseMebx: ({ iterator, offset, size, state,
|
|
11
|
+
export declare const parseMebx: ({ iterator, offset, size, state, }: {
|
|
13
12
|
iterator: BufferIterator;
|
|
14
13
|
offset: number;
|
|
15
14
|
size: number;
|
|
16
15
|
state: ParserState;
|
|
17
|
-
signal: AbortSignal | null;
|
|
18
|
-
fields: Options<ParseMediaFields>;
|
|
19
16
|
}) => Promise<MebxBox>;
|