@remotion/media-parser 4.0.194 → 4.0.195
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,19 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { BaseBox } from '../base-type';
|
|
3
|
+
type CttsEntry = {
|
|
4
|
+
sampleCount: number;
|
|
5
|
+
sampleOffset: number;
|
|
6
|
+
};
|
|
7
|
+
export interface CttsBox extends BaseBox {
|
|
8
|
+
type: 'ctts-box';
|
|
9
|
+
version: number;
|
|
10
|
+
flags: number[];
|
|
11
|
+
entryCount: number;
|
|
12
|
+
entries: CttsEntry[];
|
|
13
|
+
}
|
|
14
|
+
export declare const parseCtts: ({ iterator, offset, size, }: {
|
|
15
|
+
iterator: BufferIterator;
|
|
16
|
+
offset: number;
|
|
17
|
+
size: number;
|
|
18
|
+
}) => CttsBox;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCtts = void 0;
|
|
4
|
+
const parseCtts = ({ iterator, offset, size, }) => {
|
|
5
|
+
const version = iterator.getUint8();
|
|
6
|
+
if (version !== 0) {
|
|
7
|
+
throw new Error(`Unsupported CTTS version ${version}`);
|
|
8
|
+
}
|
|
9
|
+
const flags = iterator.getSlice(3);
|
|
10
|
+
const entryCount = iterator.getUint32();
|
|
11
|
+
const entries = [];
|
|
12
|
+
for (let i = 0; i < entryCount; i++) {
|
|
13
|
+
const sampleCount = iterator.getUint32();
|
|
14
|
+
const sampleOffset = iterator.getUint32();
|
|
15
|
+
entries.push({
|
|
16
|
+
sampleCount,
|
|
17
|
+
sampleOffset,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
type: 'ctts-box',
|
|
22
|
+
boxSize: size,
|
|
23
|
+
offset,
|
|
24
|
+
version,
|
|
25
|
+
flags: [...flags],
|
|
26
|
+
entryCount,
|
|
27
|
+
entries,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
exports.parseCtts = parseCtts;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
export interface HvccBox {
|
|
3
|
+
type: 'hvcc-box';
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
configurationString: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const parseHvcc: ({ data, size, offset, }: {
|
|
8
|
+
data: BufferIterator;
|
|
9
|
+
size: number;
|
|
10
|
+
offset: number;
|
|
11
|
+
}) => HvccBox;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseHvcc = void 0;
|
|
4
|
+
const make_hvc1_codec_strings_1 = require("../../../make-hvc1-codec-strings");
|
|
5
|
+
const parseHvcc = ({ data, size, offset, }) => {
|
|
6
|
+
const raw = data.getSlice(size - 8);
|
|
7
|
+
data.counter.decrement(size - 8);
|
|
8
|
+
const constraintString = (0, make_hvc1_codec_strings_1.getHvc1CodecString)(data);
|
|
9
|
+
const remaining = size - (data.counter.getOffset() - offset);
|
|
10
|
+
data.discard(remaining);
|
|
11
|
+
return {
|
|
12
|
+
type: 'hvcc-box',
|
|
13
|
+
data: raw,
|
|
14
|
+
configurationString: constraintString,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.parseHvcc = parseHvcc;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
2
|
import type { AnySegment } from '../../../parse-result';
|
|
3
|
+
import type { ParserContext } from '../../../parser-context';
|
|
3
4
|
import type { BaseBox } from '../base-type';
|
|
4
5
|
export interface MebxBox extends BaseBox {
|
|
5
6
|
type: 'mebx-box';
|
|
@@ -7,8 +8,9 @@ export interface MebxBox extends BaseBox {
|
|
|
7
8
|
format: string;
|
|
8
9
|
children: AnySegment[];
|
|
9
10
|
}
|
|
10
|
-
export declare const parseMebx: ({ iterator, offset, size, }: {
|
|
11
|
+
export declare const parseMebx: ({ iterator, offset, size, options, }: {
|
|
11
12
|
iterator: BufferIterator;
|
|
12
13
|
offset: number;
|
|
13
14
|
size: number;
|
|
14
|
-
|
|
15
|
+
options: ParserContext;
|
|
16
|
+
}) => Promise<MebxBox>;
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMebx = void 0;
|
|
4
4
|
const process_box_1 = require("../process-box");
|
|
5
|
-
const parseMebx = ({ iterator, offset, size, }) => {
|
|
5
|
+
const parseMebx = async ({ iterator, offset, size, options, }) => {
|
|
6
6
|
// reserved, 6 bit
|
|
7
7
|
iterator.discard(6);
|
|
8
8
|
const dataReferenceIndex = iterator.getUint16();
|
|
9
|
-
const children = (0, process_box_1.parseBoxes)({
|
|
9
|
+
const children = await (0, process_box_1.parseBoxes)({
|
|
10
10
|
iterator,
|
|
11
11
|
maxBytes: iterator.counter.getOffset() - offset,
|
|
12
12
|
allowIncompleteBoxes: false,
|
|
13
13
|
initialBoxes: [],
|
|
14
|
+
options,
|
|
15
|
+
continueMdat: false,
|
|
14
16
|
});
|
|
15
17
|
if (children.status === 'incomplete') {
|
|
16
18
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { BaseBox } from '../base-type';
|
|
3
|
+
export interface PaspBox extends BaseBox {
|
|
4
|
+
type: 'pasp-box';
|
|
5
|
+
hSpacing: number;
|
|
6
|
+
vSpacing: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const parsePasp: ({ iterator, offset, size, }: {
|
|
9
|
+
iterator: BufferIterator;
|
|
10
|
+
offset: number;
|
|
11
|
+
size: number;
|
|
12
|
+
}) => PaspBox;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePasp = void 0;
|
|
4
|
+
const parsePasp = ({ iterator, offset, size, }) => {
|
|
5
|
+
const hSpacing = iterator.getUint32();
|
|
6
|
+
const vSpacing = iterator.getUint32();
|
|
7
|
+
const bytesRemainingInBox = size - (iterator.counter.getOffset() - offset);
|
|
8
|
+
iterator.discard(bytesRemainingInBox);
|
|
9
|
+
return {
|
|
10
|
+
type: 'pasp-box',
|
|
11
|
+
boxSize: size,
|
|
12
|
+
offset,
|
|
13
|
+
hSpacing,
|
|
14
|
+
vSpacing,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.parsePasp = parsePasp;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
2
|
import type { AnySegment } from '../../../parse-result';
|
|
3
|
+
import type { ParserContext } from '../../../parser-context';
|
|
3
4
|
type SampleBase = {
|
|
4
5
|
format: string;
|
|
5
6
|
offset: number;
|
|
@@ -9,7 +10,7 @@ type SampleBase = {
|
|
|
9
10
|
vendor: number[];
|
|
10
11
|
size: number;
|
|
11
12
|
};
|
|
12
|
-
type AudioSample = SampleBase & {
|
|
13
|
+
export type AudioSample = SampleBase & {
|
|
13
14
|
type: 'audio';
|
|
14
15
|
numberOfChannels: number;
|
|
15
16
|
sampleSize: number;
|
|
@@ -22,7 +23,7 @@ type AudioSample = SampleBase & {
|
|
|
22
23
|
bitsPerSample: number | null;
|
|
23
24
|
children: AnySegment[];
|
|
24
25
|
};
|
|
25
|
-
type VideoSample = SampleBase & {
|
|
26
|
+
export type VideoSample = SampleBase & {
|
|
26
27
|
type: 'video';
|
|
27
28
|
temporalQuality: number;
|
|
28
29
|
spacialQuality: number;
|
|
@@ -35,6 +36,7 @@ type VideoSample = SampleBase & {
|
|
|
35
36
|
frameCountPerSample: number;
|
|
36
37
|
depth: number;
|
|
37
38
|
colorTableId: number;
|
|
39
|
+
descriptors: AnySegment[];
|
|
38
40
|
};
|
|
39
41
|
type UnknownSample = SampleBase & {
|
|
40
42
|
type: 'unknown';
|
|
@@ -43,8 +45,13 @@ export type Sample = AudioSample | VideoSample | UnknownSample;
|
|
|
43
45
|
type SampleAndNext = {
|
|
44
46
|
sample: Sample | null;
|
|
45
47
|
};
|
|
46
|
-
export declare const processSample: ({ iterator, }: {
|
|
48
|
+
export declare const processSample: ({ iterator, options, }: {
|
|
47
49
|
iterator: BufferIterator;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
options: ParserContext;
|
|
51
|
+
}) => Promise<SampleAndNext>;
|
|
52
|
+
export declare const parseSamples: ({ iterator, maxBytes, options, }: {
|
|
53
|
+
iterator: BufferIterator;
|
|
54
|
+
maxBytes: number;
|
|
55
|
+
options: ParserContext;
|
|
56
|
+
}) => Promise<Sample[]>;
|
|
50
57
|
export {};
|
|
@@ -32,6 +32,7 @@ const videoTags = [
|
|
|
32
32
|
'v210',
|
|
33
33
|
'hvc1',
|
|
34
34
|
'ap4h',
|
|
35
|
+
'av01',
|
|
35
36
|
];
|
|
36
37
|
// https://developer.apple.com/documentation/quicktime-file-format/sound_sample_descriptions
|
|
37
38
|
const audioTags = [
|
|
@@ -60,7 +61,7 @@ const audioTags = [
|
|
|
60
61
|
'mp4a',
|
|
61
62
|
'ac-3',
|
|
62
63
|
];
|
|
63
|
-
const processSample = ({ iterator, }) => {
|
|
64
|
+
const processSample = async ({ iterator, options, }) => {
|
|
64
65
|
const fileOffset = iterator.counter.getOffset();
|
|
65
66
|
const bytesRemaining = iterator.bytesRemaining();
|
|
66
67
|
const boxSize = iterator.getUint32();
|
|
@@ -98,13 +99,15 @@ const processSample = ({ iterator, }) => {
|
|
|
98
99
|
const sampleSize = iterator.getUint16();
|
|
99
100
|
const compressionId = iterator.getUint16();
|
|
100
101
|
const packetSize = iterator.getUint16();
|
|
101
|
-
const sampleRate = iterator.
|
|
102
|
+
const sampleRate = iterator.getFixedPointUnsigned1616Number();
|
|
102
103
|
const bytesRemainingInBox = boxSize - (iterator.counter.getOffset() - fileOffset);
|
|
103
|
-
const children = (0, process_box_1.parseBoxes)({
|
|
104
|
+
const children = await (0, process_box_1.parseBoxes)({
|
|
104
105
|
iterator,
|
|
105
106
|
allowIncompleteBoxes: false,
|
|
106
107
|
maxBytes: bytesRemainingInBox,
|
|
107
108
|
initialBoxes: [],
|
|
109
|
+
options,
|
|
110
|
+
continueMdat: false,
|
|
108
111
|
});
|
|
109
112
|
if (children.status === 'incomplete') {
|
|
110
113
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -137,17 +140,19 @@ const processSample = ({ iterator, }) => {
|
|
|
137
140
|
const sampleSize = iterator.getUint16();
|
|
138
141
|
const compressionId = iterator.getInt16();
|
|
139
142
|
const packetSize = iterator.getUint16();
|
|
140
|
-
const sampleRate = iterator.
|
|
143
|
+
const sampleRate = iterator.getFixedPointUnsigned1616Number();
|
|
141
144
|
const samplesPerPacket = iterator.getUint32();
|
|
142
145
|
const bytesPerPacket = iterator.getUint32();
|
|
143
146
|
const bytesPerFrame = iterator.getUint32();
|
|
144
147
|
const bytesPerSample = iterator.getUint32();
|
|
145
148
|
const bytesRemainingInBox = boxSize - (iterator.counter.getOffset() - fileOffset);
|
|
146
|
-
const children = (0, process_box_1.parseBoxes)({
|
|
149
|
+
const children = await (0, process_box_1.parseBoxes)({
|
|
147
150
|
iterator,
|
|
148
151
|
allowIncompleteBoxes: false,
|
|
149
152
|
maxBytes: bytesRemainingInBox,
|
|
150
153
|
initialBoxes: [],
|
|
154
|
+
options,
|
|
155
|
+
continueMdat: false,
|
|
151
156
|
});
|
|
152
157
|
if (children.status === 'incomplete') {
|
|
153
158
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -182,15 +187,25 @@ const processSample = ({ iterator, }) => {
|
|
|
182
187
|
const spacialQuality = iterator.getUint32();
|
|
183
188
|
const width = iterator.getUint16();
|
|
184
189
|
const height = iterator.getUint16();
|
|
185
|
-
const horizontalResolution = iterator.
|
|
186
|
-
const verticalResolution = iterator.
|
|
190
|
+
const horizontalResolution = iterator.getFixedPointUnsigned1616Number();
|
|
191
|
+
const verticalResolution = iterator.getFixedPointUnsigned1616Number();
|
|
187
192
|
const dataSize = iterator.getUint32();
|
|
188
193
|
const frameCountPerSample = iterator.getUint16();
|
|
189
194
|
const compressorName = iterator.getPascalString();
|
|
190
195
|
const depth = iterator.getUint16();
|
|
191
196
|
const colorTableId = iterator.getInt16();
|
|
192
197
|
const bytesRemainingInBox = boxSize - (iterator.counter.getOffset() - fileOffset);
|
|
193
|
-
|
|
198
|
+
const children = await (0, process_box_1.parseBoxes)({
|
|
199
|
+
iterator,
|
|
200
|
+
allowIncompleteBoxes: false,
|
|
201
|
+
maxBytes: bytesRemainingInBox,
|
|
202
|
+
initialBoxes: [],
|
|
203
|
+
options,
|
|
204
|
+
continueMdat: false,
|
|
205
|
+
});
|
|
206
|
+
if (children.status === 'incomplete') {
|
|
207
|
+
throw new Error('Incomplete boxes are not allowed');
|
|
208
|
+
}
|
|
194
209
|
return {
|
|
195
210
|
sample: {
|
|
196
211
|
format: boxFormat,
|
|
@@ -212,19 +227,21 @@ const processSample = ({ iterator, }) => {
|
|
|
212
227
|
compressorName,
|
|
213
228
|
depth,
|
|
214
229
|
colorTableId,
|
|
230
|
+
descriptors: children.segments,
|
|
215
231
|
},
|
|
216
232
|
};
|
|
217
233
|
}
|
|
218
234
|
throw new Error(`Unknown sample format ${boxFormat}`);
|
|
219
235
|
};
|
|
220
236
|
exports.processSample = processSample;
|
|
221
|
-
const parseSamples = (iterator, maxBytes) => {
|
|
237
|
+
const parseSamples = async ({ iterator, maxBytes, options, }) => {
|
|
222
238
|
const samples = [];
|
|
223
239
|
const initialOffset = iterator.counter.getOffset();
|
|
224
240
|
while (iterator.bytesRemaining() > 0 &&
|
|
225
241
|
iterator.counter.getOffset() - initialOffset < maxBytes) {
|
|
226
|
-
const { sample } = (0, exports.processSample)({
|
|
242
|
+
const { sample } = await (0, exports.processSample)({
|
|
227
243
|
iterator,
|
|
244
|
+
options,
|
|
228
245
|
});
|
|
229
246
|
if (sample) {
|
|
230
247
|
samples.push(sample);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { ParserContext } from '../../../parser-context';
|
|
2
3
|
import type { BaseBox } from '../base-type';
|
|
3
4
|
import type { Sample } from './samples';
|
|
4
5
|
export interface StsdBox extends BaseBox {
|
|
@@ -6,8 +7,9 @@ export interface StsdBox extends BaseBox {
|
|
|
6
7
|
numberOfEntries: number;
|
|
7
8
|
samples: Sample[];
|
|
8
9
|
}
|
|
9
|
-
export declare const parseStsd: ({ iterator, offset, size, }: {
|
|
10
|
+
export declare const parseStsd: ({ iterator, offset, size, options, }: {
|
|
10
11
|
iterator: BufferIterator;
|
|
11
12
|
offset: number;
|
|
12
13
|
size: number;
|
|
13
|
-
|
|
14
|
+
options: ParserContext;
|
|
15
|
+
}) => Promise<StsdBox>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseStsd = void 0;
|
|
4
4
|
const samples_1 = require("./samples");
|
|
5
|
-
const parseStsd = ({ iterator, offset, size, }) => {
|
|
5
|
+
const parseStsd = async ({ iterator, offset, size, options, }) => {
|
|
6
6
|
const version = iterator.getUint8();
|
|
7
7
|
if (version !== 0) {
|
|
8
8
|
throw new Error(`Unsupported STSD version ${version}`);
|
|
@@ -11,7 +11,11 @@ const parseStsd = ({ iterator, offset, size, }) => {
|
|
|
11
11
|
iterator.discard(3);
|
|
12
12
|
const numberOfEntries = iterator.getUint32();
|
|
13
13
|
const bytesRemainingInBox = size - (iterator.counter.getOffset() - offset);
|
|
14
|
-
const boxes = (0, samples_1.parseSamples)(
|
|
14
|
+
const boxes = await (0, samples_1.parseSamples)({
|
|
15
|
+
iterator,
|
|
16
|
+
maxBytes: bytesRemainingInBox,
|
|
17
|
+
options,
|
|
18
|
+
});
|
|
15
19
|
if (boxes.length !== numberOfEntries) {
|
|
16
20
|
throw new Error(`Expected ${numberOfEntries} sample descriptions, got ${boxes.length}`);
|
|
17
21
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { BaseBox } from '../base-type';
|
|
3
|
+
export interface StssBox extends BaseBox {
|
|
4
|
+
type: 'stss-box';
|
|
5
|
+
version: number;
|
|
6
|
+
flags: number[];
|
|
7
|
+
sampleNumber: number[];
|
|
8
|
+
}
|
|
9
|
+
export declare const parseStss: ({ iterator, offset, boxSize, }: {
|
|
10
|
+
iterator: BufferIterator;
|
|
11
|
+
offset: number;
|
|
12
|
+
boxSize: number;
|
|
13
|
+
}) => StssBox;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStss = void 0;
|
|
4
|
+
const parseStss = ({ iterator, offset, boxSize, }) => {
|
|
5
|
+
const version = iterator.getUint8();
|
|
6
|
+
if (version !== 0) {
|
|
7
|
+
throw new Error(`Unsupported STSS version ${version}`);
|
|
8
|
+
}
|
|
9
|
+
const flags = iterator.getSlice(3);
|
|
10
|
+
const sampleCount = iterator.getUint32();
|
|
11
|
+
const sampleNumber = [];
|
|
12
|
+
for (let i = 0; i < sampleCount; i++) {
|
|
13
|
+
sampleNumber.push(iterator.getUint32());
|
|
14
|
+
}
|
|
15
|
+
const bytesRemainingInBox = boxSize - (iterator.counter.getOffset() - offset);
|
|
16
|
+
if (bytesRemainingInBox > 0) {
|
|
17
|
+
throw new Error(`Unexpected bytes remaining in box stss`);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
type: 'stss-box',
|
|
21
|
+
version,
|
|
22
|
+
flags: [...flags],
|
|
23
|
+
sampleNumber,
|
|
24
|
+
boxSize,
|
|
25
|
+
offset,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.parseStss = parseStss;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
2
|
import type { BaseBox } from '../base-type';
|
|
3
|
+
type Discriminated = {
|
|
4
|
+
countType: 'fixed';
|
|
5
|
+
sampleSize: number;
|
|
6
|
+
} | {
|
|
7
|
+
countType: 'variable';
|
|
8
|
+
entries: number[];
|
|
9
|
+
};
|
|
3
10
|
export type StszBox = BaseBox & {
|
|
4
11
|
type: 'stsz-box';
|
|
5
12
|
version: number;
|
|
6
13
|
flags: number[];
|
|
7
|
-
sampleSize: number;
|
|
8
14
|
sampleCount: number;
|
|
9
|
-
|
|
10
|
-
};
|
|
15
|
+
} & Discriminated;
|
|
11
16
|
export declare const parseStsz: ({ iterator, offset, size, }: {
|
|
12
17
|
iterator: BufferIterator;
|
|
13
18
|
offset: number;
|
|
14
19
|
size: number;
|
|
15
20
|
}) => StszBox;
|
|
21
|
+
export {};
|
|
@@ -9,6 +9,18 @@ const parseStsz = ({ iterator, offset, size, }) => {
|
|
|
9
9
|
const flags = iterator.getSlice(3);
|
|
10
10
|
const sampleSize = iterator.getUint32();
|
|
11
11
|
const sampleCount = iterator.getUint32();
|
|
12
|
+
if (sampleSize !== 0) {
|
|
13
|
+
return {
|
|
14
|
+
type: 'stsz-box',
|
|
15
|
+
boxSize: size,
|
|
16
|
+
offset,
|
|
17
|
+
version,
|
|
18
|
+
flags: [...flags],
|
|
19
|
+
sampleCount,
|
|
20
|
+
countType: 'fixed',
|
|
21
|
+
sampleSize,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
12
24
|
const samples = [];
|
|
13
25
|
for (let i = 0; i < sampleCount; i++) {
|
|
14
26
|
const bytesRemaining = size - (iterator.counter.getOffset() - offset);
|
|
@@ -24,9 +36,9 @@ const parseStsz = ({ iterator, offset, size, }) => {
|
|
|
24
36
|
offset,
|
|
25
37
|
version,
|
|
26
38
|
flags: [...flags],
|
|
27
|
-
sampleSize,
|
|
28
39
|
sampleCount,
|
|
29
|
-
|
|
40
|
+
countType: 'variable',
|
|
41
|
+
entries: samples,
|
|
30
42
|
};
|
|
31
43
|
};
|
|
32
44
|
exports.parseStsz = parseStsz;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
export interface SttsBox {
|
|
3
|
+
type: 'stts-box';
|
|
4
|
+
sampleDistribution: SampleDistribution[];
|
|
5
|
+
}
|
|
6
|
+
type SampleDistribution = {
|
|
7
|
+
sampleCount: number;
|
|
8
|
+
sampleDelta: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const parseStts: ({ data, size, fileOffset, }: {
|
|
11
|
+
data: BufferIterator;
|
|
12
|
+
size: number;
|
|
13
|
+
fileOffset: number;
|
|
14
|
+
}) => SttsBox;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStts = void 0;
|
|
4
|
+
const parseStts = ({ data, size, fileOffset, }) => {
|
|
5
|
+
const initialOffset = data.counter.getOffset();
|
|
6
|
+
const initialCounter = initialOffset - fileOffset;
|
|
7
|
+
const version = data.getUint8();
|
|
8
|
+
if (version !== 0) {
|
|
9
|
+
throw new Error(`Unsupported STTS version ${version}`);
|
|
10
|
+
}
|
|
11
|
+
// flags, we discard them
|
|
12
|
+
data.discard(3);
|
|
13
|
+
// entry count
|
|
14
|
+
const entryCount = data.getUint32();
|
|
15
|
+
const sampleDistributions = [];
|
|
16
|
+
// entries
|
|
17
|
+
for (let i = 0; i < entryCount; i++) {
|
|
18
|
+
const sampleCount = data.getUint32();
|
|
19
|
+
const sampleDelta = data.getUint32();
|
|
20
|
+
const sampleDistribution = {
|
|
21
|
+
sampleCount,
|
|
22
|
+
sampleDelta,
|
|
23
|
+
};
|
|
24
|
+
sampleDistributions.push(sampleDistribution);
|
|
25
|
+
}
|
|
26
|
+
const bytesUsed = data.counter.getOffset() - initialOffset + initialCounter;
|
|
27
|
+
if (bytesUsed !== size) {
|
|
28
|
+
throw new Error(`Expected stts box to be ${size} bytes, but was ${bytesUsed} bytes`);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
type: 'stts-box',
|
|
32
|
+
sampleDistribution: sampleDistributions,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.parseStts = parseStts;
|
|
@@ -14,6 +14,9 @@ export interface TkhdBox extends BaseBox {
|
|
|
14
14
|
matrix: ThreeDMatrix;
|
|
15
15
|
width: number;
|
|
16
16
|
height: number;
|
|
17
|
+
unrotatedWidth: number;
|
|
18
|
+
unrotatedHeight: number;
|
|
19
|
+
rotation: number;
|
|
17
20
|
}
|
|
18
21
|
export declare const parseTkhd: ({ iterator, offset, size, }: {
|
|
19
22
|
iterator: BufferIterator;
|
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseTkhd = void 0;
|
|
4
4
|
const to_date_1 = require("./to-date");
|
|
5
|
+
function getRotationAngleFromMatrix(matrix) {
|
|
6
|
+
// Extract elements from the matrix
|
|
7
|
+
const [a, b, c, d] = matrix;
|
|
8
|
+
// Check if the matrix is a valid rotation matrix
|
|
9
|
+
if (Math.round(a * a + b * b) !== 1 || Math.round(c * c + d * d) !== 1) {
|
|
10
|
+
throw new Error('The provided matrix is not a valid rotation matrix.');
|
|
11
|
+
}
|
|
12
|
+
// Calculate the angle using the atan2 function
|
|
13
|
+
const angleRadians = Math.atan2(c, a); // atan2(sin(θ), cos(θ))
|
|
14
|
+
const angleDegrees = angleRadians * (180 / Math.PI); // Convert radians to degrees
|
|
15
|
+
return angleDegrees;
|
|
16
|
+
}
|
|
17
|
+
const applyRotation = ({ matrix, width, height, }) => {
|
|
18
|
+
const newWidth = matrix[0] * width + matrix[1] * height; // 0*3840 + 1*2160
|
|
19
|
+
const newHeight = matrix[2] * width + matrix[3] * height; // -1*3840 + 0*2160
|
|
20
|
+
return {
|
|
21
|
+
width: Math.abs(newWidth),
|
|
22
|
+
height: Math.abs(newHeight),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
5
25
|
const parseTkhd = ({ iterator, offset, size, }) => {
|
|
6
26
|
if (size !== 92) {
|
|
7
27
|
throw new Error(`Expected tkhd size of version 0 to be 92, got ${size}`);
|
|
@@ -28,21 +48,25 @@ const parseTkhd = ({ iterator, offset, size, }) => {
|
|
|
28
48
|
// reserved 4
|
|
29
49
|
iterator.discard(2);
|
|
30
50
|
const matrix = [
|
|
31
|
-
iterator.
|
|
32
|
-
iterator.
|
|
33
|
-
iterator.
|
|
34
|
-
iterator.
|
|
35
|
-
iterator.
|
|
36
|
-
iterator.
|
|
37
|
-
iterator.
|
|
38
|
-
iterator.
|
|
39
|
-
iterator.
|
|
51
|
+
iterator.getFixedPointSigned1616Number(),
|
|
52
|
+
iterator.getFixedPointSigned1616Number(),
|
|
53
|
+
iterator.getFixedPointSigned230Number(),
|
|
54
|
+
iterator.getFixedPointSigned1616Number(),
|
|
55
|
+
iterator.getFixedPointSigned1616Number(),
|
|
56
|
+
iterator.getFixedPointSigned230Number(),
|
|
57
|
+
iterator.getFixedPointSigned1616Number(),
|
|
58
|
+
iterator.getFixedPointSigned1616Number(),
|
|
59
|
+
iterator.getFixedPointSigned230Number(),
|
|
40
60
|
];
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const width
|
|
45
|
-
|
|
61
|
+
const rotationMatrix = [matrix[0], matrix[1], matrix[3], matrix[4]];
|
|
62
|
+
const widthWithoutRotationApplied = iterator.getFixedPointUnsigned1616Number();
|
|
63
|
+
const heightWithoutRotationApplied = iterator.getFixedPointSigned1616Number();
|
|
64
|
+
const { width, height } = applyRotation({
|
|
65
|
+
matrix: rotationMatrix,
|
|
66
|
+
width: widthWithoutRotationApplied,
|
|
67
|
+
height: heightWithoutRotationApplied,
|
|
68
|
+
});
|
|
69
|
+
const rotation = getRotationAngleFromMatrix(rotationMatrix);
|
|
46
70
|
return {
|
|
47
71
|
offset,
|
|
48
72
|
boxSize: size,
|
|
@@ -58,6 +82,9 @@ const parseTkhd = ({ iterator, offset, size, }) => {
|
|
|
58
82
|
width,
|
|
59
83
|
height,
|
|
60
84
|
version,
|
|
85
|
+
rotation,
|
|
86
|
+
unrotatedWidth: widthWithoutRotationApplied,
|
|
87
|
+
unrotatedHeight: heightWithoutRotationApplied,
|
|
61
88
|
};
|
|
62
89
|
};
|
|
63
90
|
exports.parseTkhd = parseTkhd;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
2
|
import type { AnySegment } from '../../../parse-result';
|
|
3
|
+
import type { ParserContext } from '../../../parser-context';
|
|
3
4
|
import type { BaseBox } from '../base-type';
|
|
4
5
|
export interface TrakBox extends BaseBox {
|
|
5
6
|
type: 'trak-box';
|
|
6
7
|
children: AnySegment[];
|
|
7
8
|
}
|
|
8
|
-
export declare const parseTrak: ({ data, size, offsetAtStart, }: {
|
|
9
|
+
export declare const parseTrak: ({ data, size, offsetAtStart, options, }: {
|
|
9
10
|
data: BufferIterator;
|
|
10
11
|
size: number;
|
|
11
12
|
offsetAtStart: number;
|
|
12
|
-
|
|
13
|
+
options: ParserContext;
|
|
14
|
+
}) => Promise<TrakBox>;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseTrak = void 0;
|
|
4
4
|
const process_box_1 = require("../process-box");
|
|
5
|
-
const parseTrak = ({ data, size, offsetAtStart, }) => {
|
|
6
|
-
const children = (0, process_box_1.parseBoxes)({
|
|
5
|
+
const parseTrak = async ({ data, size, offsetAtStart, options, }) => {
|
|
6
|
+
const children = await (0, process_box_1.parseBoxes)({
|
|
7
7
|
iterator: data,
|
|
8
8
|
maxBytes: size - (data.counter.getOffset() - offsetAtStart),
|
|
9
9
|
allowIncompleteBoxes: false,
|
|
10
10
|
initialBoxes: [],
|
|
11
|
+
options,
|
|
12
|
+
continueMdat: false,
|
|
11
13
|
});
|
|
12
14
|
if (children.status === 'incomplete') {
|
|
13
15
|
throw new Error('Incomplete boxes are not allowed');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const allowedPartialSegments: string[];
|