@remotion/media-parser 4.0.231 → 4.0.233
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/add-avc-profile-to-track.d.ts +3 -0
- package/dist/add-avc-profile-to-track.js +35 -0
- package/dist/add-new-matroska-tracks.d.ts +6 -1
- package/dist/add-new-matroska-tracks.js +16 -1
- package/dist/boxes/avc/parse-avc.d.ts +18 -0
- package/dist/boxes/avc/parse-avc.js +96 -0
- package/dist/boxes/iso-base-media/esds/decoder-specific-config.d.ts +1 -2
- package/dist/boxes/iso-base-media/esds/decoder-specific-config.js +1 -5
- package/dist/boxes/iso-base-media/esds/esds-descriptors.d.ts +2 -4
- package/dist/boxes/iso-base-media/esds/esds-descriptors.js +3 -4
- package/dist/boxes/iso-base-media/esds/esds.d.ts +1 -3
- package/dist/boxes/iso-base-media/esds/esds.js +2 -2
- package/dist/boxes/iso-base-media/get-sample-positions-from-track.js +7 -1
- package/dist/boxes/iso-base-media/make-track.js +3 -3
- package/dist/boxes/iso-base-media/mdat/mdat.d.ts +2 -2
- package/dist/boxes/iso-base-media/mdat/mdat.js +5 -2
- package/dist/boxes/iso-base-media/moov/moov.js +2 -2
- package/dist/boxes/iso-base-media/process-box.d.ts +5 -5
- package/dist/boxes/iso-base-media/process-box.js +38 -38
- package/dist/boxes/iso-base-media/stsd/mebx.js +2 -2
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +2 -2
- package/dist/boxes/iso-base-media/stsd/samples.js +15 -14
- package/dist/boxes/iso-base-media/trak/trak.js +2 -2
- package/dist/boxes/iso-base-media/traversal.d.ts +1 -1
- package/dist/boxes/riff/expect-riff-box.d.ts +16 -0
- package/dist/boxes/riff/expect-riff-box.js +49 -0
- package/dist/boxes/riff/get-tracks-from-avi.d.ts +21 -0
- package/dist/boxes/riff/get-tracks-from-avi.js +108 -0
- package/dist/boxes/riff/is-movi.d.ts +2 -0
- package/dist/boxes/riff/is-movi.js +12 -0
- package/dist/boxes/riff/parse-avih.d.ts +6 -0
- package/dist/boxes/riff/parse-avih.js +32 -0
- package/dist/boxes/riff/parse-box.d.ts +13 -0
- package/dist/boxes/riff/parse-box.js +113 -0
- package/dist/boxes/riff/parse-fmt-box.d.ts +7 -0
- package/dist/boxes/riff/parse-fmt-box.js +33 -0
- package/dist/boxes/riff/parse-list-box.d.ts +8 -0
- package/dist/boxes/riff/parse-list-box.js +30 -0
- package/dist/boxes/riff/parse-movi.d.ts +17 -0
- package/dist/boxes/riff/parse-movi.js +122 -0
- package/dist/boxes/riff/parse-riff-box.d.ts +10 -0
- package/dist/boxes/riff/parse-riff-box.js +33 -0
- package/dist/boxes/riff/parse-strf.d.ts +7 -0
- package/dist/boxes/riff/parse-strf.js +67 -0
- package/dist/boxes/riff/parse-strh.d.ts +6 -0
- package/dist/boxes/riff/parse-strh.js +46 -0
- package/dist/boxes/riff/riff-box.d.ts +81 -0
- package/dist/boxes/riff/riff-box.js +2 -0
- package/dist/boxes/riff/strf.d.ts +7 -0
- package/dist/boxes/riff/strf.js +67 -0
- package/dist/boxes/riff/timescale.d.ts +1 -0
- package/dist/boxes/riff/timescale.js +4 -0
- package/dist/boxes/riff/traversal.d.ts +8 -0
- package/dist/boxes/riff/traversal.js +36 -0
- package/dist/boxes/webm/parse-ebml.js +2 -2
- package/dist/boxes/webm/parse-webm-header.d.ts +2 -2
- package/dist/boxes/webm/parse-webm-header.js +7 -7
- package/dist/boxes/webm/traversal.d.ts +2 -2
- package/dist/buffer-iterator.d.ts +6 -1
- package/dist/buffer-iterator.js +24 -5
- package/dist/create/event-emitter.d.ts +31 -0
- package/dist/create/event-emitter.js +25 -0
- package/dist/create/iso-base-media/create-iso-base-media.d.ts +1 -1
- package/dist/create/iso-base-media/create-iso-base-media.js +3 -5
- package/dist/create/matroska/cluster.js +1 -1
- package/dist/create/matroska/create-matroska-media.d.ts +1 -1
- package/dist/create/matroska/create-matroska-media.js +7 -14
- package/dist/create/media-fn.d.ts +2 -1
- package/dist/create/mp3/create-mp3.d.ts +2 -0
- package/dist/create/mp3/create-mp3.js +49 -0
- package/dist/create/progress-tracker.d.ts +7 -0
- package/dist/create/progress-tracker.js +43 -0
- package/dist/create/wav/create-wav.d.ts +2 -0
- package/dist/create/wav/create-wav.js +110 -0
- package/dist/create/with-resolvers.d.ts +10 -0
- package/dist/create/with-resolvers.js +28 -0
- package/dist/emit-available-info.d.ts +2 -2
- package/dist/emit-available-info.js +17 -6
- package/dist/esm/from-node.mjs +2 -1
- package/dist/esm/index.mjs +1828 -605
- package/dist/get-audio-codec.d.ts +4 -3
- package/dist/get-audio-codec.js +17 -3
- package/dist/get-container.d.ts +3 -3
- package/dist/get-container.js +9 -7
- package/dist/get-dimensions.d.ts +3 -3
- package/dist/get-duration.d.ts +3 -3
- package/dist/get-duration.js +32 -14
- package/dist/get-fps.d.ts +3 -3
- package/dist/get-fps.js +31 -4
- package/dist/get-is-hdr.d.ts +4 -0
- package/dist/get-is-hdr.js +18 -0
- package/dist/get-sample-positions-from-lpcm.d.ts +3 -0
- package/dist/get-sample-positions-from-lpcm.js +46 -0
- package/dist/get-tracks.d.ts +7 -10
- package/dist/get-tracks.js +55 -27
- package/dist/get-video-codec.d.ts +5 -4
- package/dist/get-video-codec.js +47 -13
- package/dist/has-all-info.d.ts +2 -2
- package/dist/has-all-info.js +10 -5
- package/dist/index.d.ts +23 -3
- package/dist/index.js +9 -0
- package/dist/options.d.ts +16 -9
- package/dist/parse-media.js +3 -1
- package/dist/parse-result.d.ts +20 -6
- package/dist/parse-video.d.ts +2 -2
- package/dist/parse-video.js +5 -16
- package/dist/parser-context.d.ts +1 -0
- package/dist/parser-state.d.ts +11 -0
- package/dist/parser-state.js +30 -0
- package/dist/readers/from-node.js +2 -1
- package/dist/register-track.d.ts +13 -0
- package/dist/register-track.js +25 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addAvcProfileToTrack = void 0;
|
|
4
|
+
const make_header_1 = require("./boxes/webm/make-header");
|
|
5
|
+
const addAvcProfileToTrack = (track, avc1Profile) => {
|
|
6
|
+
if (avc1Profile === null) {
|
|
7
|
+
return track;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
...track,
|
|
11
|
+
codec: `avc1.${avc1Profile.sps.profile.toString(16).padStart(2, '0')}${avc1Profile.sps.compatibility.toString(16).padStart(2, '0')}${avc1Profile.sps.level.toString(16).padStart(2, '0')}`,
|
|
12
|
+
codecPrivate: (0, make_header_1.combineUint8Arrays)([
|
|
13
|
+
new Uint8Array([
|
|
14
|
+
// https://gist.github.com/uupaa/8493378ec15f644a3d2b
|
|
15
|
+
1,
|
|
16
|
+
avc1Profile.sps.level,
|
|
17
|
+
avc1Profile.sps.compatibility,
|
|
18
|
+
avc1Profile.sps.profile,
|
|
19
|
+
0xff,
|
|
20
|
+
0xe1,
|
|
21
|
+
]),
|
|
22
|
+
// sequence parameter set length
|
|
23
|
+
(0, make_header_1.serializeUint16)(avc1Profile.sps.sps.length),
|
|
24
|
+
// sequence parameter set
|
|
25
|
+
avc1Profile.sps.sps,
|
|
26
|
+
// num of PPS
|
|
27
|
+
new Uint8Array([0x01]),
|
|
28
|
+
// picture parameter set length
|
|
29
|
+
(0, make_header_1.serializeUint16)(avc1Profile.pps.pps.length),
|
|
30
|
+
// PPS
|
|
31
|
+
avc1Profile.pps.pps,
|
|
32
|
+
]),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.addAvcProfileToTrack = addAvcProfileToTrack;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Track } from './get-tracks';
|
|
1
|
+
import type { Track, VideoTrack } from './get-tracks';
|
|
2
2
|
import type { ParserContext } from './parser-context';
|
|
3
3
|
import type { ParserState } from './parser-state';
|
|
4
4
|
export declare const registerTrack: ({ state, options, track, }: {
|
|
@@ -6,3 +6,8 @@ export declare const registerTrack: ({ state, options, track, }: {
|
|
|
6
6
|
options: ParserContext;
|
|
7
7
|
track: Track;
|
|
8
8
|
}) => Promise<void>;
|
|
9
|
+
export declare const registerVideoTrackWhenProfileIsAvailable: ({ options, state, track, }: {
|
|
10
|
+
state: ParserState;
|
|
11
|
+
options: ParserContext;
|
|
12
|
+
track: VideoTrack;
|
|
13
|
+
}) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerTrack = void 0;
|
|
3
|
+
exports.registerVideoTrackWhenProfileIsAvailable = exports.registerTrack = void 0;
|
|
4
4
|
const registerTrack = async ({ state, options, track, }) => {
|
|
5
5
|
if (track.type === 'video' && options.onVideoTrack) {
|
|
6
6
|
const callback = await options.onVideoTrack(track);
|
|
@@ -12,3 +12,18 @@ const registerTrack = async ({ state, options, track, }) => {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
exports.registerTrack = registerTrack;
|
|
15
|
+
const registerVideoTrackWhenProfileIsAvailable = ({ options, state, track, }) => {
|
|
16
|
+
state.registerOnAvcProfileCallback(async (profile) => {
|
|
17
|
+
const newTrack = {
|
|
18
|
+
...track,
|
|
19
|
+
codec: 'avc1...',
|
|
20
|
+
};
|
|
21
|
+
console.log(profile, newTrack);
|
|
22
|
+
await (0, exports.registerTrack)({
|
|
23
|
+
options,
|
|
24
|
+
state,
|
|
25
|
+
track: newTrack,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.registerVideoTrackWhenProfileIsAvailable = registerVideoTrackWhenProfileIsAvailable;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type AvcProfileInfo = {
|
|
2
|
+
profile: number;
|
|
3
|
+
level: number;
|
|
4
|
+
compatibility: number;
|
|
5
|
+
sps: Uint8Array;
|
|
6
|
+
type: 'avc-profile';
|
|
7
|
+
};
|
|
8
|
+
export type AvcPPs = {
|
|
9
|
+
type: 'avc-pps';
|
|
10
|
+
pps: Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
type AvcInfo = AvcProfileInfo | AvcPPs | {
|
|
13
|
+
type: 'keyframe';
|
|
14
|
+
} | {
|
|
15
|
+
type: 'delta-frame';
|
|
16
|
+
};
|
|
17
|
+
export declare const parseAvc: (buffer: Uint8Array) => AvcInfo[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAvc = void 0;
|
|
4
|
+
const buffer_iterator_1 = require("../../buffer-iterator");
|
|
5
|
+
const readSps = (iterator) => {
|
|
6
|
+
const profile = iterator.getUint8();
|
|
7
|
+
const compatibility = iterator.getUint8();
|
|
8
|
+
const level = iterator.getUint8();
|
|
9
|
+
return {
|
|
10
|
+
profile,
|
|
11
|
+
compatibility,
|
|
12
|
+
level,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const findEnd = (buffer) => {
|
|
16
|
+
let zeroesInARow = 0;
|
|
17
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
18
|
+
const val = buffer[i];
|
|
19
|
+
if (val === 0) {
|
|
20
|
+
zeroesInARow++;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (zeroesInARow >= 2 && val === 1) {
|
|
24
|
+
return i - zeroesInARow;
|
|
25
|
+
}
|
|
26
|
+
zeroesInARow = 0;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
const inspect = (buffer) => {
|
|
31
|
+
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(buffer, buffer.byteLength);
|
|
32
|
+
iterator.startReadingBits();
|
|
33
|
+
iterator.getBits(1);
|
|
34
|
+
iterator.getBits(2);
|
|
35
|
+
const type = iterator.getBits(5);
|
|
36
|
+
iterator.stopReadingBits();
|
|
37
|
+
if (type === 7) {
|
|
38
|
+
const end = findEnd(buffer);
|
|
39
|
+
const data = readSps(iterator);
|
|
40
|
+
const sps = buffer.slice(1, end === null ? Infinity : end);
|
|
41
|
+
return {
|
|
42
|
+
level: data.level,
|
|
43
|
+
profile: data.profile,
|
|
44
|
+
compatibility: data.compatibility,
|
|
45
|
+
sps,
|
|
46
|
+
type: 'avc-profile',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (type === 5) {
|
|
50
|
+
return {
|
|
51
|
+
type: 'keyframe',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (type === 8) {
|
|
55
|
+
const end = findEnd(buffer);
|
|
56
|
+
const pps = buffer.slice(0, end === null ? Infinity : end);
|
|
57
|
+
return {
|
|
58
|
+
type: 'avc-pps',
|
|
59
|
+
pps,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (type === 1) {
|
|
63
|
+
return {
|
|
64
|
+
type: 'delta-frame',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
iterator.destroy();
|
|
68
|
+
return null;
|
|
69
|
+
};
|
|
70
|
+
// https://stackoverflow.com/questions/24884827/possible-locations-for-sequence-picture-parameter-sets-for-h-264-stream
|
|
71
|
+
const parseAvc = (buffer) => {
|
|
72
|
+
let zeroesInARow = 0;
|
|
73
|
+
const infos = [];
|
|
74
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
75
|
+
const val = buffer[i];
|
|
76
|
+
if (val === 0) {
|
|
77
|
+
zeroesInARow++;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (zeroesInARow >= 2 && val === 1) {
|
|
81
|
+
zeroesInARow = 0;
|
|
82
|
+
const info = inspect(buffer.slice(i + 1, i + 100));
|
|
83
|
+
if (info) {
|
|
84
|
+
infos.push(info);
|
|
85
|
+
if (info.type === 'keyframe' || info.type === 'delta-frame') {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (val !== 1) {
|
|
91
|
+
zeroesInARow = 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return infos;
|
|
95
|
+
};
|
|
96
|
+
exports.parseAvc = parseAvc;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
-
import type { LogLevel } from '../../../log';
|
|
3
2
|
type UnknownDecoderSpecificConfig = {
|
|
4
3
|
type: 'unknown-decoder-specific-config';
|
|
5
4
|
};
|
|
@@ -11,5 +10,5 @@ type AudioSpecificConfig = {
|
|
|
11
10
|
asBytes: Uint8Array;
|
|
12
11
|
};
|
|
13
12
|
export type DecoderSpecificConfig = UnknownDecoderSpecificConfig | AudioSpecificConfig;
|
|
14
|
-
export declare const parseDecoderSpecificConfig: (iterator: BufferIterator
|
|
13
|
+
export declare const parseDecoderSpecificConfig: (iterator: BufferIterator) => DecoderSpecificConfig;
|
|
15
14
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseDecoderSpecificConfig = void 0;
|
|
4
|
-
const
|
|
5
|
-
const parseDecoderSpecificConfig = (iterator, logLevel) => {
|
|
4
|
+
const parseDecoderSpecificConfig = (iterator) => {
|
|
6
5
|
const layerTag = iterator.getUint8();
|
|
7
6
|
const layerSize = iterator.getPaddedFourByteNumber();
|
|
8
7
|
const start = iterator.counter.getOffset();
|
|
@@ -28,9 +27,6 @@ const parseDecoderSpecificConfig = (iterator, logLevel) => {
|
|
|
28
27
|
if (read < layerSize) {
|
|
29
28
|
iterator.discard(layerSize - read);
|
|
30
29
|
}
|
|
31
|
-
if (bytes.byteLength === 2 && bytes[0] === 17 && bytes[1] === 136) {
|
|
32
|
-
log_1.Log.warn(logLevel, 'Chrome has a bug and might not be able to decode this audio. It will be fixed, see: https://issues.chromium.org/issues/360083330');
|
|
33
|
-
}
|
|
34
30
|
return {
|
|
35
31
|
type: 'mp4a-specific-config',
|
|
36
32
|
audioObjectType,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
-
import type { LogLevel } from '../../../log';
|
|
3
2
|
import type { DecoderSpecificConfig } from './decoder-specific-config';
|
|
4
3
|
type AudioObjectType = 'aac' | 'mp3' | 'unknown';
|
|
5
4
|
type DecoderConfigDescriptor = {
|
|
@@ -23,9 +22,8 @@ export type Descriptor = DecoderConfigDescriptor | SlConfigDescriptor | UnknownD
|
|
|
23
22
|
type DescriptorAndNext = {
|
|
24
23
|
descriptor: Descriptor | null;
|
|
25
24
|
};
|
|
26
|
-
export declare const processDescriptor: ({ iterator,
|
|
25
|
+
export declare const processDescriptor: ({ iterator, }: {
|
|
27
26
|
iterator: BufferIterator;
|
|
28
|
-
logLevel: LogLevel;
|
|
29
27
|
}) => DescriptorAndNext;
|
|
30
|
-
export declare const parseDescriptors: (iterator: BufferIterator, maxBytes: number
|
|
28
|
+
export declare const parseDescriptors: (iterator: BufferIterator, maxBytes: number) => Descriptor[];
|
|
31
29
|
export {};
|
|
@@ -14,7 +14,7 @@ const mapToObjectAudioIndicator = (num) => {
|
|
|
14
14
|
}
|
|
15
15
|
return 'unknown';
|
|
16
16
|
};
|
|
17
|
-
const processDescriptor = ({ iterator,
|
|
17
|
+
const processDescriptor = ({ iterator, }) => {
|
|
18
18
|
const tag = iterator.getUint8();
|
|
19
19
|
if (tag === 4) {
|
|
20
20
|
const size = iterator.getPaddedFourByteNumber();
|
|
@@ -31,7 +31,7 @@ const processDescriptor = ({ iterator, logLevel, }) => {
|
|
|
31
31
|
const avgBitrate = iterator.getUint32();
|
|
32
32
|
const decoderSpecificConfigs = [];
|
|
33
33
|
while (size - (iterator.counter.getOffset() - initialOffset) > 0) {
|
|
34
|
-
const decoderSpecificConfig = (0, decoder_specific_config_1.parseDecoderSpecificConfig)(iterator
|
|
34
|
+
const decoderSpecificConfig = (0, decoder_specific_config_1.parseDecoderSpecificConfig)(iterator);
|
|
35
35
|
decoderSpecificConfigs.push(decoderSpecificConfig);
|
|
36
36
|
}
|
|
37
37
|
return {
|
|
@@ -62,14 +62,13 @@ const processDescriptor = ({ iterator, logLevel, }) => {
|
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
exports.processDescriptor = processDescriptor;
|
|
65
|
-
const parseDescriptors = (iterator, maxBytes
|
|
65
|
+
const parseDescriptors = (iterator, maxBytes) => {
|
|
66
66
|
const descriptors = [];
|
|
67
67
|
const initialOffset = iterator.counter.getOffset();
|
|
68
68
|
while (iterator.bytesRemaining() > 0 &&
|
|
69
69
|
iterator.counter.getOffset() - initialOffset < maxBytes) {
|
|
70
70
|
const { descriptor } = (0, exports.processDescriptor)({
|
|
71
71
|
iterator,
|
|
72
|
-
logLevel,
|
|
73
72
|
});
|
|
74
73
|
if (descriptor) {
|
|
75
74
|
descriptors.push(descriptor);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
-
import type { LogLevel } from '../../../log';
|
|
3
2
|
import type { Descriptor } from './esds-descriptors';
|
|
4
3
|
export interface EsdsBox {
|
|
5
4
|
type: 'esds-box';
|
|
@@ -9,9 +8,8 @@ export interface EsdsBox {
|
|
|
9
8
|
esId: number;
|
|
10
9
|
descriptors: Descriptor[];
|
|
11
10
|
}
|
|
12
|
-
export declare const parseEsds: ({ data, size, fileOffset,
|
|
11
|
+
export declare const parseEsds: ({ data, size, fileOffset, }: {
|
|
13
12
|
data: BufferIterator;
|
|
14
13
|
size: number;
|
|
15
14
|
fileOffset: number;
|
|
16
|
-
logLevel: LogLevel;
|
|
17
15
|
}) => EsdsBox;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseEsds = void 0;
|
|
4
4
|
const esds_descriptors_1 = require("./esds-descriptors");
|
|
5
|
-
const parseEsds = ({ data, size, fileOffset,
|
|
5
|
+
const parseEsds = ({ data, size, fileOffset, }) => {
|
|
6
6
|
const version = data.getUint8();
|
|
7
7
|
// Flags, we discard them
|
|
8
8
|
data.discard(3);
|
|
@@ -12,7 +12,7 @@ const parseEsds = ({ data, size, fileOffset, logLevel, }) => {
|
|
|
12
12
|
// disard 1 byte, currently unknown
|
|
13
13
|
data.discard(1);
|
|
14
14
|
const remaining = size - (data.counter.getOffset() - fileOffset);
|
|
15
|
-
const descriptors = (0, esds_descriptors_1.parseDescriptors)(data, remaining
|
|
15
|
+
const descriptors = (0, esds_descriptors_1.parseDescriptors)(data, remaining);
|
|
16
16
|
const remainingNow = size - (data.counter.getOffset() - fileOffset);
|
|
17
17
|
data.discard(remainingNow);
|
|
18
18
|
return {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSamplePositionsFromTrack = void 0;
|
|
4
|
+
const get_audio_codec_1 = require("../../get-audio-codec");
|
|
4
5
|
const get_fps_1 = require("../../get-fps");
|
|
5
6
|
const get_sample_positions_1 = require("../../get-sample-positions");
|
|
7
|
+
const get_sample_positions_from_lpcm_1 = require("../../get-sample-positions-from-lpcm");
|
|
6
8
|
const samples_from_moof_1 = require("../../samples-from-moof");
|
|
7
9
|
const traversal_1 = require("./traversal");
|
|
8
10
|
const getSamplePositionsFromTrack = (trakBox, moofBox) => {
|
|
11
|
+
const isLpcm = (0, get_audio_codec_1.isLpcmAudioCodec)(trakBox);
|
|
12
|
+
const timescaleAndDuration = (0, get_fps_1.getTimescaleAndDuration)(trakBox);
|
|
13
|
+
if (isLpcm) {
|
|
14
|
+
return (0, get_sample_positions_from_lpcm_1.getSamplePositionsFromLpcm)(trakBox);
|
|
15
|
+
}
|
|
9
16
|
const stszBox = (0, traversal_1.getStszBox)(trakBox);
|
|
10
17
|
const stcoBox = (0, traversal_1.getStcoBox)(trakBox);
|
|
11
18
|
const stscBox = (0, traversal_1.getStscBox)(trakBox);
|
|
@@ -13,7 +20,6 @@ const getSamplePositionsFromTrack = (trakBox, moofBox) => {
|
|
|
13
20
|
const sttsBox = (0, traversal_1.getSttsBox)(trakBox);
|
|
14
21
|
const tkhdBox = (0, traversal_1.getTkhdBox)(trakBox);
|
|
15
22
|
const cttsBox = (0, traversal_1.getCttsBox)(trakBox);
|
|
16
|
-
const timescaleAndDuration = (0, get_fps_1.getTimescaleAndDuration)(trakBox);
|
|
17
23
|
if (!tkhdBox) {
|
|
18
24
|
throw new Error('Expected tkhd box in trak box');
|
|
19
25
|
}
|
|
@@ -7,7 +7,7 @@ const get_sample_aspect_ratio_1 = require("../../get-sample-aspect-ratio");
|
|
|
7
7
|
const get_video_codec_1 = require("../../get-video-codec");
|
|
8
8
|
const traversal_1 = require("./traversal");
|
|
9
9
|
const makeBaseMediaTrack = (trakBox) => {
|
|
10
|
-
var _a;
|
|
10
|
+
var _a, _b, _c;
|
|
11
11
|
const tkhdBox = (0, traversal_1.getTkhdBox)(trakBox);
|
|
12
12
|
const videoDescriptors = (0, traversal_1.getVideoDescriptors)(trakBox);
|
|
13
13
|
const timescaleAndDuration = (0, get_fps_1.getTimescaleAndDuration)(trakBox);
|
|
@@ -36,7 +36,7 @@ const makeBaseMediaTrack = (trakBox) => {
|
|
|
36
36
|
sampleRate,
|
|
37
37
|
description,
|
|
38
38
|
trakBox,
|
|
39
|
-
codecPrivate: (0, get_audio_codec_1.getCodecPrivateFromTrak)(trakBox),
|
|
39
|
+
codecPrivate: (_b = (_a = (0, get_audio_codec_1.getCodecPrivateFromTrak)(trakBox)) !== null && _a !== void 0 ? _a : description) !== null && _b !== void 0 ? _b : null,
|
|
40
40
|
codecWithoutConfig: (0, get_audio_codec_1.getAudioCodecFromTrack)(trakBox),
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -84,7 +84,7 @@ const makeBaseMediaTrack = (trakBox) => {
|
|
|
84
84
|
rotation,
|
|
85
85
|
trakBox,
|
|
86
86
|
codecPrivate: privateData,
|
|
87
|
-
color: (
|
|
87
|
+
color: (_c = (0, get_video_codec_1.getIsoBmColrConfig)(trakBox)) !== null && _c !== void 0 ? _c : {
|
|
88
88
|
fullRange: null,
|
|
89
89
|
matrixCoefficients: null,
|
|
90
90
|
primaries: null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IsoBaseMediaBox } from '../../../parse-result';
|
|
3
3
|
import type { ParserContext } from '../../../parser-context';
|
|
4
4
|
type MdatStatus = {
|
|
5
5
|
status: 'samples-buffered';
|
|
@@ -17,7 +17,7 @@ export declare const parseMdat: ({ data, size, fileOffset, existingBoxes, option
|
|
|
17
17
|
data: BufferIterator;
|
|
18
18
|
size: number;
|
|
19
19
|
fileOffset: number;
|
|
20
|
-
existingBoxes:
|
|
20
|
+
existingBoxes: IsoBaseMediaBox[];
|
|
21
21
|
options: ParserContext;
|
|
22
22
|
signal: AbortSignal | null;
|
|
23
23
|
maySkipSampleProcessing: boolean;
|
|
@@ -5,7 +5,10 @@ const get_tracks_1 = require("../../../get-tracks");
|
|
|
5
5
|
const get_sample_positions_from_track_1 = require("../get-sample-positions-from-track");
|
|
6
6
|
const traversal_1 = require("../traversal");
|
|
7
7
|
const parseMdat = async ({ data, size, fileOffset, existingBoxes, options, signal, maySkipSampleProcessing, }) => {
|
|
8
|
-
const alreadyHas = (0, get_tracks_1.hasTracks)(
|
|
8
|
+
const alreadyHas = (0, get_tracks_1.hasTracks)({
|
|
9
|
+
type: 'iso-base-media',
|
|
10
|
+
boxes: existingBoxes,
|
|
11
|
+
}, options.parserState);
|
|
9
12
|
if (!alreadyHas) {
|
|
10
13
|
if (maySkipSampleProcessing) {
|
|
11
14
|
data.discard(size - (data.counter.getOffset() - fileOffset));
|
|
@@ -25,7 +28,7 @@ const parseMdat = async ({ data, size, fileOffset, existingBoxes, options, signa
|
|
|
25
28
|
fileOffset,
|
|
26
29
|
});
|
|
27
30
|
}
|
|
28
|
-
const tracks = (0, get_tracks_1.getTracks)(existingBoxes, options.parserState);
|
|
31
|
+
const tracks = (0, get_tracks_1.getTracks)({ type: 'iso-base-media', boxes: existingBoxes }, options.parserState);
|
|
29
32
|
const allTracks = [
|
|
30
33
|
...tracks.videoTracks,
|
|
31
34
|
...tracks.audioTracks,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseMoov = void 0;
|
|
4
4
|
const process_box_1 = require("../process-box");
|
|
5
5
|
const parseMoov = async ({ iterator, offset, size, options, signal, logLevel, }) => {
|
|
6
|
-
const children = await (0, process_box_1.
|
|
6
|
+
const children = await (0, process_box_1.parseIsoBaseMediaBoxes)({
|
|
7
7
|
iterator,
|
|
8
8
|
maxBytes: size - (iterator.counter.getOffset() - offset),
|
|
9
9
|
allowIncompleteBoxes: false,
|
|
@@ -20,7 +20,7 @@ const parseMoov = async ({ iterator, offset, size, options, signal, logLevel, })
|
|
|
20
20
|
offset,
|
|
21
21
|
boxSize: size,
|
|
22
22
|
type: 'moov-box',
|
|
23
|
-
children: children.segments,
|
|
23
|
+
children: children.segments.boxes,
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
exports.parseMoov = parseMoov;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
2
|
import type { LogLevel } from '../../log';
|
|
3
|
-
import type {
|
|
3
|
+
import type { IsoBaseMediaBox, IsoBaseMediaStructure, ParseResult } from '../../parse-result';
|
|
4
4
|
import type { BoxAndNext, PartialMdatBox } from '../../parse-video';
|
|
5
5
|
import type { ParserContext } from '../../parser-context';
|
|
6
6
|
export declare const parseMdatPartially: ({ iterator, boxSize, fileOffset, parsedBoxes, options, signal, }: {
|
|
7
7
|
iterator: BufferIterator;
|
|
8
8
|
boxSize: number;
|
|
9
9
|
fileOffset: number;
|
|
10
|
-
parsedBoxes:
|
|
10
|
+
parsedBoxes: IsoBaseMediaBox[];
|
|
11
11
|
options: ParserContext;
|
|
12
12
|
signal: AbortSignal | null;
|
|
13
13
|
}) => Promise<BoxAndNext>;
|
|
14
14
|
export declare const processBox: ({ iterator, allowIncompleteBoxes, parsedBoxes, options, signal, logLevel, }: {
|
|
15
15
|
iterator: BufferIterator;
|
|
16
16
|
allowIncompleteBoxes: boolean;
|
|
17
|
-
parsedBoxes:
|
|
17
|
+
parsedBoxes: IsoBaseMediaBox[];
|
|
18
18
|
options: ParserContext;
|
|
19
19
|
signal: AbortSignal | null;
|
|
20
20
|
logLevel: LogLevel;
|
|
21
21
|
}) => Promise<BoxAndNext>;
|
|
22
|
-
export declare const
|
|
22
|
+
export declare const parseIsoBaseMediaBoxes: ({ iterator, maxBytes, allowIncompleteBoxes, initialBoxes, options, continueMdat, signal, logLevel, }: {
|
|
23
23
|
iterator: BufferIterator;
|
|
24
24
|
maxBytes: number;
|
|
25
25
|
allowIncompleteBoxes: boolean;
|
|
@@ -28,4 +28,4 @@ export declare const parseBoxes: ({ iterator, maxBytes, allowIncompleteBoxes, in
|
|
|
28
28
|
continueMdat: false | PartialMdatBox;
|
|
29
29
|
signal: AbortSignal | null;
|
|
30
30
|
logLevel: LogLevel;
|
|
31
|
-
}) => Promise<ParseResult
|
|
31
|
+
}) => Promise<ParseResult<IsoBaseMediaStructure>>;
|