@remotion/media-parser 4.0.248 → 4.0.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boxes/avc/key.d.ts +1 -1
- package/dist/boxes/iso-base-media/continue-mdat-routine.d.ts +14 -0
- package/dist/boxes/iso-base-media/continue-mdat-routine.js +74 -0
- package/dist/boxes/iso-base-media/get-children.d.ts +8 -0
- package/dist/boxes/iso-base-media/get-children.js +23 -0
- package/dist/boxes/iso-base-media/mdat/mdat.d.ts +3 -22
- package/dist/boxes/iso-base-media/mdat/mdat.js +80 -121
- package/dist/boxes/iso-base-media/moov/moov.d.ts +1 -6
- package/dist/boxes/iso-base-media/moov/moov.js +5 -15
- package/dist/boxes/iso-base-media/parse-all-children.d.ts +8 -0
- package/dist/boxes/iso-base-media/parse-all-children.js +20 -0
- package/dist/boxes/iso-base-media/parse-boxes.d.ts +7 -0
- package/dist/boxes/iso-base-media/parse-boxes.js +46 -0
- package/dist/boxes/iso-base-media/parse-mdat-partially.d.ts +9 -0
- package/dist/boxes/iso-base-media/parse-mdat-partially.js +24 -0
- package/dist/boxes/iso-base-media/process-box.d.ts +2 -29
- package/dist/boxes/iso-base-media/process-box.js +56 -367
- package/dist/boxes/iso-base-media/stsd/mebx.d.ts +1 -4
- package/dist/boxes/iso-base-media/stsd/mebx.js +5 -15
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +4 -12
- package/dist/boxes/iso-base-media/stsd/samples.js +24 -70
- package/dist/boxes/iso-base-media/stsd/stsd.d.ts +1 -4
- package/dist/boxes/iso-base-media/stsd/stsd.js +2 -5
- package/dist/boxes/iso-base-media/trak/trak.d.ts +1 -6
- package/dist/boxes/iso-base-media/trak/trak.js +5 -15
- package/dist/boxes/iso-base-media/traversal.d.ts +0 -2
- package/dist/boxes/iso-base-media/traversal.js +1 -12
- package/dist/boxes/mp3/get-duration.d.ts +2 -0
- package/dist/boxes/mp3/get-duration.js +30 -0
- package/dist/boxes/mp3/get-frame-length.d.ts +13 -0
- package/dist/boxes/mp3/get-frame-length.js +33 -0
- package/dist/boxes/mp3/get-metadata-from-mp3.d.ts +3 -0
- package/dist/boxes/mp3/get-metadata-from-mp3.js +8 -0
- package/dist/boxes/mp3/get-tracks-from-mp3.d.ts +4 -0
- package/dist/boxes/mp3/get-tracks-from-mp3.js +25 -0
- package/dist/boxes/mp3/id3-v1.d.ts +2 -0
- package/dist/boxes/mp3/id3-v1.js +12 -0
- package/dist/boxes/mp3/id3-v2.d.ts +0 -0
- package/dist/boxes/mp3/id3-v2.js +1 -0
- package/dist/boxes/mp3/id3.d.ts +6 -0
- package/dist/boxes/mp3/id3.js +80 -0
- package/dist/boxes/mp3/parse-mp3.d.ts +7 -0
- package/dist/boxes/mp3/parse-mp3.js +41 -0
- package/dist/boxes/mp3/parse-mpeg-header.d.ts +6 -0
- package/dist/boxes/mp3/parse-mpeg-header.js +274 -0
- package/dist/boxes/mp3/samples-per-mpeg-file.d.ts +4 -0
- package/dist/boxes/mp3/samples-per-mpeg-file.js +26 -0
- package/dist/boxes/riff/continue-after-riff-result.d.ts +13 -0
- package/dist/boxes/riff/continue-after-riff-result.js +34 -0
- package/dist/boxes/riff/expect-riff-box.d.ts +1 -7
- package/dist/boxes/riff/expect-riff-box.js +47 -24
- package/dist/boxes/riff/get-tracks-from-avi.d.ts +1 -1
- package/dist/boxes/riff/get-tracks-from-avi.js +6 -10
- package/dist/boxes/riff/parse-box.d.ts +1 -7
- package/dist/boxes/riff/parse-box.js +4 -120
- package/dist/boxes/riff/parse-fmt-box.d.ts +3 -2
- package/dist/boxes/riff/parse-fmt-box.js +7 -5
- package/dist/boxes/riff/parse-list-box.js +15 -14
- package/dist/boxes/riff/parse-movi.d.ts +2 -5
- package/dist/boxes/riff/parse-movi.js +34 -56
- package/dist/boxes/riff/parse-riff-body.d.ts +7 -0
- package/dist/boxes/riff/parse-riff-body.js +25 -0
- package/dist/boxes/riff/parse-riff-box.d.ts +1 -2
- package/dist/boxes/riff/parse-riff-box.js +2 -6
- package/dist/boxes/riff/parse-riff-header.d.ts +7 -0
- package/dist/boxes/riff/parse-riff-header.js +23 -0
- package/dist/boxes/riff/parse-riff.d.ts +7 -0
- package/dist/boxes/riff/parse-riff.js +15 -0
- package/dist/boxes/riff/parse-strf.d.ts +4 -4
- package/dist/boxes/riff/parse-strf.js +4 -8
- package/dist/boxes/riff/parse-strh.js +11 -0
- package/dist/boxes/riff/parse-video-section.d.ts +6 -0
- package/dist/boxes/riff/parse-video-section.js +20 -0
- package/dist/boxes/riff/riff-box.d.ts +4 -5
- package/dist/boxes/riff/traversal.d.ts +1 -2
- package/dist/boxes/riff/traversal.js +1 -6
- package/dist/boxes/transport-stream/get-tracks.d.ts +2 -3
- package/dist/boxes/transport-stream/get-tracks.js +4 -3
- package/dist/boxes/transport-stream/parse-packet.d.ts +1 -7
- package/dist/boxes/transport-stream/parse-packet.js +3 -4
- package/dist/boxes/transport-stream/parse-stream-packet.d.ts +1 -5
- package/dist/boxes/transport-stream/parse-stream-packet.js +10 -12
- package/dist/boxes/transport-stream/parse-transport-stream.d.ts +1 -7
- package/dist/boxes/transport-stream/parse-transport-stream.js +19 -49
- package/dist/boxes/transport-stream/process-stream-buffers.d.ts +1 -2
- package/dist/boxes/transport-stream/process-stream-buffers.js +3 -3
- package/dist/boxes/webm/parse-ebml.js +3 -0
- package/dist/boxes/webm/parse-webm-header.d.ts +2 -4
- package/dist/boxes/webm/parse-webm-header.js +41 -25
- package/dist/boxes/webm/segments/parse-children.d.ts +2 -16
- package/dist/boxes/webm/segments/parse-children.js +7 -130
- package/dist/boxes/webm/segments.d.ts +4 -8
- package/dist/boxes/webm/segments.js +41 -123
- package/dist/buffer-iterator.d.ts +6 -3
- package/dist/buffer-iterator.js +27 -16
- package/dist/bun-reader.d.ts +1 -0
- package/dist/bun-reader.js +17 -0
- package/dist/continue-mdat-routine.d.ts +17 -0
- package/dist/continue-mdat-routine.js +92 -0
- package/dist/emit-available-info.js +42 -28
- package/dist/esm/from-node.mjs +8 -9
- package/dist/esm/index.mjs +5133 -5085
- package/dist/file-types/detect-file-type.js +6 -2
- package/dist/get-audio-codec.d.ts +1 -1
- package/dist/get-audio-codec.js +3 -3
- package/dist/get-container.js +5 -1
- package/dist/get-dimensions.d.ts +1 -1
- package/dist/get-dimensions.js +4 -1
- package/dist/get-duration.js +6 -2
- package/dist/get-fields-from-callbacks.js +1 -0
- package/dist/get-fps.js +3 -0
- package/dist/get-is-hdr.d.ts +1 -1
- package/dist/get-is-hdr.js +3 -3
- package/dist/get-keyframes.js +1 -1
- package/dist/get-tracks.d.ts +2 -2
- package/dist/get-tracks.js +23 -15
- package/dist/get-video-codec.d.ts +1 -1
- package/dist/get-video-codec.js +3 -3
- package/dist/has-all-info.js +4 -3
- package/dist/index.d.ts +65 -21
- package/dist/index.js +1 -1
- package/dist/may-skip-video-data/may-skip-video-data.js +6 -2
- package/dist/may-skip-video-data/need-samples-for-fields.js +1 -0
- package/dist/metadata/get-metadata.d.ts +1 -0
- package/dist/metadata/get-metadata.js +16 -1
- package/dist/options.d.ts +12 -5
- package/dist/parse-media.js +88 -68
- package/dist/parse-result.d.ts +17 -19
- package/dist/parse-video.d.ts +3 -17
- package/dist/parse-video.js +52 -40
- package/dist/readers/from-node.js +7 -8
- package/dist/state/can-skip-tracks.d.ts +8 -1
- package/dist/state/can-skip-tracks.js +38 -26
- package/dist/state/emitted-fields.js +1 -0
- package/dist/state/images.d.ts +9 -0
- package/dist/state/images.js +14 -0
- package/dist/state/iso-base-media/cached-sample-positions.d.ts +15 -0
- package/dist/state/iso-base-media/cached-sample-positions.js +42 -0
- package/dist/state/iso-base-media/iso-state.d.ts +8 -0
- package/dist/state/iso-base-media/iso-state.js +15 -0
- package/dist/state/iso-state.d.ts +4 -0
- package/dist/state/iso-state.js +13 -0
- package/dist/state/mp3.d.ts +11 -0
- package/dist/state/mp3.js +13 -0
- package/dist/state/parser-state.d.ts +57 -11
- package/dist/state/parser-state.js +17 -2
- package/dist/state/sample-callbacks.d.ts +5 -1
- package/dist/state/sample-callbacks.js +8 -2
- package/dist/state/slow-duration-fps.d.ts +2 -1
- package/dist/state/slow-duration-fps.js +52 -18
- package/dist/state/transport-stream.d.ts +8 -0
- package/dist/state/transport-stream.js +11 -0
- package/dist/state/video-section.d.ts +16 -0
- package/dist/state/video-section.js +37 -0
- package/dist/state/webm.d.ts +15 -0
- package/dist/state/webm.js +32 -0
- package/dist/throttled-progress.d.ts +14 -0
- package/dist/throttled-progress.js +44 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/test.json +663 -0
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeCanSkipTracksState = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
exports.makeCanSkipTracksState = exports.needsTracksForField = void 0;
|
|
4
|
+
const needsTracksForField = ({ field, structure, }) => {
|
|
5
|
+
if (field === 'dimensions') {
|
|
6
|
+
if (structure.type === 'riff') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (field === 'audioCodec' ||
|
|
12
|
+
field === 'durationInSeconds' ||
|
|
13
|
+
field === 'slowDurationInSeconds' ||
|
|
14
|
+
field === 'slowFps' ||
|
|
15
|
+
field === 'fps' ||
|
|
16
|
+
field === 'isHdr' ||
|
|
17
|
+
field === 'rotation' ||
|
|
18
|
+
field === 'structure' ||
|
|
19
|
+
field === 'tracks' ||
|
|
20
|
+
field === 'unrotatedDimensions' ||
|
|
21
|
+
field === 'videoCodec' ||
|
|
22
|
+
field === 'metadata' ||
|
|
23
|
+
field === 'location' ||
|
|
24
|
+
field === 'slowKeyframes' ||
|
|
25
|
+
field === 'slowNumberOfFrames' ||
|
|
26
|
+
field === 'keyframes' ||
|
|
27
|
+
field === 'images') {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (field === 'container' ||
|
|
31
|
+
field === 'internalStats' ||
|
|
32
|
+
field === 'mimeType' ||
|
|
33
|
+
field === 'name' ||
|
|
34
|
+
field === 'size') {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`field not implemeted ${field}`);
|
|
27
38
|
};
|
|
28
|
-
|
|
39
|
+
exports.needsTracksForField = needsTracksForField;
|
|
40
|
+
const makeCanSkipTracksState = ({ hasAudioTrackHandlers, fields, hasVideoTrackHandlers, structure, }) => {
|
|
29
41
|
return {
|
|
30
42
|
canSkipTracks: () => {
|
|
31
43
|
if (hasAudioTrackHandlers || hasVideoTrackHandlers) {
|
|
@@ -33,7 +45,7 @@ const makeCanSkipTracksState = ({ hasAudioTrackHandlers, fields, hasVideoTrackHa
|
|
|
33
45
|
}
|
|
34
46
|
const keys = Object.keys(fields !== null && fields !== void 0 ? fields : {});
|
|
35
47
|
const selectedKeys = keys.filter((k) => fields[k]);
|
|
36
|
-
return !selectedKeys.some((k) =>
|
|
48
|
+
return !selectedKeys.some((k) => (0, exports.needsTracksForField)({ field: k, structure: structure.getStructure() }));
|
|
37
49
|
},
|
|
38
50
|
};
|
|
39
51
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type MediaParserEmbeddedImage = {
|
|
2
|
+
description: string | null;
|
|
3
|
+
mimeType: string | null;
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
};
|
|
6
|
+
export declare const imagesState: () => {
|
|
7
|
+
images: MediaParserEmbeddedImage[];
|
|
8
|
+
addImage: (image: MediaParserEmbeddedImage) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imagesState = void 0;
|
|
4
|
+
const imagesState = () => {
|
|
5
|
+
const images = [];
|
|
6
|
+
const addImage = (image) => {
|
|
7
|
+
images.push(image);
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
images,
|
|
11
|
+
addImage,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.imagesState = imagesState;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SamplePosition } from '../../get-sample-positions';
|
|
2
|
+
import type { AudioTrack, OtherTrack, VideoTrack } from '../../get-tracks';
|
|
3
|
+
import type { ParserState } from '../parser-state';
|
|
4
|
+
export type FlatSample = {
|
|
5
|
+
track: VideoTrack | AudioTrack | OtherTrack;
|
|
6
|
+
samplePosition: SamplePosition;
|
|
7
|
+
};
|
|
8
|
+
export declare const calculateFlatSamples: (state: ParserState) => {
|
|
9
|
+
track: VideoTrack | AudioTrack | OtherTrack;
|
|
10
|
+
samplePosition: SamplePosition;
|
|
11
|
+
}[];
|
|
12
|
+
export declare const cachedSamplePositionsState: () => {
|
|
13
|
+
getSamples: () => FlatSample[] | null;
|
|
14
|
+
setSamples: (samples: FlatSample[]) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cachedSamplePositionsState = exports.calculateFlatSamples = void 0;
|
|
4
|
+
const get_sample_positions_from_track_1 = require("../../boxes/iso-base-media/get-sample-positions-from-track");
|
|
5
|
+
const traversal_1 = require("../../boxes/iso-base-media/traversal");
|
|
6
|
+
const get_tracks_1 = require("../../get-tracks");
|
|
7
|
+
const calculateFlatSamples = (state) => {
|
|
8
|
+
const tracks = (0, get_tracks_1.getTracks)(state);
|
|
9
|
+
const allTracks = [
|
|
10
|
+
...tracks.videoTracks,
|
|
11
|
+
...tracks.audioTracks,
|
|
12
|
+
...tracks.otherTracks,
|
|
13
|
+
];
|
|
14
|
+
const flatSamples = allTracks
|
|
15
|
+
.map((track) => {
|
|
16
|
+
const samplePositions = (0, get_sample_positions_from_track_1.getSamplePositionsFromTrack)(track.trakBox, (0, traversal_1.getMoofBox)(state.structure.getStructure().boxes));
|
|
17
|
+
if (!samplePositions) {
|
|
18
|
+
throw new Error('No sample positions');
|
|
19
|
+
}
|
|
20
|
+
return samplePositions.map((samplePosition) => {
|
|
21
|
+
return {
|
|
22
|
+
track,
|
|
23
|
+
samplePosition,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
})
|
|
27
|
+
.flat(1);
|
|
28
|
+
return flatSamples;
|
|
29
|
+
};
|
|
30
|
+
exports.calculateFlatSamples = calculateFlatSamples;
|
|
31
|
+
const cachedSamplePositionsState = () => {
|
|
32
|
+
let cached = null;
|
|
33
|
+
return {
|
|
34
|
+
getSamples: () => {
|
|
35
|
+
return cached;
|
|
36
|
+
},
|
|
37
|
+
setSamples: (samples) => {
|
|
38
|
+
cached = samples;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.cachedSamplePositionsState = cachedSamplePositionsState;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const isoBaseMediaState: () => {
|
|
2
|
+
getShouldReturnToVideoSectionAfterEnd: () => boolean;
|
|
3
|
+
setShouldReturnToVideoSectionAfterEnd: (value: boolean) => void;
|
|
4
|
+
flatSamples: {
|
|
5
|
+
getSamples: () => import("./cached-sample-positions").FlatSample[] | null;
|
|
6
|
+
setSamples: (samples: import("./cached-sample-positions").FlatSample[]) => void;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isoBaseMediaState = void 0;
|
|
4
|
+
const cached_sample_positions_1 = require("./cached-sample-positions");
|
|
5
|
+
const isoBaseMediaState = () => {
|
|
6
|
+
let shouldReturnToVideoSectionAfterEnd = false;
|
|
7
|
+
return {
|
|
8
|
+
getShouldReturnToVideoSectionAfterEnd: () => shouldReturnToVideoSectionAfterEnd,
|
|
9
|
+
setShouldReturnToVideoSectionAfterEnd: (value) => {
|
|
10
|
+
shouldReturnToVideoSectionAfterEnd = value;
|
|
11
|
+
},
|
|
12
|
+
flatSamples: (0, cached_sample_positions_1.cachedSamplePositionsState)(),
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
exports.isoBaseMediaState = isoBaseMediaState;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isoBaseMediaState = void 0;
|
|
4
|
+
const isoBaseMediaState = () => {
|
|
5
|
+
let shouldReturnToVideoSectionAfterEnd = false;
|
|
6
|
+
return {
|
|
7
|
+
getShouldReturnToVideoSectionAfterEnd: () => shouldReturnToVideoSectionAfterEnd,
|
|
8
|
+
setShouldReturnToVideoSectionAfterEnd: (value) => {
|
|
9
|
+
shouldReturnToVideoSectionAfterEnd = value;
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
exports.isoBaseMediaState = isoBaseMediaState;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Mp3Info = {
|
|
2
|
+
sampleRate: number;
|
|
3
|
+
mpegVersion: 1 | 2;
|
|
4
|
+
layer: number;
|
|
5
|
+
bitrateKbit: number;
|
|
6
|
+
startOfMpegStream: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const makeMp3State: () => {
|
|
9
|
+
getMp3Info: () => Mp3Info | null;
|
|
10
|
+
setMp3Info: (info: Mp3Info) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeMp3State = void 0;
|
|
4
|
+
const makeMp3State = () => {
|
|
5
|
+
let mp3Info = null;
|
|
6
|
+
return {
|
|
7
|
+
getMp3Info: () => mp3Info,
|
|
8
|
+
setMp3Info: (info) => {
|
|
9
|
+
mp3Info = info;
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
exports.makeMp3State = makeMp3State;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AvcPPs, AvcProfileInfo } from '../boxes/avc/parse-avc';
|
|
2
2
|
import type { BufferIterator } from '../buffer-iterator';
|
|
3
|
+
import type { LogLevel } from '../log';
|
|
3
4
|
import type { Options, ParseMediaFields } from '../options';
|
|
4
5
|
import type { OnAudioTrack, OnVideoTrack } from '../webcodec-sample-types';
|
|
5
6
|
export type InternalStats = {
|
|
@@ -10,7 +11,7 @@ export type SpsAndPps = {
|
|
|
10
11
|
sps: AvcProfileInfo;
|
|
11
12
|
pps: AvcPPs;
|
|
12
13
|
};
|
|
13
|
-
export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHandlers, signal, getIterator, fields, onAudioTrack, onVideoTrack, supportsContentRange, }: {
|
|
14
|
+
export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHandlers, signal, getIterator, fields, onAudioTrack, onVideoTrack, supportsContentRange, contentLength, logLevel, }: {
|
|
14
15
|
hasAudioTrackHandlers: boolean;
|
|
15
16
|
hasVideoTrackHandlers: boolean;
|
|
16
17
|
signal: AbortSignal | undefined;
|
|
@@ -19,6 +20,8 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
19
20
|
supportsContentRange: boolean;
|
|
20
21
|
onAudioTrack: OnAudioTrack | null;
|
|
21
22
|
onVideoTrack: OnVideoTrack | null;
|
|
23
|
+
contentLength: number | null;
|
|
24
|
+
logLevel: LogLevel;
|
|
22
25
|
}) => {
|
|
23
26
|
riff: {
|
|
24
27
|
getAvcProfile: () => SpsAndPps | null;
|
|
@@ -27,6 +30,38 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
27
30
|
getNextTrackIndex: () => number;
|
|
28
31
|
incrementNextTrackIndex: () => void;
|
|
29
32
|
};
|
|
33
|
+
transportStream: {
|
|
34
|
+
nextPesHeaderStore: {
|
|
35
|
+
setNextPesHeader: (pesHeader: import("../boxes/transport-stream/parse-pes").PacketPes) => void;
|
|
36
|
+
getNextPesHeader: () => import("../boxes/transport-stream/parse-pes").PacketPes;
|
|
37
|
+
};
|
|
38
|
+
streamBuffers: Map<number, import("../boxes/transport-stream/process-stream-buffers").TransportStreamPacketBuffer>;
|
|
39
|
+
};
|
|
40
|
+
webm: {
|
|
41
|
+
onTrackEntrySegment: import("../boxes/webm/segments").OnTrackEntrySegment;
|
|
42
|
+
getTrackInfoByNumber: (id: number) => import("../boxes/webm/segments/track-entry").TrackInfo;
|
|
43
|
+
setTimestampOffset: (byteOffset: number, timestamp: number) => void;
|
|
44
|
+
getTimestampOffsetForByteOffset: (byteOffset: number) => number | undefined;
|
|
45
|
+
timescale: null;
|
|
46
|
+
getTimescale: () => number;
|
|
47
|
+
setTimescale: (newTimescale: number) => void;
|
|
48
|
+
addSegment: (seg: Omit<import("./webm").SegmentSection, "index">) => void;
|
|
49
|
+
addCluster: (cluster: import("./webm").ClusterSection) => void;
|
|
50
|
+
isInsideSegment: (iterator: BufferIterator) => import("./webm").SegmentSection | null;
|
|
51
|
+
isInsideCluster: (iterator: BufferIterator) => import("./webm").ClusterSection | null;
|
|
52
|
+
};
|
|
53
|
+
iso: {
|
|
54
|
+
getShouldReturnToVideoSectionAfterEnd: () => boolean;
|
|
55
|
+
setShouldReturnToVideoSectionAfterEnd: (value: boolean) => void;
|
|
56
|
+
flatSamples: {
|
|
57
|
+
getSamples: () => import("./iso-base-media/cached-sample-positions").FlatSample[] | null;
|
|
58
|
+
setSamples: (samples: import("./iso-base-media/cached-sample-positions").FlatSample[]) => void;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
mp3Info: {
|
|
62
|
+
getMp3Info: () => import("./mp3").Mp3Info | null;
|
|
63
|
+
setMp3Info: (info: import("./mp3").Mp3Info) => void;
|
|
64
|
+
};
|
|
30
65
|
callbacks: {
|
|
31
66
|
registerVideoSampleCallback: (id: number, callback: import("../webcodec-sample-types").OnVideoSample | null) => Promise<void>;
|
|
32
67
|
onAudioSample: (trackId: number, audioSample: import("../webcodec-sample-types").AudioOrVideoSample) => Promise<void>;
|
|
@@ -45,6 +80,8 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
45
80
|
};
|
|
46
81
|
audioSampleCallbacks: Record<number, import("../webcodec-sample-types").OnAudioSample>;
|
|
47
82
|
videoSampleCallbacks: Record<number, import("../webcodec-sample-types").OnVideoSample>;
|
|
83
|
+
hasAudioTrackHandlers: boolean;
|
|
84
|
+
hasVideoTrackHandlers: boolean;
|
|
48
85
|
};
|
|
49
86
|
getInternalStats: () => InternalStats;
|
|
50
87
|
getSkipBytes: () => number;
|
|
@@ -61,22 +98,31 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
|
|
|
61
98
|
onAudioTrack: OnAudioTrack | null;
|
|
62
99
|
onVideoTrack: OnVideoTrack | null;
|
|
63
100
|
supportsContentRange: boolean;
|
|
64
|
-
webm: {
|
|
65
|
-
onTrackEntrySegment: import("../boxes/webm/segments").OnTrackEntrySegment;
|
|
66
|
-
getTrackInfoByNumber: (id: number) => import("../boxes/webm/segments/track-entry").TrackInfo;
|
|
67
|
-
setTimestampOffset: (byteOffset: number, timestamp: number) => void;
|
|
68
|
-
getTimestampOffsetForByteOffset: (byteOffset: number) => number | undefined;
|
|
69
|
-
timescale: null;
|
|
70
|
-
getTimescale: () => number;
|
|
71
|
-
setTimescale: (newTimescale: number) => void;
|
|
72
|
-
};
|
|
73
101
|
emittedFields: import("../options").AllOptions<ParseMediaFields>;
|
|
74
102
|
fields: Partial<import("../options").AllOptions<ParseMediaFields>>;
|
|
75
103
|
slowDurationAndFps: {
|
|
76
|
-
|
|
104
|
+
addVideoSample: (videoSample: import("../webcodec-sample-types").AudioOrVideoSample) => void;
|
|
105
|
+
addAudioSample: (audioSample: import("../webcodec-sample-types").AudioOrVideoSample) => void;
|
|
77
106
|
getSlowDurationInSeconds: () => number;
|
|
78
107
|
getFps: () => number;
|
|
79
108
|
getSlowNumberOfFrames: () => number;
|
|
80
109
|
};
|
|
110
|
+
contentLength: number | null;
|
|
111
|
+
images: {
|
|
112
|
+
images: import("./images").MediaParserEmbeddedImage[];
|
|
113
|
+
addImage: (image: import("./images").MediaParserEmbeddedImage) => void;
|
|
114
|
+
};
|
|
115
|
+
videoSection: {
|
|
116
|
+
setVideoSection: (section: {
|
|
117
|
+
start: number;
|
|
118
|
+
size: number;
|
|
119
|
+
}) => void;
|
|
120
|
+
getVideoSection: () => {
|
|
121
|
+
start: number;
|
|
122
|
+
size: number;
|
|
123
|
+
};
|
|
124
|
+
isInVideoSectionState: (iterator: BufferIterator) => "no-section-defined" | "in-section" | "outside-section";
|
|
125
|
+
};
|
|
126
|
+
logLevel: "trace" | "verbose" | "info" | "warn" | "error";
|
|
81
127
|
};
|
|
82
128
|
export type ParserState = ReturnType<typeof makeParserState>;
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeParserState = void 0;
|
|
4
4
|
const emitted_fields_1 = require("./emitted-fields");
|
|
5
|
+
const images_1 = require("./images");
|
|
6
|
+
const iso_state_1 = require("./iso-base-media/iso-state");
|
|
5
7
|
const keyframes_1 = require("./keyframes");
|
|
8
|
+
const mp3_1 = require("./mp3");
|
|
6
9
|
const riff_1 = require("./riff");
|
|
7
10
|
const sample_callbacks_1 = require("./sample-callbacks");
|
|
8
11
|
const slow_duration_fps_1 = require("./slow-duration-fps");
|
|
9
12
|
const structure_1 = require("./structure");
|
|
13
|
+
const transport_stream_1 = require("./transport-stream");
|
|
14
|
+
const video_section_1 = require("./video-section");
|
|
10
15
|
const webm_1 = require("./webm");
|
|
11
|
-
const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, signal, getIterator, fields, onAudioTrack, onVideoTrack, supportsContentRange, }) => {
|
|
16
|
+
const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, signal, getIterator, fields, onAudioTrack, onVideoTrack, supportsContentRange, contentLength, logLevel, }) => {
|
|
12
17
|
let skippedBytes = 0;
|
|
13
18
|
const increaseSkippedBytes = (bytes) => {
|
|
14
19
|
skippedBytes += bytes;
|
|
@@ -17,8 +22,14 @@ const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, signal,
|
|
|
17
22
|
const keyframes = (0, keyframes_1.keyframesState)();
|
|
18
23
|
const emittedFields = (0, emitted_fields_1.emittedState)();
|
|
19
24
|
const slowDurationAndFps = (0, slow_duration_fps_1.slowDurationAndFpsState)();
|
|
25
|
+
const mp3Info = (0, mp3_1.makeMp3State)();
|
|
26
|
+
const images = (0, images_1.imagesState)();
|
|
20
27
|
return {
|
|
21
28
|
riff: (0, riff_1.riffSpecificState)(),
|
|
29
|
+
transportStream: (0, transport_stream_1.transportStreamState)(),
|
|
30
|
+
webm: (0, webm_1.webmState)(),
|
|
31
|
+
iso: (0, iso_state_1.isoBaseMediaState)(),
|
|
32
|
+
mp3Info,
|
|
22
33
|
callbacks: (0, sample_callbacks_1.sampleCallback)({
|
|
23
34
|
signal,
|
|
24
35
|
hasAudioTrackHandlers,
|
|
@@ -27,6 +38,7 @@ const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, signal,
|
|
|
27
38
|
keyframes,
|
|
28
39
|
emittedFields,
|
|
29
40
|
slowDurationAndFpsState: slowDurationAndFps,
|
|
41
|
+
structure,
|
|
30
42
|
}),
|
|
31
43
|
getInternalStats: () => {
|
|
32
44
|
var _a, _b;
|
|
@@ -42,10 +54,13 @@ const makeParserState = ({ hasAudioTrackHandlers, hasVideoTrackHandlers, signal,
|
|
|
42
54
|
onAudioTrack,
|
|
43
55
|
onVideoTrack,
|
|
44
56
|
supportsContentRange,
|
|
45
|
-
webm: (0, webm_1.webmState)(),
|
|
46
57
|
emittedFields,
|
|
47
58
|
fields,
|
|
48
59
|
slowDurationAndFps,
|
|
60
|
+
contentLength,
|
|
61
|
+
images,
|
|
62
|
+
videoSection: (0, video_section_1.videoSectionState)(),
|
|
63
|
+
logLevel,
|
|
49
64
|
};
|
|
50
65
|
};
|
|
51
66
|
exports.makeParserState = makeParserState;
|
|
@@ -2,7 +2,8 @@ import type { AllOptions, Options, ParseMediaFields } from '../options';
|
|
|
2
2
|
import type { AudioOrVideoSample, OnAudioSample, OnVideoSample } from '../webcodec-sample-types';
|
|
3
3
|
import { type KeyframesState } from './keyframes';
|
|
4
4
|
import type { SlowDurationAndFpsState } from './slow-duration-fps';
|
|
5
|
-
|
|
5
|
+
import type { StructureState } from './structure';
|
|
6
|
+
export declare const sampleCallback: ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers, fields, keyframes, emittedFields, slowDurationAndFpsState, structure, }: {
|
|
6
7
|
signal: AbortSignal | undefined;
|
|
7
8
|
hasAudioTrackHandlers: boolean;
|
|
8
9
|
hasVideoTrackHandlers: boolean;
|
|
@@ -10,6 +11,7 @@ export declare const sampleCallback: ({ signal, hasAudioTrackHandlers, hasVideoT
|
|
|
10
11
|
keyframes: KeyframesState;
|
|
11
12
|
emittedFields: AllOptions<ParseMediaFields>;
|
|
12
13
|
slowDurationAndFpsState: SlowDurationAndFpsState;
|
|
14
|
+
structure: StructureState;
|
|
13
15
|
}) => {
|
|
14
16
|
registerVideoSampleCallback: (id: number, callback: OnVideoSample | null) => Promise<void>;
|
|
15
17
|
onAudioSample: (trackId: number, audioSample: AudioOrVideoSample) => Promise<void>;
|
|
@@ -28,4 +30,6 @@ export declare const sampleCallback: ({ signal, hasAudioTrackHandlers, hasVideoT
|
|
|
28
30
|
};
|
|
29
31
|
audioSampleCallbacks: Record<number, OnAudioSample>;
|
|
30
32
|
videoSampleCallbacks: Record<number, OnVideoSample>;
|
|
33
|
+
hasAudioTrackHandlers: boolean;
|
|
34
|
+
hasVideoTrackHandlers: boolean;
|
|
31
35
|
};
|
|
@@ -4,7 +4,7 @@ exports.sampleCallback = void 0;
|
|
|
4
4
|
const need_samples_for_fields_1 = require("../may-skip-video-data/need-samples-for-fields");
|
|
5
5
|
const can_skip_tracks_1 = require("./can-skip-tracks");
|
|
6
6
|
const has_tracks_section_1 = require("./has-tracks-section");
|
|
7
|
-
const sampleCallback = ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers, fields, keyframes, emittedFields, slowDurationAndFpsState, }) => {
|
|
7
|
+
const sampleCallback = ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers, fields, keyframes, emittedFields, slowDurationAndFpsState, structure, }) => {
|
|
8
8
|
const videoSampleCallbacks = {};
|
|
9
9
|
const audioSampleCallbacks = {};
|
|
10
10
|
const queuedAudioSamples = {};
|
|
@@ -13,6 +13,7 @@ const sampleCallback = ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers,
|
|
|
13
13
|
hasAudioTrackHandlers,
|
|
14
14
|
fields,
|
|
15
15
|
hasVideoTrackHandlers,
|
|
16
|
+
structure,
|
|
16
17
|
});
|
|
17
18
|
const tracksState = (0, has_tracks_section_1.makeTracksSectionState)(canSkipTracksState);
|
|
18
19
|
const samplesForTrack = {};
|
|
@@ -44,6 +45,9 @@ const sampleCallback = ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers,
|
|
|
44
45
|
await callback(audioSample);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
if ((0, need_samples_for_fields_1.needsToIterateOverSamples)({ emittedFields, fields })) {
|
|
49
|
+
slowDurationAndFpsState.addAudioSample(audioSample);
|
|
50
|
+
}
|
|
47
51
|
},
|
|
48
52
|
getSamplesForTrack: (trackId) => {
|
|
49
53
|
var _a;
|
|
@@ -77,7 +81,7 @@ const sampleCallback = ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers,
|
|
|
77
81
|
sizeInBytes: videoSample.data.length,
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
|
-
slowDurationAndFpsState.
|
|
84
|
+
slowDurationAndFpsState.addVideoSample(videoSample);
|
|
81
85
|
}
|
|
82
86
|
},
|
|
83
87
|
canSkipTracksState,
|
|
@@ -96,6 +100,8 @@ const sampleCallback = ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers,
|
|
|
96
100
|
tracks: tracksState,
|
|
97
101
|
audioSampleCallbacks,
|
|
98
102
|
videoSampleCallbacks,
|
|
103
|
+
hasAudioTrackHandlers,
|
|
104
|
+
hasVideoTrackHandlers,
|
|
99
105
|
};
|
|
100
106
|
};
|
|
101
107
|
exports.sampleCallback = sampleCallback;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AudioOrVideoSample } from '../webcodec-sample-types';
|
|
2
2
|
export declare const slowDurationAndFpsState: () => {
|
|
3
|
-
|
|
3
|
+
addVideoSample: (videoSample: AudioOrVideoSample) => void;
|
|
4
|
+
addAudioSample: (audioSample: AudioOrVideoSample) => void;
|
|
4
5
|
getSlowDurationInSeconds: () => number;
|
|
5
6
|
getFps: () => number;
|
|
6
7
|
getSlowNumberOfFrames: () => number;
|
|
@@ -2,35 +2,69 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.slowDurationAndFpsState = void 0;
|
|
4
4
|
const slowDurationAndFpsState = () => {
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
let
|
|
5
|
+
let smallestVideoSample;
|
|
6
|
+
let largestVideoSample;
|
|
7
|
+
let smallestAudioSample;
|
|
8
|
+
let largestAudioSample;
|
|
9
|
+
let videoSamples = 0;
|
|
10
|
+
let audioSamples = 0;
|
|
11
|
+
const getSlowVideoDurationInSeconds = () => {
|
|
12
|
+
let videoDuration = null;
|
|
13
|
+
if (smallestVideoSample !== undefined && largestVideoSample !== undefined) {
|
|
14
|
+
const startingTimestampDifference = largestVideoSample - smallestVideoSample;
|
|
15
|
+
const timeBetweenSamples = startingTimestampDifference / (videoSamples - 1);
|
|
16
|
+
videoDuration = timeBetweenSamples * videoSamples;
|
|
17
|
+
}
|
|
18
|
+
return videoDuration;
|
|
19
|
+
};
|
|
8
20
|
const getSlowDurationInSeconds = () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
const videoDuration = getSlowVideoDurationInSeconds();
|
|
22
|
+
let audioDuration = null;
|
|
23
|
+
if (smallestAudioSample !== undefined && largestAudioSample !== undefined) {
|
|
24
|
+
const startingTimestampDifferenceAudio = largestAudioSample - smallestAudioSample;
|
|
25
|
+
const timeBetweenSamplesAudio = startingTimestampDifferenceAudio / (audioSamples - 1);
|
|
26
|
+
audioDuration = timeBetweenSamplesAudio * audioSamples;
|
|
13
27
|
}
|
|
14
|
-
|
|
28
|
+
if (videoDuration === null && audioDuration === null) {
|
|
29
|
+
throw new Error('No samples');
|
|
30
|
+
}
|
|
31
|
+
return Math.max(videoDuration !== null && videoDuration !== void 0 ? videoDuration : 0, audioDuration !== null && audioDuration !== void 0 ? audioDuration : 0);
|
|
15
32
|
};
|
|
16
33
|
return {
|
|
17
|
-
|
|
18
|
-
|
|
34
|
+
addVideoSample: (videoSample) => {
|
|
35
|
+
videoSamples++;
|
|
19
36
|
const presentationTimeInSeconds = videoSample.cts / videoSample.timescale;
|
|
20
|
-
if (
|
|
21
|
-
presentationTimeInSeconds >
|
|
22
|
-
|
|
37
|
+
if (largestVideoSample === undefined ||
|
|
38
|
+
presentationTimeInSeconds > largestVideoSample) {
|
|
39
|
+
largestVideoSample = presentationTimeInSeconds;
|
|
23
40
|
}
|
|
24
|
-
if (
|
|
25
|
-
presentationTimeInSeconds <
|
|
26
|
-
|
|
41
|
+
if (smallestVideoSample === undefined ||
|
|
42
|
+
presentationTimeInSeconds < smallestVideoSample) {
|
|
43
|
+
smallestVideoSample = presentationTimeInSeconds;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
addAudioSample: (audioSample) => {
|
|
47
|
+
audioSamples++;
|
|
48
|
+
const presentationTimeInSeconds = audioSample.cts / audioSample.timescale;
|
|
49
|
+
if (largestAudioSample === undefined ||
|
|
50
|
+
presentationTimeInSeconds > largestAudioSample) {
|
|
51
|
+
largestAudioSample = presentationTimeInSeconds;
|
|
52
|
+
}
|
|
53
|
+
if (smallestAudioSample === undefined ||
|
|
54
|
+
presentationTimeInSeconds < smallestAudioSample) {
|
|
55
|
+
smallestAudioSample = presentationTimeInSeconds;
|
|
27
56
|
}
|
|
28
57
|
},
|
|
29
58
|
getSlowDurationInSeconds,
|
|
30
59
|
getFps: () => {
|
|
31
|
-
|
|
60
|
+
var _a;
|
|
61
|
+
const videoDuration = (_a = getSlowVideoDurationInSeconds()) !== null && _a !== void 0 ? _a : 0;
|
|
62
|
+
if (videoDuration === 0) {
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
return videoSamples / videoDuration;
|
|
32
66
|
},
|
|
33
|
-
getSlowNumberOfFrames: () =>
|
|
67
|
+
getSlowNumberOfFrames: () => videoSamples,
|
|
34
68
|
};
|
|
35
69
|
};
|
|
36
70
|
exports.slowDurationAndFpsState = slowDurationAndFpsState;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TransportStreamPacketBuffer } from '../boxes/transport-stream/process-stream-buffers';
|
|
2
|
+
export declare const transportStreamState: () => {
|
|
3
|
+
nextPesHeaderStore: {
|
|
4
|
+
setNextPesHeader: (pesHeader: import("../boxes/transport-stream/parse-pes").PacketPes) => void;
|
|
5
|
+
getNextPesHeader: () => import("../boxes/transport-stream/parse-pes").PacketPes;
|
|
6
|
+
};
|
|
7
|
+
streamBuffers: Map<number, TransportStreamPacketBuffer>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transportStreamState = void 0;
|
|
4
|
+
const next_pes_header_store_1 = require("../boxes/transport-stream/next-pes-header-store");
|
|
5
|
+
const transportStreamState = () => {
|
|
6
|
+
return {
|
|
7
|
+
nextPesHeaderStore: (0, next_pes_header_store_1.makeNextPesHeaderStore)(),
|
|
8
|
+
streamBuffers: new Map(),
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.transportStreamState = transportStreamState;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps track of in which section of the file the video is playing
|
|
3
|
+
* Usually this section is in a different format and it is the only section
|
|
4
|
+
* that can be read partially
|
|
5
|
+
*/
|
|
6
|
+
import type { BufferIterator } from '../buffer-iterator';
|
|
7
|
+
type VideoSection = {
|
|
8
|
+
start: number;
|
|
9
|
+
size: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const videoSectionState: () => {
|
|
12
|
+
setVideoSection: (section: VideoSection) => void;
|
|
13
|
+
getVideoSection: () => VideoSection;
|
|
14
|
+
isInVideoSectionState: (iterator: BufferIterator) => "no-section-defined" | "in-section" | "outside-section";
|
|
15
|
+
};
|
|
16
|
+
export {};
|