@remotion/media-parser 4.0.251 → 4.0.253
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aac-codecprivate.d.ts +2 -1
- package/dist/aac-codecprivate.js +28 -7
- package/dist/abort.d.ts +1 -0
- package/dist/abort.js +7 -0
- package/dist/buffer-iterator.d.ts +5 -1
- package/dist/buffer-iterator.js +5 -5
- package/dist/containers/aac/parse-aac.js +3 -2
- package/dist/containers/flac/get-channel-count.d.ts +1 -1
- package/dist/containers/flac/get-duration-from-flac.js +1 -4
- package/dist/containers/flac/get-sample-rate.js +1 -1
- package/dist/containers/flac/parse-flac-frame.js +3 -9
- package/dist/containers/flac/parse-flac.js +2 -7
- package/dist/containers/flac/parse-header.js +2 -2
- package/dist/containers/flac/parse-metadata.js +2 -2
- package/dist/containers/flac/parse-streaminfo.js +3 -3
- package/dist/containers/flac/parse-unknown-block.js +2 -2
- package/dist/containers/iso-base-media/base-media-box.d.ts +1 -4
- package/dist/containers/iso-base-media/get-actual-number-of-channels.js +1 -1
- package/dist/containers/iso-base-media/get-children.js +2 -2
- package/dist/containers/iso-base-media/get-keyframes.d.ts +2 -2
- package/dist/containers/iso-base-media/get-keyframes.js +8 -4
- package/dist/containers/iso-base-media/get-moov-atom.d.ts +6 -0
- package/dist/containers/iso-base-media/get-moov-atom.js +73 -0
- package/dist/containers/iso-base-media/get-sample-positions-from-track.d.ts +4 -1
- package/dist/containers/iso-base-media/get-sample-positions-from-track.js +7 -3
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.js +1 -1
- package/dist/containers/iso-base-media/mdat/mdat.d.ts +2 -1
- package/dist/containers/iso-base-media/mdat/mdat.js +16 -11
- package/dist/containers/iso-base-media/parse-boxes.js +4 -26
- package/dist/containers/iso-base-media/process-box.js +50 -163
- package/dist/containers/iso-base-media/stsd/samples.js +1 -0
- package/dist/containers/iso-base-media/traversal.d.ts +3 -2
- package/dist/containers/iso-base-media/traversal.js +11 -10
- package/dist/containers/mp3/get-duration.js +0 -3
- package/dist/containers/mp3/id3.js +1 -1
- package/dist/containers/mp3/parse-mp3.js +4 -12
- package/dist/containers/mp3/parse-mpeg-header.js +1 -1
- package/dist/containers/riff/expect-riff-box.d.ts +1 -2
- package/dist/containers/riff/expect-riff-box.js +4 -14
- package/dist/containers/riff/get-tracks-from-avi.js +1 -1
- package/dist/containers/riff/parse-list-box.js +3 -5
- package/dist/containers/riff/parse-movi.d.ts +2 -4
- package/dist/containers/riff/parse-movi.js +9 -27
- package/dist/containers/riff/parse-riff-body.js +17 -11
- package/dist/containers/riff/parse-riff-header.js +2 -7
- package/dist/containers/riff/parse-video-section.d.ts +1 -1
- package/dist/containers/riff/parse-video-section.js +5 -7
- package/dist/containers/transport-stream/adts-header.js +1 -0
- package/dist/containers/transport-stream/get-tracks.js +1 -1
- package/dist/containers/transport-stream/parse-packet.js +1 -1
- package/dist/containers/transport-stream/parse-transport-stream.js +3 -10
- package/dist/containers/transport-stream/process-stream-buffers.js +1 -1
- package/dist/containers/wav/get-duration-from-wav.js +1 -4
- package/dist/containers/wav/parse-data.js +6 -6
- package/dist/containers/wav/parse-fmt.js +2 -2
- package/dist/containers/wav/parse-header.js +2 -2
- package/dist/containers/wav/parse-id3.js +2 -4
- package/dist/containers/wav/parse-list.js +2 -2
- package/dist/containers/wav/parse-video-section.js +2 -5
- package/dist/containers/webm/av1-codec-private.js +1 -1
- package/dist/containers/webm/parse-ebml.js +1 -1
- package/dist/containers/webm/parse-webm-header.js +3 -10
- package/dist/controller.d.ts +17 -0
- package/dist/controller.js +31 -0
- package/dist/download-and-parse-media.d.ts +2 -0
- package/dist/download-and-parse-media.js +72 -0
- package/dist/emit-available-info.d.ts +2 -3
- package/dist/emit-available-info.js +36 -36
- package/dist/emitter.d.ts +20 -0
- package/dist/emitter.js +29 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +13 -1
- package/dist/esm/from-fetch.mjs +134 -8
- package/dist/esm/from-node.mjs +8 -8
- package/dist/esm/from-web-file.mjs +14 -14
- package/dist/esm/index.mjs +3051 -2836
- package/dist/esm/node.mjs +113 -0
- package/dist/get-audio-codec.js +3 -0
- package/dist/get-dimensions.js +2 -2
- package/dist/get-duration.js +8 -8
- package/dist/get-fps.d.ts +4 -4
- package/dist/get-fps.js +16 -11
- package/dist/get-keyframes.d.ts +1 -2
- package/dist/get-keyframes.js +4 -3
- package/dist/get-location.d.ts +2 -2
- package/dist/get-location.js +2 -2
- package/dist/get-tracks.d.ts +3 -5
- package/dist/get-tracks.js +8 -14
- package/dist/has-all-info.js +3 -3
- package/dist/index.d.ts +132 -104
- package/dist/index.js +9 -1
- package/dist/init-video.d.ts +1 -1
- package/dist/init-video.js +8 -8
- package/dist/internal-parse-media.d.ts +2 -0
- package/dist/internal-parse-media.js +231 -0
- package/dist/make-hvc1-codec-strings.js +4 -4
- package/dist/media-parser-controller.d.ts +17 -0
- package/dist/media-parser-controller.js +31 -0
- package/dist/metadata/get-metadata.d.ts +2 -1
- package/dist/metadata/get-metadata.js +3 -2
- package/dist/metadata/metadata-from-iso.d.ts +2 -2
- package/dist/metadata/metadata-from-iso.js +2 -2
- package/dist/options.d.ts +60 -34
- package/dist/parse-and-download-media.d.ts +2 -0
- package/dist/parse-and-download-media.js +57 -0
- package/dist/parse-media.js +8 -202
- package/dist/parse-result.d.ts +2 -6
- package/dist/pause-signal.d.ts +11 -0
- package/dist/pause-signal.js +38 -0
- package/dist/perform-seek.d.ts +5 -8
- package/dist/perform-seek.js +17 -9
- package/dist/readers/from-fetch.js +11 -8
- package/dist/readers/from-node.js +8 -8
- package/dist/readers/from-web-file.js +16 -16
- package/dist/readers/reader.d.ts +8 -2
- package/dist/register-track.js +5 -0
- package/dist/remotion-license-acknowledge.d.ts +6 -0
- package/dist/remotion-license-acknowledge.js +17 -0
- package/dist/run-parse-iteration.d.ts +1 -1
- package/dist/run-parse-iteration.js +2 -2
- package/dist/skip.d.ts +5 -0
- package/dist/skip.js +8 -0
- package/dist/state/has-tracks-section.d.ts +3 -1
- package/dist/state/has-tracks-section.js +7 -1
- package/dist/state/iso-base-media/cached-sample-positions.d.ts +2 -2
- package/dist/state/iso-base-media/cached-sample-positions.js +12 -6
- package/dist/state/iso-base-media/iso-state.d.ts +6 -4
- package/dist/state/iso-base-media/iso-state.js +2 -5
- package/dist/state/iso-base-media/moov-box.d.ts +5 -0
- package/dist/state/iso-base-media/moov-box.js +13 -0
- package/dist/state/last-eventloop-break.d.ts +4 -0
- package/dist/state/last-eventloop-break.js +18 -0
- package/dist/state/parser-state.d.ts +124 -102
- package/dist/state/parser-state.js +22 -4
- package/dist/state/sample-callbacks.d.ts +5 -3
- package/dist/state/sample-callbacks.js +3 -3
- package/dist/state/structure.d.ts +7 -0
- package/dist/state/structure.js +56 -6
- package/dist/throttled-progress.d.ts +3 -2
- package/dist/throttled-progress.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/writers/node.d.ts +4 -0
- package/dist/writers/node.js +81 -0
- package/dist/writers/writer.d.ts +17 -0
- package/dist/writers/writer.js +2 -0
- package/package.json +12 -9
- package/LICENSE.md +0 -49
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMovi = exports.handleChunk = void 0;
|
|
4
4
|
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
5
|
-
const may_skip_video_data_1 = require("../../state/may-skip-video-data");
|
|
6
5
|
const key_1 = require("../avc/key");
|
|
7
6
|
const parse_avc_1 = require("../avc/parse-avc");
|
|
8
7
|
const traversal_1 = require("./traversal");
|
|
@@ -24,7 +23,7 @@ const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
|
24
23
|
const videoChunk = ckId.match(/^([0-9]{2})dc$/);
|
|
25
24
|
if (videoChunk) {
|
|
26
25
|
const trackId = parseInt(videoChunk[1], 10);
|
|
27
|
-
const strh = getStrhForIndex(state.
|
|
26
|
+
const strh = getStrhForIndex(state.getRiffStructure(), trackId);
|
|
28
27
|
const samplesPerSecond = strh.rate / strh.scale;
|
|
29
28
|
const nthSample = state.callbacks.getSamplesForTrack(trackId);
|
|
30
29
|
const timeInSec = nthSample / samplesPerSecond;
|
|
@@ -34,9 +33,9 @@ const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
|
34
33
|
const keyOrDelta = (0, key_1.getKeyFrameOrDeltaFromAvcInfo)(infos);
|
|
35
34
|
const avcProfile = infos.find((i) => i.type === 'avc-profile');
|
|
36
35
|
const ppsProfile = infos.find((i) => i.type === 'avc-pps');
|
|
37
|
-
if (avcProfile && ppsProfile) {
|
|
36
|
+
if (avcProfile && ppsProfile && !state.riff.getAvcProfile()) {
|
|
38
37
|
await state.riff.onProfile({ pps: ppsProfile, sps: avcProfile });
|
|
39
|
-
state.callbacks.tracks.setIsDone();
|
|
38
|
+
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
40
39
|
}
|
|
41
40
|
// We must also NOT pass a duration because if the the next sample is 0,
|
|
42
41
|
// this sample would be longer. Chrome will pad it with silence.
|
|
@@ -57,7 +56,7 @@ const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
|
57
56
|
const audioChunk = ckId.match(/^([0-9]{2})wb$/);
|
|
58
57
|
if (audioChunk) {
|
|
59
58
|
const trackId = parseInt(audioChunk[1], 10);
|
|
60
|
-
const strh = getStrhForIndex(state.
|
|
59
|
+
const strh = getStrhForIndex(state.getRiffStructure(), trackId);
|
|
61
60
|
const samplesPerSecond = strh.rate / strh.scale;
|
|
62
61
|
const nthSample = state.callbacks.getSamplesForTrack(trackId);
|
|
63
62
|
const timeInSec = nthSample / samplesPerSecond;
|
|
@@ -82,34 +81,21 @@ const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
|
82
81
|
}
|
|
83
82
|
};
|
|
84
83
|
exports.handleChunk = handleChunk;
|
|
85
|
-
const parseMovi = async ({
|
|
86
|
-
if ((0, may_skip_video_data_1.maySkipVideoData)({
|
|
87
|
-
state,
|
|
88
|
-
}) &&
|
|
89
|
-
state.riff.getAvcProfile()) {
|
|
90
|
-
return {
|
|
91
|
-
box: null,
|
|
92
|
-
skipTo: maxOffset,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
84
|
+
const parseMovi = async ({ state, }) => {
|
|
95
85
|
const { iterator } = state;
|
|
96
86
|
if (iterator.bytesRemaining() < 8) {
|
|
97
|
-
return
|
|
98
|
-
box: null,
|
|
99
|
-
skipTo: null,
|
|
100
|
-
};
|
|
87
|
+
return Promise.resolve();
|
|
101
88
|
}
|
|
102
89
|
const checkpoint = iterator.startCheckpoint();
|
|
103
90
|
const ckId = iterator.getByteString(4, false);
|
|
104
91
|
const ckSize = iterator.getUint32Le();
|
|
105
92
|
if (iterator.bytesRemaining() < ckSize) {
|
|
106
93
|
checkpoint.returnToCheckpoint();
|
|
107
|
-
return
|
|
108
|
-
box: null,
|
|
109
|
-
skipTo: null,
|
|
110
|
-
};
|
|
94
|
+
return Promise.resolve();
|
|
111
95
|
}
|
|
112
96
|
await (0, exports.handleChunk)({ state, ckId, ckSize });
|
|
97
|
+
const videoSection = state.videoSection.getVideoSection();
|
|
98
|
+
const maxOffset = videoSection.start + videoSection.size;
|
|
113
99
|
// Discard added zeroes
|
|
114
100
|
while (iterator.counter.getOffset() < maxOffset &&
|
|
115
101
|
iterator.bytesRemaining() > 0) {
|
|
@@ -118,9 +104,5 @@ const parseMovi = async ({ maxOffset, state, }) => {
|
|
|
118
104
|
break;
|
|
119
105
|
}
|
|
120
106
|
}
|
|
121
|
-
return {
|
|
122
|
-
box: null,
|
|
123
|
-
skipTo: null,
|
|
124
|
-
};
|
|
125
107
|
};
|
|
126
108
|
exports.parseMovi = parseMovi;
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseRiffBody = void 0;
|
|
4
|
+
const skip_1 = require("../../skip");
|
|
5
|
+
const may_skip_video_data_1 = require("../../state/may-skip-video-data");
|
|
4
6
|
const expect_riff_box_1 = require("./expect-riff-box");
|
|
5
7
|
const parse_video_section_1 = require("./parse-video-section");
|
|
6
8
|
const parseRiffBody = async (state) => {
|
|
7
9
|
if (state.videoSection.isInVideoSectionState(state.iterator) === 'in-section') {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
if ((0, may_skip_video_data_1.maySkipVideoData)({
|
|
11
|
+
state,
|
|
12
|
+
}) &&
|
|
13
|
+
state.riff.getAvcProfile()) {
|
|
14
|
+
const videoSection = state.videoSection.getVideoSection();
|
|
15
|
+
// only skipping forward in query mode
|
|
16
|
+
return Promise.resolve((0, skip_1.makeSkip)(videoSection.start + videoSection.size));
|
|
17
|
+
}
|
|
18
|
+
await (0, parse_video_section_1.parseVideoSection)(state);
|
|
19
|
+
return null;
|
|
12
20
|
}
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
const structure = state.
|
|
16
|
-
structure.boxes.push(
|
|
21
|
+
const box = await (0, expect_riff_box_1.expectRiffBox)(state);
|
|
22
|
+
if (box !== null) {
|
|
23
|
+
const structure = state.getRiffStructure();
|
|
24
|
+
structure.boxes.push(box);
|
|
17
25
|
}
|
|
18
|
-
return
|
|
19
|
-
skipTo: result.skipTo,
|
|
20
|
-
};
|
|
26
|
+
return null;
|
|
21
27
|
};
|
|
22
28
|
exports.parseRiffBody = parseRiffBody;
|
|
@@ -6,18 +6,13 @@ const parseRiffHeader = (state) => {
|
|
|
6
6
|
if (riff !== 'RIFF') {
|
|
7
7
|
throw new Error('Not a RIFF file');
|
|
8
8
|
}
|
|
9
|
-
const structure = state.
|
|
10
|
-
if (structure.type !== 'riff') {
|
|
11
|
-
throw new Error('Structure is not a RIFF structure');
|
|
12
|
-
}
|
|
9
|
+
const structure = state.getRiffStructure();
|
|
13
10
|
const size = state.iterator.getUint32Le();
|
|
14
11
|
const fileType = state.iterator.getByteString(4, false);
|
|
15
12
|
if (fileType !== 'WAVE' && fileType !== 'AVI') {
|
|
16
13
|
throw new Error(`File type ${fileType} not supported`);
|
|
17
14
|
}
|
|
18
15
|
structure.boxes.push({ type: 'riff-header', fileSize: size, fileType });
|
|
19
|
-
return
|
|
20
|
-
skipTo: null,
|
|
21
|
-
};
|
|
16
|
+
return null;
|
|
22
17
|
};
|
|
23
18
|
exports.parseRiffHeader = parseRiffHeader;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ParserState } from '../../state/parser-state';
|
|
2
|
-
export declare const parseVideoSection: (state: ParserState) => Promise<
|
|
2
|
+
export declare const parseVideoSection: (state: ParserState) => Promise<void>;
|
|
@@ -4,16 +4,14 @@ exports.parseVideoSection = void 0;
|
|
|
4
4
|
const get_tracks_1 = require("../../get-tracks");
|
|
5
5
|
const get_tracks_from_avi_1 = require("./get-tracks-from-avi");
|
|
6
6
|
const parse_movi_1 = require("./parse-movi");
|
|
7
|
-
const parseVideoSection = (state) => {
|
|
8
|
-
|
|
9
|
-
const movi = (0, parse_movi_1.parseMovi)({
|
|
10
|
-
maxOffset: videoSection.start + videoSection.size,
|
|
7
|
+
const parseVideoSection = async (state) => {
|
|
8
|
+
await (0, parse_movi_1.parseMovi)({
|
|
11
9
|
state,
|
|
12
10
|
});
|
|
13
11
|
const tracks = (0, get_tracks_1.getTracks)(state);
|
|
14
|
-
if (!tracks.videoTracks.some((t) => t.codec === get_tracks_from_avi_1.TO_BE_OVERRIDDEN_LATER)
|
|
15
|
-
state.callbacks.tracks.
|
|
12
|
+
if (!tracks.videoTracks.some((t) => t.codec === get_tracks_from_avi_1.TO_BE_OVERRIDDEN_LATER) &&
|
|
13
|
+
!state.callbacks.tracks.getIsDone()) {
|
|
14
|
+
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
16
15
|
}
|
|
17
|
-
return movi;
|
|
18
16
|
};
|
|
19
17
|
exports.parseVideoSection = parseVideoSection;
|
|
@@ -4,7 +4,7 @@ exports.hasAllTracksFromTransportStream = exports.getTracksFromTransportStream =
|
|
|
4
4
|
const truthy_1 = require("../../truthy");
|
|
5
5
|
const traversal_1 = require("./traversal");
|
|
6
6
|
const getTracksFromTransportStream = (parserState) => {
|
|
7
|
-
const structure = parserState.
|
|
7
|
+
const structure = parserState.getTsStructure();
|
|
8
8
|
const programMapTable = (0, traversal_1.findProgramMapTableOrThrow)(structure);
|
|
9
9
|
const parserTracks = parserState.callbacks.tracks.getTracks();
|
|
10
10
|
const mapped = programMapTable.streams
|
|
@@ -46,7 +46,7 @@ const parsePacket = async ({ parserState, }) => {
|
|
|
46
46
|
if (read === 188) {
|
|
47
47
|
return Promise.resolve(null);
|
|
48
48
|
}
|
|
49
|
-
const structure = parserState.
|
|
49
|
+
const structure = parserState.getTsStructure();
|
|
50
50
|
const pat = structure.boxes.find((b) => b.type === 'transport-stream-pmt-box');
|
|
51
51
|
const isPes = payloadUnitStartIndicator && (pat === null || pat === void 0 ? void 0 : pat.streams.find((e) => e.pid === programId));
|
|
52
52
|
if (isPes) {
|
|
@@ -4,15 +4,10 @@ exports.parseTransportStream = void 0;
|
|
|
4
4
|
const parse_packet_1 = require("./parse-packet");
|
|
5
5
|
const process_stream_buffers_1 = require("./process-stream-buffers");
|
|
6
6
|
const parseTransportStream = async (state) => {
|
|
7
|
-
const structure = state.
|
|
8
|
-
if (structure.type !== 'transport-stream') {
|
|
9
|
-
throw new Error('Invalid structure type');
|
|
10
|
-
}
|
|
7
|
+
const structure = state.getTsStructure();
|
|
11
8
|
const { iterator } = state;
|
|
12
9
|
if (iterator.bytesRemaining() < 188) {
|
|
13
|
-
return Promise.resolve(
|
|
14
|
-
skipTo: null,
|
|
15
|
-
});
|
|
10
|
+
return Promise.resolve(null);
|
|
16
11
|
}
|
|
17
12
|
const packet = await (0, parse_packet_1.parsePacket)({
|
|
18
13
|
parserState: state,
|
|
@@ -26,8 +21,6 @@ const parseTransportStream = async (state) => {
|
|
|
26
21
|
structure,
|
|
27
22
|
});
|
|
28
23
|
}
|
|
29
|
-
return Promise.resolve(
|
|
30
|
-
skipTo: null,
|
|
31
|
-
});
|
|
24
|
+
return Promise.resolve(null);
|
|
32
25
|
};
|
|
33
26
|
exports.parseTransportStream = parseTransportStream;
|
|
@@ -31,7 +31,7 @@ const processStreamBuffer = async ({ streamBuffer, state, programId, structure,
|
|
|
31
31
|
const tracksRegistered = state.callbacks.tracks.getTracks().length;
|
|
32
32
|
const { streams } = (0, traversal_1.findProgramMapTableOrThrow)(structure);
|
|
33
33
|
if (streams.length === tracksRegistered) {
|
|
34
|
-
state.callbacks.tracks.setIsDone();
|
|
34
|
+
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
};
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasDurationFromWav = exports.getDurationFromWav = void 0;
|
|
4
4
|
const getDurationFromWav = (state) => {
|
|
5
|
-
const structure = state.
|
|
6
|
-
if (structure.type !== 'wav') {
|
|
7
|
-
throw new Error('Expected wav structure');
|
|
8
|
-
}
|
|
5
|
+
const structure = state.getWavStructure();
|
|
9
6
|
const fmt = structure.boxes.find((b) => b.type === 'wav-fmt');
|
|
10
7
|
if (!fmt) {
|
|
11
8
|
throw new Error('Expected fmt box');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseData = void 0;
|
|
4
|
+
const skip_1 = require("../../skip");
|
|
4
5
|
const may_skip_video_data_1 = require("../../state/may-skip-video-data");
|
|
5
6
|
const parseData = ({ state, }) => {
|
|
6
7
|
const { iterator } = state;
|
|
@@ -9,17 +10,16 @@ const parseData = ({ state, }) => {
|
|
|
9
10
|
type: 'wav-data',
|
|
10
11
|
dataSize: ckSize,
|
|
11
12
|
};
|
|
12
|
-
state.
|
|
13
|
-
state.callbacks.tracks.setIsDone();
|
|
13
|
+
state.getWavStructure().boxes.push(box);
|
|
14
|
+
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
14
15
|
state.videoSection.setVideoSection({
|
|
15
16
|
size: ckSize,
|
|
16
17
|
start: iterator.counter.getOffset(),
|
|
17
18
|
});
|
|
18
19
|
if ((0, may_skip_video_data_1.maySkipVideoData)({ state })) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
20
|
+
// Skipping only in query mode
|
|
21
|
+
return Promise.resolve((0, skip_1.makeSkip)(iterator.counter.getOffset() + ckSize));
|
|
22
22
|
}
|
|
23
|
-
return Promise.resolve(
|
|
23
|
+
return Promise.resolve(null);
|
|
24
24
|
};
|
|
25
25
|
exports.parseData = parseData;
|
|
@@ -33,7 +33,7 @@ const parseFmt = async ({ state, }) => {
|
|
|
33
33
|
sampleRate,
|
|
34
34
|
type: 'wav-fmt',
|
|
35
35
|
};
|
|
36
|
-
state.
|
|
36
|
+
state.getWavStructure().boxes.push(wavHeader);
|
|
37
37
|
await (0, register_track_1.registerTrack)({
|
|
38
38
|
state,
|
|
39
39
|
track: {
|
|
@@ -51,6 +51,6 @@ const parseFmt = async ({ state, }) => {
|
|
|
51
51
|
container: 'wav',
|
|
52
52
|
});
|
|
53
53
|
box.expectNoMoreBytes();
|
|
54
|
-
return Promise.resolve(
|
|
54
|
+
return Promise.resolve(null);
|
|
55
55
|
};
|
|
56
56
|
exports.parseFmt = parseFmt;
|
|
@@ -11,7 +11,7 @@ const parseHeader = ({ state, }) => {
|
|
|
11
11
|
type: 'wav-header',
|
|
12
12
|
fileSize,
|
|
13
13
|
};
|
|
14
|
-
state.
|
|
15
|
-
return Promise.resolve(
|
|
14
|
+
state.getWavStructure().boxes.push(header);
|
|
15
|
+
return Promise.resolve(null);
|
|
16
16
|
};
|
|
17
17
|
exports.parseHeader = parseHeader;
|
|
@@ -9,9 +9,7 @@ const parseId3 = ({ state, }) => {
|
|
|
9
9
|
const id3Box = {
|
|
10
10
|
type: 'wav-id3',
|
|
11
11
|
};
|
|
12
|
-
state.
|
|
13
|
-
return Promise.resolve(
|
|
14
|
-
skipTo: null,
|
|
15
|
-
});
|
|
12
|
+
state.getWavStructure().boxes.push(id3Box);
|
|
13
|
+
return Promise.resolve(null);
|
|
16
14
|
};
|
|
17
15
|
exports.parseId3 = parseId3;
|
|
@@ -25,8 +25,8 @@ const parseList = ({ state, }) => {
|
|
|
25
25
|
type: 'wav-list',
|
|
26
26
|
metadata,
|
|
27
27
|
};
|
|
28
|
-
state.
|
|
28
|
+
state.getWavStructure().boxes.push(wavList);
|
|
29
29
|
box.expectNoMoreBytes();
|
|
30
|
-
return Promise.resolve(
|
|
30
|
+
return Promise.resolve(null);
|
|
31
31
|
};
|
|
32
32
|
exports.parseList = parseList;
|
|
@@ -4,10 +4,7 @@ exports.parseVideoSection = void 0;
|
|
|
4
4
|
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
5
5
|
const parseVideoSection = async ({ state, }) => {
|
|
6
6
|
const { iterator } = state;
|
|
7
|
-
const structure = state.
|
|
8
|
-
if (structure.type !== 'wav') {
|
|
9
|
-
throw new Error('Expected wav structure');
|
|
10
|
-
}
|
|
7
|
+
const structure = state.getWavStructure();
|
|
11
8
|
const videoSection = state.videoSection.getVideoSection();
|
|
12
9
|
const maxOffset = videoSection.start + videoSection.size;
|
|
13
10
|
const maxRead = maxOffset - iterator.counter.getOffset();
|
|
@@ -32,6 +29,6 @@ const parseVideoSection = async ({ state, }) => {
|
|
|
32
29
|
offset,
|
|
33
30
|
timescale: 1000000,
|
|
34
31
|
}, 1));
|
|
35
|
-
return
|
|
32
|
+
return null;
|
|
36
33
|
};
|
|
37
34
|
exports.parseVideoSection = parseVideoSection;
|
|
@@ -24,7 +24,7 @@ const parseAv1PrivateData = (data, colrAtom) => {
|
|
|
24
24
|
const seq_tier_0 = iterator.getBits(1);
|
|
25
25
|
// Level
|
|
26
26
|
// The level parameter value SHALL equal the first level value indicated by seq_level_idx in the Sequence Header OBU
|
|
27
|
-
str += seq_level_idx
|
|
27
|
+
str += String(seq_level_idx).padStart(2, '0');
|
|
28
28
|
str += seq_tier_0 ? 'H' : 'M';
|
|
29
29
|
str += '.';
|
|
30
30
|
// bitDepth
|
|
@@ -111,7 +111,7 @@ const postprocessEbml = async ({ offset, ebml, state, }) => {
|
|
|
111
111
|
state.webm.setTimescale(ebml.value.value);
|
|
112
112
|
}
|
|
113
113
|
if (ebml.type === 'Tracks') {
|
|
114
|
-
state.callbacks.tracks.setIsDone();
|
|
114
|
+
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
115
115
|
}
|
|
116
116
|
if (ebml.type === 'TrackEntry') {
|
|
117
117
|
state.webm.onTrackEntrySegment(ebml);
|
|
@@ -4,10 +4,7 @@ exports.parseWebm = void 0;
|
|
|
4
4
|
const segments_1 = require("./segments");
|
|
5
5
|
// Parsing according to https://darkcoding.net/software/reading-mediarecorders-webm-opus-output/
|
|
6
6
|
const parseWebm = async (state) => {
|
|
7
|
-
const structure = state.
|
|
8
|
-
if (structure.type !== 'matroska') {
|
|
9
|
-
throw new Error('Invalid structure type');
|
|
10
|
-
}
|
|
7
|
+
const structure = state.getMatroskaStructure();
|
|
11
8
|
const { iterator } = state;
|
|
12
9
|
const isInsideSegment = state.webm.isInsideSegment(iterator);
|
|
13
10
|
const isInsideCluster = state.webm.isInsideCluster(iterator);
|
|
@@ -16,9 +13,7 @@ const parseWebm = async (state) => {
|
|
|
16
13
|
isInsideSegment,
|
|
17
14
|
});
|
|
18
15
|
if (results === null) {
|
|
19
|
-
return
|
|
20
|
-
skipTo: null,
|
|
21
|
-
};
|
|
16
|
+
return null;
|
|
22
17
|
}
|
|
23
18
|
if (isInsideCluster) {
|
|
24
19
|
const segments = structure.boxes.filter((box) => box.type === 'Segment');
|
|
@@ -46,8 +41,6 @@ const parseWebm = async (state) => {
|
|
|
46
41
|
else {
|
|
47
42
|
structure.boxes.push(results);
|
|
48
43
|
}
|
|
49
|
-
return
|
|
50
|
-
skipTo: null,
|
|
51
|
-
};
|
|
44
|
+
return null;
|
|
52
45
|
};
|
|
53
46
|
exports.parseWebm = parseWebm;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MediaParserEmitter } from './emitter';
|
|
2
|
+
import type { PauseSignal } from './pause-signal';
|
|
3
|
+
export type MediaParserController = {
|
|
4
|
+
abort: (reason?: any) => void;
|
|
5
|
+
pause: PauseSignal['pause'];
|
|
6
|
+
resume: PauseSignal['resume'];
|
|
7
|
+
addEventListener: MediaParserEmitter['addEventListener'];
|
|
8
|
+
removeEventListener: MediaParserEmitter['removeEventListener'];
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Not public API
|
|
11
|
+
*/
|
|
12
|
+
_internals: {
|
|
13
|
+
signal: AbortSignal;
|
|
14
|
+
checkForAbortAndPause: () => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const mediaParserController: () => MediaParserController;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mediaParserController = void 0;
|
|
4
|
+
const emitter_1 = require("./emitter");
|
|
5
|
+
const pause_signal_1 = require("./pause-signal");
|
|
6
|
+
const mediaParserController = () => {
|
|
7
|
+
const abortController = new AbortController();
|
|
8
|
+
const emitter = new emitter_1.MediaParserEmitter();
|
|
9
|
+
const pauseSignal = (0, pause_signal_1.makePauseSignal)(emitter);
|
|
10
|
+
const checkForAbortAndPause = async () => {
|
|
11
|
+
if (abortController.signal.aborted) {
|
|
12
|
+
throw new Error('Aborted');
|
|
13
|
+
}
|
|
14
|
+
await pauseSignal.waitUntilResume();
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
abort: (reason) => {
|
|
19
|
+
abortController.abort(reason);
|
|
20
|
+
},
|
|
21
|
+
pause: pauseSignal.pause,
|
|
22
|
+
resume: pauseSignal.resume,
|
|
23
|
+
addEventListener: emitter.addEventListener,
|
|
24
|
+
removeEventListener: emitter.removeEventListener,
|
|
25
|
+
_internals: {
|
|
26
|
+
signal: abortController.signal,
|
|
27
|
+
checkForAbortAndPause,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.mediaParserController = mediaParserController;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadAndParseMedia = void 0;
|
|
4
|
+
const internal_parse_media_1 = require("./internal-parse-media");
|
|
5
|
+
const log_1 = require("./log");
|
|
6
|
+
const from_fetch_1 = require("./readers/from-fetch");
|
|
7
|
+
const downloadAndParseMedia = async (options) => {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
9
|
+
const logLevel = (_a = options.logLevel) !== null && _a !== void 0 ? _a : 'info';
|
|
10
|
+
const content = await options.writer.createContent({
|
|
11
|
+
filename: 'hmm',
|
|
12
|
+
mimeType: 'shouldnotmatter',
|
|
13
|
+
logLevel,
|
|
14
|
+
});
|
|
15
|
+
const returnValue = await (0, internal_parse_media_1.internalParseMedia)({
|
|
16
|
+
fields: (_b = options.fields) !== null && _b !== void 0 ? _b : null,
|
|
17
|
+
logLevel,
|
|
18
|
+
mode: 'download',
|
|
19
|
+
onAudioCodec: (_c = options.onAudioCodec) !== null && _c !== void 0 ? _c : null,
|
|
20
|
+
onAudioTrack: null,
|
|
21
|
+
onContainer: (_d = options.onContainer) !== null && _d !== void 0 ? _d : null,
|
|
22
|
+
onDimensions: (_e = options.onDimensions) !== null && _e !== void 0 ? _e : null,
|
|
23
|
+
onDiscardedData: async (data) => {
|
|
24
|
+
await content.write(data);
|
|
25
|
+
},
|
|
26
|
+
onDurationInSeconds: (_f = options.onDurationInSeconds) !== null && _f !== void 0 ? _f : null,
|
|
27
|
+
onFps: (_g = options.onFps) !== null && _g !== void 0 ? _g : null,
|
|
28
|
+
onImages: (_h = options.onImages) !== null && _h !== void 0 ? _h : null,
|
|
29
|
+
onInternalStats: (_j = options.onInternalStats) !== null && _j !== void 0 ? _j : null,
|
|
30
|
+
onIsHdr: (_k = options.onIsHdr) !== null && _k !== void 0 ? _k : null,
|
|
31
|
+
onKeyframes: (_l = options.onKeyframes) !== null && _l !== void 0 ? _l : null,
|
|
32
|
+
onLocation: (_m = options.onLocation) !== null && _m !== void 0 ? _m : null,
|
|
33
|
+
onMetadata: (_o = options.onMetadata) !== null && _o !== void 0 ? _o : null,
|
|
34
|
+
onMimeType: (_p = options.onMimeType) !== null && _p !== void 0 ? _p : null,
|
|
35
|
+
onName: (_q = options.onName) !== null && _q !== void 0 ? _q : null,
|
|
36
|
+
onNumberOfAudioChannels: (_r = options.onNumberOfAudioChannels) !== null && _r !== void 0 ? _r : null,
|
|
37
|
+
onParseProgress: (_s = options.onParseProgress) !== null && _s !== void 0 ? _s : null,
|
|
38
|
+
onRotation: (_t = options.onRotation) !== null && _t !== void 0 ? _t : null,
|
|
39
|
+
onSampleRate: (_u = options.onSampleRate) !== null && _u !== void 0 ? _u : null,
|
|
40
|
+
onSize: (_v = options.onSize) !== null && _v !== void 0 ? _v : null,
|
|
41
|
+
onSlowAudioBitrate: (_w = options.onSlowAudioBitrate) !== null && _w !== void 0 ? _w : null,
|
|
42
|
+
onSlowDurationInSeconds: (_x = options.onSlowDurationInSeconds) !== null && _x !== void 0 ? _x : null,
|
|
43
|
+
onSlowFps: (_y = options.onSlowFps) !== null && _y !== void 0 ? _y : null,
|
|
44
|
+
onSlowKeyframes: (_z = options.onSlowKeyframes) !== null && _z !== void 0 ? _z : null,
|
|
45
|
+
onSlowNumberOfFrames: (_0 = options.onSlowNumberOfFrames) !== null && _0 !== void 0 ? _0 : null,
|
|
46
|
+
onSlowVideoBitrate: (_1 = options.onSlowVideoBitrate) !== null && _1 !== void 0 ? _1 : null,
|
|
47
|
+
onStructure: (_2 = options.onStructure) !== null && _2 !== void 0 ? _2 : null,
|
|
48
|
+
onTracks: (_3 = options.onTracks) !== null && _3 !== void 0 ? _3 : null,
|
|
49
|
+
onUnrotatedDimensions: (_4 = options.onUnrotatedDimensions) !== null && _4 !== void 0 ? _4 : null,
|
|
50
|
+
onVideoCodec: (_5 = options.onVideoCodec) !== null && _5 !== void 0 ? _5 : null,
|
|
51
|
+
onVideoTrack: null,
|
|
52
|
+
progressIntervalInMs: (_6 = options.progressIntervalInMs) !== null && _6 !== void 0 ? _6 : null,
|
|
53
|
+
reader: (_7 = options.reader) !== null && _7 !== void 0 ? _7 : from_fetch_1.fetchReader,
|
|
54
|
+
controller: (_8 = options.controller) !== null && _8 !== void 0 ? _8 : undefined,
|
|
55
|
+
src: options.src,
|
|
56
|
+
onError: async (err) => {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
const action = (_b = (await ((_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, err)))) !== null && _b !== void 0 ? _b : { action: 'fail' };
|
|
59
|
+
if (action.action === 'fail') {
|
|
60
|
+
log_1.Log.verbose(logLevel, 'Removing content');
|
|
61
|
+
await content.finish();
|
|
62
|
+
await content.remove();
|
|
63
|
+
}
|
|
64
|
+
return action;
|
|
65
|
+
},
|
|
66
|
+
acknowledgeRemotionLicense: Boolean(options.acknowledgeRemotionLicense),
|
|
67
|
+
apiName: 'parseAndDownloadMedia()',
|
|
68
|
+
});
|
|
69
|
+
await content.finish();
|
|
70
|
+
return returnValue;
|
|
71
|
+
};
|
|
72
|
+
exports.downloadAndParseMedia = downloadAndParseMedia;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { AllParseMediaFields, Options, ParseMediaCallbacks, ParseMediaFields, ParseMediaResult } from './options';
|
|
2
2
|
import type { ParserState } from './state/parser-state';
|
|
3
|
-
export declare const emitAvailableInfo: ({ hasInfo, callbacks, state, returnValue,
|
|
3
|
+
export declare const emitAvailableInfo: ({ hasInfo, callbacks, state, returnValue, name, mimeType, fieldsInReturnValue, }: {
|
|
4
4
|
hasInfo: Record<keyof Options<ParseMediaFields>, boolean>;
|
|
5
5
|
callbacks: ParseMediaCallbacks;
|
|
6
6
|
fieldsInReturnValue: Options<ParseMediaFields>;
|
|
7
7
|
state: ParserState;
|
|
8
8
|
returnValue: ParseMediaResult<AllParseMediaFields>;
|
|
9
|
-
contentLength: number | null;
|
|
10
9
|
mimeType: string | null;
|
|
11
10
|
name: string;
|
|
12
|
-
}) => void
|
|
11
|
+
}) => Promise<void>;
|