@remotion/media-parser 4.0.251 → 4.0.253
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 +2 -1
- package/dist/aac-codecprivate.js +28 -7
- package/dist/abort.d.ts +1 -0
- package/dist/abort.js +7 -0
- package/dist/buffer-iterator.d.ts +5 -1
- package/dist/buffer-iterator.js +5 -5
- package/dist/containers/aac/parse-aac.js +3 -2
- package/dist/containers/flac/get-channel-count.d.ts +1 -1
- package/dist/containers/flac/get-duration-from-flac.js +1 -4
- package/dist/containers/flac/get-sample-rate.js +1 -1
- package/dist/containers/flac/parse-flac-frame.js +3 -9
- package/dist/containers/flac/parse-flac.js +2 -7
- package/dist/containers/flac/parse-header.js +2 -2
- package/dist/containers/flac/parse-metadata.js +2 -2
- package/dist/containers/flac/parse-streaminfo.js +3 -3
- package/dist/containers/flac/parse-unknown-block.js +2 -2
- package/dist/containers/iso-base-media/base-media-box.d.ts +1 -4
- package/dist/containers/iso-base-media/get-actual-number-of-channels.js +1 -1
- package/dist/containers/iso-base-media/get-children.js +2 -2
- package/dist/containers/iso-base-media/get-keyframes.d.ts +2 -2
- package/dist/containers/iso-base-media/get-keyframes.js +8 -4
- package/dist/containers/iso-base-media/get-moov-atom.d.ts +6 -0
- package/dist/containers/iso-base-media/get-moov-atom.js +73 -0
- package/dist/containers/iso-base-media/get-sample-positions-from-track.d.ts +4 -1
- package/dist/containers/iso-base-media/get-sample-positions-from-track.js +7 -3
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.js +1 -1
- package/dist/containers/iso-base-media/mdat/mdat.d.ts +2 -1
- package/dist/containers/iso-base-media/mdat/mdat.js +16 -11
- package/dist/containers/iso-base-media/parse-boxes.js +4 -26
- package/dist/containers/iso-base-media/process-box.js +50 -163
- package/dist/containers/iso-base-media/stsd/samples.js +1 -0
- package/dist/containers/iso-base-media/traversal.d.ts +3 -2
- package/dist/containers/iso-base-media/traversal.js +11 -10
- package/dist/containers/mp3/get-duration.js +0 -3
- package/dist/containers/mp3/id3.js +1 -1
- package/dist/containers/mp3/parse-mp3.js +4 -12
- package/dist/containers/mp3/parse-mpeg-header.js +1 -1
- package/dist/containers/riff/expect-riff-box.d.ts +1 -2
- package/dist/containers/riff/expect-riff-box.js +4 -14
- package/dist/containers/riff/get-tracks-from-avi.js +1 -1
- package/dist/containers/riff/parse-list-box.js +3 -5
- package/dist/containers/riff/parse-movi.d.ts +2 -4
- package/dist/containers/riff/parse-movi.js +9 -27
- package/dist/containers/riff/parse-riff-body.js +17 -11
- package/dist/containers/riff/parse-riff-header.js +2 -7
- package/dist/containers/riff/parse-video-section.d.ts +1 -1
- package/dist/containers/riff/parse-video-section.js +5 -7
- package/dist/containers/transport-stream/adts-header.js +1 -0
- package/dist/containers/transport-stream/get-tracks.js +1 -1
- package/dist/containers/transport-stream/parse-packet.js +1 -1
- package/dist/containers/transport-stream/parse-transport-stream.js +3 -10
- package/dist/containers/transport-stream/process-stream-buffers.js +1 -1
- package/dist/containers/wav/get-duration-from-wav.js +1 -4
- package/dist/containers/wav/parse-data.js +6 -6
- package/dist/containers/wav/parse-fmt.js +2 -2
- package/dist/containers/wav/parse-header.js +2 -2
- package/dist/containers/wav/parse-id3.js +2 -4
- package/dist/containers/wav/parse-list.js +2 -2
- package/dist/containers/wav/parse-video-section.js +2 -5
- package/dist/containers/webm/av1-codec-private.js +1 -1
- package/dist/containers/webm/parse-ebml.js +1 -1
- package/dist/containers/webm/parse-webm-header.js +3 -10
- package/dist/controller.d.ts +17 -0
- package/dist/controller.js +31 -0
- package/dist/download-and-parse-media.d.ts +2 -0
- package/dist/download-and-parse-media.js +72 -0
- package/dist/emit-available-info.d.ts +2 -3
- package/dist/emit-available-info.js +36 -36
- package/dist/emitter.d.ts +20 -0
- package/dist/emitter.js +29 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +13 -1
- package/dist/esm/from-fetch.mjs +134 -8
- package/dist/esm/from-node.mjs +8 -8
- package/dist/esm/from-web-file.mjs +14 -14
- package/dist/esm/index.mjs +3051 -2836
- package/dist/esm/node.mjs +113 -0
- package/dist/get-audio-codec.js +3 -0
- package/dist/get-dimensions.js +2 -2
- package/dist/get-duration.js +8 -8
- package/dist/get-fps.d.ts +4 -4
- package/dist/get-fps.js +16 -11
- package/dist/get-keyframes.d.ts +1 -2
- package/dist/get-keyframes.js +4 -3
- package/dist/get-location.d.ts +2 -2
- package/dist/get-location.js +2 -2
- package/dist/get-tracks.d.ts +3 -5
- package/dist/get-tracks.js +8 -14
- package/dist/has-all-info.js +3 -3
- package/dist/index.d.ts +132 -104
- package/dist/index.js +9 -1
- package/dist/init-video.d.ts +1 -1
- package/dist/init-video.js +8 -8
- package/dist/internal-parse-media.d.ts +2 -0
- package/dist/internal-parse-media.js +231 -0
- package/dist/make-hvc1-codec-strings.js +4 -4
- package/dist/media-parser-controller.d.ts +17 -0
- package/dist/media-parser-controller.js +31 -0
- package/dist/metadata/get-metadata.d.ts +2 -1
- package/dist/metadata/get-metadata.js +3 -2
- package/dist/metadata/metadata-from-iso.d.ts +2 -2
- package/dist/metadata/metadata-from-iso.js +2 -2
- package/dist/options.d.ts +60 -34
- package/dist/parse-and-download-media.d.ts +2 -0
- package/dist/parse-and-download-media.js +57 -0
- package/dist/parse-media.js +8 -202
- package/dist/parse-result.d.ts +2 -6
- package/dist/pause-signal.d.ts +11 -0
- package/dist/pause-signal.js +38 -0
- package/dist/perform-seek.d.ts +5 -8
- package/dist/perform-seek.js +17 -9
- package/dist/readers/from-fetch.js +11 -8
- package/dist/readers/from-node.js +8 -8
- package/dist/readers/from-web-file.js +16 -16
- package/dist/readers/reader.d.ts +8 -2
- package/dist/register-track.js +5 -0
- package/dist/remotion-license-acknowledge.d.ts +6 -0
- package/dist/remotion-license-acknowledge.js +17 -0
- package/dist/run-parse-iteration.d.ts +1 -1
- package/dist/run-parse-iteration.js +2 -2
- package/dist/skip.d.ts +5 -0
- package/dist/skip.js +8 -0
- package/dist/state/has-tracks-section.d.ts +3 -1
- package/dist/state/has-tracks-section.js +7 -1
- package/dist/state/iso-base-media/cached-sample-positions.d.ts +2 -2
- package/dist/state/iso-base-media/cached-sample-positions.js +12 -6
- package/dist/state/iso-base-media/iso-state.d.ts +6 -4
- package/dist/state/iso-base-media/iso-state.js +2 -5
- package/dist/state/iso-base-media/moov-box.d.ts +5 -0
- package/dist/state/iso-base-media/moov-box.js +13 -0
- package/dist/state/last-eventloop-break.d.ts +4 -0
- package/dist/state/last-eventloop-break.js +18 -0
- package/dist/state/parser-state.d.ts +124 -102
- package/dist/state/parser-state.js +22 -4
- package/dist/state/sample-callbacks.d.ts +5 -3
- package/dist/state/sample-callbacks.js +3 -3
- package/dist/state/structure.d.ts +7 -0
- package/dist/state/structure.js +56 -6
- package/dist/throttled-progress.d.ts +3 -2
- package/dist/throttled-progress.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/writers/node.d.ts +4 -0
- package/dist/writers/node.js +81 -0
- package/dist/writers/writer.d.ts +17 -0
- package/dist/writers/writer.js +2 -0
- package/package.json +12 -9
- package/LICENSE.md +0 -49
|
@@ -36,14 +36,12 @@ const processBox = async (state) => {
|
|
|
36
36
|
const fileOffset = iterator.counter.getOffset();
|
|
37
37
|
const { returnToCheckpoint } = iterator.startCheckpoint();
|
|
38
38
|
const bytesRemaining = iterator.bytesRemaining();
|
|
39
|
+
const startOff = iterator.counter.getOffset();
|
|
39
40
|
const boxSizeRaw = iterator.getFourByteNumber();
|
|
40
41
|
if (boxSizeRaw === 0) {
|
|
41
42
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
boxSize: 0,
|
|
45
|
-
},
|
|
46
|
-
skipTo: null,
|
|
43
|
+
type: 'void-box',
|
|
44
|
+
boxSize: 0,
|
|
47
45
|
};
|
|
48
46
|
}
|
|
49
47
|
// If `boxSize === 1`, the 8 bytes after the box type are the size of the box.
|
|
@@ -55,200 +53,126 @@ const processBox = async (state) => {
|
|
|
55
53
|
const boxType = iterator.getByteString(4, false);
|
|
56
54
|
const boxSize = boxSizeRaw === 1 ? iterator.getEightByteNumber() : boxSizeRaw;
|
|
57
55
|
log_1.Log.trace(state.logLevel, 'Found box', boxType, boxSize);
|
|
56
|
+
const headerLength = iterator.counter.getOffset() - startOff;
|
|
58
57
|
if (boxType === 'mdat') {
|
|
59
58
|
state.videoSection.setVideoSection({
|
|
60
|
-
size: boxSize -
|
|
59
|
+
size: boxSize - headerLength,
|
|
61
60
|
start: iterator.counter.getOffset(),
|
|
62
61
|
});
|
|
63
|
-
return
|
|
64
|
-
box: null,
|
|
65
|
-
skipTo: null,
|
|
66
|
-
};
|
|
62
|
+
return null;
|
|
67
63
|
}
|
|
68
64
|
if (bytesRemaining < boxSize) {
|
|
69
65
|
returnToCheckpoint();
|
|
70
|
-
return
|
|
71
|
-
box: null,
|
|
72
|
-
skipTo: null,
|
|
73
|
-
};
|
|
66
|
+
return null;
|
|
74
67
|
}
|
|
75
68
|
if (boxType === 'ftyp') {
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
box,
|
|
79
|
-
skipTo: null,
|
|
80
|
-
};
|
|
69
|
+
return (0, ftyp_1.parseFtyp)({ iterator, size: boxSize, offset: fileOffset });
|
|
81
70
|
}
|
|
82
71
|
if (boxType === 'colr') {
|
|
83
|
-
|
|
72
|
+
return (0, colr_1.parseColorParameterBox)({
|
|
84
73
|
iterator,
|
|
85
74
|
size: boxSize,
|
|
86
75
|
});
|
|
87
|
-
return {
|
|
88
|
-
box,
|
|
89
|
-
skipTo: null,
|
|
90
|
-
};
|
|
91
76
|
}
|
|
92
77
|
if (boxType === 'mvhd') {
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
box,
|
|
96
|
-
skipTo: null,
|
|
97
|
-
};
|
|
78
|
+
return (0, mvhd_1.parseMvhd)({ iterator, offset: fileOffset, size: boxSize });
|
|
98
79
|
}
|
|
99
80
|
if (boxType === 'tkhd') {
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
box,
|
|
103
|
-
skipTo: null,
|
|
104
|
-
};
|
|
81
|
+
return (0, tkhd_1.parseTkhd)({ iterator, offset: fileOffset, size: boxSize });
|
|
105
82
|
}
|
|
106
83
|
if (boxType === 'trun') {
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
box,
|
|
110
|
-
skipTo: null,
|
|
111
|
-
};
|
|
84
|
+
return (0, trun_1.parseTrun)({ iterator, offset: fileOffset, size: boxSize });
|
|
112
85
|
}
|
|
113
86
|
if (boxType === 'tfdt') {
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
box,
|
|
117
|
-
skipTo: null,
|
|
118
|
-
};
|
|
87
|
+
return (0, tfdt_1.parseTfdt)({ iterator, size: boxSize, offset: fileOffset });
|
|
119
88
|
}
|
|
120
89
|
if (boxType === 'stsd') {
|
|
121
|
-
|
|
90
|
+
return (0, stsd_1.parseStsd)({
|
|
122
91
|
offset: fileOffset,
|
|
123
92
|
size: boxSize,
|
|
124
93
|
state,
|
|
125
94
|
});
|
|
126
|
-
return {
|
|
127
|
-
box,
|
|
128
|
-
skipTo: null,
|
|
129
|
-
};
|
|
130
95
|
}
|
|
131
96
|
if (boxType === 'stsz') {
|
|
132
|
-
|
|
97
|
+
return (0, stsz_1.parseStsz)({
|
|
133
98
|
iterator,
|
|
134
99
|
offset: fileOffset,
|
|
135
100
|
size: boxSize,
|
|
136
101
|
});
|
|
137
|
-
return {
|
|
138
|
-
box,
|
|
139
|
-
skipTo: null,
|
|
140
|
-
};
|
|
141
102
|
}
|
|
142
103
|
if (boxType === 'stco' || boxType === 'co64') {
|
|
143
|
-
|
|
104
|
+
return (0, stco_1.parseStco)({
|
|
144
105
|
iterator,
|
|
145
106
|
offset: fileOffset,
|
|
146
107
|
size: boxSize,
|
|
147
108
|
mode64Bit: boxType === 'co64',
|
|
148
109
|
});
|
|
149
|
-
return {
|
|
150
|
-
box,
|
|
151
|
-
skipTo: null,
|
|
152
|
-
};
|
|
153
110
|
}
|
|
154
111
|
if (boxType === 'pasp') {
|
|
155
|
-
|
|
112
|
+
return (0, pasp_1.parsePasp)({
|
|
156
113
|
iterator,
|
|
157
114
|
offset: fileOffset,
|
|
158
115
|
size: boxSize,
|
|
159
116
|
});
|
|
160
|
-
return {
|
|
161
|
-
box,
|
|
162
|
-
skipTo: null,
|
|
163
|
-
};
|
|
164
117
|
}
|
|
165
118
|
if (boxType === 'stss') {
|
|
166
|
-
|
|
119
|
+
return (0, stss_1.parseStss)({
|
|
167
120
|
iterator,
|
|
168
121
|
offset: fileOffset,
|
|
169
122
|
boxSize,
|
|
170
123
|
});
|
|
171
|
-
return {
|
|
172
|
-
box,
|
|
173
|
-
skipTo: null,
|
|
174
|
-
};
|
|
175
124
|
}
|
|
176
125
|
if (boxType === 'ctts') {
|
|
177
|
-
|
|
126
|
+
return (0, ctts_1.parseCtts)({
|
|
178
127
|
iterator,
|
|
179
128
|
offset: fileOffset,
|
|
180
129
|
size: boxSize,
|
|
181
130
|
});
|
|
182
|
-
return {
|
|
183
|
-
box,
|
|
184
|
-
skipTo: null,
|
|
185
|
-
};
|
|
186
131
|
}
|
|
187
132
|
if (boxType === 'stsc') {
|
|
188
|
-
|
|
133
|
+
return (0, stsc_1.parseStsc)({
|
|
189
134
|
iterator,
|
|
190
135
|
offset: fileOffset,
|
|
191
136
|
size: boxSize,
|
|
192
137
|
});
|
|
193
|
-
return {
|
|
194
|
-
box,
|
|
195
|
-
skipTo: null,
|
|
196
|
-
};
|
|
197
138
|
}
|
|
198
139
|
if (boxType === 'mebx') {
|
|
199
|
-
|
|
140
|
+
return (0, mebx_1.parseMebx)({
|
|
200
141
|
offset: fileOffset,
|
|
201
142
|
size: boxSize,
|
|
202
143
|
state,
|
|
203
144
|
});
|
|
204
|
-
return {
|
|
205
|
-
box,
|
|
206
|
-
skipTo: null,
|
|
207
|
-
};
|
|
208
145
|
}
|
|
209
146
|
if (boxType === 'hdlr') {
|
|
210
|
-
|
|
211
|
-
return {
|
|
212
|
-
box,
|
|
213
|
-
skipTo: null,
|
|
214
|
-
};
|
|
147
|
+
return (0, hdlr_1.parseHdlr)({ iterator, size: boxSize, offset: fileOffset });
|
|
215
148
|
}
|
|
216
149
|
if (boxType === 'keys') {
|
|
217
|
-
|
|
218
|
-
return {
|
|
219
|
-
box,
|
|
220
|
-
skipTo: null,
|
|
221
|
-
};
|
|
150
|
+
return (0, keys_1.parseKeys)({ iterator, size: boxSize, offset: fileOffset });
|
|
222
151
|
}
|
|
223
152
|
if (boxType === 'ilst') {
|
|
224
|
-
|
|
153
|
+
return (0, ilst_1.parseIlstBox)({
|
|
225
154
|
iterator,
|
|
226
155
|
offset: fileOffset,
|
|
227
156
|
size: boxSize,
|
|
228
157
|
});
|
|
229
|
-
return {
|
|
230
|
-
box,
|
|
231
|
-
skipTo: null,
|
|
232
|
-
};
|
|
233
158
|
}
|
|
234
159
|
if (boxType === 'moov') {
|
|
235
160
|
if (state.callbacks.tracks.hasAllTracks()) {
|
|
236
161
|
iterator.discard(boxSize - 8);
|
|
237
|
-
return
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
if (state.iso.moov.getMoovBox()) {
|
|
165
|
+
log_1.Log.verbose(state.logLevel, 'Moov box already parsed, skipping');
|
|
166
|
+
iterator.discard(boxSize - 8);
|
|
167
|
+
return null;
|
|
241
168
|
}
|
|
242
169
|
const box = await (0, moov_1.parseMoov)({
|
|
243
170
|
offset: fileOffset,
|
|
244
171
|
size: boxSize,
|
|
245
172
|
state,
|
|
246
173
|
});
|
|
247
|
-
state.callbacks.tracks.setIsDone();
|
|
248
|
-
return
|
|
249
|
-
box,
|
|
250
|
-
skipTo: null,
|
|
251
|
-
};
|
|
174
|
+
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
175
|
+
return box;
|
|
252
176
|
}
|
|
253
177
|
if (boxType === 'trak') {
|
|
254
178
|
const box = await (0, trak_1.parseTrak)({
|
|
@@ -264,85 +188,54 @@ const processBox = async (state) => {
|
|
|
264
188
|
container: 'mp4',
|
|
265
189
|
});
|
|
266
190
|
}
|
|
267
|
-
return
|
|
268
|
-
box,
|
|
269
|
-
skipTo: null,
|
|
270
|
-
};
|
|
191
|
+
return box;
|
|
271
192
|
}
|
|
272
193
|
if (boxType === 'stts') {
|
|
273
|
-
|
|
194
|
+
return (0, stts_1.parseStts)({
|
|
274
195
|
data: iterator,
|
|
275
196
|
size: boxSize,
|
|
276
197
|
fileOffset,
|
|
277
198
|
});
|
|
278
|
-
return {
|
|
279
|
-
box,
|
|
280
|
-
skipTo: null,
|
|
281
|
-
};
|
|
282
199
|
}
|
|
283
200
|
if (boxType === 'avcC') {
|
|
284
|
-
|
|
201
|
+
return (0, avcc_1.parseAvcc)({
|
|
285
202
|
data: iterator,
|
|
286
203
|
size: boxSize,
|
|
287
204
|
});
|
|
288
|
-
return {
|
|
289
|
-
box,
|
|
290
|
-
skipTo: null,
|
|
291
|
-
};
|
|
292
205
|
}
|
|
293
206
|
if (boxType === 'av1C') {
|
|
294
|
-
|
|
207
|
+
return (0, av1c_1.parseAv1C)({
|
|
295
208
|
data: iterator,
|
|
296
209
|
size: boxSize,
|
|
297
210
|
});
|
|
298
|
-
return {
|
|
299
|
-
box,
|
|
300
|
-
skipTo: null,
|
|
301
|
-
};
|
|
302
211
|
}
|
|
303
212
|
if (boxType === 'hvcC') {
|
|
304
|
-
|
|
213
|
+
return (0, hvcc_1.parseHvcc)({
|
|
305
214
|
data: iterator,
|
|
306
215
|
size: boxSize,
|
|
307
216
|
offset: fileOffset,
|
|
308
217
|
});
|
|
309
|
-
return {
|
|
310
|
-
box,
|
|
311
|
-
skipTo: null,
|
|
312
|
-
};
|
|
313
218
|
}
|
|
314
219
|
if (boxType === 'tfhd') {
|
|
315
|
-
|
|
220
|
+
return (0, tfhd_1.getTfhd)({
|
|
316
221
|
iterator,
|
|
317
222
|
offset: fileOffset,
|
|
318
223
|
size: boxSize,
|
|
319
224
|
});
|
|
320
|
-
return {
|
|
321
|
-
box,
|
|
322
|
-
skipTo: null,
|
|
323
|
-
};
|
|
324
225
|
}
|
|
325
226
|
if (boxType === 'mdhd') {
|
|
326
|
-
|
|
227
|
+
return (0, mdhd_1.parseMdhd)({
|
|
327
228
|
data: iterator,
|
|
328
229
|
size: boxSize,
|
|
329
230
|
fileOffset,
|
|
330
231
|
});
|
|
331
|
-
return {
|
|
332
|
-
box,
|
|
333
|
-
skipTo: null,
|
|
334
|
-
};
|
|
335
232
|
}
|
|
336
233
|
if (boxType === 'esds') {
|
|
337
|
-
|
|
234
|
+
return (0, esds_1.parseEsds)({
|
|
338
235
|
data: iterator,
|
|
339
236
|
size: boxSize,
|
|
340
237
|
fileOffset,
|
|
341
238
|
});
|
|
342
|
-
return {
|
|
343
|
-
box,
|
|
344
|
-
skipTo: null,
|
|
345
|
-
};
|
|
346
239
|
}
|
|
347
240
|
if (boxType === 'mdia' ||
|
|
348
241
|
boxType === 'minf' ||
|
|
@@ -359,26 +252,20 @@ const processBox = async (state) => {
|
|
|
359
252
|
size: boxSize - 8,
|
|
360
253
|
});
|
|
361
254
|
return {
|
|
362
|
-
box: {
|
|
363
|
-
type: 'regular-box',
|
|
364
|
-
boxType,
|
|
365
|
-
boxSize,
|
|
366
|
-
children,
|
|
367
|
-
offset: fileOffset,
|
|
368
|
-
},
|
|
369
|
-
skipTo: null,
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
iterator.discard(boxSize - 8);
|
|
373
|
-
return {
|
|
374
|
-
box: {
|
|
375
255
|
type: 'regular-box',
|
|
376
256
|
boxType,
|
|
377
257
|
boxSize,
|
|
378
|
-
children
|
|
258
|
+
children,
|
|
379
259
|
offset: fileOffset,
|
|
380
|
-
}
|
|
381
|
-
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
iterator.discard(boxSize - 8);
|
|
263
|
+
return {
|
|
264
|
+
type: 'regular-box',
|
|
265
|
+
boxType,
|
|
266
|
+
boxSize,
|
|
267
|
+
children: [],
|
|
268
|
+
offset: fileOffset,
|
|
382
269
|
};
|
|
383
270
|
};
|
|
384
271
|
exports.processBox = processBox;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AnySegment } from '../../parse-result';
|
|
2
|
+
import type { ParserState } from '../../state/parser-state';
|
|
2
3
|
import type { IsoBaseMediaBox, RegularBox } from './base-media-box';
|
|
3
4
|
import type { FtypBox } from './ftyp';
|
|
4
5
|
import type { MdhdBox } from './mdhd';
|
|
@@ -17,8 +18,8 @@ import type { TkhdBox } from './tkhd';
|
|
|
17
18
|
import type { TrakBox } from './trak/trak';
|
|
18
19
|
import type { TrunBox } from './trun';
|
|
19
20
|
export declare const getFtypBox: (segments: AnySegment[]) => FtypBox | null;
|
|
20
|
-
export declare const getMoovBox: (
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const getMoovBox: (state: ParserState) => MoovBox | null;
|
|
22
|
+
export declare const getMoofBoxes: (main: AnySegment[]) => IsoBaseMediaBox[];
|
|
22
23
|
export declare const getMvhdBox: (moovBox: MoovBox) => MvhdBox | null;
|
|
23
24
|
export declare const getTraks: (moovBox: MoovBox) => TrakBox[];
|
|
24
25
|
export declare const getTkhdBox: (trakBox: TrakBox) => TkhdBox | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTrunBoxes = exports.getTfhdBox = exports.getTfdtBox = exports.getStssBox = exports.getStscBox = exports.getStszBox = exports.getCttsBox = exports.getSttsBox = exports.getStcoBox = exports.getVideoDescriptors = exports.getStsdBox = exports.getStblBox = exports.getMdhdBox = exports.getMdiaBox = exports.getTkhdBox = exports.getTraks = exports.getMvhdBox = exports.
|
|
3
|
+
exports.getTrunBoxes = exports.getTfhdBox = exports.getTfdtBox = exports.getStssBox = exports.getStscBox = exports.getStszBox = exports.getCttsBox = exports.getSttsBox = exports.getStcoBox = exports.getVideoDescriptors = exports.getStsdBox = exports.getStblBox = exports.getMdhdBox = exports.getMdiaBox = exports.getTkhdBox = exports.getTraks = exports.getMvhdBox = exports.getMoofBoxes = exports.getMoovBox = exports.getFtypBox = void 0;
|
|
4
4
|
const getFtypBox = (segments) => {
|
|
5
5
|
const ftypBox = segments.find((s) => s.type === 'ftyp-box');
|
|
6
6
|
if (!ftypBox || ftypBox.type !== 'ftyp-box') {
|
|
@@ -9,22 +9,23 @@ const getFtypBox = (segments) => {
|
|
|
9
9
|
return ftypBox;
|
|
10
10
|
};
|
|
11
11
|
exports.getFtypBox = getFtypBox;
|
|
12
|
-
const getMoovBox = (
|
|
13
|
-
|
|
12
|
+
const getMoovBox = (state) => {
|
|
13
|
+
if (state.iso.moov.getMoovBox()) {
|
|
14
|
+
return state.iso.moov.getMoovBox();
|
|
15
|
+
}
|
|
16
|
+
const structure = state.getIsoStructure();
|
|
17
|
+
const moovBox = structure.boxes.find((s) => s.type === 'moov-box');
|
|
14
18
|
if (!moovBox || moovBox.type !== 'moov-box') {
|
|
15
19
|
return null;
|
|
16
20
|
}
|
|
17
21
|
return moovBox;
|
|
18
22
|
};
|
|
19
23
|
exports.getMoovBox = getMoovBox;
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return moofBox;
|
|
24
|
+
const getMoofBoxes = (main) => {
|
|
25
|
+
const moofBoxes = main.filter((s) => s.type === 'regular-box' && s.boxType === 'moof');
|
|
26
|
+
return moofBoxes;
|
|
26
27
|
};
|
|
27
|
-
exports.
|
|
28
|
+
exports.getMoofBoxes = getMoofBoxes;
|
|
28
29
|
const getMvhdBox = (moovBox) => {
|
|
29
30
|
const mvHdBox = moovBox.children.find((s) => s.type === 'mvhd-box');
|
|
30
31
|
if (!mvHdBox || mvHdBox.type !== 'mvhd-box') {
|
|
@@ -4,9 +4,6 @@ exports.getDurationFromMp3 = void 0;
|
|
|
4
4
|
const get_frame_length_1 = require("./get-frame-length");
|
|
5
5
|
const samples_per_mpeg_file_1 = require("./samples-per-mpeg-file");
|
|
6
6
|
const getDurationFromMp3 = (state) => {
|
|
7
|
-
if (state.contentLength === null) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
7
|
const mp3Info = state.mp3Info.getMp3Info();
|
|
11
8
|
if (!mp3Info) {
|
|
12
9
|
throw new Error('No mp3 info');
|
|
@@ -7,9 +7,7 @@ const parse_mpeg_header_1 = require("./parse-mpeg-header");
|
|
|
7
7
|
const parseMp3 = async (state) => {
|
|
8
8
|
const { iterator } = state;
|
|
9
9
|
if (iterator.bytesRemaining() < 3) {
|
|
10
|
-
return
|
|
11
|
-
skipTo: null,
|
|
12
|
-
};
|
|
10
|
+
return null;
|
|
13
11
|
}
|
|
14
12
|
const { returnToCheckpoint } = iterator.startCheckpoint();
|
|
15
13
|
const bytes = iterator.getSlice(3);
|
|
@@ -17,24 +15,18 @@ const parseMp3 = async (state) => {
|
|
|
17
15
|
// ID3 v1
|
|
18
16
|
if (bytes[0] === 0x54 && bytes[1] === 0x41 && bytes[2] === 0x47) {
|
|
19
17
|
(0, id3_v1_1.parseID3V1)(iterator);
|
|
20
|
-
return
|
|
21
|
-
skipTo: null,
|
|
22
|
-
};
|
|
18
|
+
return null;
|
|
23
19
|
}
|
|
24
20
|
// ID3 v2 or v3
|
|
25
21
|
if (bytes[0] === 0x49 && bytes[1] === 0x44 && bytes[2] === 0x33) {
|
|
26
22
|
(0, id3_1.parseId3)({ state });
|
|
27
|
-
return
|
|
28
|
-
skipTo: null,
|
|
29
|
-
};
|
|
23
|
+
return null;
|
|
30
24
|
}
|
|
31
25
|
if (bytes[0] === 0xff) {
|
|
32
26
|
await (0, parse_mpeg_header_1.parseMpegHeader)({
|
|
33
27
|
state,
|
|
34
28
|
});
|
|
35
|
-
return
|
|
36
|
-
skipTo: null,
|
|
37
|
-
};
|
|
29
|
+
return null;
|
|
38
30
|
}
|
|
39
31
|
throw new Error('Unknown MP3 header ' + JSON.stringify(bytes));
|
|
40
32
|
};
|
|
@@ -2,6 +2,5 @@ import type { ParserState } from '../../state/parser-state';
|
|
|
2
2
|
import type { RiffBox } from './riff-box';
|
|
3
3
|
export type RiffResult = {
|
|
4
4
|
box: RiffBox | null;
|
|
5
|
-
skipTo: number | null;
|
|
6
5
|
};
|
|
7
|
-
export declare const expectRiffBox: (state: ParserState) => Promise<
|
|
6
|
+
export declare const expectRiffBox: (state: ParserState) => Promise<RiffBox | null>;
|
|
@@ -5,15 +5,11 @@ const register_track_1 = require("../../register-track");
|
|
|
5
5
|
const get_tracks_from_avi_1 = require("./get-tracks-from-avi");
|
|
6
6
|
const is_movi_1 = require("./is-movi");
|
|
7
7
|
const parse_riff_box_1 = require("./parse-riff-box");
|
|
8
|
-
const parse_video_section_1 = require("./parse-video-section");
|
|
9
8
|
const expectRiffBox = async (state) => {
|
|
10
9
|
const { iterator } = state;
|
|
11
10
|
// Need at least 16 bytes to read LIST,size,movi,size
|
|
12
11
|
if (state.iterator.bytesRemaining() < 16) {
|
|
13
|
-
return
|
|
14
|
-
box: null,
|
|
15
|
-
skipTo: null,
|
|
16
|
-
};
|
|
12
|
+
return null;
|
|
17
13
|
}
|
|
18
14
|
const checkpoint = iterator.startCheckpoint();
|
|
19
15
|
const ckId = iterator.getByteString(4, false);
|
|
@@ -24,14 +20,11 @@ const expectRiffBox = async (state) => {
|
|
|
24
20
|
start: iterator.counter.getOffset(),
|
|
25
21
|
size: ckSize - 4,
|
|
26
22
|
});
|
|
27
|
-
return
|
|
23
|
+
return null;
|
|
28
24
|
}
|
|
29
25
|
if (iterator.bytesRemaining() < ckSize) {
|
|
30
26
|
checkpoint.returnToCheckpoint();
|
|
31
|
-
return
|
|
32
|
-
box: null,
|
|
33
|
-
skipTo: null,
|
|
34
|
-
};
|
|
27
|
+
return null;
|
|
35
28
|
}
|
|
36
29
|
const box = await (0, parse_riff_box_1.parseRiffBox)({
|
|
37
30
|
id: ckId,
|
|
@@ -64,9 +57,6 @@ const expectRiffBox = async (state) => {
|
|
|
64
57
|
}
|
|
65
58
|
state.riff.incrementNextTrackIndex();
|
|
66
59
|
}
|
|
67
|
-
return
|
|
68
|
-
box,
|
|
69
|
-
skipTo: null,
|
|
70
|
-
};
|
|
60
|
+
return box;
|
|
71
61
|
};
|
|
72
62
|
exports.expectRiffBox = expectRiffBox;
|
|
@@ -94,7 +94,7 @@ const getTracksFromAvi = (structure, state) => {
|
|
|
94
94
|
exports.getTracksFromAvi = getTracksFromAvi;
|
|
95
95
|
const hasAllTracksFromAvi = (state) => {
|
|
96
96
|
try {
|
|
97
|
-
const structure = state.
|
|
97
|
+
const structure = state.getRiffStructure();
|
|
98
98
|
const numberOfTracks = (0, exports.getNumberOfTracks)(structure);
|
|
99
99
|
const tracks = (0, exports.getTracksFromAvi)(structure, state);
|
|
100
100
|
return (tracks.videoTracks.length +
|
|
@@ -12,13 +12,11 @@ const parseListBox = async ({ size, state, }) => {
|
|
|
12
12
|
const boxes = [];
|
|
13
13
|
const maxOffset = counter + size;
|
|
14
14
|
while (iterator.counter.getOffset() < maxOffset) {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
boxes.push(result.box);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
15
|
+
const box = await (0, expect_riff_box_1.expectRiffBox)(state);
|
|
16
|
+
if (box === null) {
|
|
20
17
|
throw new Error('Unexpected result');
|
|
21
18
|
}
|
|
19
|
+
boxes.push(box);
|
|
22
20
|
}
|
|
23
21
|
return {
|
|
24
22
|
type: 'list-box',
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { ParserState } from '../../state/parser-state';
|
|
2
|
-
import type { RiffResult } from './expect-riff-box';
|
|
3
2
|
export declare const handleChunk: ({ state, ckId, ckSize, }: {
|
|
4
3
|
state: ParserState;
|
|
5
4
|
ckId: string;
|
|
6
5
|
ckSize: number;
|
|
7
6
|
}) => Promise<void>;
|
|
8
|
-
export declare const parseMovi: ({
|
|
9
|
-
maxOffset: number;
|
|
7
|
+
export declare const parseMovi: ({ state, }: {
|
|
10
8
|
state: ParserState;
|
|
11
|
-
}) => Promise<
|
|
9
|
+
}) => Promise<void>;
|