@remotion/media-parser 4.0.194 → 4.0.196
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-new-matroska-tracks.d.ts +8 -0
- package/dist/add-new-matroska-tracks.js +14 -0
- package/dist/av1-codec-string.d.ts +3 -0
- package/dist/av1-codec-string.js +91 -0
- package/dist/boxes/iso-base-media/esds/decoder-specific-config.d.ts +14 -0
- package/dist/boxes/iso-base-media/esds/decoder-specific-config.js +38 -0
- package/dist/boxes/iso-base-media/esds/esds-descriptors.d.ts +8 -0
- package/dist/boxes/iso-base-media/esds/esds-descriptors.js +22 -2
- package/dist/boxes/iso-base-media/ftype.d.ts +9 -0
- package/dist/boxes/iso-base-media/ftype.js +31 -0
- package/dist/boxes/iso-base-media/make-track.d.ts +3 -0
- package/dist/boxes/iso-base-media/make-track.js +112 -0
- package/dist/boxes/iso-base-media/mdat/mdat.d.ts +6 -2
- package/dist/boxes/iso-base-media/mdat/mdat.js +90 -6
- package/dist/boxes/iso-base-media/moov/moov.d.ts +4 -2
- package/dist/boxes/iso-base-media/moov/moov.js +4 -2
- package/dist/boxes/iso-base-media/mvhd.js +7 -1
- package/dist/boxes/iso-base-media/process-box.d.ts +20 -3
- package/dist/boxes/iso-base-media/process-box.js +322 -34
- package/dist/boxes/iso-base-media/stsd/av1c.d.ts +9 -0
- package/dist/boxes/iso-base-media/stsd/av1c.js +10 -0
- package/dist/boxes/iso-base-media/stsd/avcc-hvcc.d.ts +20 -0
- package/dist/boxes/iso-base-media/stsd/avcc-hvcc.js +73 -0
- package/dist/boxes/iso-base-media/stsd/avcc.d.ts +10 -0
- package/dist/boxes/iso-base-media/stsd/avcc.js +21 -0
- package/dist/boxes/iso-base-media/stsd/colr.d.ts +11 -0
- package/dist/boxes/iso-base-media/stsd/colr.js +35 -0
- package/dist/boxes/iso-base-media/stsd/ctts.d.ts +19 -0
- package/dist/boxes/iso-base-media/stsd/ctts.js +30 -0
- package/dist/boxes/iso-base-media/stsd/hvcc.d.ts +11 -0
- package/dist/boxes/iso-base-media/stsd/hvcc.js +17 -0
- package/dist/boxes/iso-base-media/stsd/keys.js +1 -0
- package/dist/boxes/iso-base-media/stsd/mebx.d.ts +4 -2
- package/dist/boxes/iso-base-media/stsd/mebx.js +4 -2
- package/dist/boxes/iso-base-media/stsd/pasp.d.ts +12 -0
- package/dist/boxes/iso-base-media/stsd/pasp.js +17 -0
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +12 -5
- package/dist/boxes/iso-base-media/stsd/samples.js +27 -10
- package/dist/boxes/iso-base-media/stsd/stsd.d.ts +4 -2
- package/dist/boxes/iso-base-media/stsd/stsd.js +6 -2
- package/dist/boxes/iso-base-media/stsd/stss.d.ts +13 -0
- package/dist/boxes/iso-base-media/stsd/stss.js +28 -0
- package/dist/boxes/iso-base-media/stsd/stsz.d.ts +9 -3
- package/dist/boxes/iso-base-media/stsd/stsz.js +14 -2
- package/dist/boxes/iso-base-media/stsd/stts.d.ts +15 -0
- package/dist/boxes/iso-base-media/stsd/stts.js +35 -0
- package/dist/boxes/iso-base-media/tkhd.d.ts +3 -0
- package/dist/boxes/iso-base-media/tkhd.js +41 -14
- package/dist/boxes/iso-base-media/trak/trak.d.ts +4 -2
- package/dist/boxes/iso-base-media/trak/trak.js +4 -2
- package/dist/boxes/iso-base-media/void-box.d.ts +4 -0
- package/dist/boxes/iso-base-media/void-box.js +2 -0
- package/dist/boxes/webm/allowed-partial-segments.d.ts +1 -0
- package/dist/boxes/webm/allowed-partial-segments.js +4 -0
- package/dist/boxes/webm/av1-codec-private.d.ts +2 -0
- package/dist/boxes/webm/av1-codec-private.js +95 -0
- package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.d.ts +14 -0
- package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.js +67 -0
- package/dist/boxes/webm/bitstream/av1/bitstream-frame.d.ts +11 -0
- package/dist/boxes/webm/bitstream/av1/bitstream-frame.js +14 -0
- package/dist/boxes/webm/bitstream/av1/chroma-sample-position.d.ts +6 -0
- package/dist/boxes/webm/bitstream/av1/chroma-sample-position.js +9 -0
- package/dist/boxes/webm/bitstream/av1/color-config.d.ts +16 -0
- package/dist/boxes/webm/bitstream/av1/color-config.js +103 -0
- package/dist/boxes/webm/bitstream/av1/color-primaries.d.ts +14 -0
- package/dist/boxes/webm/bitstream/av1/color-primaries.js +17 -0
- package/dist/boxes/webm/bitstream/av1/decoder-model-info.d.ts +9 -0
- package/dist/boxes/webm/bitstream/av1/decoder-model-info.js +17 -0
- package/dist/boxes/webm/bitstream/av1/header-segment.d.ts +51 -0
- package/dist/boxes/webm/bitstream/av1/header-segment.js +183 -0
- package/dist/boxes/webm/bitstream/av1/matrix-coefficients.d.ts +17 -0
- package/dist/boxes/webm/bitstream/av1/matrix-coefficients.js +20 -0
- package/dist/boxes/webm/bitstream/av1/operating-parameters-info.d.ts +10 -0
- package/dist/boxes/webm/bitstream/av1/operating-parameters-info.js +15 -0
- package/dist/boxes/webm/bitstream/av1/temporal-point-info.d.ts +5 -0
- package/dist/boxes/webm/bitstream/av1/temporal-point-info.js +8 -0
- package/dist/boxes/webm/bitstream/av1/timing-info.d.ts +8 -0
- package/dist/boxes/webm/bitstream/av1/timing-info.js +20 -0
- package/dist/boxes/webm/bitstream/av1/transfer-characteristics.d.ts +21 -0
- package/dist/boxes/webm/bitstream/av1/transfer-characteristics.js +24 -0
- package/dist/boxes/webm/bitstream/av1/uvlc.d.ts +2 -0
- package/dist/boxes/webm/bitstream/av1/uvlc.js +20 -0
- package/dist/boxes/webm/bitstream/av1.d.ts +20 -0
- package/dist/boxes/webm/bitstream/av1.js +118 -0
- package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.d.ts +0 -0
- package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.js +1 -0
- package/dist/boxes/webm/description.d.ts +2 -0
- package/dist/boxes/webm/description.js +83 -0
- package/dist/boxes/webm/get-ready-tracks.d.ts +3 -0
- package/dist/boxes/webm/get-ready-tracks.js +29 -0
- package/dist/boxes/webm/get-track.d.ts +6 -0
- package/dist/boxes/webm/get-track.js +183 -0
- package/dist/boxes/webm/parse-webm-header.d.ts +2 -1
- package/dist/boxes/webm/parse-webm-header.js +2 -2
- package/dist/boxes/webm/segments/all-segments.d.ts +269 -0
- package/dist/boxes/webm/segments/all-segments.js +277 -0
- package/dist/boxes/webm/segments/duration.d.ts +1 -1
- package/dist/boxes/webm/segments/duration.js +13 -9
- package/dist/boxes/webm/segments/info.d.ts +2 -1
- package/dist/boxes/webm/segments/info.js +12 -4
- package/dist/boxes/webm/segments/main.d.ts +0 -2
- package/dist/boxes/webm/segments/main.js +0 -11
- package/dist/boxes/webm/segments/muxing.d.ts +1 -1
- package/dist/boxes/webm/segments/muxing.js +1 -2
- package/dist/boxes/webm/segments/parse-children.d.ts +11 -1
- package/dist/boxes/webm/segments/parse-children.js +82 -6
- package/dist/boxes/webm/segments/seek-head.d.ts +2 -1
- package/dist/boxes/webm/segments/seek-head.js +12 -3
- package/dist/boxes/webm/segments/seek-position.d.ts +1 -1
- package/dist/boxes/webm/segments/seek-position.js +1 -2
- package/dist/boxes/webm/segments/seek.d.ts +7 -2
- package/dist/boxes/webm/segments/seek.js +22 -9
- package/dist/boxes/webm/segments/track-entry.d.ts +102 -22
- package/dist/boxes/webm/segments/track-entry.js +269 -57
- package/dist/boxes/webm/segments/tracks.d.ts +2 -1
- package/dist/boxes/webm/segments/tracks.js +12 -4
- package/dist/boxes/webm/segments/void.d.ts +1 -1
- package/dist/boxes/webm/segments/void.js +1 -2
- package/dist/boxes/webm/segments/writing.d.ts +1 -1
- package/dist/boxes/webm/segments/writing.js +1 -2
- package/dist/boxes/webm/segments.d.ts +8 -4
- package/dist/boxes/webm/segments.js +176 -40
- package/dist/boxes/webm/traversal.d.ts +7 -0
- package/dist/boxes/webm/traversal.js +25 -0
- package/dist/buffer-iterator.d.ts +15 -1
- package/dist/buffer-iterator.js +115 -46
- package/dist/combine-uint8array.d.ts +1 -0
- package/dist/combine-uint8array.js +13 -0
- package/dist/from-fetch.d.ts +2 -0
- package/dist/from-fetch.js +54 -0
- package/dist/from-node.js +6 -0
- package/dist/from-web-file.d.ts +2 -0
- package/dist/from-web-file.js +34 -0
- package/dist/from-web.js +6 -9
- package/dist/get-audio-codec.d.ts +19 -0
- package/dist/get-audio-codec.js +153 -60
- package/dist/get-dimensions.d.ts +8 -2
- package/dist/get-dimensions.js +13 -91
- package/dist/get-duration.js +4 -7
- package/dist/get-fps.d.ts +4 -3
- package/dist/get-fps.js +17 -116
- package/dist/get-sample-aspect-ratio.d.ts +37 -0
- package/dist/get-sample-aspect-ratio.js +137 -0
- package/dist/get-sample-positions.d.ts +11 -1
- package/dist/get-sample-positions.js +31 -2
- package/dist/get-tracks.d.ts +44 -5
- package/dist/get-tracks.js +66 -48
- package/dist/get-video-codec.d.ts +2 -0
- package/dist/get-video-codec.js +47 -31
- package/dist/get-video-metadata.d.ts +2 -0
- package/dist/get-video-metadata.js +44 -0
- package/dist/has-all-info.d.ts +2 -1
- package/dist/has-all-info.js +14 -5
- package/dist/index.d.ts +1 -0
- package/dist/make-hvc1-codec-strings.d.ts +2 -0
- package/dist/make-hvc1-codec-strings.js +47 -0
- package/dist/options.d.ts +26 -4
- package/dist/parse-media.js +62 -17
- package/dist/parse-result.d.ts +16 -5
- package/dist/parse-video.d.ts +11 -2
- package/dist/parse-video.js +14 -6
- package/dist/parser-context.d.ts +8 -0
- package/dist/parser-context.js +2 -0
- package/dist/parser-state.d.ts +23 -0
- package/dist/parser-state.js +112 -0
- package/dist/read-and-increment-offset.d.ts +28 -0
- package/dist/read-and-increment-offset.js +177 -0
- package/dist/reader.d.ts +2 -2
- package/dist/traversal.d.ts +37 -0
- package/dist/traversal.js +244 -1
- package/dist/understand-vorbis.d.ts +1 -0
- package/dist/understand-vorbis.js +12 -0
- package/dist/webcodec-sample-types.d.ts +21 -0
- package/dist/webcodec-sample-types.js +2 -0
- package/package.json +10 -2
- package/src/add-new-matroska-tracks.ts +23 -0
- package/src/boxes/iso-base-media/esds/decoder-specific-config.ts +61 -0
- package/src/boxes/iso-base-media/esds/esds-descriptors.ts +33 -2
- package/src/boxes/iso-base-media/make-track.ts +157 -0
- package/src/boxes/iso-base-media/mdat/mdat.ts +131 -0
- package/src/boxes/iso-base-media/moov/moov.ts +8 -3
- package/src/boxes/iso-base-media/mvhd.ts +7 -1
- package/src/boxes/iso-base-media/process-box.ts +388 -38
- package/src/boxes/iso-base-media/stsd/av1c.ts +19 -0
- package/src/boxes/iso-base-media/stsd/avcc.ts +36 -0
- package/src/boxes/iso-base-media/stsd/colr.ts +49 -0
- package/src/boxes/iso-base-media/stsd/ctts.ts +55 -0
- package/src/boxes/iso-base-media/stsd/hvcc.ts +32 -0
- package/src/boxes/iso-base-media/stsd/keys.ts +2 -0
- package/src/boxes/iso-base-media/stsd/mebx.ts +8 -3
- package/src/boxes/iso-base-media/stsd/pasp.ts +32 -0
- package/src/boxes/iso-base-media/stsd/samples.ts +43 -16
- package/src/boxes/iso-base-media/stsd/stco.ts +50 -0
- package/src/boxes/iso-base-media/stsd/stsc.ts +61 -0
- package/src/boxes/iso-base-media/stsd/stsd.ts +10 -3
- package/src/boxes/iso-base-media/stsd/stss.ts +47 -0
- package/src/boxes/iso-base-media/stsd/stsz.ts +75 -0
- package/src/boxes/iso-base-media/tkhd.ts +63 -16
- package/src/boxes/iso-base-media/trak/trak.ts +8 -3
- package/src/boxes/iso-base-media/void-box.ts +4 -0
- package/src/boxes/webm/allowed-partial-segments.ts +1 -0
- package/src/boxes/webm/av1-codec-private.ts +113 -0
- package/src/boxes/webm/description.ts +101 -0
- package/src/boxes/webm/get-ready-tracks.ts +36 -0
- package/src/boxes/webm/get-track.ts +250 -0
- package/src/boxes/webm/parse-webm-header.ts +6 -2
- package/src/boxes/webm/segments/all-segments.ts +285 -0
- package/src/boxes/webm/segments/duration.ts +15 -8
- package/src/boxes/webm/segments/info.ts +18 -4
- package/src/boxes/webm/segments/main.ts +0 -13
- package/src/boxes/webm/segments/muxing.ts +1 -1
- package/src/boxes/webm/segments/parse-children.ts +132 -9
- package/src/boxes/webm/segments/seek-head.ts +17 -4
- package/src/boxes/webm/segments/seek-position.ts +1 -2
- package/src/boxes/webm/segments/seek.ts +31 -9
- package/src/boxes/webm/segments/track-entry.ts +475 -65
- package/src/boxes/webm/segments/tracks.ts +17 -7
- package/src/boxes/webm/segments/void.ts +4 -2
- package/src/boxes/webm/segments/writing.ts +1 -1
- package/src/boxes/webm/segments.ts +266 -42
- package/src/boxes/webm/traversal.ts +32 -0
- package/src/buffer-iterator.ts +140 -45
- package/src/combine-uint8array.ts +13 -0
- package/src/{from-web.ts → from-fetch.ts} +9 -1
- package/src/from-node.ts +8 -0
- package/src/from-web-file.ts +39 -0
- package/src/get-audio-codec.ts +213 -84
- package/src/get-dimensions.ts +25 -132
- package/src/get-duration.ts +4 -8
- package/src/get-fps.ts +27 -172
- package/src/get-sample-aspect-ratio.ts +204 -0
- package/src/get-sample-positions.ts +93 -0
- package/src/get-tracks.ts +147 -0
- package/src/get-video-codec.ts +62 -47
- package/src/has-all-info.ts +35 -5
- package/src/index.ts +8 -0
- package/src/make-hvc1-codec-strings.ts +55 -0
- package/src/options.ts +48 -9
- package/src/parse-media.ts +90 -21
- package/src/parse-result.ts +28 -4
- package/src/parse-video.ts +30 -7
- package/src/parser-context.ts +9 -0
- package/src/parser-state.ts +151 -0
- package/src/reader.ts +2 -2
- package/src/test/aspect-ratio.test.ts +42 -0
- package/src/test/av1.test.ts +108 -0
- package/src/test/duration.test.ts +5 -21
- package/src/test/matroska.test.ts +350 -31
- package/src/test/mvhd.test.ts +6 -1
- package/src/test/parse-esds.test.ts +29 -6
- package/src/test/parse-stco.test.ts +59 -0
- package/src/test/parse-stsc.test.ts +104 -0
- package/src/test/parse-stsz.test.ts +57 -0
- package/src/test/parse-stts.test.ts +1 -1
- package/src/test/parse-video.test.ts +23 -35
- package/src/test/parse-webm.test.ts +5 -5
- package/src/test/stream-local.test.ts +542 -46
- package/src/test/stream-remote.test.ts +15 -13
- package/src/test/stream-samples.test.ts +259 -0
- package/src/test/stsd.test.ts +60 -8
- package/src/test/tkhd.test.ts +4 -1
- package/src/traversal.ts +496 -0
- package/src/webcodec-sample-types.ts +30 -0
- package/tsconfig.json +5 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/boxes.json +0 -1
- package/dist/boxes/iso-base-media/esds-descriptors.d.ts +0 -21
- package/dist/boxes/iso-base-media/esds-descriptors.js +0 -62
- package/dist/boxes/iso-base-media/esds.d.ts +0 -15
- package/dist/boxes/iso-base-media/esds.js +0 -27
- package/dist/get-codec.d.ts +0 -4
- package/dist/get-codec.js +0 -22
- /package/dist/{get-samples.d.ts → boxes/webm/bitstream/av1/frame.d.ts} +0 -0
- /package/dist/{get-samples.js → boxes/webm/bitstream/av1/frame.js} +0 -0
- /package/src/boxes/iso-base-media/{stts → stsd}/stts.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchReader = void 0;
|
|
4
|
+
exports.fetchReader = {
|
|
5
|
+
read: async (src, range) => {
|
|
6
|
+
if (typeof src !== 'string') {
|
|
7
|
+
throw new Error('src must be a string when using `webReader`');
|
|
8
|
+
}
|
|
9
|
+
const resolvedUrl = typeof window !== 'undefined' && typeof window.location !== 'undefined'
|
|
10
|
+
? new URL(src, window.location.origin).toString()
|
|
11
|
+
: src;
|
|
12
|
+
if (!resolvedUrl.startsWith('https://') &&
|
|
13
|
+
!resolvedUrl.startsWith('http://')) {
|
|
14
|
+
return Promise.reject(new Error(resolvedUrl +
|
|
15
|
+
' is not a URL - needs to start with http:// or https://. If you want to read a local file, pass `nodeReader` to parseMedia().'));
|
|
16
|
+
}
|
|
17
|
+
const res = await fetch(resolvedUrl, {
|
|
18
|
+
headers: range === null
|
|
19
|
+
? {}
|
|
20
|
+
: typeof range === 'number'
|
|
21
|
+
? {
|
|
22
|
+
Range: `bytes=${range}`,
|
|
23
|
+
}
|
|
24
|
+
: {
|
|
25
|
+
Range: `bytes=${`${range[0]}-${range[1]}`}`,
|
|
26
|
+
},
|
|
27
|
+
// Disable Next.js caching
|
|
28
|
+
cache: 'no-store',
|
|
29
|
+
});
|
|
30
|
+
if (!res.body) {
|
|
31
|
+
throw new Error('No body');
|
|
32
|
+
}
|
|
33
|
+
const length = res.headers.get('content-length');
|
|
34
|
+
const contentLength = length === null ? null : parseInt(length, 10);
|
|
35
|
+
const reader = res.body.getReader();
|
|
36
|
+
return { reader, contentLength };
|
|
37
|
+
},
|
|
38
|
+
getLength: async (src) => {
|
|
39
|
+
if (typeof src !== 'string') {
|
|
40
|
+
throw new Error('src must be a string when using `webReader`');
|
|
41
|
+
}
|
|
42
|
+
const res = await fetch(src, {
|
|
43
|
+
method: 'HEAD',
|
|
44
|
+
});
|
|
45
|
+
if (!res.body) {
|
|
46
|
+
throw new Error('No body');
|
|
47
|
+
}
|
|
48
|
+
const length = res.headers.get('content-length');
|
|
49
|
+
if (!length) {
|
|
50
|
+
throw new Error('No content-length');
|
|
51
|
+
}
|
|
52
|
+
return parseInt(length, 10);
|
|
53
|
+
},
|
|
54
|
+
};
|
package/dist/from-node.js
CHANGED
|
@@ -6,6 +6,9 @@ const promises_1 = require("node:fs/promises");
|
|
|
6
6
|
const stream_1 = require("stream");
|
|
7
7
|
exports.nodeReader = {
|
|
8
8
|
read: async (src, range) => {
|
|
9
|
+
if (typeof src !== 'string') {
|
|
10
|
+
throw new Error('src must be a string when using `nodeReader`');
|
|
11
|
+
}
|
|
9
12
|
const stream = (0, fs_1.createReadStream)(src, {
|
|
10
13
|
start: range === null ? 0 : typeof range === 'number' ? range : range[0],
|
|
11
14
|
end: range === null
|
|
@@ -21,6 +24,9 @@ exports.nodeReader = {
|
|
|
21
24
|
};
|
|
22
25
|
},
|
|
23
26
|
getLength: async (src) => {
|
|
27
|
+
if (typeof src !== 'string') {
|
|
28
|
+
throw new Error('src must be a string when using `nodeReader`');
|
|
29
|
+
}
|
|
24
30
|
const stats = await (0, promises_1.stat)(src);
|
|
25
31
|
return stats.size;
|
|
26
32
|
},
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webFileReader = void 0;
|
|
4
|
+
exports.webFileReader = {
|
|
5
|
+
read: (file, range) => {
|
|
6
|
+
if (typeof file === 'string') {
|
|
7
|
+
throw new Error('`inputTypeFileReader` only supports `File` objects');
|
|
8
|
+
}
|
|
9
|
+
const part = range === null
|
|
10
|
+
? file
|
|
11
|
+
: typeof range === 'number'
|
|
12
|
+
? file.slice(range)
|
|
13
|
+
: file.slice(range[0], range[1]);
|
|
14
|
+
const reader = new FileReader();
|
|
15
|
+
reader.readAsArrayBuffer(file);
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
reader.onload = () => {
|
|
18
|
+
resolve({
|
|
19
|
+
reader: part.stream().getReader(),
|
|
20
|
+
contentLength: file.size,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
reader.onerror = (error) => {
|
|
24
|
+
reject(error);
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
getLength: (src) => {
|
|
29
|
+
if (typeof src === 'string') {
|
|
30
|
+
throw new Error('`inputTypeFileReader` only supports `File` objects');
|
|
31
|
+
}
|
|
32
|
+
return Promise.resolve(src.size);
|
|
33
|
+
},
|
|
34
|
+
};
|
package/dist/from-web.js
CHANGED
|
@@ -14,20 +14,17 @@ exports.webReader = {
|
|
|
14
14
|
const res = await fetch(resolvedUrl, {
|
|
15
15
|
headers: range === null
|
|
16
16
|
? {}
|
|
17
|
-
:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
: {
|
|
22
|
-
Range: `bytes=${`${range[0]}-${range[1]}`}`,
|
|
23
|
-
},
|
|
24
|
-
// Disable Next.js caching
|
|
25
|
-
cache: 'no-store',
|
|
17
|
+
: {
|
|
18
|
+
Range: `bytes=${`${range[0]}-${range[1]}`}`,
|
|
19
|
+
},
|
|
26
20
|
});
|
|
27
21
|
if (!res.body) {
|
|
28
22
|
throw new Error('No body');
|
|
29
23
|
}
|
|
30
24
|
const length = res.headers.get('content-length');
|
|
25
|
+
if (!length) {
|
|
26
|
+
throw new Error('No content-length');
|
|
27
|
+
}
|
|
31
28
|
const contentLength = length === null ? null : parseInt(length, 10);
|
|
32
29
|
const reader = res.body.getReader();
|
|
33
30
|
return { reader, contentLength };
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
+
import type { MoovBox } from './boxes/iso-base-media/moov/moov';
|
|
2
|
+
import type { TrakBox } from './boxes/iso-base-media/trak/trak';
|
|
3
|
+
import type { MainSegment } from './boxes/webm/segments/main';
|
|
1
4
|
import type { KnownAudioCodecs } from './options';
|
|
2
5
|
import type { AnySegment } from './parse-result';
|
|
3
6
|
export declare const hasAudioCodec: (boxes: AnySegment[]) => boolean;
|
|
7
|
+
type AudioCodecInfo = {
|
|
8
|
+
format: string;
|
|
9
|
+
primarySpecificator: number | null;
|
|
10
|
+
secondarySpecificator: number | null;
|
|
11
|
+
description: Uint8Array | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare const getNumberOfChannelsFromTrak: (trak: TrakBox) => number | null;
|
|
14
|
+
export declare const getSampleRate: (trak: TrakBox) => number | null;
|
|
15
|
+
export declare const getAudioCodecFromTrak: (trak: TrakBox) => AudioCodecInfo | null;
|
|
16
|
+
export declare const getAudioCodecFromIso: (moov: MoovBox) => AudioCodecInfo | null;
|
|
17
|
+
export declare const getAudioCodecFromMatroska: (mainSegment: MainSegment) => "opus" | "vorbis" | "mp3" | "aac" | "pcm" | null;
|
|
18
|
+
export declare const getAudioCodecStringFromTrak: (trak: TrakBox) => {
|
|
19
|
+
codecString: string;
|
|
20
|
+
description: Uint8Array | undefined;
|
|
21
|
+
};
|
|
4
22
|
export declare const getAudioCodec: (boxes: AnySegment[]) => KnownAudioCodecs | null;
|
|
23
|
+
export {};
|
package/dist/get-audio-codec.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAudioCodec = exports.hasAudioCodec = void 0;
|
|
3
|
+
exports.getAudioCodec = exports.getAudioCodecStringFromTrak = exports.getAudioCodecFromMatroska = exports.getAudioCodecFromIso = exports.getAudioCodecFromTrak = exports.getSampleRate = exports.getNumberOfChannelsFromTrak = exports.hasAudioCodec = void 0;
|
|
4
4
|
const get_fps_1 = require("./get-fps");
|
|
5
|
+
const traversal_1 = require("./traversal");
|
|
5
6
|
const hasAudioCodec = (boxes) => {
|
|
6
7
|
try {
|
|
7
8
|
return (0, exports.getAudioCodec)(boxes) !== null;
|
|
@@ -11,79 +12,109 @@ const hasAudioCodec = (boxes) => {
|
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
exports.hasAudioCodec = hasAudioCodec;
|
|
14
|
-
const
|
|
15
|
+
const getCodecSpecificatorFromEsdsBox = ({ child, }) => {
|
|
16
|
+
const descriptor = child.descriptors.find((d) => d.type === 'decoder-config-descriptor');
|
|
17
|
+
if (!descriptor) {
|
|
18
|
+
throw new Error('No decoder-config-descriptor');
|
|
19
|
+
}
|
|
20
|
+
if (descriptor.type !== 'decoder-config-descriptor') {
|
|
21
|
+
throw new Error('Expected decoder-config-descriptor');
|
|
22
|
+
}
|
|
23
|
+
if (descriptor.asNumber !== 0x40) {
|
|
24
|
+
return {
|
|
25
|
+
primary: descriptor.asNumber,
|
|
26
|
+
secondary: null,
|
|
27
|
+
description: undefined,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const audioSpecificConfig = descriptor.decoderSpecificConfigs.find((d) => {
|
|
31
|
+
return d.type === 'audio-specific-config' ? d : null;
|
|
32
|
+
});
|
|
33
|
+
if (!audioSpecificConfig ||
|
|
34
|
+
audioSpecificConfig.type !== 'audio-specific-config') {
|
|
35
|
+
throw new Error('No audio-specific-config');
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
primary: descriptor.asNumber,
|
|
39
|
+
secondary: audioSpecificConfig.audioObjectType,
|
|
40
|
+
description: audioSpecificConfig.asBytes,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const onSample = (sample, children) => {
|
|
44
|
+
const child = children.find((c) => c.type === 'esds-box');
|
|
15
45
|
if (child && child.type === 'esds-box') {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
46
|
+
const ret = getCodecSpecificatorFromEsdsBox({ child });
|
|
47
|
+
return {
|
|
48
|
+
format: sample.format,
|
|
49
|
+
primarySpecificator: ret.primary,
|
|
50
|
+
secondarySpecificator: ret.secondary,
|
|
51
|
+
description: ret.description,
|
|
52
|
+
};
|
|
20
53
|
}
|
|
21
|
-
return
|
|
54
|
+
return {
|
|
55
|
+
format: sample.format,
|
|
56
|
+
primarySpecificator: null,
|
|
57
|
+
secondarySpecificator: null,
|
|
58
|
+
description: undefined,
|
|
59
|
+
};
|
|
22
60
|
};
|
|
23
|
-
const
|
|
24
|
-
|
|
61
|
+
const getNumberOfChannelsFromTrak = (trak) => {
|
|
62
|
+
const stsdBox = (0, traversal_1.getStsdBox)(trak);
|
|
63
|
+
if (!stsdBox) {
|
|
25
64
|
return null;
|
|
26
65
|
}
|
|
27
|
-
|
|
66
|
+
const sample = stsdBox.samples.find((s) => s.type === 'audio');
|
|
67
|
+
if (!sample || sample.type !== 'audio') {
|
|
28
68
|
return null;
|
|
29
69
|
}
|
|
30
|
-
|
|
31
|
-
|
|
70
|
+
return sample.numberOfChannels;
|
|
71
|
+
};
|
|
72
|
+
exports.getNumberOfChannelsFromTrak = getNumberOfChannelsFromTrak;
|
|
73
|
+
const getSampleRate = (trak) => {
|
|
74
|
+
const stsdBox = (0, traversal_1.getStsdBox)(trak);
|
|
75
|
+
if (!stsdBox) {
|
|
76
|
+
return null;
|
|
32
77
|
}
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
if (ret) {
|
|
37
|
-
return ret;
|
|
38
|
-
}
|
|
78
|
+
const sample = stsdBox.samples.find((s) => s.type === 'audio');
|
|
79
|
+
if (!sample || sample.type !== 'audio') {
|
|
80
|
+
return null;
|
|
39
81
|
}
|
|
82
|
+
return sample.sampleRate;
|
|
40
83
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const stsdBox = stblBox === null || stblBox === void 0 ? void 0 : stblBox.children.find((b) => b.type === 'stsd-box');
|
|
57
|
-
if (stsdBox && stsdBox.type === 'stsd-box') {
|
|
58
|
-
const sample = stsdBox.samples.find((s) => s.type === 'audio');
|
|
59
|
-
if (sample && sample.type === 'audio') {
|
|
60
|
-
const ret = onSample(sample);
|
|
61
|
-
if (ret) {
|
|
62
|
-
return ret;
|
|
63
|
-
}
|
|
64
|
-
const waveBox = sample.children.find((b) => b.type === 'regular-box' && b.boxType === 'wave');
|
|
65
|
-
if (waveBox &&
|
|
66
|
-
waveBox.type === 'regular-box' &&
|
|
67
|
-
waveBox.boxType === 'wave') {
|
|
68
|
-
const esdsBox = waveBox.children.find((b) => b.type === 'esds-box');
|
|
69
|
-
if (esdsBox && esdsBox.type === 'esds-box') {
|
|
70
|
-
const ret2 = onEsdsBox(esdsBox);
|
|
71
|
-
if (ret2) {
|
|
72
|
-
return ret2;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
84
|
+
exports.getSampleRate = getSampleRate;
|
|
85
|
+
const getAudioCodecFromTrak = (trak) => {
|
|
86
|
+
const stsdBox = (0, traversal_1.getStsdBox)(trak);
|
|
87
|
+
if (!stsdBox) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const sample = stsdBox.samples.find((s) => s.type === 'audio');
|
|
91
|
+
if (!sample || sample.type !== 'audio') {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const waveBox = sample.children.find((b) => b.type === 'regular-box' && b.boxType === 'wave');
|
|
95
|
+
if (waveBox && waveBox.type === 'regular-box' && waveBox.boxType === 'wave') {
|
|
96
|
+
const esdsSample = onSample(sample, waveBox.children);
|
|
97
|
+
if (esdsSample) {
|
|
98
|
+
return esdsSample;
|
|
81
99
|
}
|
|
82
100
|
}
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
101
|
+
const ret = onSample(sample, sample.children);
|
|
102
|
+
if (ret) {
|
|
103
|
+
return ret;
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
};
|
|
107
|
+
exports.getAudioCodecFromTrak = getAudioCodecFromTrak;
|
|
108
|
+
const getAudioCodecFromIso = (moov) => {
|
|
109
|
+
const traks = (0, traversal_1.getTraks)(moov);
|
|
110
|
+
const trakBox = traks.find((b) => b.type === 'trak-box' && (0, get_fps_1.trakBoxContainsAudio)(b));
|
|
111
|
+
if (!trakBox) {
|
|
85
112
|
return null;
|
|
86
113
|
}
|
|
114
|
+
return (0, exports.getAudioCodecFromTrak)(trakBox);
|
|
115
|
+
};
|
|
116
|
+
exports.getAudioCodecFromIso = getAudioCodecFromIso;
|
|
117
|
+
const getAudioCodecFromMatroska = (mainSegment) => {
|
|
87
118
|
const tracksSegment = mainSegment.children.find((b) => b.type === 'tracks-segment');
|
|
88
119
|
if (!tracksSegment || tracksSegment.type !== 'tracks-segment') {
|
|
89
120
|
return null;
|
|
@@ -95,12 +126,74 @@ const getAudioCodec = (boxes) => {
|
|
|
95
126
|
if (trackType.codec === 'A_OPUS') {
|
|
96
127
|
return 'opus';
|
|
97
128
|
}
|
|
129
|
+
if (trackType.codec === 'A_VORBIS') {
|
|
130
|
+
return 'vorbis';
|
|
131
|
+
}
|
|
98
132
|
if (trackType.codec === 'A_PCM/INT/LIT') {
|
|
99
133
|
return 'pcm';
|
|
100
134
|
}
|
|
135
|
+
if (trackType.codec === 'A_AAC') {
|
|
136
|
+
return 'aac';
|
|
137
|
+
}
|
|
138
|
+
if (trackType.codec === 'A_MPEG/L3') {
|
|
139
|
+
return 'mp3';
|
|
140
|
+
}
|
|
101
141
|
}
|
|
102
142
|
}
|
|
103
143
|
}
|
|
104
144
|
return null;
|
|
105
145
|
};
|
|
146
|
+
exports.getAudioCodecFromMatroska = getAudioCodecFromMatroska;
|
|
147
|
+
const getAudioCodecStringFromTrak = (trak) => {
|
|
148
|
+
const codec = (0, exports.getAudioCodecFromTrak)(trak);
|
|
149
|
+
if (!codec) {
|
|
150
|
+
throw new Error('Expected codec');
|
|
151
|
+
}
|
|
152
|
+
const codecStringWithoutMp3Exception = [
|
|
153
|
+
codec.format,
|
|
154
|
+
codec.primarySpecificator ? codec.primarySpecificator.toString(16) : null,
|
|
155
|
+
codec.secondarySpecificator
|
|
156
|
+
? codec.secondarySpecificator.toString().padStart(2, '0')
|
|
157
|
+
: null,
|
|
158
|
+
].filter(Boolean).join('.');
|
|
159
|
+
// Really, MP3? 😔
|
|
160
|
+
const codecString = codecStringWithoutMp3Exception === 'mp4a.6b'
|
|
161
|
+
? 'mp3' // or "mp4a.6B" would also work, with the uppercasing, but mp3 is probably more obvious
|
|
162
|
+
: codecStringWithoutMp3Exception;
|
|
163
|
+
return {
|
|
164
|
+
codecString,
|
|
165
|
+
description: codec.description,
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
exports.getAudioCodecStringFromTrak = getAudioCodecStringFromTrak;
|
|
169
|
+
const getAudioCodec = (boxes) => {
|
|
170
|
+
const moovBox = (0, traversal_1.getMoovBox)(boxes);
|
|
171
|
+
if (moovBox) {
|
|
172
|
+
const codec = (0, exports.getAudioCodecFromIso)(moovBox);
|
|
173
|
+
if (!codec) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
if (codec.format === 'sowt') {
|
|
177
|
+
return 'aiff';
|
|
178
|
+
}
|
|
179
|
+
if (codec.format === 'mp4a') {
|
|
180
|
+
if (codec.primarySpecificator === 0x40) {
|
|
181
|
+
return 'aac';
|
|
182
|
+
}
|
|
183
|
+
if (codec.primarySpecificator === 0x6b) {
|
|
184
|
+
return 'mp3';
|
|
185
|
+
}
|
|
186
|
+
if (codec.primarySpecificator === null) {
|
|
187
|
+
return 'aac';
|
|
188
|
+
}
|
|
189
|
+
throw new Error('Unknown mp4a codec: ' + codec.primarySpecificator);
|
|
190
|
+
}
|
|
191
|
+
throw new Error('Unknown audio format: ' + codec.format);
|
|
192
|
+
}
|
|
193
|
+
const mainSegment = boxes.find((b) => b.type === 'main-segment');
|
|
194
|
+
if (!mainSegment || mainSegment.type !== 'main-segment') {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return (0, exports.getAudioCodecFromMatroska)(mainSegment);
|
|
198
|
+
};
|
|
106
199
|
exports.getAudioCodec = getAudioCodec;
|
package/dist/get-dimensions.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { AnySegment } from './parse-result';
|
|
2
|
+
import type { ParserState } from './parser-state';
|
|
2
3
|
export type Dimensions = {
|
|
3
4
|
width: number;
|
|
4
5
|
height: number;
|
|
5
6
|
};
|
|
6
|
-
export
|
|
7
|
-
|
|
7
|
+
export type ExpandedDimensions = Dimensions & {
|
|
8
|
+
rotation: number;
|
|
9
|
+
unrotatedWidth: number;
|
|
10
|
+
unrotatedHeight: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const getDimensions: (boxes: AnySegment[], state: ParserState) => ExpandedDimensions;
|
|
13
|
+
export declare const hasDimensions: (boxes: AnySegment[], state: ParserState) => boolean;
|
package/dist/get-dimensions.js
CHANGED
|
@@ -1,105 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasDimensions = exports.getDimensions = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const trackEntrySegment = tracksSegment.children.find((b) => {
|
|
10
|
-
if (b.type !== 'track-entry-segment') {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
return (b.children.find((c) => c.type === 'codec-segment' && c.codec.startsWith('V_')) !== undefined);
|
|
14
|
-
});
|
|
15
|
-
if (!trackEntrySegment || trackEntrySegment.type !== 'track-entry-segment') {
|
|
16
|
-
throw new Error('No track entry segment');
|
|
17
|
-
}
|
|
18
|
-
const videoSegment = trackEntrySegment.children.find((b) => b.type === 'video-segment');
|
|
19
|
-
if (!videoSegment || videoSegment.type !== 'video-segment') {
|
|
20
|
-
throw new Error('No video segment');
|
|
21
|
-
}
|
|
22
|
-
const widthSegment = videoSegment.children.find((b) => b.type === 'width-segment');
|
|
23
|
-
if (!widthSegment || widthSegment.type !== 'width-segment') {
|
|
24
|
-
throw new Error('No width segment');
|
|
25
|
-
}
|
|
26
|
-
const heightSegment = videoSegment.children.find((b) => b.type === 'height-segment');
|
|
27
|
-
if (!heightSegment || heightSegment.type !== 'height-segment') {
|
|
28
|
-
throw new Error('No height segment');
|
|
4
|
+
const get_tracks_1 = require("./get-tracks");
|
|
5
|
+
const getDimensions = (boxes, state) => {
|
|
6
|
+
const { videoTracks } = (0, get_tracks_1.getTracks)(boxes, state);
|
|
7
|
+
if (!videoTracks.length) {
|
|
8
|
+
throw new Error('Expected video track');
|
|
29
9
|
}
|
|
10
|
+
const firstVideoTrack = videoTracks[0];
|
|
30
11
|
return {
|
|
31
|
-
width:
|
|
32
|
-
height:
|
|
12
|
+
width: firstVideoTrack.width,
|
|
13
|
+
height: firstVideoTrack.height,
|
|
14
|
+
rotation: firstVideoTrack.rotation,
|
|
15
|
+
unrotatedHeight: firstVideoTrack.displayAspectHeight,
|
|
16
|
+
unrotatedWidth: firstVideoTrack.displayAspectWidth,
|
|
33
17
|
};
|
|
34
18
|
};
|
|
35
|
-
const getDimensions = (boxes) => {
|
|
36
|
-
const matroskaBox = boxes.find((b) => b.type === 'main-segment');
|
|
37
|
-
if (matroskaBox && matroskaBox.type === 'main-segment') {
|
|
38
|
-
return getDimensionsFromMatroska(matroskaBox);
|
|
39
|
-
}
|
|
40
|
-
const moovBox = boxes.find((b) => b.type === 'moov-box');
|
|
41
|
-
if (!moovBox || moovBox.type !== 'moov-box') {
|
|
42
|
-
throw new Error('Expected moov box');
|
|
43
|
-
}
|
|
44
|
-
const { children } = moovBox;
|
|
45
|
-
if (!children) {
|
|
46
|
-
throw new Error('Expected moov box children');
|
|
47
|
-
}
|
|
48
|
-
const t = children.find((b) => b.type === 'trak-box');
|
|
49
|
-
if (!t || t.type !== 'trak-box') {
|
|
50
|
-
throw new Error('Expected trak box');
|
|
51
|
-
}
|
|
52
|
-
const mdiaBox = t.children.find((c) => c.type === 'regular-box' && c.boxType === 'mdia');
|
|
53
|
-
const tkhdBox = t.children.find((c) => c.type === 'tkhd-box');
|
|
54
|
-
if (tkhdBox && tkhdBox.type === 'tkhd-box') {
|
|
55
|
-
return {
|
|
56
|
-
width: tkhdBox.width,
|
|
57
|
-
height: tkhdBox.height,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
if (!mdiaBox) {
|
|
61
|
-
throw new Error('Expected mdia box');
|
|
62
|
-
}
|
|
63
|
-
if (mdiaBox.type !== 'regular-box') {
|
|
64
|
-
throw new Error('Expected mdia box');
|
|
65
|
-
}
|
|
66
|
-
const minfBox = mdiaBox.children.find((c) => c.type === 'regular-box' && c.boxType === 'minf');
|
|
67
|
-
if (!minfBox) {
|
|
68
|
-
throw new Error('Expected minf box');
|
|
69
|
-
}
|
|
70
|
-
if (minfBox.type !== 'regular-box') {
|
|
71
|
-
throw new Error('Expected minf box');
|
|
72
|
-
}
|
|
73
|
-
const stblBox = minfBox.children.find((c) => c.type === 'regular-box' && c.boxType === 'stbl');
|
|
74
|
-
if (!stblBox) {
|
|
75
|
-
throw new Error('Expected stbl box');
|
|
76
|
-
}
|
|
77
|
-
if (stblBox.type !== 'regular-box') {
|
|
78
|
-
throw new Error('Expected stbl box');
|
|
79
|
-
}
|
|
80
|
-
const stsdBox = stblBox.children.find((c) => c.type === 'stsd-box');
|
|
81
|
-
if (!stsdBox) {
|
|
82
|
-
throw new Error('Expected stsd box');
|
|
83
|
-
}
|
|
84
|
-
if (stsdBox.type !== 'stsd-box') {
|
|
85
|
-
throw new Error('Expected stsd box');
|
|
86
|
-
}
|
|
87
|
-
const videoSamples = stsdBox.samples.filter((s) => s.type === 'video');
|
|
88
|
-
if (videoSamples.length === 0) {
|
|
89
|
-
throw new Error('Has no video stream');
|
|
90
|
-
}
|
|
91
|
-
const [firstTrack] = videoSamples;
|
|
92
|
-
if (firstTrack.type !== 'video') {
|
|
93
|
-
throw new Error('Expected video track');
|
|
94
|
-
}
|
|
95
|
-
return { width: firstTrack.width, height: firstTrack.height };
|
|
96
|
-
};
|
|
97
19
|
exports.getDimensions = getDimensions;
|
|
98
20
|
// TODO: An audio track should return 'hasDimensions' = true on an audio file
|
|
99
21
|
// and stop parsing
|
|
100
|
-
const hasDimensions = (boxes) => {
|
|
22
|
+
const hasDimensions = (boxes, state) => {
|
|
101
23
|
try {
|
|
102
|
-
return (0, exports.getDimensions)(boxes) !== null;
|
|
24
|
+
return (0, exports.getDimensions)(boxes, state) !== null;
|
|
103
25
|
}
|
|
104
26
|
catch (err) {
|
|
105
27
|
return false;
|
package/dist/get-duration.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasDuration = exports.getDuration = void 0;
|
|
4
|
+
const traversal_1 = require("./traversal");
|
|
4
5
|
const getDurationFromMatroska = (segments) => {
|
|
5
6
|
const mainSegment = segments.find((s) => s.type === 'main-segment');
|
|
6
7
|
if (!mainSegment || mainSegment.type !== 'main-segment') {
|
|
@@ -32,15 +33,11 @@ const getDuration = (boxes) => {
|
|
|
32
33
|
if (matroskaBox) {
|
|
33
34
|
return getDurationFromMatroska(boxes);
|
|
34
35
|
}
|
|
35
|
-
const moovBox =
|
|
36
|
-
if (!moovBox
|
|
36
|
+
const moovBox = (0, traversal_1.getMoovBox)(boxes);
|
|
37
|
+
if (!moovBox) {
|
|
37
38
|
return null;
|
|
38
39
|
}
|
|
39
|
-
const
|
|
40
|
-
if (!children) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const mvhdBox = children.find((b) => b.type === 'mvhd-box');
|
|
40
|
+
const mvhdBox = (0, traversal_1.getMvhdBox)(moovBox);
|
|
44
41
|
if (!mvhdBox) {
|
|
45
42
|
return null;
|
|
46
43
|
}
|
package/dist/get-fps.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { TrakBox } from './boxes/iso-base-media/trak/trak';
|
|
1
2
|
import type { AnySegment } from './parse-result';
|
|
2
3
|
type TimescaleAndDuration = {
|
|
3
4
|
timescale: number;
|
|
4
5
|
duration: number;
|
|
5
6
|
};
|
|
6
|
-
export declare const trakBoxContainsAudio: (trakBox:
|
|
7
|
-
export declare const trakBoxContainsVideo: (trakBox:
|
|
8
|
-
export declare const getTimescaleAndDuration: (
|
|
7
|
+
export declare const trakBoxContainsAudio: (trakBox: TrakBox) => boolean;
|
|
8
|
+
export declare const trakBoxContainsVideo: (trakBox: TrakBox) => boolean;
|
|
9
|
+
export declare const getTimescaleAndDuration: (trakBox: TrakBox) => TimescaleAndDuration | null;
|
|
9
10
|
export declare const getFps: (segments: AnySegment[]) => number | null;
|
|
10
11
|
export declare const hasFps: (boxes: AnySegment[]) => boolean;
|
|
11
12
|
export {};
|