@remotion/media-parser 4.0.290 → 4.0.292
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/containers/iso-base-media/base-media-box.d.ts +0 -1
- package/dist/containers/iso-base-media/collect-sample-positions-from-moof-boxes.d.ts +4 -1
- package/dist/containers/iso-base-media/collect-sample-positions-from-moof-boxes.js +9 -5
- package/dist/containers/iso-base-media/find-keyframe-before-time.js +16 -11
- package/dist/containers/iso-base-media/find-track-to-seek.d.ts +14 -0
- package/dist/containers/iso-base-media/find-track-to-seek.js +39 -0
- package/dist/containers/iso-base-media/get-children.js +2 -2
- package/dist/containers/iso-base-media/get-keyframes.js +6 -1
- package/dist/containers/iso-base-media/get-mfra-seeking-box.d.ts +3 -1
- package/dist/containers/iso-base-media/get-mfra-seeking-box.js +5 -1
- package/dist/containers/iso-base-media/get-moov-atom.js +6 -3
- package/dist/containers/iso-base-media/get-sample-position-bounds.js +3 -1
- package/dist/containers/iso-base-media/get-sample-positions-from-track.js +1 -1
- package/dist/containers/iso-base-media/get-seeking-byte-from-fragmented-mp4.d.ts +14 -0
- package/dist/containers/iso-base-media/get-seeking-byte-from-fragmented-mp4.js +89 -0
- package/dist/containers/iso-base-media/get-seeking-byte.d.ts +3 -3
- package/dist/containers/iso-base-media/get-seeking-byte.js +32 -96
- package/dist/containers/iso-base-media/mdat/calculate-jump-marks.d.ts +6 -0
- package/dist/containers/iso-base-media/mdat/calculate-jump-marks.js +131 -0
- package/dist/containers/iso-base-media/mdat/mdat.d.ts +2 -2
- package/dist/containers/iso-base-media/mdat/mdat.js +18 -2
- package/dist/containers/iso-base-media/mfra/find-best-segment-from-tfra.d.ts +3 -3
- package/dist/containers/iso-base-media/mfra/find-best-segment-from-tfra.js +2 -2
- package/dist/containers/iso-base-media/mfra/get-mfra-atom.d.ts +5 -1
- package/dist/containers/iso-base-media/mfra/get-mfra-atom.js +3 -1
- package/dist/containers/iso-base-media/mfra/get-mfro-atom.d.ts +5 -1
- package/dist/containers/iso-base-media/mfra/get-mfro-atom.js +3 -1
- package/dist/containers/iso-base-media/parse-boxes.js +5 -2
- package/dist/containers/iso-base-media/process-box.d.ts +16 -5
- package/dist/containers/iso-base-media/process-box.js +206 -118
- package/dist/containers/iso-base-media/sample-positions.d.ts +25 -0
- package/dist/containers/iso-base-media/sample-positions.js +37 -0
- package/dist/containers/iso-base-media/stsd/samples.js +1 -0
- package/dist/containers/iso-base-media/stsd/stsc.d.ts +1 -6
- package/dist/containers/iso-base-media/stsd/stsc.js +2 -5
- package/dist/containers/iso-base-media/stsd/stss.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stss.js +2 -2
- package/dist/containers/iso-base-media/turn-sample-positions-into-array.d.ts +19 -0
- package/dist/containers/iso-base-media/turn-sample-positions-into-array.js +73 -0
- package/dist/containers/m3u/after-manifest-fetch.d.ts +5 -1
- package/dist/containers/m3u/after-manifest-fetch.js +3 -1
- package/dist/containers/m3u/first-sample-in-m3u-chunk.d.ts +13 -0
- package/dist/containers/m3u/first-sample-in-m3u-chunk.js +31 -0
- package/dist/containers/m3u/get-seeking-byte.d.ts +13 -0
- package/dist/containers/m3u/get-seeking-byte.js +32 -0
- package/dist/containers/m3u/get-streams.d.ts +1 -0
- package/dist/containers/m3u/get-streams.js +1 -0
- package/dist/containers/m3u/iterate-over-segment-files.d.ts +5 -3
- package/dist/containers/m3u/iterate-over-segment-files.js +11 -1
- package/dist/containers/m3u/parse-m3u-media-directive.js +1 -0
- package/dist/containers/m3u/parse-m3u.js +8 -0
- package/dist/containers/m3u/process-m3u-chunk.d.ts +12 -0
- package/dist/containers/m3u/process-m3u-chunk.js +274 -0
- package/dist/containers/m3u/run-over-m3u.js +7 -80
- package/dist/containers/m3u/sample-sorter.d.ts +1 -0
- package/dist/containers/m3u/sample-sorter.js +4 -1
- package/dist/containers/m3u/seek/get-chunk-to-seek-to.d.ts +5 -0
- package/dist/containers/m3u/seek/get-chunk-to-seek-to.js +14 -0
- package/dist/containers/m3u/seeking-hints.d.ts +2 -0
- package/dist/containers/m3u/seeking-hints.js +9 -0
- package/dist/containers/m3u/select-stream.d.ts +2 -1
- package/dist/containers/m3u/select-stream.js +7 -2
- package/dist/containers/m3u/types.d.ts +1 -0
- package/dist/containers/riff/seek/fetch-idx1.d.ts +3 -1
- package/dist/containers/riff/seek/fetch-idx1.js +3 -1
- package/dist/containers/transport-stream/handle-aac-packet.d.ts +2 -2
- package/dist/containers/transport-stream/handle-avc-packet.d.ts +2 -2
- package/dist/containers/transport-stream/process-audio.d.ts +2 -2
- package/dist/containers/transport-stream/process-stream-buffers.d.ts +3 -3
- package/dist/containers/transport-stream/process-video.d.ts +2 -2
- package/dist/containers/webm/get-sample-from-block.d.ts +12 -2
- package/dist/containers/webm/get-sample-from-block.js +40 -9
- package/dist/containers/webm/parse-ebml.js +28 -10
- package/dist/containers/webm/seek/fetch-web-cues.d.ts +3 -1
- package/dist/containers/webm/seek/fetch-web-cues.js +3 -1
- package/dist/containers/webm/state-for-processing.d.ts +2 -2
- package/dist/controller/media-parser-controller.d.ts +1 -1
- package/dist/controller/media-parser-controller.js +6 -2
- package/dist/controller/seek-signal.d.ts +1 -5
- package/dist/download-and-parse-media.js +1 -1
- package/dist/esm/index.mjs +1400 -611
- package/dist/esm/node.mjs +23 -3
- package/dist/esm/server-worker.mjs +8 -1
- package/dist/esm/universal.mjs +168 -15
- package/dist/esm/web.mjs +145 -13
- package/dist/esm/worker-server-entry.mjs +1467 -635
- package/dist/esm/worker-web-entry.mjs +1439 -634
- package/dist/esm/worker.mjs +8 -1
- package/dist/get-audio-codec.js +3 -0
- package/dist/get-duration.js +2 -1
- package/dist/get-fps.js +2 -1
- package/dist/get-sample-positions-from-mp4.js +10 -5
- package/dist/get-sample-positions.js +4 -4
- package/dist/get-seeking-byte.d.ts +5 -3
- package/dist/get-seeking-byte.js +19 -10
- package/dist/get-seeking-hints.d.ts +3 -3
- package/dist/get-seeking-hints.js +18 -13
- package/dist/get-tracks.d.ts +9 -1
- package/dist/get-tracks.js +13 -6
- package/dist/index.d.ts +21 -5
- package/dist/init-video.js +3 -2
- package/dist/internal-parse-media.js +13 -4
- package/dist/iterator/buffer-iterator.js +5 -3
- package/dist/metadata/metadata-from-iso.js +2 -1
- package/dist/options.d.ts +6 -1
- package/dist/parse-loop.js +22 -6
- package/dist/parse-media-on-worker-entry.js +1 -0
- package/dist/parse-media.js +1 -1
- package/dist/parse-result.d.ts +2 -2
- package/dist/perform-seek.d.ts +3 -1
- package/dist/perform-seek.js +3 -1
- package/dist/readers/fetch/get-body-and-reader.js +17 -2
- package/dist/readers/from-fetch.d.ts +17 -1
- package/dist/readers/from-fetch.js +68 -13
- package/dist/readers/from-node.js +24 -2
- package/dist/readers/from-web-file.js +3 -0
- package/dist/readers/reader.d.ts +19 -2
- package/dist/readers/universal.js +9 -0
- package/dist/readers/web.js +6 -0
- package/dist/register-track.d.ts +3 -3
- package/dist/seek-backwards.d.ts +3 -1
- package/dist/seek-backwards.js +4 -1
- package/dist/seek-forwards.d.ts +3 -1
- package/dist/seek-forwards.js +3 -1
- package/dist/seeking-hints.d.ts +4 -1
- package/dist/set-seeking-hints.js +4 -0
- package/dist/skip.d.ts +5 -0
- package/dist/skip.js +6 -1
- package/dist/state/can-skip-tracks.d.ts +1 -0
- package/dist/state/can-skip-tracks.js +10 -6
- package/dist/state/iso-base-media/cached-sample-positions.d.ts +15 -1
- package/dist/state/iso-base-media/cached-sample-positions.js +9 -4
- package/dist/state/iso-base-media/iso-state.d.ts +5 -1
- package/dist/state/iso-base-media/iso-state.js +2 -1
- package/dist/state/iso-base-media/lazy-mfra-load.d.ts +3 -1
- package/dist/state/iso-base-media/lazy-mfra-load.js +2 -1
- package/dist/state/keyframes.js +1 -0
- package/dist/state/m3u-state.d.ts +15 -4
- package/dist/state/m3u-state.js +20 -0
- package/dist/state/matroska/lazy-cues-fetch.d.ts +3 -1
- package/dist/state/matroska/lazy-cues-fetch.js +2 -1
- package/dist/state/matroska/webm.d.ts +3 -1
- package/dist/state/matroska/webm.js +2 -1
- package/dist/state/parser-state.d.ts +29 -13
- package/dist/state/parser-state.js +19 -5
- package/dist/state/riff/lazy-idx1-fetch.d.ts +3 -1
- package/dist/state/riff/lazy-idx1-fetch.js +2 -1
- package/dist/state/riff.d.ts +3 -1
- package/dist/state/riff.js +2 -1
- package/dist/state/sample-callbacks.d.ts +3 -2
- package/dist/state/sample-callbacks.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/work-on-seek-request.d.ts +6 -3
- package/dist/work-on-seek-request.js +13 -13
- package/dist/worker/forward-controller-to-worker.js +1 -1
- package/dist/worker/serialize-error.js +26 -3
- package/dist/worker/worker-types.d.ts +7 -1
- package/dist/worker-server.js +2 -2
- package/package.json +3 -3
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.processBox = void 0;
|
|
4
4
|
const log_1 = require("../../log");
|
|
5
5
|
const register_track_1 = require("../../register-track");
|
|
6
|
+
const skip_1 = require("../../skip");
|
|
6
7
|
const esds_1 = require("./esds/esds");
|
|
7
8
|
const ftyp_1 = require("./ftyp");
|
|
8
9
|
const get_children_1 = require("./get-children");
|
|
@@ -41,8 +42,11 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
|
|
|
41
42
|
const boxSizeRaw = iterator.getFourByteNumber();
|
|
42
43
|
if (boxSizeRaw === 0) {
|
|
43
44
|
return {
|
|
44
|
-
type: '
|
|
45
|
-
|
|
45
|
+
type: 'box',
|
|
46
|
+
box: {
|
|
47
|
+
type: 'void-box',
|
|
48
|
+
boxSize: 0,
|
|
49
|
+
},
|
|
46
50
|
};
|
|
47
51
|
}
|
|
48
52
|
// If `boxSize === 1`, the 8 bytes after the box type are the size of the box.
|
|
@@ -58,120 +62,177 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
|
|
|
58
62
|
const headerLength = iterator.counter.getOffset() - startOff;
|
|
59
63
|
if (boxType === 'mdat') {
|
|
60
64
|
if (!onlyIfMdatAtomExpected) {
|
|
61
|
-
return
|
|
65
|
+
return { type: 'nothing' };
|
|
62
66
|
}
|
|
63
67
|
const { mediaSectionState } = onlyIfMdatAtomExpected;
|
|
64
68
|
mediaSectionState.addMediaSection({
|
|
65
69
|
size: boxSize - headerLength,
|
|
66
70
|
start: iterator.counter.getOffset(),
|
|
67
71
|
});
|
|
68
|
-
return
|
|
72
|
+
return { type: 'nothing' };
|
|
69
73
|
}
|
|
70
74
|
if (bytesRemaining < boxSize) {
|
|
71
75
|
returnToCheckpoint();
|
|
72
|
-
return
|
|
76
|
+
return {
|
|
77
|
+
type: 'fetch-more-data',
|
|
78
|
+
bytesNeeded: (0, skip_1.makeFetchMoreData)(boxSize - bytesRemaining),
|
|
79
|
+
};
|
|
73
80
|
}
|
|
74
81
|
if (boxType === 'ftyp') {
|
|
75
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
type: 'box',
|
|
84
|
+
box: await (0, ftyp_1.parseFtyp)({ iterator, size: boxSize, offset: fileOffset }),
|
|
85
|
+
};
|
|
76
86
|
}
|
|
77
87
|
if (boxType === 'colr') {
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
return {
|
|
89
|
+
type: 'box',
|
|
90
|
+
box: await (0, colr_1.parseColorParameterBox)({
|
|
91
|
+
iterator,
|
|
92
|
+
size: boxSize,
|
|
93
|
+
}),
|
|
94
|
+
};
|
|
82
95
|
}
|
|
83
96
|
if (boxType === 'mvhd') {
|
|
84
|
-
return
|
|
97
|
+
return {
|
|
98
|
+
type: 'box',
|
|
99
|
+
box: await (0, mvhd_1.parseMvhd)({ iterator, offset: fileOffset, size: boxSize }),
|
|
100
|
+
};
|
|
85
101
|
}
|
|
86
102
|
if (boxType === 'tkhd') {
|
|
87
|
-
return
|
|
103
|
+
return {
|
|
104
|
+
type: 'box',
|
|
105
|
+
box: await (0, tkhd_1.parseTkhd)({ iterator, offset: fileOffset, size: boxSize }),
|
|
106
|
+
};
|
|
88
107
|
}
|
|
89
108
|
if (boxType === 'trun') {
|
|
90
|
-
return
|
|
109
|
+
return {
|
|
110
|
+
type: 'box',
|
|
111
|
+
box: await (0, trun_1.parseTrun)({ iterator, offset: fileOffset, size: boxSize }),
|
|
112
|
+
};
|
|
91
113
|
}
|
|
92
114
|
if (boxType === 'tfdt') {
|
|
93
|
-
return
|
|
115
|
+
return {
|
|
116
|
+
type: 'box',
|
|
117
|
+
box: await (0, tfdt_1.parseTfdt)({ iterator, size: boxSize, offset: fileOffset }),
|
|
118
|
+
};
|
|
94
119
|
}
|
|
95
120
|
if (boxType === 'stsd') {
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
121
|
+
return {
|
|
122
|
+
type: 'box',
|
|
123
|
+
box: await (0, stsd_1.parseStsd)({
|
|
124
|
+
offset: fileOffset,
|
|
125
|
+
size: boxSize,
|
|
126
|
+
iterator,
|
|
127
|
+
logLevel,
|
|
128
|
+
contentLength,
|
|
129
|
+
}),
|
|
130
|
+
};
|
|
103
131
|
}
|
|
104
132
|
if (boxType === 'stsz') {
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
133
|
+
return {
|
|
134
|
+
type: 'box',
|
|
135
|
+
box: await (0, stsz_1.parseStsz)({
|
|
136
|
+
iterator,
|
|
137
|
+
offset: fileOffset,
|
|
138
|
+
size: boxSize,
|
|
139
|
+
}),
|
|
140
|
+
};
|
|
110
141
|
}
|
|
111
142
|
if (boxType === 'stco' || boxType === 'co64') {
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
143
|
+
return {
|
|
144
|
+
type: 'box',
|
|
145
|
+
box: await (0, stco_1.parseStco)({
|
|
146
|
+
iterator,
|
|
147
|
+
offset: fileOffset,
|
|
148
|
+
size: boxSize,
|
|
149
|
+
mode64Bit: boxType === 'co64',
|
|
150
|
+
}),
|
|
151
|
+
};
|
|
118
152
|
}
|
|
119
153
|
if (boxType === 'pasp') {
|
|
120
|
-
return
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
154
|
+
return {
|
|
155
|
+
type: 'box',
|
|
156
|
+
box: await (0, pasp_1.parsePasp)({
|
|
157
|
+
iterator,
|
|
158
|
+
offset: fileOffset,
|
|
159
|
+
size: boxSize,
|
|
160
|
+
}),
|
|
161
|
+
};
|
|
125
162
|
}
|
|
126
163
|
if (boxType === 'stss') {
|
|
127
|
-
return
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
164
|
+
return {
|
|
165
|
+
type: 'box',
|
|
166
|
+
box: await (0, stss_1.parseStss)({
|
|
167
|
+
iterator,
|
|
168
|
+
offset: fileOffset,
|
|
169
|
+
boxSize,
|
|
170
|
+
}),
|
|
171
|
+
};
|
|
132
172
|
}
|
|
133
173
|
if (boxType === 'ctts') {
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
174
|
+
return {
|
|
175
|
+
type: 'box',
|
|
176
|
+
box: await (0, ctts_1.parseCtts)({
|
|
177
|
+
iterator,
|
|
178
|
+
offset: fileOffset,
|
|
179
|
+
size: boxSize,
|
|
180
|
+
}),
|
|
181
|
+
};
|
|
139
182
|
}
|
|
140
183
|
if (boxType === 'stsc') {
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
184
|
+
return {
|
|
185
|
+
type: 'box',
|
|
186
|
+
box: await (0, stsc_1.parseStsc)({
|
|
187
|
+
iterator,
|
|
188
|
+
offset: fileOffset,
|
|
189
|
+
size: boxSize,
|
|
190
|
+
}),
|
|
191
|
+
};
|
|
146
192
|
}
|
|
147
193
|
if (boxType === 'mebx') {
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
194
|
+
return {
|
|
195
|
+
type: 'box',
|
|
196
|
+
box: await (0, mebx_1.parseMebx)({
|
|
197
|
+
offset: fileOffset,
|
|
198
|
+
size: boxSize,
|
|
199
|
+
iterator,
|
|
200
|
+
logLevel,
|
|
201
|
+
contentLength,
|
|
202
|
+
}),
|
|
203
|
+
};
|
|
155
204
|
}
|
|
156
205
|
if (boxType === 'hdlr') {
|
|
157
|
-
return
|
|
206
|
+
return {
|
|
207
|
+
type: 'box',
|
|
208
|
+
box: await (0, hdlr_1.parseHdlr)({ iterator, size: boxSize, offset: fileOffset }),
|
|
209
|
+
};
|
|
158
210
|
}
|
|
159
211
|
if (boxType === 'keys') {
|
|
160
|
-
return
|
|
212
|
+
return {
|
|
213
|
+
type: 'box',
|
|
214
|
+
box: await (0, keys_1.parseKeys)({ iterator, size: boxSize, offset: fileOffset }),
|
|
215
|
+
};
|
|
161
216
|
}
|
|
162
217
|
if (boxType === 'ilst') {
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
218
|
+
return {
|
|
219
|
+
type: 'box',
|
|
220
|
+
box: await (0, ilst_1.parseIlstBox)({
|
|
221
|
+
iterator,
|
|
222
|
+
offset: fileOffset,
|
|
223
|
+
size: boxSize,
|
|
224
|
+
}),
|
|
225
|
+
};
|
|
168
226
|
}
|
|
169
227
|
if (boxType === 'tfra') {
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
228
|
+
return {
|
|
229
|
+
type: 'box',
|
|
230
|
+
box: await (0, tfra_1.parseTfraBox)({
|
|
231
|
+
iterator,
|
|
232
|
+
offset: fileOffset,
|
|
233
|
+
size: boxSize,
|
|
234
|
+
}),
|
|
235
|
+
};
|
|
175
236
|
}
|
|
176
237
|
if (boxType === 'moov') {
|
|
177
238
|
if (!onlyIfMoovAtomExpected) {
|
|
@@ -180,14 +241,14 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
|
|
|
180
241
|
const { tracks, isoState } = onlyIfMoovAtomExpected;
|
|
181
242
|
if (tracks.hasAllTracks()) {
|
|
182
243
|
iterator.discard(boxSize - 8);
|
|
183
|
-
return
|
|
244
|
+
return { type: 'nothing' };
|
|
184
245
|
}
|
|
185
246
|
if (isoState &&
|
|
186
247
|
isoState.moov.getMoovBoxAndPrecomputed() &&
|
|
187
248
|
!((_a = isoState.moov.getMoovBoxAndPrecomputed()) === null || _a === void 0 ? void 0 : _a.precomputed)) {
|
|
188
249
|
log_1.Log.verbose(logLevel, 'Moov box already parsed, skipping');
|
|
189
250
|
iterator.discard(boxSize - 8);
|
|
190
|
-
return
|
|
251
|
+
return { type: 'nothing' };
|
|
191
252
|
}
|
|
192
253
|
const box = await (0, moov_1.parseMoov)({
|
|
193
254
|
offset: fileOffset,
|
|
@@ -198,7 +259,7 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
|
|
|
198
259
|
contentLength,
|
|
199
260
|
});
|
|
200
261
|
tracks.setIsDone(logLevel);
|
|
201
|
-
return box;
|
|
262
|
+
return { type: 'box', box };
|
|
202
263
|
}
|
|
203
264
|
if (boxType === 'trak') {
|
|
204
265
|
if (!onlyIfMoovAtomExpected) {
|
|
@@ -233,54 +294,75 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
|
|
|
233
294
|
onAudioTrack,
|
|
234
295
|
});
|
|
235
296
|
}
|
|
236
|
-
return box;
|
|
297
|
+
return { type: 'box', box };
|
|
237
298
|
}
|
|
238
299
|
if (boxType === 'stts') {
|
|
239
|
-
return
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
300
|
+
return {
|
|
301
|
+
type: 'box',
|
|
302
|
+
box: await (0, stts_1.parseStts)({
|
|
303
|
+
data: iterator,
|
|
304
|
+
size: boxSize,
|
|
305
|
+
fileOffset,
|
|
306
|
+
}),
|
|
307
|
+
};
|
|
244
308
|
}
|
|
245
309
|
if (boxType === 'avcC') {
|
|
246
|
-
return
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
310
|
+
return {
|
|
311
|
+
type: 'box',
|
|
312
|
+
box: await (0, avcc_1.parseAvcc)({
|
|
313
|
+
data: iterator,
|
|
314
|
+
size: boxSize,
|
|
315
|
+
}),
|
|
316
|
+
};
|
|
250
317
|
}
|
|
251
318
|
if (boxType === 'av1C') {
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
319
|
+
return {
|
|
320
|
+
type: 'box',
|
|
321
|
+
box: await (0, av1c_1.parseAv1C)({
|
|
322
|
+
data: iterator,
|
|
323
|
+
size: boxSize,
|
|
324
|
+
}),
|
|
325
|
+
};
|
|
256
326
|
}
|
|
257
327
|
if (boxType === 'hvcC') {
|
|
258
|
-
return
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
328
|
+
return {
|
|
329
|
+
type: 'box',
|
|
330
|
+
box: await (0, hvcc_1.parseHvcc)({
|
|
331
|
+
data: iterator,
|
|
332
|
+
size: boxSize,
|
|
333
|
+
offset: fileOffset,
|
|
334
|
+
}),
|
|
335
|
+
};
|
|
263
336
|
}
|
|
264
337
|
if (boxType === 'tfhd') {
|
|
265
|
-
return
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
338
|
+
return {
|
|
339
|
+
type: 'box',
|
|
340
|
+
box: await (0, tfhd_1.getTfhd)({
|
|
341
|
+
iterator,
|
|
342
|
+
offset: fileOffset,
|
|
343
|
+
size: boxSize,
|
|
344
|
+
}),
|
|
345
|
+
};
|
|
270
346
|
}
|
|
271
347
|
if (boxType === 'mdhd') {
|
|
272
|
-
return
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
348
|
+
return {
|
|
349
|
+
type: 'box',
|
|
350
|
+
box: await (0, mdhd_1.parseMdhd)({
|
|
351
|
+
data: iterator,
|
|
352
|
+
size: boxSize,
|
|
353
|
+
fileOffset,
|
|
354
|
+
}),
|
|
355
|
+
};
|
|
277
356
|
}
|
|
278
357
|
if (boxType === 'esds') {
|
|
279
|
-
return
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
358
|
+
return {
|
|
359
|
+
type: 'box',
|
|
360
|
+
box: await (0, esds_1.parseEsds)({
|
|
361
|
+
data: iterator,
|
|
362
|
+
size: boxSize,
|
|
363
|
+
fileOffset,
|
|
364
|
+
}),
|
|
365
|
+
};
|
|
284
366
|
}
|
|
285
367
|
if (boxType === 'moof') {
|
|
286
368
|
(_b = onlyIfMoovAtomExpected === null || onlyIfMoovAtomExpected === void 0 ? void 0 : onlyIfMoovAtomExpected.isoState) === null || _b === void 0 ? void 0 : _b.mfra.triggerLoad();
|
|
@@ -304,20 +386,26 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
|
|
|
304
386
|
contentLength,
|
|
305
387
|
});
|
|
306
388
|
return {
|
|
307
|
-
type: '
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
389
|
+
type: 'box',
|
|
390
|
+
box: {
|
|
391
|
+
type: 'regular-box',
|
|
392
|
+
boxType,
|
|
393
|
+
boxSize,
|
|
394
|
+
children,
|
|
395
|
+
offset: fileOffset,
|
|
396
|
+
},
|
|
312
397
|
};
|
|
313
398
|
}
|
|
314
399
|
iterator.discard(boxSize - 8);
|
|
315
400
|
return {
|
|
316
|
-
type: '
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
401
|
+
type: 'box',
|
|
402
|
+
box: {
|
|
403
|
+
type: 'regular-box',
|
|
404
|
+
boxType,
|
|
405
|
+
boxSize,
|
|
406
|
+
children: [],
|
|
407
|
+
offset: fileOffset,
|
|
408
|
+
},
|
|
321
409
|
};
|
|
322
410
|
};
|
|
323
411
|
exports.processBox = processBox;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SamplePosition } from '../../get-sample-positions';
|
|
2
|
+
import type { CttsBox } from './stsd/ctts';
|
|
3
|
+
import type { StcoBox } from './stsd/stco';
|
|
4
|
+
import type { StscBox } from './stsd/stsc';
|
|
5
|
+
import type { StssBox } from './stsd/stss';
|
|
6
|
+
import type { StszBox } from './stsd/stsz';
|
|
7
|
+
import type { SttsBox } from './stsd/stts';
|
|
8
|
+
export type GroupOfSamplePositions = {
|
|
9
|
+
type: 'array';
|
|
10
|
+
boxes: SamplePosition[];
|
|
11
|
+
} | {
|
|
12
|
+
type: 'map';
|
|
13
|
+
boxes: {
|
|
14
|
+
stszBox: StszBox;
|
|
15
|
+
stcoBox: StcoBox;
|
|
16
|
+
stscBox: StscBox;
|
|
17
|
+
sttsBox: SttsBox;
|
|
18
|
+
stssBox: StssBox | null;
|
|
19
|
+
cttsBox: CttsBox | null;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare const hasNoSamplePositions: (samplePositions: GroupOfSamplePositions) => boolean;
|
|
23
|
+
export declare const hasNoSamplePositionsGroup: (samplePositions: GroupOfSamplePositions[]) => boolean;
|
|
24
|
+
export declare const getKeyframesFromGroupOfSamplePositions: (samplePositions: GroupOfSamplePositions) => SamplePosition[];
|
|
25
|
+
export declare const groupGetKeyframesFromGroupOfSamplePositions: (samplePositions: GroupOfSamplePositions[]) => SamplePosition[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.groupGetKeyframesFromGroupOfSamplePositions = exports.getKeyframesFromGroupOfSamplePositions = exports.hasNoSamplePositionsGroup = exports.hasNoSamplePositions = void 0;
|
|
4
|
+
const turn_sample_positions_into_array_1 = require("./turn-sample-positions-into-array");
|
|
5
|
+
const hasNoSamplePositions = (samplePositions) => {
|
|
6
|
+
if (samplePositions.type === 'array') {
|
|
7
|
+
return samplePositions.boxes.length === 0;
|
|
8
|
+
}
|
|
9
|
+
return samplePositions.boxes.stcoBox.entryCount === 0;
|
|
10
|
+
};
|
|
11
|
+
exports.hasNoSamplePositions = hasNoSamplePositions;
|
|
12
|
+
const hasNoSamplePositionsGroup = (samplePositions) => {
|
|
13
|
+
return samplePositions.every((s) => (0, exports.hasNoSamplePositions)(s));
|
|
14
|
+
};
|
|
15
|
+
exports.hasNoSamplePositionsGroup = hasNoSamplePositionsGroup;
|
|
16
|
+
const getKeyframesFromGroupOfSamplePositions = (samplePositions) => {
|
|
17
|
+
if (samplePositions.type === 'array') {
|
|
18
|
+
return samplePositions.boxes.filter((s) => s.isKeyframe);
|
|
19
|
+
}
|
|
20
|
+
if (!samplePositions.boxes.stssBox) {
|
|
21
|
+
return (0, turn_sample_positions_into_array_1.turnSamplePositionsIntoArraySlow)({
|
|
22
|
+
...samplePositions.boxes,
|
|
23
|
+
onlyKeyframes: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return (0, turn_sample_positions_into_array_1.turnSamplePositionsIntoArraySlow)({
|
|
27
|
+
...samplePositions.boxes,
|
|
28
|
+
onlyKeyframes: false,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.getKeyframesFromGroupOfSamplePositions = getKeyframesFromGroupOfSamplePositions;
|
|
32
|
+
const groupGetKeyframesFromGroupOfSamplePositions = (samplePositions) => {
|
|
33
|
+
return samplePositions
|
|
34
|
+
.map((s) => (0, exports.getKeyframesFromGroupOfSamplePositions)(s))
|
|
35
|
+
.flat();
|
|
36
|
+
};
|
|
37
|
+
exports.groupGetKeyframesFromGroupOfSamplePositions = groupGetKeyframesFromGroupOfSamplePositions;
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../iterator/buffer-iterator';
|
|
2
2
|
import type { BaseBox } from '../base-type';
|
|
3
|
-
type StscEntry = {
|
|
4
|
-
firstChunk: number;
|
|
5
|
-
samplesPerChunk: number;
|
|
6
|
-
};
|
|
7
3
|
export interface StscBox extends BaseBox {
|
|
8
4
|
type: 'stsc-box';
|
|
9
5
|
version: number;
|
|
10
6
|
flags: number[];
|
|
11
7
|
entryCount: number;
|
|
12
|
-
entries:
|
|
8
|
+
entries: Map<number, number>;
|
|
13
9
|
}
|
|
14
10
|
export declare const parseStsc: ({ iterator, offset, size, }: {
|
|
15
11
|
iterator: BufferIterator;
|
|
16
12
|
offset: number;
|
|
17
13
|
size: number;
|
|
18
14
|
}) => StscBox;
|
|
19
|
-
export {};
|
|
@@ -8,7 +8,7 @@ const parseStsc = ({ iterator, offset, size, }) => {
|
|
|
8
8
|
}
|
|
9
9
|
const flags = iterator.getSlice(3);
|
|
10
10
|
const entryCount = iterator.getUint32();
|
|
11
|
-
const entries =
|
|
11
|
+
const entries = new Map();
|
|
12
12
|
for (let i = 0; i < entryCount; i++) {
|
|
13
13
|
const firstChunk = iterator.getUint32();
|
|
14
14
|
const samplesPerChunk = iterator.getUint32();
|
|
@@ -16,10 +16,7 @@ const parseStsc = ({ iterator, offset, size, }) => {
|
|
|
16
16
|
if (sampleDescriptionIndex !== 1) {
|
|
17
17
|
throw new Error(`Expected sampleDescriptionIndex to be 1, but got ${sampleDescriptionIndex}`);
|
|
18
18
|
}
|
|
19
|
-
entries.
|
|
20
|
-
firstChunk,
|
|
21
|
-
samplesPerChunk,
|
|
22
|
-
});
|
|
19
|
+
entries.set(firstChunk, samplesPerChunk);
|
|
23
20
|
}
|
|
24
21
|
return {
|
|
25
22
|
type: 'stsc-box',
|
|
@@ -8,9 +8,9 @@ const parseStss = ({ iterator, offset, boxSize, }) => {
|
|
|
8
8
|
}
|
|
9
9
|
const flags = iterator.getSlice(3);
|
|
10
10
|
const sampleCount = iterator.getUint32();
|
|
11
|
-
const sampleNumber =
|
|
11
|
+
const sampleNumber = new Set();
|
|
12
12
|
for (let i = 0; i < sampleCount; i++) {
|
|
13
|
-
sampleNumber.
|
|
13
|
+
sampleNumber.add(iterator.getUint32());
|
|
14
14
|
}
|
|
15
15
|
const bytesRemainingInBox = boxSize - (iterator.counter.getOffset() - offset);
|
|
16
16
|
if (bytesRemainingInBox > 0) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SamplePosition } from '../../get-sample-positions';
|
|
2
|
+
import type { GroupOfSamplePositions } from './sample-positions';
|
|
3
|
+
import type { CttsBox } from './stsd/ctts';
|
|
4
|
+
import type { StcoBox } from './stsd/stco';
|
|
5
|
+
import type { StscBox } from './stsd/stsc';
|
|
6
|
+
import type { StssBox } from './stsd/stss';
|
|
7
|
+
import type { StszBox } from './stsd/stsz';
|
|
8
|
+
import type { SttsBox } from './stsd/stts';
|
|
9
|
+
export declare const turnSamplePositionsIntoArraySlow: ({ stcoBox, stszBox, stscBox, stssBox, sttsBox, cttsBox, onlyKeyframes, }: {
|
|
10
|
+
stcoBox: StcoBox;
|
|
11
|
+
stszBox: StszBox;
|
|
12
|
+
stscBox: StscBox;
|
|
13
|
+
stssBox: StssBox | null;
|
|
14
|
+
sttsBox: SttsBox;
|
|
15
|
+
cttsBox: CttsBox | null;
|
|
16
|
+
onlyKeyframes: boolean;
|
|
17
|
+
}) => SamplePosition[];
|
|
18
|
+
export declare const turnIntoOld: (samplePositions: GroupOfSamplePositions) => SamplePosition[];
|
|
19
|
+
export declare const turnGroupIntoOld: (samplePositions: GroupOfSamplePositions[]) => SamplePosition[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.turnGroupIntoOld = exports.turnIntoOld = exports.turnSamplePositionsIntoArraySlow = void 0;
|
|
4
|
+
const turnSamplePositionsIntoArraySlow = ({ stcoBox, stszBox, stscBox, stssBox, sttsBox, cttsBox, onlyKeyframes, }) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const sttsDeltas = [];
|
|
7
|
+
for (const distribution of sttsBox.sampleDistribution) {
|
|
8
|
+
for (let i = 0; i < distribution.sampleCount; i++) {
|
|
9
|
+
sttsDeltas.push(distribution.sampleDelta);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const cttsEntries = [];
|
|
13
|
+
for (const entry of (_a = cttsBox === null || cttsBox === void 0 ? void 0 : cttsBox.entries) !== null && _a !== void 0 ? _a : [
|
|
14
|
+
{ sampleCount: sttsDeltas.length, sampleOffset: 0 },
|
|
15
|
+
]) {
|
|
16
|
+
for (let i = 0; i < entry.sampleCount; i++) {
|
|
17
|
+
cttsEntries.push(entry.sampleOffset);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
let dts = 0;
|
|
21
|
+
const samples = [];
|
|
22
|
+
let samplesPerChunk = 1;
|
|
23
|
+
for (let i = 0; i < stcoBox.entries.length; i++) {
|
|
24
|
+
const hasEntry = stscBox.entries.find((entry) => entry.firstChunk === i + 1);
|
|
25
|
+
if (hasEntry) {
|
|
26
|
+
samplesPerChunk = hasEntry.samplesPerChunk;
|
|
27
|
+
}
|
|
28
|
+
let offsetInThisChunk = 0;
|
|
29
|
+
for (let j = 0; j < samplesPerChunk; j++) {
|
|
30
|
+
const isKeyframe = stssBox
|
|
31
|
+
? stssBox.sampleNumber.includes(samples.length + 1)
|
|
32
|
+
: true;
|
|
33
|
+
if (onlyKeyframes && !isKeyframe) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const size = stszBox.countType === 'fixed'
|
|
37
|
+
? stszBox.sampleSize
|
|
38
|
+
: stszBox.entries[samples.length];
|
|
39
|
+
const delta = sttsDeltas[samples.length];
|
|
40
|
+
const ctsOffset = cttsEntries[samples.length];
|
|
41
|
+
const cts = dts + ctsOffset;
|
|
42
|
+
samples.push({
|
|
43
|
+
offset: Number(stcoBox.entries[i]) + offsetInThisChunk,
|
|
44
|
+
size,
|
|
45
|
+
isKeyframe,
|
|
46
|
+
dts,
|
|
47
|
+
cts,
|
|
48
|
+
duration: delta,
|
|
49
|
+
chunk: i,
|
|
50
|
+
bigEndian: false,
|
|
51
|
+
chunkSize: null,
|
|
52
|
+
});
|
|
53
|
+
dts += delta;
|
|
54
|
+
offsetInThisChunk += size;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return samples;
|
|
58
|
+
};
|
|
59
|
+
exports.turnSamplePositionsIntoArraySlow = turnSamplePositionsIntoArraySlow;
|
|
60
|
+
const turnIntoOld = (samplePositions) => {
|
|
61
|
+
if (samplePositions.type === 'map') {
|
|
62
|
+
return (0, exports.turnSamplePositionsIntoArraySlow)({
|
|
63
|
+
...samplePositions.boxes,
|
|
64
|
+
onlyKeyframes: false,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return samplePositions.boxes;
|
|
68
|
+
};
|
|
69
|
+
exports.turnIntoOld = turnIntoOld;
|
|
70
|
+
const turnGroupIntoOld = (samplePositions) => {
|
|
71
|
+
return samplePositions.map((s) => (0, exports.turnIntoOld)(s)).flat();
|
|
72
|
+
};
|
|
73
|
+
exports.turnGroupIntoOld = turnGroupIntoOld;
|