@remotion/media-parser 4.0.278 → 4.0.280
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/check-if-done.d.ts +2 -0
- package/dist/check-if-done.js +34 -0
- package/dist/containers/aac/parse-aac.js +15 -10
- package/dist/containers/avc/parse-avc.js +1 -1
- package/dist/containers/flac/get-block-size.d.ts +1 -1
- package/dist/containers/flac/get-channel-count.d.ts +2 -2
- package/dist/containers/flac/get-sample-rate.d.ts +1 -1
- package/dist/containers/flac/parse-flac-frame.d.ts +1 -1
- package/dist/containers/flac/parse-flac-frame.js +16 -11
- package/dist/containers/flac/parse-flac.d.ts +1 -1
- package/dist/containers/flac/parse-header.d.ts +1 -1
- package/dist/containers/flac/parse-metadata.d.ts +1 -1
- package/dist/containers/flac/parse-streaminfo.d.ts +1 -1
- package/dist/containers/flac/parse-unknown-block.d.ts +1 -1
- package/dist/containers/iso-base-media/esds/decoder-specific-config.d.ts +1 -1
- package/dist/containers/iso-base-media/esds/esds-descriptors.d.ts +1 -1
- package/dist/containers/iso-base-media/esds/esds.d.ts +1 -1
- package/dist/containers/iso-base-media/ftyp.d.ts +1 -1
- package/dist/containers/iso-base-media/get-moov-atom.js +9 -3
- package/dist/containers/iso-base-media/get-seeking-from-mp4.d.ts +5 -0
- package/dist/containers/iso-base-media/get-seeking-from-mp4.js +56 -0
- package/dist/containers/iso-base-media/mdat/mdat.js +29 -20
- package/dist/containers/iso-base-media/mdhd.d.ts +1 -1
- package/dist/containers/iso-base-media/meta/hdlr.d.ts +1 -1
- package/dist/containers/iso-base-media/meta/ilst.d.ts +1 -1
- package/dist/containers/iso-base-media/mvhd.d.ts +1 -1
- package/dist/containers/iso-base-media/mvhd.js +1 -1
- package/dist/containers/iso-base-media/parse-icc-profile.js +1 -1
- package/dist/containers/iso-base-media/stsd/av1c.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/avcc.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/colr.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/ctts.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/hvcc.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/keys.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/pasp.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stco.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stsc.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stss.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stsz.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stts.d.ts +1 -1
- package/dist/containers/iso-base-media/tfdt.d.ts +1 -1
- package/dist/containers/iso-base-media/tfhd.d.ts +1 -1
- package/dist/containers/iso-base-media/tkhd.d.ts +1 -1
- package/dist/containers/iso-base-media/trun.d.ts +1 -1
- package/dist/containers/m3u/parse-m3u-manifest.d.ts +1 -1
- package/dist/containers/mp3/id3-v1.d.ts +1 -1
- package/dist/containers/mp3/parse-mpeg-header.js +14 -9
- package/dist/containers/riff/is-movi.d.ts +1 -1
- package/dist/containers/riff/parse-avih.d.ts +1 -1
- package/dist/containers/riff/parse-isft.d.ts +1 -1
- package/dist/containers/riff/parse-movi.js +29 -20
- package/dist/containers/riff/parse-strf.d.ts +1 -1
- package/dist/containers/riff/parse-strh.d.ts +1 -1
- package/dist/containers/transport-stream/adts-header.js +1 -1
- package/dist/containers/transport-stream/discard-rest-of-packet.d.ts +1 -1
- package/dist/containers/transport-stream/handle-aac-packet.js +6 -1
- package/dist/containers/transport-stream/handle-avc-packet.js +6 -1
- package/dist/containers/transport-stream/parse-pat.d.ts +1 -1
- package/dist/containers/transport-stream/parse-pes.d.ts +1 -1
- package/dist/containers/transport-stream/parse-pmt.d.ts +1 -1
- package/dist/containers/wav/parse-video-section.js +15 -10
- package/dist/containers/webm/av1-codec-private.js +1 -1
- package/dist/containers/webm/description.js +1 -1
- package/dist/containers/webm/get-sample-from-block.js +1 -1
- package/dist/containers/webm/make-track.js +1 -1
- package/dist/containers/webm/parse-ebml.js +16 -3
- package/dist/containers/webm/segments/block-simple-block-flags.d.ts +1 -1
- package/dist/emit-all-info.d.ts +3 -0
- package/dist/emit-all-info.js +30 -0
- package/dist/emit-audio-sample.d.ts +12 -0
- package/dist/emit-audio-sample.js +14 -0
- package/dist/emit-available-info.d.ts +2 -7
- package/dist/emit-available-info.js +34 -31
- package/dist/esm/index.mjs +1936 -1635
- package/dist/esm/worker-server-entry.mjs +855 -554
- package/dist/esm/worker-web-entry.mjs +855 -554
- package/dist/fields.d.ts +61 -0
- package/dist/fields.js +2 -0
- package/dist/get-fields-from-callbacks.d.ts +2 -1
- package/dist/get-seeking-info.d.ts +4 -0
- package/dist/get-seeking-info.js +22 -0
- package/dist/has-all-info.d.ts +3 -5
- package/dist/has-all-info.js +3 -4
- package/dist/index.d.ts +53 -14
- package/dist/index.js +1 -1
- package/dist/init-video.d.ts +1 -4
- package/dist/init-video.js +2 -1
- package/dist/internal-parse-media.js +25 -188
- package/dist/{buffer-iterator.d.ts → iterator/buffer-iterator.d.ts} +12 -15
- package/dist/{buffer-iterator.js → iterator/buffer-iterator.js} +8 -116
- package/dist/iterator/buffer-manager.d.ts +18 -0
- package/dist/iterator/buffer-manager.js +86 -0
- package/dist/iterator/offset-counter.d.ts +10 -0
- package/dist/iterator/offset-counter.js +31 -0
- package/dist/make-hvc1-codec-strings.d.ts +1 -1
- package/dist/make-progress-object.d.ts +6 -0
- package/dist/make-progress-object.js +13 -0
- package/dist/media-parser-controller.d.ts +3 -0
- package/dist/media-parser-controller.js +4 -0
- package/dist/options.d.ts +1 -61
- package/dist/parse-loop.d.ts +8 -0
- package/dist/parse-loop.js +93 -0
- package/dist/parse-media-on-worker-entry.d.ts +2 -1
- package/dist/perform-seek.d.ts +2 -7
- package/dist/perform-seek.js +23 -24
- package/dist/print-timings.d.ts +2 -0
- package/dist/print-timings.js +12 -0
- package/dist/register-track.js +3 -0
- package/dist/run-parse-iteration.d.ts +1 -4
- package/dist/run-parse-iteration.js +1 -4
- package/dist/seek-backwards.d.ts +2 -0
- package/dist/seek-backwards.js +26 -0
- package/dist/seek-forwards.d.ts +2 -0
- package/dist/seek-forwards.js +28 -0
- package/dist/seek-signal.d.ts +22 -0
- package/dist/seek-signal.js +26 -0
- package/dist/seeking-info.d.ts +8 -0
- package/dist/seeking-info.js +2 -0
- package/dist/state/can-skip-tracks.d.ts +2 -2
- package/dist/state/can-skip-tracks.js +5 -2
- package/dist/state/emitted-fields.d.ts +1 -1
- package/dist/state/has-tracks-section.d.ts +2 -1
- package/dist/state/need-samples-for-fields.d.ts +1 -1
- package/dist/state/parser-state.d.ts +38 -8
- package/dist/state/parser-state.js +22 -2
- package/dist/state/sample-callbacks.d.ts +8 -3
- package/dist/state/sample-callbacks.js +16 -3
- package/dist/state/slow-duration-fps.js +15 -17
- package/dist/state/timings.d.ts +8 -0
- package/dist/state/timings.js +13 -0
- package/dist/state/video-section.d.ts +1 -1
- package/dist/state/webm.d.ts +1 -1
- package/dist/throttled-progress.d.ts +2 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/work-on-seek-request.d.ts +2 -0
- package/dist/work-on-seek-request.js +43 -0
- package/dist/worker/worker-types.d.ts +2 -1
- package/package.json +10 -10
- package/dist/parse-media-on-server-worker.d.ts +0 -2
- package/dist/parse-media-on-server-worker.js +0 -4
- package/dist/parse-media-on-web-worker.d.ts +0 -2
- package/dist/parse-media-on-web-worker.js +0 -4
- package/dist/worker.module.d.ts +0 -4
- package/dist/worker.module.js +0 -16
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIfDone = void 0;
|
|
4
|
+
const has_all_info_1 = require("./has-all-info");
|
|
5
|
+
const log_1 = require("./log");
|
|
6
|
+
const checkIfDone = async (state) => {
|
|
7
|
+
const startCheck = Date.now();
|
|
8
|
+
const hasAll = (0, has_all_info_1.hasAllInfo)({
|
|
9
|
+
state,
|
|
10
|
+
});
|
|
11
|
+
state.timings.timeCheckingIfDone += Date.now() - startCheck;
|
|
12
|
+
if (hasAll && state.mode === 'query') {
|
|
13
|
+
log_1.Log.verbose(state.logLevel, 'Got all info, skipping to the end.');
|
|
14
|
+
state.increaseSkippedBytes(state.contentLength - state.iterator.counter.getOffset());
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
if (state.iterator.counter.getOffset() === state.contentLength) {
|
|
18
|
+
if (state.getStructure().type === 'm3u' &&
|
|
19
|
+
!state.m3u.getAllChunksProcessedOverall()) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
log_1.Log.verbose(state.logLevel, 'Reached end of file');
|
|
23
|
+
await state.discardReadBytes(true);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (state.iterator.counter.getOffset() + state.iterator.bytesRemaining() ===
|
|
27
|
+
state.contentLength &&
|
|
28
|
+
state.errored) {
|
|
29
|
+
log_1.Log.verbose(state.logLevel, 'Reached end of file and errorred');
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
exports.checkIfDone = checkIfDone;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseAac = void 0;
|
|
4
4
|
const aac_codecprivate_1 = require("../../aac-codecprivate");
|
|
5
5
|
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
6
|
+
const emit_audio_sample_1 = require("../../emit-audio-sample");
|
|
6
7
|
const register_track_1 = require("../../register-track");
|
|
7
8
|
const parseAac = async (state) => {
|
|
8
9
|
const { iterator } = state;
|
|
@@ -68,17 +69,21 @@ const parseAac = async (state) => {
|
|
|
68
69
|
const { index } = state.aac.addSample({ offset: startOffset, size: frameLength });
|
|
69
70
|
const timestamp = (1024 / sampleRate) * index;
|
|
70
71
|
// One ADTS frame contains 1024 samples
|
|
71
|
-
await
|
|
72
|
-
duration,
|
|
73
|
-
type: 'key',
|
|
74
|
-
data,
|
|
75
|
-
offset: startOffset,
|
|
76
|
-
timescale: 1000000,
|
|
72
|
+
await (0, emit_audio_sample_1.emitAudioSample)({
|
|
77
73
|
trackId: 0,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
audioSample: (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
75
|
+
duration,
|
|
76
|
+
type: 'key',
|
|
77
|
+
data,
|
|
78
|
+
offset: startOffset,
|
|
79
|
+
timescale: 1000000,
|
|
80
|
+
trackId: 0,
|
|
81
|
+
cts: timestamp,
|
|
82
|
+
dts: timestamp,
|
|
83
|
+
timestamp,
|
|
84
|
+
}, 1),
|
|
85
|
+
state,
|
|
86
|
+
});
|
|
82
87
|
return Promise.resolve(null);
|
|
83
88
|
};
|
|
84
89
|
exports.parseAac = parseAac;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Page 455
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.parseAvc = void 0;
|
|
6
|
-
const buffer_iterator_1 = require("../../buffer-iterator");
|
|
6
|
+
const buffer_iterator_1 = require("../../iterator/buffer-iterator");
|
|
7
7
|
const Extended_SAR = 255;
|
|
8
8
|
const readVuiParameters = (iterator) => {
|
|
9
9
|
let sar_width = null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
export declare const getBlockSize: (iterator: BufferIterator) => number | "uncommon-u16" | "uncommon-u8";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
export declare const getChannelCount: (iterator: BufferIterator) =>
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
|
+
export declare const getChannelCount: (iterator: BufferIterator) => 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParserState } from '../../state/parser-state';
|
|
3
3
|
export declare const getSampleRate: (iterator: BufferIterator, state: ParserState) => number | "uncommon-u8" | "uncommon-u16" | "uncommon-u16-10";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import { type BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { ParserState } from '../../state/parser-state';
|
|
4
4
|
export declare const parseFrameHeader: ({ iterator, state, }: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseFlacFrame = exports.parseFrameHeader = void 0;
|
|
4
|
-
const buffer_iterator_1 = require("../../buffer-iterator");
|
|
5
4
|
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
5
|
+
const emit_audio_sample_1 = require("../../emit-audio-sample");
|
|
6
|
+
const buffer_iterator_1 = require("../../iterator/buffer-iterator");
|
|
6
7
|
const get_block_size_1 = require("./get-block-size");
|
|
7
8
|
const get_channel_count_1 = require("./get-channel-count");
|
|
8
9
|
const get_sample_rate_1 = require("./get-sample-rate");
|
|
@@ -80,17 +81,21 @@ const emitSample = async ({ state, data, offset, }) => {
|
|
|
80
81
|
throw new Error('Cannot determine timestamp');
|
|
81
82
|
}
|
|
82
83
|
const timestamp = (num * streamInfo.maximumBlockSize) / streamInfo.sampleRate;
|
|
83
|
-
await
|
|
84
|
-
data,
|
|
85
|
-
duration,
|
|
86
|
-
cts: timestamp,
|
|
87
|
-
dts: timestamp,
|
|
88
|
-
timestamp,
|
|
89
|
-
type: 'key',
|
|
90
|
-
offset,
|
|
91
|
-
timescale: 1000000,
|
|
84
|
+
await (0, emit_audio_sample_1.emitAudioSample)({
|
|
92
85
|
trackId: 0,
|
|
93
|
-
|
|
86
|
+
audioSample: (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
87
|
+
data,
|
|
88
|
+
duration,
|
|
89
|
+
cts: timestamp,
|
|
90
|
+
dts: timestamp,
|
|
91
|
+
timestamp,
|
|
92
|
+
type: 'key',
|
|
93
|
+
offset,
|
|
94
|
+
timescale: 1000000,
|
|
95
|
+
trackId: 0,
|
|
96
|
+
}, 1),
|
|
97
|
+
state,
|
|
98
|
+
});
|
|
94
99
|
iterator.destroy();
|
|
95
100
|
};
|
|
96
101
|
const parseFlacFrame = async ({ state, iterator, }) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { ParserState } from '../../state/parser-state';
|
|
4
4
|
export declare const parseFlac: ({ iterator, state, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { ParserState } from '../../state/parser-state';
|
|
4
4
|
export declare const parseFlacHeader: ({ state, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { ParserState } from '../../state/parser-state';
|
|
4
4
|
export declare const parseVorbisComment: ({ state, iterator, size, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { ParserState } from '../../state/parser-state';
|
|
4
4
|
export declare const parseStreamInfo: ({ iterator, state, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { ParserState } from '../../state/parser-state';
|
|
4
4
|
export declare const parseFlacUnkownBlock: ({ iterator, state, size, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../../iterator/buffer-iterator';
|
|
2
2
|
import type { DecoderSpecificConfig } from './decoder-specific-config';
|
|
3
3
|
type AudioObjectType = 'aac' | 'mp3' | 'unknown';
|
|
4
4
|
type DecoderConfigDescriptor = {
|
|
@@ -6,6 +6,7 @@ const register_track_1 = require("../../register-track");
|
|
|
6
6
|
const parser_state_1 = require("../../state/parser-state");
|
|
7
7
|
const process_box_1 = require("./process-box");
|
|
8
8
|
const traversal_1 = require("./traversal");
|
|
9
|
+
// TODO: await parseMedia({fields: {moovAtom: true}) would be a nicer API
|
|
9
10
|
const getMoovAtom = async ({ endOfMdat, state, }) => {
|
|
10
11
|
const headerSegment = state.mp4HeaderSegment;
|
|
11
12
|
if (headerSegment) {
|
|
@@ -26,9 +27,6 @@ const getMoovAtom = async ({ endOfMdat, state, }) => {
|
|
|
26
27
|
hasAudioTrackHandlers: false,
|
|
27
28
|
hasVideoTrackHandlers: false,
|
|
28
29
|
controller: state.controller,
|
|
29
|
-
fields: {
|
|
30
|
-
structure: true,
|
|
31
|
-
},
|
|
32
30
|
onAudioTrack: state.onAudioTrack
|
|
33
31
|
? async ({ track, container }) => {
|
|
34
32
|
await (0, register_track_1.registerAudioTrack)({ state, track, container });
|
|
@@ -50,6 +48,14 @@ const getMoovAtom = async ({ endOfMdat, state, }) => {
|
|
|
50
48
|
selectM3uStreamFn: state.selectM3uStreamFn,
|
|
51
49
|
selectM3uAssociatedPlaylistsFn: state.selectM3uAssociatedPlaylistsFn,
|
|
52
50
|
mp4HeaderSegment: state.mp4HeaderSegment,
|
|
51
|
+
callbacks: {},
|
|
52
|
+
fieldsInReturnValue: {
|
|
53
|
+
structure: true,
|
|
54
|
+
},
|
|
55
|
+
contentType: null,
|
|
56
|
+
mimeType: null,
|
|
57
|
+
name: '',
|
|
58
|
+
initialReaderInstance: reader,
|
|
53
59
|
});
|
|
54
60
|
while (true) {
|
|
55
61
|
const result = await reader.reader.read();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SamplePosition } from '../../get-sample-positions';
|
|
2
|
+
import type { IsoBaseMediaSeekingInfo, SeekingInfo } from '../../seeking-info';
|
|
3
|
+
import type { ParserState } from '../../state/parser-state';
|
|
4
|
+
export declare const getSeekingInfoFromMp4: (state: ParserState) => SeekingInfo | null;
|
|
5
|
+
export declare const getSeekingByteFromIsoBaseMedia: (info: IsoBaseMediaSeekingInfo, time: number) => SamplePosition;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSeekingByteFromIsoBaseMedia = exports.getSeekingInfoFromMp4 = void 0;
|
|
4
|
+
const get_tracks_1 = require("../../get-tracks");
|
|
5
|
+
const get_sample_positions_from_track_1 = require("./get-sample-positions-from-track");
|
|
6
|
+
const traversal_1 = require("./traversal");
|
|
7
|
+
const getSeekingInfoFromMp4 = (state) => {
|
|
8
|
+
const structure = state.getIsoStructure();
|
|
9
|
+
const moovAtom = (0, traversal_1.getMoovBoxFromState)(state);
|
|
10
|
+
const moofBoxes = (0, traversal_1.getMoofBoxes)(structure.boxes);
|
|
11
|
+
if (!moovAtom) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
type: 'iso-base-media-seeking-info',
|
|
16
|
+
moovBox: moovAtom,
|
|
17
|
+
moofBoxes,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.getSeekingInfoFromMp4 = getSeekingInfoFromMp4;
|
|
21
|
+
const getSeekingByteFromIsoBaseMedia = (info, time) => {
|
|
22
|
+
const tracks = (0, get_tracks_1.getTracksFromMoovBox)(info.moovBox);
|
|
23
|
+
const allTracks = [
|
|
24
|
+
...tracks.videoTracks,
|
|
25
|
+
...tracks.audioTracks,
|
|
26
|
+
...tracks.otherTracks,
|
|
27
|
+
];
|
|
28
|
+
let byte = 0;
|
|
29
|
+
let sam = null;
|
|
30
|
+
for (const t of allTracks) {
|
|
31
|
+
const { timescale: ts, type } = t;
|
|
32
|
+
if (type !== 'video') {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const samplePositions = (0, get_sample_positions_from_track_1.getSamplePositionsFromTrack)({
|
|
36
|
+
trakBox: t.trakBox,
|
|
37
|
+
moofBoxes: info.moofBoxes,
|
|
38
|
+
});
|
|
39
|
+
for (const sample of samplePositions) {
|
|
40
|
+
const ctsInSeconds = sample.cts / ts;
|
|
41
|
+
const dtsInSeconds = sample.dts / ts;
|
|
42
|
+
if ((ctsInSeconds <= time || dtsInSeconds <= time) &&
|
|
43
|
+
byte <= sample.offset &&
|
|
44
|
+
type === 'video' &&
|
|
45
|
+
sample.isKeyframe) {
|
|
46
|
+
byte = sample.offset;
|
|
47
|
+
sam = sample;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!sam) {
|
|
52
|
+
throw new Error('No sample found');
|
|
53
|
+
}
|
|
54
|
+
return sam;
|
|
55
|
+
};
|
|
56
|
+
exports.getSeekingByteFromIsoBaseMedia = getSeekingByteFromIsoBaseMedia;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMdatSection = void 0;
|
|
4
4
|
const convert_audio_or_video_sample_1 = require("../../../convert-audio-or-video-sample");
|
|
5
|
+
const emit_audio_sample_1 = require("../../../emit-audio-sample");
|
|
5
6
|
const get_tracks_1 = require("../../../get-tracks");
|
|
6
7
|
const skip_1 = require("../../../skip");
|
|
7
8
|
const cached_sample_positions_1 = require("../../../state/iso-base-media/cached-sample-positions");
|
|
@@ -54,17 +55,21 @@ const parseMdatSection = async (state) => {
|
|
|
54
55
|
const bytes = iterator.getSlice(samplesWithIndex.samplePosition.size);
|
|
55
56
|
const { cts, dts, duration, isKeyframe, offset } = samplesWithIndex.samplePosition;
|
|
56
57
|
if (samplesWithIndex.track.type === 'audio') {
|
|
57
|
-
await
|
|
58
|
-
data: bytes,
|
|
59
|
-
timestamp: cts,
|
|
60
|
-
duration,
|
|
61
|
-
cts,
|
|
62
|
-
dts,
|
|
58
|
+
await (0, emit_audio_sample_1.emitAudioSample)({
|
|
63
59
|
trackId: samplesWithIndex.track.trackId,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
audioSample: (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
61
|
+
data: bytes,
|
|
62
|
+
timestamp: cts,
|
|
63
|
+
duration,
|
|
64
|
+
cts,
|
|
65
|
+
dts,
|
|
66
|
+
trackId: samplesWithIndex.track.trackId,
|
|
67
|
+
type: isKeyframe ? 'key' : 'delta',
|
|
68
|
+
offset,
|
|
69
|
+
timescale: samplesWithIndex.track.timescale,
|
|
70
|
+
}, samplesWithIndex.track.timescale),
|
|
71
|
+
state,
|
|
72
|
+
});
|
|
68
73
|
}
|
|
69
74
|
if (samplesWithIndex.track.type === 'video') {
|
|
70
75
|
// https://remotion-assets.s3.eu-central-1.amazonaws.com/example-videos/sei_checkpoint.mp4
|
|
@@ -79,17 +84,21 @@ const parseMdatSection = async (state) => {
|
|
|
79
84
|
const seiType = bytes[5];
|
|
80
85
|
isRecoveryPoint = seiType === 6;
|
|
81
86
|
}
|
|
82
|
-
await
|
|
83
|
-
data: bytes,
|
|
84
|
-
timestamp: cts,
|
|
85
|
-
duration,
|
|
86
|
-
cts,
|
|
87
|
-
dts,
|
|
87
|
+
await (0, emit_audio_sample_1.emitVideoSample)({
|
|
88
88
|
trackId: samplesWithIndex.track.trackId,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
videoSample: (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
90
|
+
data: bytes,
|
|
91
|
+
timestamp: cts,
|
|
92
|
+
duration,
|
|
93
|
+
cts,
|
|
94
|
+
dts,
|
|
95
|
+
trackId: samplesWithIndex.track.trackId,
|
|
96
|
+
type: isKeyframe && !isRecoveryPoint ? 'key' : 'delta',
|
|
97
|
+
offset,
|
|
98
|
+
timescale: samplesWithIndex.track.timescale,
|
|
99
|
+
}, samplesWithIndex.track.timescale),
|
|
100
|
+
state,
|
|
101
|
+
});
|
|
93
102
|
}
|
|
94
103
|
return null;
|
|
95
104
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMvhd = void 0;
|
|
4
|
-
const buffer_iterator_1 = require("../../buffer-iterator");
|
|
4
|
+
const buffer_iterator_1 = require("../../iterator/buffer-iterator");
|
|
5
5
|
const to_date_1 = require("./to-date");
|
|
6
6
|
const parseMvhd = ({ iterator, offset, size, }) => {
|
|
7
7
|
const version = iterator.getUint8();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseIccProfile = void 0;
|
|
4
|
-
const buffer_iterator_1 = require("../../buffer-iterator");
|
|
4
|
+
const buffer_iterator_1 = require("../../iterator/buffer-iterator");
|
|
5
5
|
const parseIccProfile = (data) => {
|
|
6
6
|
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(data, Infinity);
|
|
7
7
|
const size = iterator.getUint32();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { M3uStructure } from './types';
|
|
4
4
|
export declare const parseM3uManifest: ({ iterator, structure, contentLength, }: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
export declare const parseID3V1: (iterator: BufferIterator) => void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// spec: http://www.mp3-tech.org/programmer/frame_header.html
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.parseMpegHeader = void 0;
|
|
5
|
+
const emit_audio_sample_1 = require("../../emit-audio-sample");
|
|
5
6
|
const log_1 = require("../../log");
|
|
6
7
|
const register_track_1 = require("../../register-track");
|
|
7
8
|
const get_frame_length_1 = require("./get-frame-length");
|
|
@@ -276,16 +277,20 @@ const parseMpegHeader = async ({ state, }) => {
|
|
|
276
277
|
const timeInSeconds = (nthFrame * samplesPerFrame) / sampleRate;
|
|
277
278
|
const timestamp = Math.round(timeInSeconds * 1000000);
|
|
278
279
|
const duration = Math.round(durationInSeconds * 1000000);
|
|
279
|
-
await
|
|
280
|
-
data,
|
|
281
|
-
cts: timestamp,
|
|
282
|
-
dts: timestamp,
|
|
283
|
-
duration,
|
|
284
|
-
offset: initialOffset,
|
|
285
|
-
timescale: 1000000,
|
|
286
|
-
timestamp,
|
|
280
|
+
await (0, emit_audio_sample_1.emitAudioSample)({
|
|
287
281
|
trackId: 0,
|
|
288
|
-
|
|
282
|
+
audioSample: {
|
|
283
|
+
data,
|
|
284
|
+
cts: timestamp,
|
|
285
|
+
dts: timestamp,
|
|
286
|
+
duration,
|
|
287
|
+
offset: initialOffset,
|
|
288
|
+
timescale: 1000000,
|
|
289
|
+
timestamp,
|
|
290
|
+
trackId: 0,
|
|
291
|
+
type: 'key',
|
|
292
|
+
},
|
|
293
|
+
state,
|
|
289
294
|
});
|
|
290
295
|
}
|
|
291
296
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
export declare const isMoviAtom: (iterator: BufferIterator, ckId: string) => boolean;
|