@remotion/media-parser 4.0.285 → 4.0.286
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 +1 -1
- package/dist/combine-uint8-arrays.d.ts +1 -1
- package/dist/containers/aac/parse-aac.js +0 -3
- package/dist/containers/avc/create-sps-pps-data.d.ts +1 -1
- package/dist/containers/flac/get-channel-count.d.ts +1 -1
- package/dist/containers/flac/parse-flac-frame.js +0 -2
- package/dist/containers/flac/parse-streaminfo.js +0 -2
- package/dist/containers/iso-base-media/collect-sample-positions-from-trak.js +4 -3
- package/dist/containers/iso-base-media/get-moov-atom.js +0 -4
- package/dist/containers/iso-base-media/mdat/mdat.js +0 -3
- package/dist/containers/iso-base-media/mfra/get-mfra-atom.d.ts +3 -3
- package/dist/containers/iso-base-media/parse-boxes.js +0 -2
- package/dist/containers/iso-base-media/process-box.d.ts +0 -2
- package/dist/containers/iso-base-media/process-box.js +1 -3
- package/dist/containers/m3u/iterate-over-segment-files.js +1 -0
- package/dist/containers/m3u/run-over-m3u.js +0 -3
- package/dist/containers/mp3/parse-mpeg-header.js +0 -3
- package/dist/containers/riff/expect-riff-box.js +0 -2
- package/dist/containers/riff/parse-movi.js +0 -3
- package/dist/containers/transport-stream/adts-header.d.ts +1 -1
- package/dist/containers/transport-stream/discard-rest-of-packet.d.ts +1 -1
- package/dist/containers/transport-stream/find-separator.d.ts +17 -1
- package/dist/containers/transport-stream/find-separator.js +6 -5
- package/dist/containers/transport-stream/get-seeking-info.d.ts +4 -0
- package/dist/containers/transport-stream/get-seeking-info.js +17 -0
- package/dist/containers/transport-stream/handle-aac-packet.d.ts +10 -3
- package/dist/containers/transport-stream/handle-aac-packet.js +21 -16
- package/dist/containers/transport-stream/handle-avc-packet.d.ts +10 -3
- package/dist/containers/transport-stream/handle-avc-packet.js +26 -17
- package/dist/containers/transport-stream/parse-packet.d.ts +8 -4
- package/dist/containers/transport-stream/parse-packet.js +15 -16
- package/dist/containers/transport-stream/parse-pes.d.ts +5 -1
- package/dist/containers/transport-stream/parse-pes.js +4 -3
- package/dist/containers/transport-stream/parse-stream-packet.d.ts +6 -6
- package/dist/containers/transport-stream/parse-stream-packet.js +10 -115
- package/dist/containers/transport-stream/parse-transport-stream.js +15 -3
- package/dist/containers/transport-stream/process-stream-buffers.d.ts +26 -6
- package/dist/containers/transport-stream/process-stream-buffers.js +77 -12
- package/dist/containers/transport-stream/traversal.d.ts +3 -1
- package/dist/containers/transport-stream/traversal.js +10 -2
- package/dist/containers/wav/parse-fmt.js +0 -2
- package/dist/containers/wav/parse-media-section.js +0 -2
- package/dist/containers/webm/cues/fetch-web-cues.d.ts +12 -0
- package/dist/containers/webm/cues/fetch-web-cues.js +32 -0
- package/dist/containers/webm/cues/format-cues.d.ts +8 -0
- package/dist/containers/webm/cues/format-cues.js +41 -0
- package/dist/containers/webm/cues/get-seeking-byte.d.ts +14 -0
- package/dist/containers/webm/cues/get-seeking-byte.js +91 -0
- package/dist/containers/webm/fetch-web-cues.d.ts +12 -0
- package/dist/containers/webm/fetch-web-cues.js +29 -0
- package/dist/containers/webm/get-byte-for-cues.d.ts +5 -0
- package/dist/containers/webm/get-byte-for-cues.js +33 -0
- package/dist/containers/webm/get-ready-tracks.d.ts +9 -4
- package/dist/containers/webm/get-ready-tracks.js +6 -6
- package/dist/containers/webm/get-sample-from-block.d.ts +3 -2
- package/dist/containers/webm/get-sample-from-block.js +9 -8
- package/dist/containers/webm/get-seeking-byte.d.ts +14 -0
- package/dist/containers/webm/get-seeking-byte.js +91 -0
- package/dist/containers/webm/get-seeking-info.d.ts +3 -0
- package/dist/containers/webm/get-seeking-info.js +17 -0
- package/dist/containers/webm/parse-ebml.d.ts +5 -4
- package/dist/containers/webm/parse-ebml.js +29 -34
- package/dist/containers/webm/parse-webm-header.js +14 -2
- package/dist/containers/webm/seek/fetch-web-cues.d.ts +12 -0
- package/dist/containers/webm/seek/fetch-web-cues.js +32 -0
- package/dist/containers/webm/seek/format-cues.d.ts +8 -0
- package/dist/containers/webm/seek/format-cues.js +42 -0
- package/dist/containers/webm/seek/get-seeking-byte.d.ts +14 -0
- package/dist/containers/webm/seek/get-seeking-byte.js +100 -0
- package/dist/containers/webm/seek/get-seeking-info.d.ts +3 -0
- package/dist/containers/webm/seek/get-seeking-info.js +17 -0
- package/dist/containers/webm/segments/all-segments.d.ts +1 -0
- package/dist/containers/webm/segments.d.ts +10 -4
- package/dist/containers/webm/segments.js +30 -12
- package/dist/containers/webm/state-for-processing.d.ts +15 -0
- package/dist/containers/webm/state-for-processing.js +14 -0
- package/dist/controller/seek-signal.d.ts +2 -2
- package/dist/download-and-parse-media.js +2 -1
- package/dist/emit-audio-sample.d.ts +2 -5
- package/dist/emit-audio-sample.js +2 -5
- package/dist/esm/index.mjs +5057 -4394
- package/dist/esm/universal.mjs +1 -1
- package/dist/esm/web.mjs +1 -1
- package/dist/esm/worker-server-entry.mjs +2327 -1664
- package/dist/esm/worker-web-entry.mjs +2327 -1664
- package/dist/file-types/detect-file-type.js +3 -1
- package/dist/get-audio-codec.d.ts +2 -1
- package/dist/get-audio-codec.js +15 -1
- package/dist/get-sample-positions-from-mp4.d.ts +3 -0
- package/dist/get-sample-positions-from-mp4.js +46 -0
- package/dist/get-seeking-byte.d.ts +19 -0
- package/dist/get-seeking-byte.js +50 -0
- package/dist/get-seeking-info.d.ts +5 -10
- package/dist/get-seeking-info.js +12 -25
- package/dist/get-tracks.js +6 -2
- package/dist/index.d.ts +44 -19
- package/dist/init-video.js +4 -3
- package/dist/internal-parse-media.js +3 -2
- package/dist/iterator/buffer-iterator.d.ts +3 -3
- package/dist/iterator/buffer-manager.d.ts +3 -3
- package/dist/log.d.ts +5 -5
- package/dist/options.d.ts +1 -0
- package/dist/parse-loop.js +0 -3
- package/dist/parse-media-on-worker-entry.d.ts +1 -1
- package/dist/parse-media.js +2 -1
- package/dist/readers/from-web-file.js +1 -1
- package/dist/register-track.d.ts +2 -5
- package/dist/register-track.js +2 -10
- package/dist/seek-backwards.js +2 -3
- package/dist/seeking-info.d.ts +14 -1
- package/dist/state/iso-base-media/cached-sample-positions.d.ts +1 -1
- package/dist/state/keyframes.js +3 -0
- package/dist/state/matroska/lazy-cues-fetch.d.ts +19 -0
- package/dist/state/matroska/lazy-cues-fetch.js +51 -0
- package/dist/state/matroska/lazy-seek-fetch.d.ts +1 -0
- package/dist/state/matroska/lazy-seek-fetch.js +5 -0
- package/dist/state/matroska/webm.d.ts +46 -0
- package/dist/state/matroska/webm.js +121 -0
- package/dist/state/matroska.d.ts +0 -0
- package/dist/state/matroska.js +1 -0
- package/dist/state/parser-state.d.ts +34 -9
- package/dist/state/parser-state.js +7 -6
- package/dist/state/sample-callbacks.d.ts +1 -1
- package/dist/state/sample-callbacks.js +9 -9
- package/dist/state/samples-observed/slow-duration-fps.d.ts +11 -0
- package/dist/state/samples-observed/slow-duration-fps.js +92 -0
- package/dist/state/seek-infinite-loop.js +12 -2
- package/dist/state/transport-stream/observed-pes-header.d.ts +13 -0
- package/dist/state/transport-stream/observed-pes-header.js +29 -0
- package/dist/state/transport-stream/pts-start-offset.d.ts +5 -0
- package/dist/state/transport-stream/pts-start-offset.js +13 -0
- package/dist/state/transport-stream/start-offset.d.ts +2 -1
- package/dist/state/transport-stream/start-offset.js +3 -3
- package/dist/state/transport-stream/transport-stream.d.ts +6 -0
- package/dist/state/transport-stream/transport-stream.js +4 -2
- package/dist/state/video-section.js +14 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/work-on-seek-request.d.ts +8 -0
- package/dist/work-on-seek-request.js +24 -6
- package/dist/worker-server.js +1 -0
- package/dist/worker.d.ts +0 -1
- package/package.json +4 -4
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseWebm = void 0;
|
|
4
|
+
const get_byte_for_cues_1 = require("./get-byte-for-cues");
|
|
4
5
|
const segments_1 = require("./segments");
|
|
6
|
+
const state_for_processing_1 = require("./state-for-processing");
|
|
5
7
|
// Parsing according to https://darkcoding.net/software/reading-mediarecorders-webm-opus-output/
|
|
6
8
|
const parseWebm = async (state) => {
|
|
7
9
|
const structure = state.structure.getMatroskaStructure();
|
|
8
10
|
const { iterator } = state;
|
|
11
|
+
const offset = iterator.counter.getOffset();
|
|
9
12
|
const isInsideSegment = state.webm.isInsideSegment(iterator);
|
|
10
|
-
const isInsideCluster = state.webm.isInsideCluster(
|
|
13
|
+
const isInsideCluster = state.webm.isInsideCluster(offset);
|
|
11
14
|
const results = await (0, segments_1.expectSegment)({
|
|
12
|
-
|
|
15
|
+
iterator,
|
|
16
|
+
logLevel: state.logLevel,
|
|
17
|
+
statesForProcessing: (0, state_for_processing_1.selectStatesForProcessing)(state),
|
|
13
18
|
isInsideSegment,
|
|
19
|
+
mediaSectionState: state.mediaSection,
|
|
14
20
|
});
|
|
21
|
+
if ((results === null || results === void 0 ? void 0 : results.type) === 'SeekHead') {
|
|
22
|
+
const position = (0, get_byte_for_cues_1.getByteForSeek)({ seekHeadSegment: results, offset });
|
|
23
|
+
if (position !== null) {
|
|
24
|
+
state.webm.cues.triggerLoad(position, offset);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
15
27
|
if (results === null) {
|
|
16
28
|
return null;
|
|
17
29
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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';
|
|
5
|
+
import type { MatroskaCue } from './format-cues';
|
|
6
|
+
export declare const fetchWebmCues: ({ src, readerInterface, controller, position, logLevel, }: {
|
|
7
|
+
src: ParseMediaSrc;
|
|
8
|
+
readerInterface: ReaderInterface;
|
|
9
|
+
controller: MediaParserController;
|
|
10
|
+
position: number;
|
|
11
|
+
logLevel: LogLevel;
|
|
12
|
+
}) => Promise<MatroskaCue[] | null>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchWebmCues = void 0;
|
|
4
|
+
const buffer_iterator_1 = require("../../../iterator/buffer-iterator");
|
|
5
|
+
const segments_1 = require("../segments");
|
|
6
|
+
const format_cues_1 = require("./format-cues");
|
|
7
|
+
const fetchWebmCues = async ({ src, readerInterface, controller, position, logLevel, }) => {
|
|
8
|
+
const result = await readerInterface.read({
|
|
9
|
+
controller,
|
|
10
|
+
range: position,
|
|
11
|
+
src,
|
|
12
|
+
});
|
|
13
|
+
const { value } = await result.reader.reader.read();
|
|
14
|
+
if (!value) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
result.reader.abort();
|
|
18
|
+
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(value, value.length);
|
|
19
|
+
const segment = await (0, segments_1.expectSegment)({
|
|
20
|
+
iterator,
|
|
21
|
+
logLevel,
|
|
22
|
+
statesForProcessing: null,
|
|
23
|
+
isInsideSegment: null,
|
|
24
|
+
mediaSectionState: null,
|
|
25
|
+
});
|
|
26
|
+
iterator.destroy();
|
|
27
|
+
if (!(segment === null || segment === void 0 ? void 0 : segment.value)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return (0, format_cues_1.formatCues)(segment.value);
|
|
31
|
+
};
|
|
32
|
+
exports.fetchWebmCues = fetchWebmCues;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PossibleEbml } from '../segments/all-segments';
|
|
2
|
+
export type MatroskaCue = {
|
|
3
|
+
trackId: number;
|
|
4
|
+
timeInTimescale: number;
|
|
5
|
+
clusterPositionInSegment: number;
|
|
6
|
+
relativePosition: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const formatCues: (cues: PossibleEbml[]) => MatroskaCue[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCues = void 0;
|
|
4
|
+
const formatCues = (cues) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const matroskaCues = [];
|
|
7
|
+
for (const cue of cues) {
|
|
8
|
+
if (cue.type === 'Crc32') {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (cue.type !== 'CuePoint') {
|
|
12
|
+
throw new Error('Expected CuePoint');
|
|
13
|
+
}
|
|
14
|
+
const cueTime = cue.value.find((_cue) => _cue.type === 'CueTime');
|
|
15
|
+
if (!cueTime) {
|
|
16
|
+
throw new Error('Expected CueTime');
|
|
17
|
+
}
|
|
18
|
+
const cueTrackPositions = cue.value.find((c) => c.type === 'CueTrackPositions');
|
|
19
|
+
if (!cueTrackPositions) {
|
|
20
|
+
throw new Error('Expected CueTrackPositions');
|
|
21
|
+
}
|
|
22
|
+
const cueTimeValue = cueTime.value.value;
|
|
23
|
+
const cueTrack = cueTrackPositions.value.find((_c) => _c.type === 'CueTrack');
|
|
24
|
+
if (!cueTrack) {
|
|
25
|
+
throw new Error('Expected CueTrack');
|
|
26
|
+
}
|
|
27
|
+
const cueClusterPosition = cueTrackPositions.value.find((_c) => _c.type === 'CueClusterPosition');
|
|
28
|
+
if (!cueClusterPosition) {
|
|
29
|
+
throw new Error('Expected CueClusterPosition');
|
|
30
|
+
}
|
|
31
|
+
const cueRelativePosition = cueTrackPositions.value.find((_c) => _c.type === 'CueRelativePosition');
|
|
32
|
+
const matroskaCue = {
|
|
33
|
+
trackId: cueTrack.value.value,
|
|
34
|
+
timeInTimescale: cueTimeValue,
|
|
35
|
+
clusterPositionInSegment: cueClusterPosition.value.value,
|
|
36
|
+
relativePosition: (_a = cueRelativePosition === null || cueRelativePosition === void 0 ? void 0 : cueRelativePosition.value.value) !== null && _a !== void 0 ? _a : 0,
|
|
37
|
+
};
|
|
38
|
+
matroskaCues.push(matroskaCue);
|
|
39
|
+
}
|
|
40
|
+
return matroskaCues;
|
|
41
|
+
};
|
|
42
|
+
exports.formatCues = formatCues;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LogLevel } from '../../../log';
|
|
2
|
+
import type { WebmSeekingInfo } from '../../../seeking-info';
|
|
3
|
+
import type { KeyframesState } from '../../../state/keyframes';
|
|
4
|
+
import type { WebmState } from '../../../state/matroska/webm';
|
|
5
|
+
import type { MediaSectionState } from '../../../state/video-section';
|
|
6
|
+
import type { SeekResolution } from '../../../work-on-seek-request';
|
|
7
|
+
export declare const getSeekingByteFromMatroska: ({ time, webmState, info, logLevel, mediaSection, keyframes, }: {
|
|
8
|
+
time: number;
|
|
9
|
+
webmState: WebmState;
|
|
10
|
+
info: WebmSeekingInfo;
|
|
11
|
+
logLevel: LogLevel;
|
|
12
|
+
mediaSection: MediaSectionState;
|
|
13
|
+
keyframes: KeyframesState;
|
|
14
|
+
}) => Promise<SeekResolution>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSeekingByteFromMatroska = void 0;
|
|
4
|
+
const log_1 = require("../../../log");
|
|
5
|
+
const toSeconds = (timeInTimescale, track) => {
|
|
6
|
+
return (timeInTimescale / track.timescale) * 1000;
|
|
7
|
+
};
|
|
8
|
+
const findBiggestCueBeforeTime = ({ cues, time, track, }) => {
|
|
9
|
+
let biggestCueBeforeTime;
|
|
10
|
+
for (const cue of cues) {
|
|
11
|
+
const cueTimeInSeconds = toSeconds(cue.timeInTimescale, track);
|
|
12
|
+
if (cueTimeInSeconds < time &&
|
|
13
|
+
(!biggestCueBeforeTime ||
|
|
14
|
+
cueTimeInSeconds >
|
|
15
|
+
toSeconds(biggestCueBeforeTime.timeInTimescale, track))) {
|
|
16
|
+
biggestCueBeforeTime = cue;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return biggestCueBeforeTime;
|
|
20
|
+
};
|
|
21
|
+
const findKeyframeBeforeTime = ({ keyframes, time, }) => {
|
|
22
|
+
var _a;
|
|
23
|
+
let keyframeBeforeTime;
|
|
24
|
+
for (const keyframe of keyframes) {
|
|
25
|
+
if (keyframe.decodingTimeInSeconds < time &&
|
|
26
|
+
(!keyframeBeforeTime ||
|
|
27
|
+
keyframe.decodingTimeInSeconds >
|
|
28
|
+
keyframeBeforeTime.decodingTimeInSeconds)) {
|
|
29
|
+
keyframeBeforeTime = keyframe;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return (_a = keyframeBeforeTime === null || keyframeBeforeTime === void 0 ? void 0 : keyframeBeforeTime.positionInBytes) !== null && _a !== void 0 ? _a : null;
|
|
33
|
+
};
|
|
34
|
+
const getByteFromCues = ({ cuesResponse, time, info, logLevel, }) => {
|
|
35
|
+
if (!cuesResponse) {
|
|
36
|
+
log_1.Log.trace(logLevel, 'Has no Matroska cues at the moment, cannot use them');
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const { cues, segmentOffset } = cuesResponse;
|
|
40
|
+
log_1.Log.trace(logLevel, 'Has Matroska cues. Will use them to perform a seek.');
|
|
41
|
+
const biggestCueBeforeTime = findBiggestCueBeforeTime({
|
|
42
|
+
cues,
|
|
43
|
+
time,
|
|
44
|
+
track: info.track,
|
|
45
|
+
});
|
|
46
|
+
if (!biggestCueBeforeTime) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return biggestCueBeforeTime.clusterPositionInSegment + segmentOffset;
|
|
50
|
+
};
|
|
51
|
+
const getSeekingByteFromMatroska = async ({ time, webmState, info, logLevel, mediaSection, keyframes, }) => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
if (!info.track) {
|
|
54
|
+
log_1.Log.trace(logLevel, 'No video track found, cannot seek yet');
|
|
55
|
+
return {
|
|
56
|
+
type: 'valid-but-must-wait',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const cuesResponse = (await webmState.cues.getLoadedCues());
|
|
60
|
+
// Check if we have already read keyframes
|
|
61
|
+
const byteFromObservedKeyframe = findKeyframeBeforeTime({
|
|
62
|
+
keyframes: keyframes.getKeyframes(),
|
|
63
|
+
time,
|
|
64
|
+
});
|
|
65
|
+
// Check if we have `Cues`
|
|
66
|
+
const byteFromCues = getByteFromCues({
|
|
67
|
+
cuesResponse,
|
|
68
|
+
time,
|
|
69
|
+
info,
|
|
70
|
+
logLevel,
|
|
71
|
+
});
|
|
72
|
+
// Fallback: back to the beginning
|
|
73
|
+
const byteFromFirstMediaSection = (_b = (_a = webmState.getFirstCluster()) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : null;
|
|
74
|
+
// Optimization possibility for later:
|
|
75
|
+
// Don't seek back, if the last seen time is smaller than the time we want to seek to
|
|
76
|
+
const seekPossibilities = [
|
|
77
|
+
byteFromCues,
|
|
78
|
+
byteFromObservedKeyframe,
|
|
79
|
+
byteFromFirstMediaSection,
|
|
80
|
+
].filter((n) => n !== null);
|
|
81
|
+
const byteToSeekTo = seekPossibilities.length === 0 ? null : Math.max(...seekPossibilities);
|
|
82
|
+
if (byteToSeekTo === null) {
|
|
83
|
+
// dont know what to do
|
|
84
|
+
return {
|
|
85
|
+
type: 'invalid',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// we have assured this is in a media section, but it might not be marked yet
|
|
89
|
+
// setting size because there is deduplication and media sections which are encompassed
|
|
90
|
+
// by others will get deleted
|
|
91
|
+
mediaSection.addMediaSection({
|
|
92
|
+
start: byteToSeekTo,
|
|
93
|
+
size: 1,
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
type: 'do-seek',
|
|
97
|
+
byte: byteToSeekTo,
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
exports.getSeekingByteFromMatroska = getSeekingByteFromMatroska;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSeekingInfoFromMatroska = void 0;
|
|
4
|
+
const getSeekingInfoFromMatroska = (tracksState) => {
|
|
5
|
+
const tracks = tracksState.getTracks();
|
|
6
|
+
const firstVideoTrack = tracks.find((track) => track.type === 'video');
|
|
7
|
+
return {
|
|
8
|
+
type: 'webm-seeking-info',
|
|
9
|
+
track: firstVideoTrack
|
|
10
|
+
? {
|
|
11
|
+
timescale: firstVideoTrack.timescale,
|
|
12
|
+
trackId: firstVideoTrack.trackId,
|
|
13
|
+
}
|
|
14
|
+
: null,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.getSeekingInfoFromMatroska = getSeekingInfoFromMatroska;
|
|
@@ -371,6 +371,7 @@ export declare const seekHead: {
|
|
|
371
371
|
readonly name: "SeekHead";
|
|
372
372
|
readonly type: "children";
|
|
373
373
|
};
|
|
374
|
+
export type SeekHeadSegment = EbmlParsed<typeof seekHead>;
|
|
374
375
|
export declare const voidHeader: {
|
|
375
376
|
readonly name: "Void";
|
|
376
377
|
readonly type: "uint8array";
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
|
+
import type { LogLevel } from '../../log';
|
|
3
|
+
import type { SegmentSection } from '../../state/matroska/webm';
|
|
4
|
+
import type { MediaSectionState } from '../../state/video-section';
|
|
3
5
|
import { type PossibleEbml, type TrackEntry } from './segments/all-segments';
|
|
6
|
+
import { type WebmRequiredStatesForProcessing } from './state-for-processing';
|
|
4
7
|
export type MatroskaSegment = PossibleEbml;
|
|
5
8
|
export type OnTrackEntrySegment = (trackEntry: TrackEntry) => void;
|
|
6
|
-
export declare const expectSegment: ({
|
|
7
|
-
|
|
9
|
+
export declare const expectSegment: ({ statesForProcessing, isInsideSegment, iterator, logLevel, mediaSectionState, }: {
|
|
10
|
+
iterator: BufferIterator;
|
|
11
|
+
logLevel: LogLevel;
|
|
12
|
+
statesForProcessing: WebmRequiredStatesForProcessing | null;
|
|
8
13
|
isInsideSegment: SegmentSection | null;
|
|
14
|
+
mediaSectionState: MediaSectionState | null;
|
|
9
15
|
}) => Promise<MatroskaSegment | null>;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.expectSegment = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
5
4
|
const log_1 = require("../../log");
|
|
6
5
|
const parse_ebml_1 = require("./parse-ebml");
|
|
7
6
|
const all_segments_1 = require("./segments/all-segments");
|
|
8
|
-
const expectSegment = async ({
|
|
7
|
+
const expectSegment = async ({ statesForProcessing, isInsideSegment, iterator, logLevel, mediaSectionState, }) => {
|
|
9
8
|
var _a;
|
|
10
|
-
const { iterator } = state;
|
|
11
9
|
if (iterator.bytesRemaining() === 0) {
|
|
12
10
|
throw new Error('has no bytes');
|
|
13
11
|
}
|
|
@@ -26,9 +24,12 @@ const expectSegment = async ({ state, isInsideSegment, }) => {
|
|
|
26
24
|
return null;
|
|
27
25
|
}
|
|
28
26
|
const bytesRemainingNow = iterator.bytesRemaining();
|
|
29
|
-
log_1.Log.trace(
|
|
27
|
+
log_1.Log.trace(logLevel, 'Segment ID:', (_a = all_segments_1.ebmlMap[segmentId]) === null || _a === void 0 ? void 0 : _a.name, 'Size:' + size, bytesRemainingNow);
|
|
30
28
|
if (segmentId === all_segments_1.matroskaElements.Segment) {
|
|
31
|
-
|
|
29
|
+
if (!statesForProcessing) {
|
|
30
|
+
throw new Error('States for processing are required');
|
|
31
|
+
}
|
|
32
|
+
statesForProcessing.webmState.addSegment({
|
|
32
33
|
start: offset,
|
|
33
34
|
size,
|
|
34
35
|
});
|
|
@@ -43,7 +44,16 @@ const expectSegment = async ({ state, isInsideSegment, }) => {
|
|
|
43
44
|
if (isInsideSegment === null) {
|
|
44
45
|
throw new Error('Expected to be inside segment');
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
if (!statesForProcessing) {
|
|
48
|
+
throw new Error('States for processing are required');
|
|
49
|
+
}
|
|
50
|
+
if (mediaSectionState) {
|
|
51
|
+
mediaSectionState.addMediaSection({
|
|
52
|
+
start: offset,
|
|
53
|
+
size,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
statesForProcessing.webmState.addCluster({
|
|
47
57
|
start: offset,
|
|
48
58
|
size,
|
|
49
59
|
segment: isInsideSegment.index,
|
|
@@ -62,19 +72,27 @@ const expectSegment = async ({ state, isInsideSegment, }) => {
|
|
|
62
72
|
const segment = await parseSegment({
|
|
63
73
|
segmentId,
|
|
64
74
|
length: size,
|
|
65
|
-
state,
|
|
66
75
|
headerReadSoFar: iterator.counter.getOffset() - offset,
|
|
76
|
+
statesForProcessing,
|
|
77
|
+
iterator,
|
|
67
78
|
});
|
|
68
79
|
return segment;
|
|
69
80
|
};
|
|
70
81
|
exports.expectSegment = expectSegment;
|
|
71
|
-
const parseSegment = async ({ segmentId, length,
|
|
82
|
+
const parseSegment = async ({ segmentId, length, iterator, headerReadSoFar, statesForProcessing, }) => {
|
|
72
83
|
if (length < 0) {
|
|
73
84
|
throw new Error(`Expected length of ${segmentId} to be greater or equal 0`);
|
|
74
85
|
}
|
|
75
|
-
|
|
76
|
-
const offset =
|
|
77
|
-
const ebml = await (0, parse_ebml_1.parseEbml)(
|
|
78
|
-
|
|
86
|
+
iterator.counter.decrement(headerReadSoFar);
|
|
87
|
+
const offset = iterator.counter.getOffset();
|
|
88
|
+
const ebml = await (0, parse_ebml_1.parseEbml)(iterator, statesForProcessing);
|
|
89
|
+
if (!statesForProcessing) {
|
|
90
|
+
return ebml;
|
|
91
|
+
}
|
|
92
|
+
const remapped = await (0, parse_ebml_1.postprocessEbml)({
|
|
93
|
+
offset,
|
|
94
|
+
ebml,
|
|
95
|
+
statesForProcessing,
|
|
96
|
+
});
|
|
79
97
|
return remapped;
|
|
80
98
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LogLevel } from '../../log';
|
|
2
|
+
import type { WebmState } from '../../state/matroska/webm';
|
|
3
|
+
import type { ParserState } from '../../state/parser-state';
|
|
4
|
+
import type { SampleCallbacks } from '../../state/sample-callbacks';
|
|
5
|
+
import type { StructureState } from '../../state/structure';
|
|
6
|
+
import type { OnAudioTrack, OnVideoTrack } from '../../webcodec-sample-types';
|
|
7
|
+
export type WebmRequiredStatesForProcessing = {
|
|
8
|
+
webmState: WebmState;
|
|
9
|
+
callbacks: SampleCallbacks;
|
|
10
|
+
logLevel: LogLevel;
|
|
11
|
+
onAudioTrack: OnAudioTrack | null;
|
|
12
|
+
onVideoTrack: OnVideoTrack | null;
|
|
13
|
+
structureState: StructureState;
|
|
14
|
+
};
|
|
15
|
+
export declare const selectStatesForProcessing: ({ callbacks, logLevel, onAudioTrack, onVideoTrack, structure, webm, }: ParserState) => WebmRequiredStatesForProcessing;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectStatesForProcessing = void 0;
|
|
4
|
+
const selectStatesForProcessing = ({ callbacks, logLevel, onAudioTrack, onVideoTrack, structure, webm, }) => {
|
|
5
|
+
return {
|
|
6
|
+
webmState: webm,
|
|
7
|
+
callbacks,
|
|
8
|
+
logLevel,
|
|
9
|
+
onAudioTrack,
|
|
10
|
+
onVideoTrack,
|
|
11
|
+
structureState: structure,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.selectStatesForProcessing = selectStatesForProcessing;
|
|
@@ -6,7 +6,7 @@ const internal_parse_media_1 = require("./internal-parse-media");
|
|
|
6
6
|
const log_1 = require("./log");
|
|
7
7
|
const web_1 = require("./web");
|
|
8
8
|
const downloadAndParseMedia = async (options) => {
|
|
9
|
-
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, _10, _11, _12, _13, _14;
|
|
9
|
+
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, _10, _11, _12, _13, _14, _15;
|
|
10
10
|
const logLevel = (_a = options.logLevel) !== null && _a !== void 0 ? _a : 'info';
|
|
11
11
|
const content = await options.writer.createContent({
|
|
12
12
|
filename: 'hmm',
|
|
@@ -70,6 +70,7 @@ const downloadAndParseMedia = async (options) => {
|
|
|
70
70
|
},
|
|
71
71
|
acknowledgeRemotionLicense: Boolean(options.acknowledgeRemotionLicense),
|
|
72
72
|
apiName: 'parseAndDownloadMedia()',
|
|
73
|
+
makeSamplesStartAtZero: (_15 = options.makeSamplesStartAtZero) !== null && _15 !== void 0 ? _15 : true,
|
|
73
74
|
});
|
|
74
75
|
await content.finish();
|
|
75
76
|
return returnValue;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import type { SampleCallbacks } from './state/sample-callbacks';
|
|
2
2
|
import type { AudioOrVideoSample } from './webcodec-sample-types';
|
|
3
|
-
|
|
4
|
-
export declare const emitAudioSample: ({ trackId, audioSample, workOnSeekRequestOptions, callbacks, }: {
|
|
3
|
+
export declare const emitAudioSample: ({ trackId, audioSample, callbacks, }: {
|
|
5
4
|
trackId: number;
|
|
6
5
|
audioSample: AudioOrVideoSample;
|
|
7
|
-
workOnSeekRequestOptions: WorkOnSeekRequestOptions;
|
|
8
6
|
callbacks: SampleCallbacks;
|
|
9
7
|
}) => Promise<void>;
|
|
10
|
-
export declare const emitVideoSample: ({ trackId, videoSample,
|
|
8
|
+
export declare const emitVideoSample: ({ trackId, videoSample, callbacks, }: {
|
|
11
9
|
trackId: number;
|
|
12
10
|
videoSample: AudioOrVideoSample;
|
|
13
|
-
workOnSeekRequestOptions: WorkOnSeekRequestOptions;
|
|
14
11
|
callbacks: SampleCallbacks;
|
|
15
12
|
}) => Promise<void>;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.emitVideoSample = exports.emitAudioSample = void 0;
|
|
4
|
-
const
|
|
5
|
-
const emitAudioSample = async ({ trackId, audioSample, workOnSeekRequestOptions, callbacks, }) => {
|
|
4
|
+
const emitAudioSample = async ({ trackId, audioSample, callbacks, }) => {
|
|
6
5
|
await callbacks.onAudioSample(trackId, audioSample);
|
|
7
|
-
await (0, work_on_seek_request_1.workOnSeekRequest)(workOnSeekRequestOptions);
|
|
8
6
|
};
|
|
9
7
|
exports.emitAudioSample = emitAudioSample;
|
|
10
|
-
const emitVideoSample = async ({ trackId, videoSample,
|
|
8
|
+
const emitVideoSample = async ({ trackId, videoSample, callbacks, }) => {
|
|
11
9
|
await callbacks.onVideoSample(trackId, videoSample);
|
|
12
|
-
await (0, work_on_seek_request_1.workOnSeekRequest)(workOnSeekRequestOptions);
|
|
13
10
|
};
|
|
14
11
|
exports.emitVideoSample = emitVideoSample;
|