@remotion/media-parser 4.0.289 → 4.0.291
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/flac/get-channel-count.d.ts +1 -1
- 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/get-video-codec-from-iso-track.d.ts +1 -1
- 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/seeking-hints.d.ts +1 -1
- 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/mp3/get-duration.d.ts +5 -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/wav/get-duration-from-wav.d.ts +0 -1
- 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/mp3.d.ts +16 -5
- package/dist/state/mp3.js +7 -5
- package/dist/state/parser-state.d.ts +31 -15
- package/dist/state/parser-state.js +19 -5
- package/dist/state/riff/lazy-idx1-fetch.d.ts +5 -3
- package/dist/state/riff/lazy-idx1-fetch.js +2 -1
- package/dist/state/riff.d.ts +5 -3
- 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
package/dist/esm/worker.mjs
CHANGED
|
@@ -144,8 +144,14 @@ var deserializeError = (error) => {
|
|
|
144
144
|
});
|
|
145
145
|
case "MediaParserAbortError":
|
|
146
146
|
return new MediaParserAbortError(error.errorMessage);
|
|
147
|
-
|
|
147
|
+
case "Error":
|
|
148
|
+
return new Error(error.errorMessage);
|
|
149
|
+
case "AbortError":
|
|
148
150
|
return new Error(error.errorMessage);
|
|
151
|
+
case "NotReadableError":
|
|
152
|
+
return new Error(error.errorMessage);
|
|
153
|
+
default:
|
|
154
|
+
throw new Error(`Unknown error name: ${error}`);
|
|
149
155
|
}
|
|
150
156
|
};
|
|
151
157
|
|
|
@@ -280,6 +286,7 @@ var parseMediaOnWorkerImplementation = async ({ controller, reader, ...params },
|
|
|
280
286
|
if (data.type === "response-error") {
|
|
281
287
|
cleanup();
|
|
282
288
|
const error = deserializeError(data);
|
|
289
|
+
error.stack = data.errorStack;
|
|
283
290
|
reject(error);
|
|
284
291
|
if (data.errorName === "MediaParserAbortError") {
|
|
285
292
|
finalSeekingHints = data.seekingHints;
|
package/dist/get-audio-codec.js
CHANGED
|
@@ -223,6 +223,9 @@ const getAudioCodecFromAudioCodecInfo = (codec) => {
|
|
|
223
223
|
if (codec.format === 'ac-3') {
|
|
224
224
|
return 'ac3';
|
|
225
225
|
}
|
|
226
|
+
if (codec.format === 'Opus') {
|
|
227
|
+
return 'opus';
|
|
228
|
+
}
|
|
226
229
|
if (codec.format === 'mp4a') {
|
|
227
230
|
if (codec.primarySpecificator === 0x40) {
|
|
228
231
|
return 'aac';
|
package/dist/get-duration.js
CHANGED
|
@@ -39,11 +39,12 @@ const isMatroska = (boxes) => {
|
|
|
39
39
|
};
|
|
40
40
|
exports.isMatroska = isMatroska;
|
|
41
41
|
const getDurationFromIsoBaseMedia = (parserState) => {
|
|
42
|
+
var _a, _b;
|
|
42
43
|
const structure = parserState.structure.getIsoStructure();
|
|
43
44
|
const moovBox = (0, traversal_1.getMoovBoxFromState)({
|
|
44
45
|
structureState: parserState.structure,
|
|
45
46
|
isoState: parserState.iso,
|
|
46
|
-
mp4HeaderSegment: parserState.mp4HeaderSegment,
|
|
47
|
+
mp4HeaderSegment: (_b = (_a = parserState.m3uPlaylistContext) === null || _a === void 0 ? void 0 : _a.mp4HeaderSegment) !== null && _b !== void 0 ? _b : null,
|
|
47
48
|
mayUsePrecomputed: true,
|
|
48
49
|
});
|
|
49
50
|
if (!moovBox) {
|
package/dist/get-fps.js
CHANGED
|
@@ -65,10 +65,11 @@ const getFpsFromMp4TrakBox = (trakBox) => {
|
|
|
65
65
|
};
|
|
66
66
|
exports.getFpsFromMp4TrakBox = getFpsFromMp4TrakBox;
|
|
67
67
|
const getFpsFromIsoMaseMedia = (state) => {
|
|
68
|
+
var _a, _b;
|
|
68
69
|
const moovBox = (0, traversal_1.getMoovBoxFromState)({
|
|
69
70
|
structureState: state.structure,
|
|
70
71
|
isoState: state.iso,
|
|
71
|
-
mp4HeaderSegment: state.mp4HeaderSegment,
|
|
72
|
+
mp4HeaderSegment: (_b = (_a = state.m3uPlaylistContext) === null || _a === void 0 ? void 0 : _a.mp4HeaderSegment) !== null && _b !== void 0 ? _b : null,
|
|
72
73
|
mayUsePrecomputed: true,
|
|
73
74
|
});
|
|
74
75
|
if (!moovBox) {
|
|
@@ -23,11 +23,16 @@ const getGroupedSamplesPositionsFromMp4 = ({ trakBox, bigEndian, }) => {
|
|
|
23
23
|
}
|
|
24
24
|
const samples = [];
|
|
25
25
|
let timestamp = 0;
|
|
26
|
+
const stscKeys = Array.from(stscBox.entries.keys());
|
|
26
27
|
for (let i = 0; i < stcoBox.entries.length; i++) {
|
|
27
28
|
const entry = stcoBox.entries[i];
|
|
28
29
|
const chunk = i + 1;
|
|
29
|
-
const stscEntry =
|
|
30
|
-
if (
|
|
30
|
+
const stscEntry = stscKeys.findLast((e) => e <= chunk);
|
|
31
|
+
if (stscEntry === undefined) {
|
|
32
|
+
throw new Error('should not be');
|
|
33
|
+
}
|
|
34
|
+
const samplesPerChunk = stscBox.entries.get(stscEntry);
|
|
35
|
+
if (samplesPerChunk === undefined) {
|
|
31
36
|
throw new Error('should not be');
|
|
32
37
|
}
|
|
33
38
|
samples.push({
|
|
@@ -35,13 +40,13 @@ const getGroupedSamplesPositionsFromMp4 = ({ trakBox, bigEndian, }) => {
|
|
|
35
40
|
cts: timestamp,
|
|
36
41
|
dts: timestamp,
|
|
37
42
|
offset: Number(entry),
|
|
38
|
-
size: stszBox.sampleSize *
|
|
39
|
-
duration:
|
|
43
|
+
size: stszBox.sampleSize * samplesPerChunk,
|
|
44
|
+
duration: samplesPerChunk,
|
|
40
45
|
isKeyframe: true,
|
|
41
46
|
bigEndian,
|
|
42
47
|
chunkSize: stszBox.sampleSize,
|
|
43
48
|
});
|
|
44
|
-
timestamp +=
|
|
49
|
+
timestamp += samplesPerChunk;
|
|
45
50
|
}
|
|
46
51
|
return samples;
|
|
47
52
|
};
|
|
@@ -22,9 +22,9 @@ const getSamplePositions = ({ stcoBox, stszBox, stscBox, stssBox, sttsBox, cttsB
|
|
|
22
22
|
const samples = [];
|
|
23
23
|
let samplesPerChunk = 1;
|
|
24
24
|
for (let i = 0; i < chunks.length; i++) {
|
|
25
|
-
const hasEntry = stscBox.entries.
|
|
26
|
-
if (hasEntry) {
|
|
27
|
-
samplesPerChunk = hasEntry
|
|
25
|
+
const hasEntry = stscBox.entries.get(i + 1);
|
|
26
|
+
if (hasEntry !== undefined) {
|
|
27
|
+
samplesPerChunk = hasEntry;
|
|
28
28
|
}
|
|
29
29
|
let offsetInThisChunk = 0;
|
|
30
30
|
for (let j = 0; j < samplesPerChunk; j++) {
|
|
@@ -32,7 +32,7 @@ const getSamplePositions = ({ stcoBox, stszBox, stscBox, stssBox, sttsBox, cttsB
|
|
|
32
32
|
? stszBox.sampleSize
|
|
33
33
|
: stszBox.entries[samples.length];
|
|
34
34
|
const isKeyframe = stssBox
|
|
35
|
-
? stssBox.sampleNumber.
|
|
35
|
+
? stssBox.sampleNumber.has(samples.length + 1)
|
|
36
36
|
: true;
|
|
37
37
|
const delta = sttsDeltas[samples.length];
|
|
38
38
|
const ctsOffset = cttsEntries[samples.length];
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { LogLevel } from './log';
|
|
2
|
-
import type {
|
|
2
|
+
import type { M3uPlaylistContext } from './options';
|
|
3
3
|
import type { SeekingHints } from './seeking-hints';
|
|
4
4
|
import type { IsoBaseMediaState } from './state/iso-base-media/iso-state';
|
|
5
|
+
import type { M3uState } from './state/m3u-state';
|
|
5
6
|
import type { WebmState } from './state/matroska/webm';
|
|
6
7
|
import type { RiffState } from './state/riff';
|
|
7
8
|
import type { StructureState } from './state/structure';
|
|
8
9
|
import type { TransportStreamState } from './state/transport-stream/transport-stream';
|
|
9
10
|
import type { MediaSectionState } from './state/video-section';
|
|
10
11
|
import type { SeekResolution } from './work-on-seek-request';
|
|
11
|
-
export declare const getSeekingByte: ({ info, time, logLevel, currentPosition, isoState, transportStream, webmState, mediaSection,
|
|
12
|
+
export declare const getSeekingByte: ({ info, time, logLevel, currentPosition, isoState, transportStream, webmState, mediaSection, m3uPlaylistContext, structure, riffState, m3uState, }: {
|
|
12
13
|
info: SeekingHints;
|
|
13
14
|
time: number;
|
|
14
15
|
logLevel: LogLevel;
|
|
@@ -18,6 +19,7 @@ export declare const getSeekingByte: ({ info, time, logLevel, currentPosition, i
|
|
|
18
19
|
webmState: WebmState;
|
|
19
20
|
mediaSection: MediaSectionState;
|
|
20
21
|
structure: StructureState;
|
|
21
|
-
|
|
22
|
+
m3uPlaylistContext: M3uPlaylistContext | null;
|
|
22
23
|
riffState: RiffState;
|
|
24
|
+
m3uState: M3uState;
|
|
23
25
|
}) => Promise<SeekResolution>;
|
package/dist/get-seeking-byte.js
CHANGED
|
@@ -4,12 +4,13 @@ exports.getSeekingByte = void 0;
|
|
|
4
4
|
const get_seeking_byte_1 = require("./containers/aac/get-seeking-byte");
|
|
5
5
|
const get_seeking_byte_2 = require("./containers/flac/get-seeking-byte");
|
|
6
6
|
const get_seeking_byte_3 = require("./containers/iso-base-media/get-seeking-byte");
|
|
7
|
-
const get_seeking_byte_4 = require("./containers/
|
|
8
|
-
const get_seeking_byte_5 = require("./containers/
|
|
9
|
-
const get_seeking_byte_6 = require("./containers/
|
|
10
|
-
const get_seeking_byte_7 = require("./containers/
|
|
7
|
+
const get_seeking_byte_4 = require("./containers/m3u/get-seeking-byte");
|
|
8
|
+
const get_seeking_byte_5 = require("./containers/mp3/get-seeking-byte");
|
|
9
|
+
const get_seeking_byte_6 = require("./containers/riff/get-seeking-byte");
|
|
10
|
+
const get_seeking_byte_7 = require("./containers/wav/get-seeking-byte");
|
|
11
|
+
const get_seeking_byte_8 = require("./containers/webm/seek/get-seeking-byte");
|
|
11
12
|
const observed_pes_header_1 = require("./state/transport-stream/observed-pes-header");
|
|
12
|
-
const getSeekingByte = ({ info, time, logLevel, currentPosition, isoState, transportStream, webmState, mediaSection,
|
|
13
|
+
const getSeekingByte = ({ info, time, logLevel, currentPosition, isoState, transportStream, webmState, mediaSection, m3uPlaylistContext, structure, riffState, m3uState, }) => {
|
|
13
14
|
var _a;
|
|
14
15
|
if (info.type === 'iso-base-media-seeking-hints') {
|
|
15
16
|
return (0, get_seeking_byte_3.getSeekingByteFromIsoBaseMedia)({
|
|
@@ -18,18 +19,18 @@ const getSeekingByte = ({ info, time, logLevel, currentPosition, isoState, trans
|
|
|
18
19
|
logLevel,
|
|
19
20
|
currentPosition,
|
|
20
21
|
isoState,
|
|
21
|
-
mp4HeaderSegment,
|
|
22
22
|
structure,
|
|
23
|
+
m3uPlaylistContext,
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
if (info.type === 'wav-seeking-hints') {
|
|
26
|
-
return (0,
|
|
27
|
+
return (0, get_seeking_byte_7.getSeekingByteFromWav)({
|
|
27
28
|
info,
|
|
28
29
|
time,
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
if (info.type === 'webm-seeking-hints') {
|
|
32
|
-
return (0,
|
|
33
|
+
return (0, get_seeking_byte_8.getSeekingByteFromMatroska)({
|
|
33
34
|
info,
|
|
34
35
|
time,
|
|
35
36
|
webmState,
|
|
@@ -66,14 +67,14 @@ const getSeekingByte = ({ info, time, logLevel, currentPosition, isoState, trans
|
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
if (info.type === 'riff-seeking-hints') {
|
|
69
|
-
return (0,
|
|
70
|
+
return (0, get_seeking_byte_6.getSeekingByteForRiff)({
|
|
70
71
|
info,
|
|
71
72
|
time,
|
|
72
73
|
riffState,
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
if (info.type === 'mp3-seeking-hints') {
|
|
76
|
-
return Promise.resolve((0,
|
|
77
|
+
return Promise.resolve((0, get_seeking_byte_5.getSeekingByteForMp3)({
|
|
77
78
|
info,
|
|
78
79
|
time,
|
|
79
80
|
}));
|
|
@@ -84,6 +85,14 @@ const getSeekingByte = ({ info, time, logLevel, currentPosition, isoState, trans
|
|
|
84
85
|
seekingHints: info,
|
|
85
86
|
}));
|
|
86
87
|
}
|
|
88
|
+
if (info.type === 'm3u8-seeking-hints') {
|
|
89
|
+
return Promise.resolve((0, get_seeking_byte_4.getSeekingByteForM3u8)({
|
|
90
|
+
time,
|
|
91
|
+
currentPosition,
|
|
92
|
+
m3uState,
|
|
93
|
+
logLevel,
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
87
96
|
throw new Error(`Unknown seeking info type: ${info}`);
|
|
88
97
|
};
|
|
89
98
|
exports.getSeekingByte = getSeekingByte;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { M3uPlaylistContext } from './options';
|
|
2
2
|
import type { SeekingHints } from './seeking-hints';
|
|
3
3
|
import type { AacState } from './state/aac-state';
|
|
4
4
|
import type { FlacState } from './state/flac-state';
|
|
@@ -12,9 +12,9 @@ import type { SamplesObservedState } from './state/samples-observed/slow-duratio
|
|
|
12
12
|
import type { StructureState } from './state/structure';
|
|
13
13
|
import type { TransportStreamState } from './state/transport-stream/transport-stream';
|
|
14
14
|
import type { MediaSectionState } from './state/video-section';
|
|
15
|
-
export declare const getSeekingHints: ({ structureState,
|
|
15
|
+
export declare const getSeekingHints: ({ structureState, m3uPlaylistContext, mediaSectionState, isoState, transportStream, tracksState, keyframesState, webmState, flacState, samplesObserved, riffState, mp3State, contentLength, aacState, }: {
|
|
16
16
|
structureState: StructureState;
|
|
17
|
-
|
|
17
|
+
m3uPlaylistContext: M3uPlaylistContext | null;
|
|
18
18
|
mediaSectionState: MediaSectionState;
|
|
19
19
|
isoState: IsoBaseMediaState;
|
|
20
20
|
transportStream: TransportStreamState;
|
|
@@ -4,12 +4,14 @@ exports.getSeekingHints = void 0;
|
|
|
4
4
|
const seeking_hints_1 = require("./containers/aac/seeking-hints");
|
|
5
5
|
const seeking_hints_2 = require("./containers/flac/seeking-hints");
|
|
6
6
|
const seeking_hints_3 = require("./containers/iso-base-media/seeking-hints");
|
|
7
|
-
const seeking_hints_4 = require("./containers/
|
|
8
|
-
const seeking_hints_5 = require("./containers/
|
|
9
|
-
const seeking_hints_6 = require("./containers/
|
|
10
|
-
const seeking_hints_7 = require("./containers/
|
|
11
|
-
const seeking_hints_8 = require("./containers/
|
|
12
|
-
const
|
|
7
|
+
const seeking_hints_4 = require("./containers/m3u/seeking-hints");
|
|
8
|
+
const seeking_hints_5 = require("./containers/mp3/seeking-hints");
|
|
9
|
+
const seeking_hints_6 = require("./containers/riff/seeking-hints");
|
|
10
|
+
const seeking_hints_7 = require("./containers/transport-stream/seeking-hints");
|
|
11
|
+
const seeking_hints_8 = require("./containers/wav/seeking-hints");
|
|
12
|
+
const seeking_hints_9 = require("./containers/webm/seek/seeking-hints");
|
|
13
|
+
const getSeekingHints = ({ structureState, m3uPlaylistContext, mediaSectionState, isoState, transportStream, tracksState, keyframesState, webmState, flacState, samplesObserved, riffState, mp3State, contentLength, aacState, }) => {
|
|
14
|
+
var _a;
|
|
13
15
|
const structure = structureState.getStructureOrNull();
|
|
14
16
|
if (!structure) {
|
|
15
17
|
return null;
|
|
@@ -18,21 +20,21 @@ const getSeekingHints = ({ structureState, mp4HeaderSegment, mediaSectionState,
|
|
|
18
20
|
return (0, seeking_hints_3.getSeekingHintsFromMp4)({
|
|
19
21
|
structureState,
|
|
20
22
|
isoState,
|
|
21
|
-
mp4HeaderSegment,
|
|
23
|
+
mp4HeaderSegment: (_a = m3uPlaylistContext === null || m3uPlaylistContext === void 0 ? void 0 : m3uPlaylistContext.mp4HeaderSegment) !== null && _a !== void 0 ? _a : null,
|
|
22
24
|
mediaSectionState,
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
if (structure.type === 'wav') {
|
|
26
|
-
return (0,
|
|
28
|
+
return (0, seeking_hints_8.getSeekingHintsFromWav)({
|
|
27
29
|
structure,
|
|
28
30
|
mediaSectionState,
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
if (structure.type === 'matroska') {
|
|
32
|
-
return (0,
|
|
34
|
+
return (0, seeking_hints_9.getSeekingHintsFromMatroska)(tracksState, keyframesState, webmState);
|
|
33
35
|
}
|
|
34
36
|
if (structure.type === 'transport-stream') {
|
|
35
|
-
return (0,
|
|
37
|
+
return (0, seeking_hints_7.getSeekingHintsFromTransportStream)(transportStream, tracksState);
|
|
36
38
|
}
|
|
37
39
|
if (structure.type === 'flac') {
|
|
38
40
|
return (0, seeking_hints_2.getSeekingHintsForFlac)({
|
|
@@ -41,14 +43,14 @@ const getSeekingHints = ({ structureState, mp4HeaderSegment, mediaSectionState,
|
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
if (structure.type === 'riff') {
|
|
44
|
-
return (0,
|
|
46
|
+
return (0, seeking_hints_6.getSeekingHintsForRiff)({
|
|
45
47
|
structureState,
|
|
46
48
|
riffState,
|
|
47
49
|
mediaSectionState,
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
if (structure.type === 'mp3') {
|
|
51
|
-
return (0,
|
|
53
|
+
return (0, seeking_hints_5.getSeekingHintsForMp3)({
|
|
52
54
|
mp3State,
|
|
53
55
|
samplesObserved,
|
|
54
56
|
mediaSectionState,
|
|
@@ -61,6 +63,9 @@ const getSeekingHints = ({ structureState, mp4HeaderSegment, mediaSectionState,
|
|
|
61
63
|
samplesObserved,
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
|
-
|
|
66
|
+
if (structure.type === 'm3u') {
|
|
67
|
+
return (0, seeking_hints_4.getSeekingHintsForM3u)();
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`Seeking is not supported for this format: ${structure}`);
|
|
65
70
|
};
|
|
66
71
|
exports.getSeekingHints = getSeekingHints;
|
package/dist/get-tracks.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import type { MatrixCoefficients, Primaries, TransferCharacteristics } from './c
|
|
|
2
2
|
import type { MoovBox } from './containers/iso-base-media/moov/moov';
|
|
3
3
|
import type { TrakBox } from './containers/iso-base-media/trak/trak';
|
|
4
4
|
import type { AllTracks } from './containers/riff/get-tracks-from-avi';
|
|
5
|
+
import type { M3uPlaylistContext } from './options';
|
|
6
|
+
import type { IsoBaseMediaState } from './state/iso-base-media/iso-state';
|
|
5
7
|
import type { ParserState } from './state/parser-state';
|
|
8
|
+
import type { StructureState } from './state/structure';
|
|
6
9
|
type SampleAspectRatio = {
|
|
7
10
|
numerator: number;
|
|
8
11
|
denominator: number;
|
|
@@ -63,7 +66,12 @@ export declare const getTracksFromMoovBox: (moovBox: MoovBox) => {
|
|
|
63
66
|
audioTracks: AudioTrack[];
|
|
64
67
|
otherTracks: OtherTrack[];
|
|
65
68
|
};
|
|
66
|
-
export declare const getTracksFromIsoBaseMedia: (
|
|
69
|
+
export declare const getTracksFromIsoBaseMedia: ({ mayUsePrecomputed, structure, isoState, m3uPlaylistContext, }: {
|
|
70
|
+
structure: StructureState;
|
|
71
|
+
isoState: IsoBaseMediaState;
|
|
72
|
+
m3uPlaylistContext: M3uPlaylistContext | null;
|
|
73
|
+
mayUsePrecomputed: boolean;
|
|
74
|
+
}) => {
|
|
67
75
|
videoTracks: VideoTrack[];
|
|
68
76
|
audioTracks: AudioTrack[];
|
|
69
77
|
otherTracks: OtherTrack[];
|
package/dist/get-tracks.js
CHANGED
|
@@ -15,10 +15,11 @@ const getNumberOfTracks = (moovBox) => {
|
|
|
15
15
|
};
|
|
16
16
|
exports.getNumberOfTracks = getNumberOfTracks;
|
|
17
17
|
const isoBaseMediaHasTracks = (state, mayUsePrecomputed) => {
|
|
18
|
+
var _a, _b;
|
|
18
19
|
return Boolean((0, traversal_1.getMoovBoxFromState)({
|
|
19
20
|
structureState: state.structure,
|
|
20
21
|
isoState: state.iso,
|
|
21
|
-
mp4HeaderSegment: state.mp4HeaderSegment,
|
|
22
|
+
mp4HeaderSegment: (_b = (_a = state.m3uPlaylistContext) === null || _a === void 0 ? void 0 : _a.mp4HeaderSegment) !== null && _b !== void 0 ? _b : null,
|
|
22
23
|
mayUsePrecomputed,
|
|
23
24
|
}));
|
|
24
25
|
};
|
|
@@ -110,11 +111,12 @@ const getTracksFromMoovBox = (moovBox) => {
|
|
|
110
111
|
};
|
|
111
112
|
};
|
|
112
113
|
exports.getTracksFromMoovBox = getTracksFromMoovBox;
|
|
113
|
-
const getTracksFromIsoBaseMedia = (
|
|
114
|
+
const getTracksFromIsoBaseMedia = ({ mayUsePrecomputed, structure, isoState, m3uPlaylistContext, }) => {
|
|
115
|
+
var _a;
|
|
114
116
|
const moovBox = (0, traversal_1.getMoovBoxFromState)({
|
|
115
|
-
structureState:
|
|
116
|
-
isoState
|
|
117
|
-
mp4HeaderSegment:
|
|
117
|
+
structureState: structure,
|
|
118
|
+
isoState,
|
|
119
|
+
mp4HeaderSegment: (_a = m3uPlaylistContext === null || m3uPlaylistContext === void 0 ? void 0 : m3uPlaylistContext.mp4HeaderSegment) !== null && _a !== void 0 ? _a : null,
|
|
118
120
|
mayUsePrecomputed,
|
|
119
121
|
});
|
|
120
122
|
if (!moovBox) {
|
|
@@ -155,7 +157,12 @@ const getTracks = (state, mayUsePrecomputed) => {
|
|
|
155
157
|
return getCategorizedTracksFromMatroska(state);
|
|
156
158
|
}
|
|
157
159
|
if (structure.type === 'iso-base-media') {
|
|
158
|
-
return (0, exports.getTracksFromIsoBaseMedia)(
|
|
160
|
+
return (0, exports.getTracksFromIsoBaseMedia)({
|
|
161
|
+
isoState: state.iso,
|
|
162
|
+
m3uPlaylistContext: state.m3uPlaylistContext,
|
|
163
|
+
structure: state.structure,
|
|
164
|
+
mayUsePrecomputed,
|
|
165
|
+
});
|
|
159
166
|
}
|
|
160
167
|
if (structure.type === 'riff') {
|
|
161
168
|
return (0, get_tracks_from_avi_1.getTracksFromAvi)(structure, state);
|
package/dist/index.d.ts
CHANGED
|
@@ -739,7 +739,7 @@ export declare const MediaParserInternals: {
|
|
|
739
739
|
logLevel: LogLevel;
|
|
740
740
|
contentLength: number;
|
|
741
741
|
}) => Promise<import("./containers/iso-base-media/stsd/stsd").StsdBox>;
|
|
742
|
-
makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHandlers, controller, onAudioTrack, onVideoTrack, contentLength, logLevel, mode, src, readerInterface, onDiscardedData, selectM3uStreamFn, selectM3uAssociatedPlaylistsFn,
|
|
742
|
+
makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHandlers, controller, onAudioTrack, onVideoTrack, contentLength, logLevel, mode, src, readerInterface, onDiscardedData, selectM3uStreamFn, selectM3uAssociatedPlaylistsFn, m3uPlaylistContext, contentType, name, callbacks, fieldsInReturnValue, mimeType, initialReaderInstance, makeSamplesStartAtZero, prefetchCache, }: {
|
|
743
743
|
hasAudioTrackHandlers: boolean;
|
|
744
744
|
hasVideoTrackHandlers: boolean;
|
|
745
745
|
controller: import("./controller/media-parser-controller").MediaParserController;
|
|
@@ -753,7 +753,7 @@ export declare const MediaParserInternals: {
|
|
|
753
753
|
onDiscardedData: import("./options").OnDiscardedData | null;
|
|
754
754
|
selectM3uStreamFn: import("./containers/m3u/select-stream").SelectM3uStreamFn;
|
|
755
755
|
selectM3uAssociatedPlaylistsFn: import("./containers/m3u/select-stream").SelectM3uAssociatedPlaylistsFn;
|
|
756
|
-
|
|
756
|
+
m3uPlaylistContext: import("./options").M3uPlaylistContext | null;
|
|
757
757
|
contentType: string | null;
|
|
758
758
|
name: string;
|
|
759
759
|
callbacks: import("./options").ParseMediaCallbacks;
|
|
@@ -761,6 +761,7 @@ export declare const MediaParserInternals: {
|
|
|
761
761
|
mimeType: string | null;
|
|
762
762
|
initialReaderInstance: import("./readers/reader").Reader;
|
|
763
763
|
makeSamplesStartAtZero: boolean;
|
|
764
|
+
prefetchCache: import("./fetch").PrefetchCache;
|
|
764
765
|
}) => {
|
|
765
766
|
riff: {
|
|
766
767
|
getAvcProfile: () => import("./state/parser-state").SpsAndPps | null;
|
|
@@ -859,6 +860,8 @@ export declare const MediaParserInternals: {
|
|
|
859
860
|
flatSamples: {
|
|
860
861
|
getSamples: (mdatStart: number) => import("./state/iso-base-media/cached-sample-positions").FlatSample[] | null;
|
|
861
862
|
setSamples: (mdatStart: number, samples: import("./state/iso-base-media/cached-sample-positions").FlatSample[]) => void;
|
|
863
|
+
setJumpMarks: (mdatStart: number, marks: import("./containers/iso-base-media/mdat/calculate-jump-marks").JumpMark[]) => void;
|
|
864
|
+
getJumpMarks: (mdatStart: number) => import("./containers/iso-base-media/mdat/calculate-jump-marks").JumpMark[];
|
|
862
865
|
};
|
|
863
866
|
moov: {
|
|
864
867
|
setMoovBox: (moov: {
|
|
@@ -936,19 +939,22 @@ export declare const MediaParserInternals: {
|
|
|
936
939
|
setReadyToIterateOverM3u: () => void;
|
|
937
940
|
isReadyToIterateOverM3u: () => boolean;
|
|
938
941
|
setAllChunksProcessed: (src: string) => void;
|
|
942
|
+
clearAllChunksProcessed: () => void;
|
|
939
943
|
getAllChunksProcessedForPlaylist: (src: string) => boolean;
|
|
940
944
|
getAllChunksProcessedOverall: () => boolean;
|
|
941
945
|
setHasFinishedManifest: () => void;
|
|
942
946
|
hasFinishedManifest: () => boolean;
|
|
943
|
-
setM3uStreamRun: (playlistUrl: string, run: import("./state/m3u-state").
|
|
947
|
+
setM3uStreamRun: (playlistUrl: string, run: import("./state/m3u-state").M3uRun | null) => void;
|
|
944
948
|
setTracksDone: (playlistUrl: string) => boolean;
|
|
945
949
|
getTrackDone: (playlistUrl: string) => boolean;
|
|
946
|
-
|
|
950
|
+
clearTracksDone: () => void;
|
|
951
|
+
getM3uStreamRun: (playlistUrl: string) => import("./state/m3u-state").M3uRun;
|
|
947
952
|
abortM3UStreamRuns: () => void;
|
|
948
953
|
setAssociatedPlaylists: (playlists: import("./containers/m3u/get-streams").M3uAssociatedPlaylist[]) => void;
|
|
949
954
|
getAssociatedPlaylists: () => import("./containers/m3u/get-streams").M3uAssociatedPlaylist[] | null;
|
|
950
955
|
getSelectedPlaylists: () => string[];
|
|
951
956
|
sampleSorter: {
|
|
957
|
+
clearSamples: () => void;
|
|
952
958
|
addToStreamWithTrack: (src: string) => void;
|
|
953
959
|
addVideoStreamToConsider: (src: string, callback: import("./webcodec-sample-types").OnVideoSample) => void;
|
|
954
960
|
addAudioStreamToConsider: (src: string, callback: import("./webcodec-sample-types").OnAudioSample) => void;
|
|
@@ -960,6 +966,14 @@ export declare const MediaParserInternals: {
|
|
|
960
966
|
};
|
|
961
967
|
setMp4HeaderSegment: (playlistUrl: string, structure: import("./parse-result").IsoBaseMediaStructure) => void;
|
|
962
968
|
getMp4HeaderSegment: (playlistUrl: string) => import("./parse-result").IsoBaseMediaStructure;
|
|
969
|
+
setSeekToSecondsToProcess: (playlistUrl: string, m3uSeek: {
|
|
970
|
+
targetTime: number;
|
|
971
|
+
} | null) => void;
|
|
972
|
+
getSeekToSecondsToProcess: (playlistUrl: string) => {
|
|
973
|
+
targetTime: number;
|
|
974
|
+
} | null;
|
|
975
|
+
setNextSeekShouldSubtractChunks: (playlistUrl: string, chunks: number) => void;
|
|
976
|
+
getNextSeekShouldSubtractChunks: (playlistUrl: string) => number;
|
|
963
977
|
};
|
|
964
978
|
timings: {
|
|
965
979
|
timeIterating: number;
|
|
@@ -973,6 +987,7 @@ export declare const MediaParserInternals: {
|
|
|
973
987
|
onAudioSample: (trackId: number, audioSample: import("./webcodec-sample-types").AudioOrVideoSample) => Promise<void>;
|
|
974
988
|
onVideoSample: (trackId: number, videoSample: import("./webcodec-sample-types").AudioOrVideoSample) => Promise<void>;
|
|
975
989
|
canSkipTracksState: {
|
|
990
|
+
doFieldsNeedTracks: () => boolean;
|
|
976
991
|
canSkipTracks: () => boolean;
|
|
977
992
|
};
|
|
978
993
|
registerAudioSampleCallback: (id: number, callback: import("./webcodec-sample-types").OnAudioSample | null) => Promise<void>;
|
|
@@ -1125,7 +1140,7 @@ export declare const MediaParserInternals: {
|
|
|
1125
1140
|
discardReadBytes: (force: boolean) => Promise<void>;
|
|
1126
1141
|
selectM3uStreamFn: import("./containers/m3u/select-stream").SelectM3uStreamFn;
|
|
1127
1142
|
selectM3uAssociatedPlaylistsFn: import("./containers/m3u/select-stream").SelectM3uAssociatedPlaylistsFn;
|
|
1128
|
-
|
|
1143
|
+
m3uPlaylistContext: import("./options").M3uPlaylistContext | null;
|
|
1129
1144
|
contentType: string | null;
|
|
1130
1145
|
name: string;
|
|
1131
1146
|
returnValue: import("./options").ParseMediaResult<import("./options").AllParseMediaFields>;
|
|
@@ -1142,6 +1157,7 @@ export declare const MediaParserInternals: {
|
|
|
1142
1157
|
reset: () => void;
|
|
1143
1158
|
};
|
|
1144
1159
|
makeSamplesStartAtZero: boolean;
|
|
1160
|
+
prefetchCache: import("./fetch").PrefetchCache;
|
|
1145
1161
|
};
|
|
1146
1162
|
processSample: ({ iterator, logLevel, contentLength, }: {
|
|
1147
1163
|
iterator: import("./iterator/buffer-iterator").BufferIterator;
|
package/dist/init-video.js
CHANGED
|
@@ -7,6 +7,7 @@ const get_tracks_1 = require("./get-tracks");
|
|
|
7
7
|
const log_1 = require("./log");
|
|
8
8
|
const register_track_1 = require("./register-track");
|
|
9
9
|
const initVideo = async ({ state }) => {
|
|
10
|
+
var _a;
|
|
10
11
|
const fileType = state.iterator.detectFileType();
|
|
11
12
|
const { mimeType, name, contentLength } = state;
|
|
12
13
|
if (fileType.type === 'riff') {
|
|
@@ -17,9 +18,9 @@ const initVideo = async ({ state }) => {
|
|
|
17
18
|
});
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
|
-
if (state.mp4HeaderSegment) {
|
|
21
|
+
if ((_a = state.m3uPlaylistContext) === null || _a === void 0 ? void 0 : _a.mp4HeaderSegment) {
|
|
21
22
|
log_1.Log.verbose(state.logLevel, 'Detected ISO Base Media segment');
|
|
22
|
-
const moovAtom = (0, traversal_1.getMoovFromFromIsoStructure)(state.mp4HeaderSegment);
|
|
23
|
+
const moovAtom = (0, traversal_1.getMoovFromFromIsoStructure)(state.m3uPlaylistContext.mp4HeaderSegment);
|
|
23
24
|
if (!moovAtom) {
|
|
24
25
|
throw new Error('No moov box found');
|
|
25
26
|
}
|
|
@@ -11,7 +11,7 @@ const remotion_license_acknowledge_1 = require("./remotion-license-acknowledge")
|
|
|
11
11
|
const set_seeking_hints_1 = require("./set-seeking-hints");
|
|
12
12
|
const parser_state_1 = require("./state/parser-state");
|
|
13
13
|
const throttled_progress_1 = require("./throttled-progress");
|
|
14
|
-
const internalParseMedia = async function ({ src, fields: _fieldsInReturnValue, reader: readerInterface, onAudioTrack, onVideoTrack, controller = (0, media_parser_controller_1.mediaParserController)(), logLevel, onParseProgress: onParseProgressDoNotCallDirectly, progressIntervalInMs, mode, onDiscardedData, onError, acknowledgeRemotionLicense, apiName, selectM3uStream: selectM3uStreamFn, selectM3uAssociatedPlaylists: selectM3uAssociatedPlaylistsFn,
|
|
14
|
+
const internalParseMedia = async function ({ src, fields: _fieldsInReturnValue, reader: readerInterface, onAudioTrack, onVideoTrack, controller = (0, media_parser_controller_1.mediaParserController)(), logLevel, onParseProgress: onParseProgressDoNotCallDirectly, progressIntervalInMs, mode, onDiscardedData, onError, acknowledgeRemotionLicense, apiName, selectM3uStream: selectM3uStreamFn, selectM3uAssociatedPlaylists: selectM3uAssociatedPlaylistsFn, m3uPlaylistContext, makeSamplesStartAtZero, seekingHints, ...more }) {
|
|
15
15
|
var _a;
|
|
16
16
|
controller._internals.markAsReadyToEmitEvents();
|
|
17
17
|
(0, remotion_license_acknowledge_1.warnIfRemotionLicenseNotAcknowledged)({
|
|
@@ -20,7 +20,14 @@ const internalParseMedia = async function ({ src, fields: _fieldsInReturnValue,
|
|
|
20
20
|
apiName,
|
|
21
21
|
});
|
|
22
22
|
log_1.Log.verbose(logLevel, `Reading ${typeof src === 'string' ? src : src instanceof URL ? src.toString() : src instanceof File ? src.name : src.toString()}`);
|
|
23
|
-
const
|
|
23
|
+
const prefetchCache = new Map();
|
|
24
|
+
const { reader: readerInstance, contentLength, name, contentType, supportsContentRange, needsContentRange, } = await readerInterface.read({
|
|
25
|
+
src,
|
|
26
|
+
range: null,
|
|
27
|
+
controller,
|
|
28
|
+
logLevel,
|
|
29
|
+
prefetchCache,
|
|
30
|
+
});
|
|
24
31
|
if (contentLength === null) {
|
|
25
32
|
throw new Error(`Cannot read media ${src} without a content length. This is currently not supported. Ensure the media has a "Content-Length" HTTP header.`);
|
|
26
33
|
}
|
|
@@ -43,7 +50,7 @@ const internalParseMedia = async function ({ src, fields: _fieldsInReturnValue,
|
|
|
43
50
|
onDiscardedData,
|
|
44
51
|
selectM3uStreamFn,
|
|
45
52
|
selectM3uAssociatedPlaylistsFn,
|
|
46
|
-
|
|
53
|
+
m3uPlaylistContext,
|
|
47
54
|
contentType,
|
|
48
55
|
name,
|
|
49
56
|
callbacks: more,
|
|
@@ -51,6 +58,7 @@ const internalParseMedia = async function ({ src, fields: _fieldsInReturnValue,
|
|
|
51
58
|
mimeType: contentType,
|
|
52
59
|
initialReaderInstance: readerInstance,
|
|
53
60
|
makeSamplesStartAtZero,
|
|
61
|
+
prefetchCache,
|
|
54
62
|
});
|
|
55
63
|
if (seekingHints) {
|
|
56
64
|
(0, set_seeking_hints_1.setSeekingHints)({ hints: seekingHints, state });
|
|
@@ -60,7 +68,7 @@ const internalParseMedia = async function ({ src, fields: _fieldsInReturnValue,
|
|
|
60
68
|
keyframesState: state.keyframes,
|
|
61
69
|
webmState: state.webm,
|
|
62
70
|
structureState: state.structure,
|
|
63
|
-
|
|
71
|
+
m3uPlaylistContext: state.m3uPlaylistContext,
|
|
64
72
|
mediaSectionState: state.mediaSection,
|
|
65
73
|
isoState: state.iso,
|
|
66
74
|
transportStream: state.transportStream,
|
|
@@ -92,6 +100,7 @@ const internalParseMedia = async function ({ src, fields: _fieldsInReturnValue,
|
|
|
92
100
|
(_a = state.iterator) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
93
101
|
state.callbacks.tracks.ensureHasTracksAtEnd(state.fields);
|
|
94
102
|
state.m3u.abortM3UStreamRuns();
|
|
103
|
+
prefetchCache.clear();
|
|
95
104
|
if (state.errored) {
|
|
96
105
|
throw state.errored;
|
|
97
106
|
}
|
|
@@ -66,14 +66,15 @@ const getArrayBufferIterator = (initialData, maxBytes) => {
|
|
|
66
66
|
const six = getUint8();
|
|
67
67
|
const seven = getUint8();
|
|
68
68
|
const eight = getUint8();
|
|
69
|
-
return ((eight << 56) |
|
|
69
|
+
return (((eight << 56) |
|
|
70
70
|
(seven << 48) |
|
|
71
71
|
(six << 40) |
|
|
72
72
|
(five << 32) |
|
|
73
73
|
(four << 24) |
|
|
74
74
|
(three << 16) |
|
|
75
75
|
(two << 8) |
|
|
76
|
-
one)
|
|
76
|
+
one) >>>
|
|
77
|
+
0);
|
|
77
78
|
}
|
|
78
79
|
function byteArrayToBigInt(byteArray) {
|
|
79
80
|
let result = BigInt(0);
|
|
@@ -95,7 +96,8 @@ const getArrayBufferIterator = (initialData, maxBytes) => {
|
|
|
95
96
|
return Number(bigInt);
|
|
96
97
|
};
|
|
97
98
|
const getFourByteNumber = () => {
|
|
98
|
-
|
|
99
|
+
const unsigned = (getUint8() << 24) | (getUint8() << 16) | (getUint8() << 8) | getUint8();
|
|
100
|
+
return unsigned >>> 0;
|
|
99
101
|
};
|
|
100
102
|
const getPaddedFourByteNumber = () => {
|
|
101
103
|
let lastInt = 128;
|
|
@@ -116,10 +116,11 @@ const parseIsoMetaBox = (meta, trackId) => {
|
|
|
116
116
|
};
|
|
117
117
|
exports.parseIsoMetaBox = parseIsoMetaBox;
|
|
118
118
|
const getMetadataFromIsoBase = (state) => {
|
|
119
|
+
var _a, _b;
|
|
119
120
|
const moov = (0, traversal_1.getMoovBoxFromState)({
|
|
120
121
|
structureState: state.structure,
|
|
121
122
|
isoState: state.iso,
|
|
122
|
-
mp4HeaderSegment: state.mp4HeaderSegment,
|
|
123
|
+
mp4HeaderSegment: (_b = (_a = state.m3uPlaylistContext) === null || _a === void 0 ? void 0 : _a.mp4HeaderSegment) !== null && _b !== void 0 ? _b : null,
|
|
123
124
|
mayUsePrecomputed: true,
|
|
124
125
|
});
|
|
125
126
|
if (!moov) {
|
package/dist/options.d.ts
CHANGED
|
@@ -130,12 +130,16 @@ export type ParseMediaOnProgress = (progress: ParseMediaProgress) => void | Prom
|
|
|
130
130
|
type ReaderParams = {
|
|
131
131
|
reader: ReaderInterface;
|
|
132
132
|
};
|
|
133
|
+
export type M3uPlaylistContext = {
|
|
134
|
+
mp4HeaderSegment: IsoBaseMediaStructure | null;
|
|
135
|
+
isLastChunkInPlaylist: boolean;
|
|
136
|
+
};
|
|
133
137
|
export type SerializeableOptionalParseMediaParams<F extends Options<ParseMediaFields>> = {
|
|
134
138
|
logLevel: LogLevel;
|
|
135
139
|
progressIntervalInMs: number | null;
|
|
136
140
|
fields: F | null;
|
|
137
141
|
acknowledgeRemotionLicense: boolean;
|
|
138
|
-
|
|
142
|
+
m3uPlaylistContext: M3uPlaylistContext | null;
|
|
139
143
|
makeSamplesStartAtZero: boolean;
|
|
140
144
|
seekingHints: SeekingHints | null;
|
|
141
145
|
};
|
|
@@ -151,6 +155,7 @@ type ParseMediaSampleCallbacks = {
|
|
|
151
155
|
};
|
|
152
156
|
export type ParseMediaMode = 'query' | 'download';
|
|
153
157
|
export type ParseMediaSrc = string | Blob | URL;
|
|
158
|
+
export type ParseMediaRange = [number, number] | number | null;
|
|
154
159
|
export type OnDiscardedData = (data: Uint8Array) => Promise<void>;
|
|
155
160
|
export type ContinueAfterError = {
|
|
156
161
|
action: 'fail';
|