@remotion/media-parser 4.0.288 → 4.0.289
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/aac/get-seeking-byte.d.ts +6 -0
- package/dist/containers/aac/get-seeking-byte.js +30 -0
- package/dist/containers/aac/parse-aac.js +23 -18
- package/dist/containers/aac/seeking-hints.d.ts +13 -0
- package/dist/containers/aac/seeking-hints.js +14 -0
- package/dist/containers/flac/get-channel-count.d.ts +1 -1
- package/dist/containers/flac/get-seeking-byte.d.ts +1 -2
- package/dist/containers/flac/get-seeking-byte.js +6 -2
- package/dist/containers/flac/parse-flac-frame.js +18 -17
- package/dist/containers/flac/parse-flac.js +5 -25
- package/dist/containers/flac/seeking-hints.d.ts +4 -1
- package/dist/containers/flac/seeking-hints.js +2 -1
- package/dist/containers/iso-base-media/get-children.d.ts +2 -1
- package/dist/containers/iso-base-media/get-children.js +2 -1
- package/dist/containers/iso-base-media/get-mfra-seeking-box.js +1 -0
- package/dist/containers/iso-base-media/get-moov-atom.js +2 -1
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.d.ts +1 -1
- package/dist/containers/iso-base-media/mdat/mdat.js +26 -33
- package/dist/containers/iso-base-media/moov/moov.d.ts +2 -1
- package/dist/containers/iso-base-media/moov/moov.js +2 -1
- package/dist/containers/iso-base-media/parse-boxes.js +1 -0
- package/dist/containers/iso-base-media/process-box.d.ts +2 -1
- package/dist/containers/iso-base-media/process-box.js +10 -4
- package/dist/containers/iso-base-media/stsd/mebx.d.ts +2 -1
- package/dist/containers/iso-base-media/stsd/mebx.js +2 -1
- package/dist/containers/iso-base-media/stsd/samples.d.ts +4 -2
- package/dist/containers/iso-base-media/stsd/samples.js +7 -2
- package/dist/containers/iso-base-media/stsd/stsd.d.ts +2 -1
- package/dist/containers/iso-base-media/stsd/stsd.js +2 -1
- package/dist/containers/iso-base-media/trak/trak.d.ts +2 -1
- package/dist/containers/iso-base-media/trak/trak.js +2 -1
- package/dist/containers/mp3/audio-sample-from-cbr.d.ts +11 -0
- package/dist/containers/mp3/audio-sample-from-cbr.js +35 -0
- package/dist/containers/mp3/get-duration.js +33 -6
- package/dist/containers/mp3/get-seeking-byte.d.ts +6 -0
- package/dist/containers/mp3/get-seeking-byte.js +49 -0
- package/dist/containers/mp3/parse-mp3.js +9 -0
- package/dist/containers/mp3/parse-mpeg-header.js +74 -263
- package/dist/containers/mp3/parse-packet-header.d.ts +30 -0
- package/dist/containers/mp3/parse-packet-header.js +258 -0
- package/dist/containers/mp3/parse-xing.d.ts +19 -0
- package/dist/containers/mp3/parse-xing.js +120 -0
- package/dist/containers/mp3/seek/audio-sample-from-cbr.d.ts +16 -0
- package/dist/containers/mp3/seek/audio-sample-from-cbr.js +35 -0
- package/dist/containers/mp3/seek/audio-sample-from-vbr.d.ts +8 -0
- package/dist/containers/mp3/seek/audio-sample-from-vbr.js +47 -0
- package/dist/containers/mp3/seek/get-approximate-byte-from-bitrate.d.ts +9 -0
- package/dist/containers/mp3/seek/get-approximate-byte-from-bitrate.js +28 -0
- package/dist/containers/mp3/seek/get-byte-from-observed-samples.d.ts +6 -0
- package/dist/containers/mp3/seek/get-byte-from-observed-samples.js +27 -0
- package/dist/containers/mp3/seek/get-seek-point-from-xing.d.ts +7 -0
- package/dist/containers/mp3/seek/get-seek-point-from-xing.js +29 -0
- package/dist/containers/mp3/seek/wait-until-syncword.d.ts +4 -0
- package/dist/containers/mp3/seek/wait-until-syncword.js +25 -0
- package/dist/containers/mp3/seeking-hints.d.ts +24 -0
- package/dist/containers/mp3/seeking-hints.js +21 -0
- package/dist/containers/riff/expect-riff-box.d.ts +6 -1
- package/dist/containers/riff/expect-riff-box.js +37 -27
- package/dist/containers/riff/get-seeking-byte.d.ts +8 -0
- package/dist/containers/riff/get-seeking-byte.js +56 -0
- package/dist/containers/riff/has-index.d.ts +2 -0
- package/dist/containers/riff/has-index.js +8 -0
- package/dist/containers/riff/parse-avih.js +3 -0
- package/dist/containers/riff/parse-idx1.d.ts +6 -0
- package/dist/containers/riff/parse-idx1.js +47 -0
- package/dist/containers/riff/parse-list-box.d.ts +4 -2
- package/dist/containers/riff/parse-list-box.js +8 -3
- package/dist/containers/riff/parse-movi.js +35 -40
- package/dist/containers/riff/parse-riff-body.js +5 -1
- package/dist/containers/riff/parse-riff-box.d.ts +4 -2
- package/dist/containers/riff/parse-riff-box.js +10 -3
- package/dist/containers/riff/riff-box.d.ts +14 -1
- package/dist/containers/riff/seek/fetch-idx1.d.ts +15 -0
- package/dist/containers/riff/seek/fetch-idx1.js +38 -0
- package/dist/containers/riff/seeking-hints.d.ts +23 -0
- package/dist/containers/riff/seeking-hints.js +36 -0
- package/dist/containers/transport-stream/handle-aac-packet.js +4 -8
- package/dist/containers/transport-stream/handle-avc-packet.js +4 -8
- package/dist/containers/wav/get-duration-from-wav.js +1 -10
- package/dist/containers/wav/parse-media-section.js +14 -18
- package/dist/containers/webm/parse-ebml.js +3 -16
- package/dist/containers/webm/seek/seeking-hints.js +1 -1
- package/dist/emit-available-info.js +8 -8
- package/dist/esm/index.mjs +1479 -383
- package/dist/esm/worker-server-entry.mjs +1475 -379
- package/dist/esm/worker-web-entry.mjs +1475 -379
- package/dist/find-last-keyframe.d.ts +5 -0
- package/dist/find-last-keyframe.js +18 -0
- package/dist/get-seeking-byte.d.ts +3 -1
- package/dist/get-seeking-byte.js +45 -7
- package/dist/get-seeking-hints.d.ts +12 -1
- package/dist/get-seeking-hints.js +40 -9
- package/dist/index.d.ts +56 -8
- package/dist/internal-parse-media.js +6 -0
- package/dist/parse-loop.js +15 -0
- package/dist/seeking-hints.d.ts +5 -1
- package/dist/set-seeking-hints.js +28 -8
- package/dist/state/aac-state.d.ts +6 -0
- package/dist/state/aac-state.js +7 -2
- package/dist/state/flac-state.d.ts +6 -0
- package/dist/state/flac-state.js +3 -0
- package/dist/state/keyframes.d.ts +1 -2
- package/dist/state/keyframes.js +2 -2
- package/dist/state/matroska/lazy-cues-fetch.js +13 -1
- package/dist/state/parser-state.d.ts +52 -6
- package/dist/state/parser-state.js +6 -6
- package/dist/state/riff/lazy-idx1-fetch.d.ts +30 -0
- package/dist/state/riff/lazy-idx1-fetch.js +63 -0
- package/dist/state/riff/riff-keyframes.d.ts +10 -0
- package/dist/state/riff/riff-keyframes.js +26 -0
- package/dist/state/riff/sample-counter.d.ts +12 -0
- package/dist/state/riff/sample-counter.js +52 -0
- package/dist/state/riff.d.ts +41 -1
- package/dist/state/riff.js +12 -1
- package/dist/state/sample-callbacks.d.ts +3 -4
- package/dist/state/sample-callbacks.js +3 -16
- package/dist/state/samples-observed/slow-duration-fps.d.ts +3 -1
- package/dist/state/samples-observed/slow-duration-fps.js +7 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/work-on-seek-request.d.ts +10 -0
- package/dist/work-on-seek-request.js +20 -2
- package/package.json +3 -3
|
@@ -45,6 +45,36 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
45
45
|
registerOnAvcProfileCallback: (callback: (profile: SpsAndPps) => Promise<void>) => void;
|
|
46
46
|
getNextTrackIndex: () => number;
|
|
47
47
|
incrementNextTrackIndex: () => void;
|
|
48
|
+
lazyIdx1: {
|
|
49
|
+
triggerLoad: (position: number) => Promise<{
|
|
50
|
+
entries: import("../containers/riff/riff-box").Idx1Entry[];
|
|
51
|
+
videoTrackIndex: number | null;
|
|
52
|
+
}>;
|
|
53
|
+
getLoadedIdx1: () => Promise<{
|
|
54
|
+
entries: import("../containers/riff/riff-box").Idx1Entry[];
|
|
55
|
+
videoTrackIndex: number | null;
|
|
56
|
+
} | null>;
|
|
57
|
+
getIfAlreadyLoaded: () => {
|
|
58
|
+
entries: import("../containers/riff/riff-box").Idx1Entry[];
|
|
59
|
+
videoTrackIndex: number | null;
|
|
60
|
+
} | null;
|
|
61
|
+
setFromSeekingHints: (hints: import("../containers/riff/seeking-hints").RiffSeekingHints) => void;
|
|
62
|
+
waitForLoaded: () => Promise<null> | Promise<{
|
|
63
|
+
entries: import("../containers/riff/riff-box").Idx1Entry[];
|
|
64
|
+
videoTrackIndex: number | null;
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
sampleCounter: {
|
|
68
|
+
onAudioSample: (trackId: number, audioSample: import("../webcodec-sample-types").AudioOrVideoSample) => void;
|
|
69
|
+
onVideoSample: (trackId: number, videoSample: import("../webcodec-sample-types").AudioOrVideoSample) => void;
|
|
70
|
+
getSamplesForTrack: (trackId: number) => number;
|
|
71
|
+
setSamplesFromSeek: (samples: Record<number, number>) => void;
|
|
72
|
+
riffKeys: {
|
|
73
|
+
addKeyframe: (keyframe: import("./riff/riff-keyframes").RiffKeyframe) => void;
|
|
74
|
+
getKeyframes: () => import("./riff/riff-keyframes").RiffKeyframe[];
|
|
75
|
+
setFromSeekingHints: (keyframesFromHints: import("./riff/riff-keyframes").RiffKeyframe[]) => void;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
48
78
|
};
|
|
49
79
|
transportStream: {
|
|
50
80
|
nextPesHeaderStore: {
|
|
@@ -131,11 +161,16 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
131
161
|
setTfraBoxes: (boxes: import("../containers/iso-base-media/mfra/tfra").TfraBox[]) => void;
|
|
132
162
|
};
|
|
133
163
|
};
|
|
134
|
-
|
|
164
|
+
mp3: {
|
|
135
165
|
getMp3Info: () => import("./mp3").Mp3Info | null;
|
|
136
166
|
setMp3Info: (info: import("./mp3").Mp3Info) => void;
|
|
137
|
-
|
|
138
|
-
|
|
167
|
+
getMp3BitrateInfo: () => import("./mp3").Mp3BitrateInfo | null;
|
|
168
|
+
setMp3BitrateInfo: (info: import("./mp3").Mp3BitrateInfo) => void;
|
|
169
|
+
audioSamples: {
|
|
170
|
+
addSample: (audioSampleOffset: import("./audio-sample-map").AudioSampleOffset) => void;
|
|
171
|
+
getSamples: () => import("./audio-sample-map").AudioSampleOffset[];
|
|
172
|
+
setFromSeekingHints: (newMap: import("./audio-sample-map").AudioSampleOffset[]) => void;
|
|
173
|
+
};
|
|
139
174
|
};
|
|
140
175
|
aac: {
|
|
141
176
|
addSample: ({ offset, size }: {
|
|
@@ -151,10 +186,20 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
151
186
|
index: number;
|
|
152
187
|
size: number;
|
|
153
188
|
}[];
|
|
189
|
+
audioSamples: {
|
|
190
|
+
addSample: (audioSampleOffset: import("./audio-sample-map").AudioSampleOffset) => void;
|
|
191
|
+
getSamples: () => import("./audio-sample-map").AudioSampleOffset[];
|
|
192
|
+
setFromSeekingHints: (newMap: import("./audio-sample-map").AudioSampleOffset[]) => void;
|
|
193
|
+
};
|
|
154
194
|
};
|
|
155
195
|
flac: {
|
|
156
196
|
setBlockingBitStrategy: (strategy: number) => void;
|
|
157
197
|
getBlockingBitStrategy: () => number | undefined;
|
|
198
|
+
audioSamples: {
|
|
199
|
+
addSample: (audioSampleOffset: import("./audio-sample-map").AudioSampleOffset) => void;
|
|
200
|
+
getSamples: () => import("./audio-sample-map").AudioSampleOffset[];
|
|
201
|
+
setFromSeekingHints: (newMap: import("./audio-sample-map").AudioSampleOffset[]) => void;
|
|
202
|
+
};
|
|
158
203
|
};
|
|
159
204
|
m3u: {
|
|
160
205
|
setSelectedMainPlaylist: (stream: import("./m3u-state").M3uStreamOrInitialUrl) => void;
|
|
@@ -203,7 +248,6 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
203
248
|
callbacks: {
|
|
204
249
|
registerVideoSampleCallback: (id: number, callback: import("../webcodec-sample-types").OnVideoSample | null) => Promise<void>;
|
|
205
250
|
onAudioSample: (trackId: number, audioSample: import("../webcodec-sample-types").AudioOrVideoSample) => Promise<void>;
|
|
206
|
-
getSamplesForTrack: (trackId: number) => number;
|
|
207
251
|
onVideoSample: (trackId: number, videoSample: import("../webcodec-sample-types").AudioOrVideoSample) => Promise<void>;
|
|
208
252
|
canSkipTracksState: {
|
|
209
253
|
canSkipTracks: () => boolean;
|
|
@@ -228,7 +272,7 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
228
272
|
keyframes: {
|
|
229
273
|
addKeyframe: (keyframe: import("../options").MediaParserKeyframe) => void;
|
|
230
274
|
getKeyframes: () => import("../options").MediaParserKeyframe[];
|
|
231
|
-
setFromSeekingHints: (
|
|
275
|
+
setFromSeekingHints: (keyframesFromHints: import("../options").MediaParserKeyframe[]) => void;
|
|
232
276
|
};
|
|
233
277
|
structure: {
|
|
234
278
|
getStructureOrNull: () => import("../parse-result").MediaParserStructureUnstable | null;
|
|
@@ -247,7 +291,7 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
247
291
|
onVideoTrack: OnVideoTrack | null;
|
|
248
292
|
emittedFields: import("../fields").AllOptions<ParseMediaFields>;
|
|
249
293
|
fields: Partial<import("../fields").AllOptions<ParseMediaFields>>;
|
|
250
|
-
|
|
294
|
+
samplesObserved: {
|
|
251
295
|
addVideoSample: (videoSample: import("../webcodec-sample-types").AudioOrVideoSample) => void;
|
|
252
296
|
addAudioSample: (audioSample: import("../webcodec-sample-types").AudioOrVideoSample) => void;
|
|
253
297
|
getSlowDurationInSeconds: () => number;
|
|
@@ -255,6 +299,8 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
255
299
|
getSlowNumberOfFrames: () => number;
|
|
256
300
|
getAudioBitrate: () => number | null;
|
|
257
301
|
getVideoBitrate: () => number | null;
|
|
302
|
+
getLastSampleObserved: () => boolean;
|
|
303
|
+
setLastSampleObserved: () => void;
|
|
258
304
|
};
|
|
259
305
|
contentLength: number;
|
|
260
306
|
images: {
|
|
@@ -32,8 +32,8 @@ const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, control
|
|
|
32
32
|
const structure = (0, structure_1.structureState)();
|
|
33
33
|
const keyframes = (0, keyframes_1.keyframesState)();
|
|
34
34
|
const emittedFields = (0, emitted_fields_1.emittedState)();
|
|
35
|
-
const
|
|
36
|
-
const
|
|
35
|
+
const samplesObserved = (0, slow_duration_fps_1.samplesObservedState)();
|
|
36
|
+
const mp3 = (0, mp3_1.makeMp3State)();
|
|
37
37
|
const images = (0, images_1.imagesState)();
|
|
38
38
|
const timings = (0, timings_1.timingsState)();
|
|
39
39
|
const seekInfiniteLoop = (0, seek_infinite_loop_1.seekInfiniteLoopDetectionState)();
|
|
@@ -53,7 +53,7 @@ const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, control
|
|
|
53
53
|
callbacks,
|
|
54
54
|
});
|
|
55
55
|
return {
|
|
56
|
-
riff: (0, riff_1.riffSpecificState)(),
|
|
56
|
+
riff: (0, riff_1.riffSpecificState)({ controller, logLevel, readerInterface, src }),
|
|
57
57
|
transportStream: (0, transport_stream_1.transportStreamState)(),
|
|
58
58
|
webm: (0, webm_1.webmState)({ controller, logLevel, readerInterface, src }),
|
|
59
59
|
iso: (0, iso_state_1.isoBaseMediaState)({
|
|
@@ -63,7 +63,7 @@ const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, control
|
|
|
63
63
|
src,
|
|
64
64
|
logLevel,
|
|
65
65
|
}),
|
|
66
|
-
|
|
66
|
+
mp3,
|
|
67
67
|
aac: (0, aac_state_1.aacState)(),
|
|
68
68
|
flac: (0, flac_state_1.flacState)(),
|
|
69
69
|
m3u: (0, m3u_state_1.m3uState)(logLevel),
|
|
@@ -75,7 +75,7 @@ const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, control
|
|
|
75
75
|
fields,
|
|
76
76
|
keyframes,
|
|
77
77
|
emittedFields,
|
|
78
|
-
|
|
78
|
+
samplesObserved,
|
|
79
79
|
structure,
|
|
80
80
|
src,
|
|
81
81
|
seekSignal: controller._internals.seekSignal,
|
|
@@ -96,7 +96,7 @@ const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, control
|
|
|
96
96
|
onVideoTrack,
|
|
97
97
|
emittedFields,
|
|
98
98
|
fields,
|
|
99
|
-
|
|
99
|
+
samplesObserved,
|
|
100
100
|
contentLength,
|
|
101
101
|
images,
|
|
102
102
|
mediaSection: (0, video_section_1.mediaSectionState)(),
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RiffSeekingHints } from '../../containers/riff/seeking-hints';
|
|
2
|
+
import type { MediaParserController } from '../../controller/media-parser-controller';
|
|
3
|
+
import type { LogLevel } from '../../log';
|
|
4
|
+
import type { ParseMediaSrc } from '../../options';
|
|
5
|
+
import type { ReaderInterface } from '../../readers/reader';
|
|
6
|
+
export declare const lazyIdx1Fetch: ({ controller, logLevel, readerInterface, src, }: {
|
|
7
|
+
controller: MediaParserController;
|
|
8
|
+
logLevel: LogLevel;
|
|
9
|
+
readerInterface: ReaderInterface;
|
|
10
|
+
src: ParseMediaSrc;
|
|
11
|
+
}) => {
|
|
12
|
+
triggerLoad: (position: number) => Promise<{
|
|
13
|
+
entries: import("../../containers/riff/riff-box").Idx1Entry[];
|
|
14
|
+
videoTrackIndex: number | null;
|
|
15
|
+
}>;
|
|
16
|
+
getLoadedIdx1: () => Promise<{
|
|
17
|
+
entries: import("../../containers/riff/riff-box").Idx1Entry[];
|
|
18
|
+
videoTrackIndex: number | null;
|
|
19
|
+
} | null>;
|
|
20
|
+
getIfAlreadyLoaded: () => {
|
|
21
|
+
entries: import("../../containers/riff/riff-box").Idx1Entry[];
|
|
22
|
+
videoTrackIndex: number | null;
|
|
23
|
+
} | null;
|
|
24
|
+
setFromSeekingHints: (hints: RiffSeekingHints) => void;
|
|
25
|
+
waitForLoaded: () => Promise<null> | Promise<{
|
|
26
|
+
entries: import("../../containers/riff/riff-box").Idx1Entry[];
|
|
27
|
+
videoTrackIndex: number | null;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
export type LazyIdx1Fetch = ReturnType<typeof lazyIdx1Fetch>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lazyIdx1Fetch = void 0;
|
|
4
|
+
const fetch_idx1_1 = require("../../containers/riff/seek/fetch-idx1");
|
|
5
|
+
const lazyIdx1Fetch = ({ controller, logLevel, readerInterface, src, }) => {
|
|
6
|
+
let prom = null;
|
|
7
|
+
let result = null;
|
|
8
|
+
const triggerLoad = (position) => {
|
|
9
|
+
if (result) {
|
|
10
|
+
return Promise.resolve(result);
|
|
11
|
+
}
|
|
12
|
+
if (prom) {
|
|
13
|
+
return prom;
|
|
14
|
+
}
|
|
15
|
+
prom = (0, fetch_idx1_1.fetchIdx1)({
|
|
16
|
+
controller,
|
|
17
|
+
logLevel,
|
|
18
|
+
position,
|
|
19
|
+
readerInterface,
|
|
20
|
+
src,
|
|
21
|
+
}).then((entries) => {
|
|
22
|
+
prom = null;
|
|
23
|
+
result = entries;
|
|
24
|
+
return entries;
|
|
25
|
+
});
|
|
26
|
+
return prom;
|
|
27
|
+
};
|
|
28
|
+
const getLoadedIdx1 = async () => {
|
|
29
|
+
if (!prom) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const entries = await prom;
|
|
33
|
+
return entries;
|
|
34
|
+
};
|
|
35
|
+
const getIfAlreadyLoaded = () => {
|
|
36
|
+
if (result) {
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
41
|
+
const setFromSeekingHints = (hints) => {
|
|
42
|
+
if (hints.idx1Entries) {
|
|
43
|
+
result = hints.idx1Entries;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const waitForLoaded = () => {
|
|
47
|
+
if (result) {
|
|
48
|
+
return Promise.resolve(result);
|
|
49
|
+
}
|
|
50
|
+
if (prom) {
|
|
51
|
+
return prom;
|
|
52
|
+
}
|
|
53
|
+
return Promise.resolve(null);
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
triggerLoad,
|
|
57
|
+
getLoadedIdx1,
|
|
58
|
+
getIfAlreadyLoaded,
|
|
59
|
+
setFromSeekingHints,
|
|
60
|
+
waitForLoaded,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.lazyIdx1Fetch = lazyIdx1Fetch;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MediaParserKeyframe } from '../../options';
|
|
2
|
+
export type RiffKeyframe = MediaParserKeyframe & {
|
|
3
|
+
sampleCounts: Record<number, number>;
|
|
4
|
+
};
|
|
5
|
+
export declare const riffKeyframesState: () => {
|
|
6
|
+
addKeyframe: (keyframe: RiffKeyframe) => void;
|
|
7
|
+
getKeyframes: () => RiffKeyframe[];
|
|
8
|
+
setFromSeekingHints: (keyframesFromHints: RiffKeyframe[]) => void;
|
|
9
|
+
};
|
|
10
|
+
export type RiffKeyframesState = ReturnType<typeof riffKeyframesState>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.riffKeyframesState = void 0;
|
|
4
|
+
const riffKeyframesState = () => {
|
|
5
|
+
const keyframes = [];
|
|
6
|
+
const addKeyframe = (keyframe) => {
|
|
7
|
+
if (keyframes.find((k) => k.positionInBytes === keyframe.positionInBytes)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
keyframes.push(keyframe);
|
|
11
|
+
};
|
|
12
|
+
const getKeyframes = () => {
|
|
13
|
+
return keyframes;
|
|
14
|
+
};
|
|
15
|
+
const setFromSeekingHints = (keyframesFromHints) => {
|
|
16
|
+
for (const keyframe of keyframesFromHints) {
|
|
17
|
+
addKeyframe(keyframe);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
addKeyframe,
|
|
22
|
+
getKeyframes,
|
|
23
|
+
setFromSeekingHints,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exports.riffKeyframesState = riffKeyframesState;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AudioOrVideoSample } from '../../webcodec-sample-types';
|
|
2
|
+
export declare const riffSampleCounter: () => {
|
|
3
|
+
onAudioSample: (trackId: number, audioSample: AudioOrVideoSample) => void;
|
|
4
|
+
onVideoSample: (trackId: number, videoSample: AudioOrVideoSample) => void;
|
|
5
|
+
getSamplesForTrack: (trackId: number) => number;
|
|
6
|
+
setSamplesFromSeek: (samples: Record<number, number>) => void;
|
|
7
|
+
riffKeys: {
|
|
8
|
+
addKeyframe: (keyframe: import("./riff-keyframes").RiffKeyframe) => void;
|
|
9
|
+
getKeyframes: () => import("./riff-keyframes").RiffKeyframe[];
|
|
10
|
+
setFromSeekingHints: (keyframesFromHints: import("./riff-keyframes").RiffKeyframe[]) => void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.riffSampleCounter = void 0;
|
|
4
|
+
const riff_keyframes_1 = require("./riff-keyframes");
|
|
5
|
+
const riffSampleCounter = () => {
|
|
6
|
+
const samplesForTrack = {};
|
|
7
|
+
const riffKeys = (0, riff_keyframes_1.riffKeyframesState)();
|
|
8
|
+
const onAudioSample = (trackId, audioSample) => {
|
|
9
|
+
if (typeof samplesForTrack[trackId] === 'undefined') {
|
|
10
|
+
samplesForTrack[trackId] = 0;
|
|
11
|
+
}
|
|
12
|
+
if (audioSample.data.length > 0) {
|
|
13
|
+
samplesForTrack[trackId]++;
|
|
14
|
+
}
|
|
15
|
+
samplesForTrack[trackId]++;
|
|
16
|
+
};
|
|
17
|
+
const onVideoSample = (trackId, videoSample) => {
|
|
18
|
+
if (typeof samplesForTrack[trackId] === 'undefined') {
|
|
19
|
+
samplesForTrack[trackId] = 0;
|
|
20
|
+
}
|
|
21
|
+
if (videoSample.type === 'key') {
|
|
22
|
+
riffKeys.addKeyframe({
|
|
23
|
+
trackId,
|
|
24
|
+
decodingTimeInSeconds: videoSample.dts / videoSample.timescale,
|
|
25
|
+
positionInBytes: videoSample.offset,
|
|
26
|
+
presentationTimeInSeconds: videoSample.cts / videoSample.timescale,
|
|
27
|
+
sizeInBytes: videoSample.data.length,
|
|
28
|
+
sampleCounts: { ...samplesForTrack },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (videoSample.data.length > 0) {
|
|
32
|
+
samplesForTrack[trackId]++;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const getSamplesForTrack = (trackId) => {
|
|
36
|
+
var _a;
|
|
37
|
+
return (_a = samplesForTrack[trackId]) !== null && _a !== void 0 ? _a : 0;
|
|
38
|
+
};
|
|
39
|
+
const setSamplesFromSeek = (samples) => {
|
|
40
|
+
for (const trackId in samples) {
|
|
41
|
+
samplesForTrack[trackId] = samples[trackId];
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
onAudioSample,
|
|
46
|
+
onVideoSample,
|
|
47
|
+
getSamplesForTrack,
|
|
48
|
+
setSamplesFromSeek,
|
|
49
|
+
riffKeys,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
exports.riffSampleCounter = riffSampleCounter;
|
package/dist/state/riff.d.ts
CHANGED
|
@@ -1,10 +1,50 @@
|
|
|
1
|
+
import type { MediaParserController } from '../controller/media-parser-controller';
|
|
2
|
+
import type { LogLevel } from '../log';
|
|
3
|
+
import type { ParseMediaSrc } from '../options';
|
|
4
|
+
import type { ReaderInterface } from '../readers/reader';
|
|
1
5
|
import type { SpsAndPps } from './parser-state';
|
|
2
6
|
type AvcProfileInfoCallback = (profile: SpsAndPps) => Promise<void>;
|
|
3
|
-
export declare const riffSpecificState: (
|
|
7
|
+
export declare const riffSpecificState: ({ controller, logLevel, readerInterface, src, }: {
|
|
8
|
+
controller: MediaParserController;
|
|
9
|
+
logLevel: LogLevel;
|
|
10
|
+
readerInterface: ReaderInterface;
|
|
11
|
+
src: ParseMediaSrc;
|
|
12
|
+
}) => {
|
|
4
13
|
getAvcProfile: () => SpsAndPps | null;
|
|
5
14
|
onProfile: (profile: SpsAndPps) => Promise<void>;
|
|
6
15
|
registerOnAvcProfileCallback: (callback: AvcProfileInfoCallback) => void;
|
|
7
16
|
getNextTrackIndex: () => number;
|
|
8
17
|
incrementNextTrackIndex: () => void;
|
|
18
|
+
lazyIdx1: {
|
|
19
|
+
triggerLoad: (position: number) => Promise<{
|
|
20
|
+
entries: import("../containers/riff/riff-box").Idx1Entry[];
|
|
21
|
+
videoTrackIndex: number | null;
|
|
22
|
+
}>;
|
|
23
|
+
getLoadedIdx1: () => Promise<{
|
|
24
|
+
entries: import("../containers/riff/riff-box").Idx1Entry[];
|
|
25
|
+
videoTrackIndex: number | null;
|
|
26
|
+
} | null>;
|
|
27
|
+
getIfAlreadyLoaded: () => {
|
|
28
|
+
entries: import("../containers/riff/riff-box").Idx1Entry[];
|
|
29
|
+
videoTrackIndex: number | null;
|
|
30
|
+
} | null;
|
|
31
|
+
setFromSeekingHints: (hints: import("../containers/riff/seeking-hints").RiffSeekingHints) => void;
|
|
32
|
+
waitForLoaded: () => Promise<null> | Promise<{
|
|
33
|
+
entries: import("../containers/riff/riff-box").Idx1Entry[];
|
|
34
|
+
videoTrackIndex: number | null;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
sampleCounter: {
|
|
38
|
+
onAudioSample: (trackId: number, audioSample: import("..").AudioOrVideoSample) => void;
|
|
39
|
+
onVideoSample: (trackId: number, videoSample: import("..").AudioOrVideoSample) => void;
|
|
40
|
+
getSamplesForTrack: (trackId: number) => number;
|
|
41
|
+
setSamplesFromSeek: (samples: Record<number, number>) => void;
|
|
42
|
+
riffKeys: {
|
|
43
|
+
addKeyframe: (keyframe: import("./riff/riff-keyframes").RiffKeyframe) => void;
|
|
44
|
+
getKeyframes: () => import("./riff/riff-keyframes").RiffKeyframe[];
|
|
45
|
+
setFromSeekingHints: (keyframesFromHints: import("./riff/riff-keyframes").RiffKeyframe[]) => void;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
9
48
|
};
|
|
49
|
+
export type RiffState = ReturnType<typeof riffSpecificState>;
|
|
10
50
|
export {};
|
package/dist/state/riff.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.riffSpecificState = void 0;
|
|
4
|
-
const
|
|
4
|
+
const lazy_idx1_fetch_1 = require("./riff/lazy-idx1-fetch");
|
|
5
|
+
const sample_counter_1 = require("./riff/sample-counter");
|
|
6
|
+
const riffSpecificState = ({ controller, logLevel, readerInterface, src, }) => {
|
|
5
7
|
let avcProfile = null;
|
|
6
8
|
let nextTrackIndex = 0;
|
|
7
9
|
const profileCallbacks = [];
|
|
@@ -15,6 +17,13 @@ const riffSpecificState = () => {
|
|
|
15
17
|
}
|
|
16
18
|
profileCallbacks.length = 0;
|
|
17
19
|
};
|
|
20
|
+
const lazyIdx1 = (0, lazy_idx1_fetch_1.lazyIdx1Fetch)({
|
|
21
|
+
controller,
|
|
22
|
+
logLevel,
|
|
23
|
+
readerInterface,
|
|
24
|
+
src,
|
|
25
|
+
});
|
|
26
|
+
const sampleCounter = (0, sample_counter_1.riffSampleCounter)();
|
|
18
27
|
return {
|
|
19
28
|
getAvcProfile: () => {
|
|
20
29
|
return avcProfile;
|
|
@@ -27,6 +36,8 @@ const riffSpecificState = () => {
|
|
|
27
36
|
incrementNextTrackIndex: () => {
|
|
28
37
|
nextTrackIndex++;
|
|
29
38
|
},
|
|
39
|
+
lazyIdx1,
|
|
40
|
+
sampleCounter,
|
|
30
41
|
};
|
|
31
42
|
};
|
|
32
43
|
exports.riffSpecificState = riffSpecificState;
|
|
@@ -5,16 +5,16 @@ import type { LogLevel } from '../log';
|
|
|
5
5
|
import type { ParseMediaSrc } from '../options';
|
|
6
6
|
import type { AudioOrVideoSample, OnAudioSample, OnVideoSample } from '../webcodec-sample-types';
|
|
7
7
|
import { type KeyframesState } from './keyframes';
|
|
8
|
-
import type {
|
|
8
|
+
import type { SamplesObservedState } from './samples-observed/slow-duration-fps';
|
|
9
9
|
import type { StructureState } from './structure';
|
|
10
|
-
export declare const sampleCallback: ({ controller, hasAudioTrackHandlers, hasVideoTrackHandlers, fields, keyframes, emittedFields,
|
|
10
|
+
export declare const sampleCallback: ({ controller, hasAudioTrackHandlers, hasVideoTrackHandlers, fields, keyframes, emittedFields, samplesObserved, structure, src, seekSignal, logLevel, }: {
|
|
11
11
|
controller: MediaParserController;
|
|
12
12
|
hasAudioTrackHandlers: boolean;
|
|
13
13
|
hasVideoTrackHandlers: boolean;
|
|
14
14
|
fields: Options<ParseMediaFields>;
|
|
15
15
|
keyframes: KeyframesState;
|
|
16
16
|
emittedFields: AllOptions<ParseMediaFields>;
|
|
17
|
-
|
|
17
|
+
samplesObserved: SamplesObservedState;
|
|
18
18
|
structure: StructureState;
|
|
19
19
|
src: ParseMediaSrc;
|
|
20
20
|
seekSignal: SeekSignal;
|
|
@@ -22,7 +22,6 @@ export declare const sampleCallback: ({ controller, hasAudioTrackHandlers, hasVi
|
|
|
22
22
|
}) => {
|
|
23
23
|
registerVideoSampleCallback: (id: number, callback: OnVideoSample | null) => Promise<void>;
|
|
24
24
|
onAudioSample: (trackId: number, audioSample: AudioOrVideoSample) => Promise<void>;
|
|
25
|
-
getSamplesForTrack: (trackId: number) => number;
|
|
26
25
|
onVideoSample: (trackId: number, videoSample: AudioOrVideoSample) => Promise<void>;
|
|
27
26
|
canSkipTracksState: {
|
|
28
27
|
canSkipTracks: () => boolean;
|
|
@@ -5,7 +5,7 @@ const log_1 = require("../log");
|
|
|
5
5
|
const can_skip_tracks_1 = require("./can-skip-tracks");
|
|
6
6
|
const has_tracks_section_1 = require("./has-tracks-section");
|
|
7
7
|
const need_samples_for_fields_1 = require("./need-samples-for-fields");
|
|
8
|
-
const sampleCallback = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandlers, fields, keyframes, emittedFields,
|
|
8
|
+
const sampleCallback = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandlers, fields, keyframes, emittedFields, samplesObserved, structure, src, seekSignal, logLevel, }) => {
|
|
9
9
|
const videoSampleCallbacks = {};
|
|
10
10
|
const audioSampleCallbacks = {};
|
|
11
11
|
const queuedAudioSamples = {};
|
|
@@ -17,7 +17,6 @@ const sampleCallback = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandle
|
|
|
17
17
|
structure,
|
|
18
18
|
});
|
|
19
19
|
const tracksState = (0, has_tracks_section_1.makeTracksSectionState)(canSkipTracksState, src);
|
|
20
|
-
const samplesForTrack = {};
|
|
21
20
|
return {
|
|
22
21
|
registerVideoSampleCallback: async (id, callback) => {
|
|
23
22
|
var _a;
|
|
@@ -35,12 +34,8 @@ const sampleCallback = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandle
|
|
|
35
34
|
if (controller._internals.signal.aborted) {
|
|
36
35
|
throw new Error('Aborted');
|
|
37
36
|
}
|
|
38
|
-
if (typeof samplesForTrack[trackId] === 'undefined') {
|
|
39
|
-
samplesForTrack[trackId] = 0;
|
|
40
|
-
}
|
|
41
37
|
const callback = audioSampleCallbacks[trackId];
|
|
42
38
|
if (audioSample.data.length > 0) {
|
|
43
|
-
samplesForTrack[trackId]++;
|
|
44
39
|
// If we emit samples with data length 0, Chrome will fail
|
|
45
40
|
if (callback) {
|
|
46
41
|
if (seekSignal.getSeek()) {
|
|
@@ -52,22 +47,14 @@ const sampleCallback = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandle
|
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
49
|
if ((0, need_samples_for_fields_1.needsToIterateOverSamples)({ emittedFields, fields })) {
|
|
55
|
-
|
|
50
|
+
samplesObserved.addAudioSample(audioSample);
|
|
56
51
|
}
|
|
57
52
|
},
|
|
58
|
-
getSamplesForTrack: (trackId) => {
|
|
59
|
-
var _a;
|
|
60
|
-
return (_a = samplesForTrack[trackId]) !== null && _a !== void 0 ? _a : 0;
|
|
61
|
-
},
|
|
62
53
|
onVideoSample: async (trackId, videoSample) => {
|
|
63
54
|
if (controller._internals.signal.aborted) {
|
|
64
55
|
throw new Error('Aborted');
|
|
65
56
|
}
|
|
66
|
-
if (typeof samplesForTrack[trackId] === 'undefined') {
|
|
67
|
-
samplesForTrack[trackId] = 0;
|
|
68
|
-
}
|
|
69
57
|
if (videoSample.data.length > 0) {
|
|
70
|
-
samplesForTrack[trackId]++;
|
|
71
58
|
const callback = videoSampleCallbacks[trackId];
|
|
72
59
|
// If we emit samples with data 0, Chrome will fail
|
|
73
60
|
if (callback) {
|
|
@@ -92,7 +79,7 @@ const sampleCallback = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandle
|
|
|
92
79
|
fields,
|
|
93
80
|
emittedFields,
|
|
94
81
|
})) {
|
|
95
|
-
|
|
82
|
+
samplesObserved.addVideoSample(videoSample);
|
|
96
83
|
}
|
|
97
84
|
},
|
|
98
85
|
canSkipTracksState,
|
|
@@ -7,5 +7,7 @@ export declare const samplesObservedState: () => {
|
|
|
7
7
|
getSlowNumberOfFrames: () => number;
|
|
8
8
|
getAudioBitrate: () => number | null;
|
|
9
9
|
getVideoBitrate: () => number | null;
|
|
10
|
+
getLastSampleObserved: () => boolean;
|
|
11
|
+
setLastSampleObserved: () => void;
|
|
10
12
|
};
|
|
11
|
-
export type
|
|
13
|
+
export type SamplesObservedState = ReturnType<typeof samplesObservedState>;
|
|
@@ -6,6 +6,7 @@ const samplesObservedState = () => {
|
|
|
6
6
|
let largestVideoSample;
|
|
7
7
|
let smallestAudioSample;
|
|
8
8
|
let largestAudioSample;
|
|
9
|
+
let lastSampleObserved = false;
|
|
9
10
|
const videoSamples = new Map();
|
|
10
11
|
const audioSamples = new Map();
|
|
11
12
|
const getSlowVideoDurationInSeconds = () => {
|
|
@@ -76,6 +77,10 @@ const samplesObservedState = () => {
|
|
|
76
77
|
const videoSizesInBytes = Array.from(videoSamples.values()).reduce((acc, size) => acc + size, 0);
|
|
77
78
|
return (videoSizesInBytes * 8) / videoDuration;
|
|
78
79
|
};
|
|
80
|
+
const getLastSampleObserved = () => lastSampleObserved;
|
|
81
|
+
const setLastSampleObserved = () => {
|
|
82
|
+
lastSampleObserved = true;
|
|
83
|
+
};
|
|
79
84
|
return {
|
|
80
85
|
addVideoSample,
|
|
81
86
|
addAudioSample,
|
|
@@ -84,6 +89,8 @@ const samplesObservedState = () => {
|
|
|
84
89
|
getSlowNumberOfFrames,
|
|
85
90
|
getAudioBitrate,
|
|
86
91
|
getVideoBitrate,
|
|
92
|
+
getLastSampleObserved,
|
|
93
|
+
setLastSampleObserved,
|
|
87
94
|
};
|
|
88
95
|
};
|
|
89
96
|
exports.samplesObservedState = samplesObservedState;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.0.
|
|
1
|
+
export declare const VERSION = "4.0.289";
|
package/dist/version.js
CHANGED
|
@@ -5,12 +5,17 @@ import type { LogLevel } from './log';
|
|
|
5
5
|
import type { ParseMediaMode, ParseMediaSrc } from './options';
|
|
6
6
|
import type { IsoBaseMediaStructure } from './parse-result';
|
|
7
7
|
import type { ReaderInterface } from './readers/reader';
|
|
8
|
+
import type { AacState } from './state/aac-state';
|
|
8
9
|
import type { CurrentReader } from './state/current-reader';
|
|
10
|
+
import type { FlacState } from './state/flac-state';
|
|
9
11
|
import type { TracksState } from './state/has-tracks-section';
|
|
10
12
|
import type { IsoBaseMediaState } from './state/iso-base-media/iso-state';
|
|
11
13
|
import type { KeyframesState } from './state/keyframes';
|
|
12
14
|
import type { WebmState } from './state/matroska/webm';
|
|
15
|
+
import type { Mp3State } from './state/mp3';
|
|
13
16
|
import type { ParserState } from './state/parser-state';
|
|
17
|
+
import type { RiffState } from './state/riff';
|
|
18
|
+
import type { SamplesObservedState } from './state/samples-observed/slow-duration-fps';
|
|
14
19
|
import type { SeekInfiniteLoop } from './state/seek-infinite-loop';
|
|
15
20
|
import type { StructureState } from './state/structure';
|
|
16
21
|
import type { TransportStreamState } from './state/transport-stream/transport-stream';
|
|
@@ -35,6 +40,11 @@ export type WorkOnSeekRequestOptions = {
|
|
|
35
40
|
tracksState: TracksState;
|
|
36
41
|
webmState: WebmState;
|
|
37
42
|
keyframes: KeyframesState;
|
|
43
|
+
flacState: FlacState;
|
|
44
|
+
samplesObserved: SamplesObservedState;
|
|
45
|
+
riffState: RiffState;
|
|
46
|
+
mp3State: Mp3State;
|
|
47
|
+
aacState: AacState;
|
|
38
48
|
};
|
|
39
49
|
export declare const getWorkOnSeekRequestOptions: (state: ParserState) => WorkOnSeekRequestOptions;
|
|
40
50
|
export declare const workOnSeekRequest: (options: WorkOnSeekRequestOptions) => Promise<void>;
|