@remotion/media-parser 4.0.209 → 4.0.211
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/buffer.js +2 -0
- package/dist/boxes/iso-base-media/get-sample-positions-from-track.js +1 -1
- package/dist/boxes/iso-base-media/make-track.js +14 -2
- package/dist/boxes/iso-base-media/mdat/mdat.d.ts +13 -4
- package/dist/boxes/iso-base-media/mdat/mdat.js +20 -5
- package/dist/boxes/iso-base-media/moov/moov.d.ts +2 -1
- package/dist/boxes/iso-base-media/moov/moov.js +2 -1
- package/dist/boxes/iso-base-media/process-box.d.ts +6 -3
- package/dist/boxes/iso-base-media/process-box.js +66 -12
- package/dist/boxes/iso-base-media/stsd/avcc.d.ts +1 -1
- package/dist/boxes/iso-base-media/stsd/avcc.js +2 -2
- package/dist/boxes/iso-base-media/stsd/ctts.js +2 -5
- package/dist/boxes/iso-base-media/stsd/hvcc.d.ts +1 -1
- package/dist/boxes/iso-base-media/stsd/hvcc.js +2 -2
- package/dist/boxes/iso-base-media/stsd/mebx.d.ts +2 -1
- package/dist/boxes/iso-base-media/stsd/mebx.js +2 -1
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +4 -2
- package/dist/boxes/iso-base-media/stsd/samples.js +69 -11
- package/dist/boxes/iso-base-media/stsd/stsd.d.ts +2 -1
- package/dist/boxes/iso-base-media/stsd/stsd.js +2 -1
- package/dist/boxes/iso-base-media/trak/trak.d.ts +2 -1
- package/dist/boxes/iso-base-media/trak/trak.js +2 -1
- package/dist/boxes/iso-base-media/traversal.d.ts +39 -0
- package/dist/boxes/iso-base-media/traversal.js +201 -0
- package/dist/boxes/webm/color.d.ts +4 -0
- package/dist/boxes/webm/color.js +127 -0
- package/dist/boxes/webm/description.js +1 -1
- package/dist/boxes/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/get-ready-tracks.js +3 -3
- package/dist/boxes/webm/get-sample-from-block.js +1 -1
- package/dist/boxes/webm/make-track.d.ts +9 -0
- package/dist/boxes/webm/make-track.js +260 -0
- package/dist/boxes/webm/parse-ebml.js +2 -2
- package/dist/boxes/webm/segments/all-segments.d.ts +36 -3
- package/dist/boxes/webm/segments/all-segments.js +34 -6
- package/dist/boxes/webm/segments/parse-children.js +6 -0
- package/dist/boxes/webm/traversal.d.ts +26 -1
- package/dist/boxes/webm/traversal.js +214 -1
- package/dist/buffer-iterator.d.ts +4 -1
- package/dist/buffer-iterator.js +31 -5
- package/dist/create/cluster-segment.js +0 -2
- package/dist/create/cluster.d.ts +16 -2
- package/dist/create/cluster.js +17 -10
- package/dist/create/create-media.d.ts +4 -2
- package/dist/create/create-media.js +101 -22
- package/dist/create/make-duration-with-padding.d.ts +1 -1
- package/dist/create/make-duration-with-padding.js +3 -3
- package/dist/create/matroska-cues.d.ts +6 -0
- package/dist/create/matroska-cues.js +49 -0
- package/dist/create/matroska-info.js +1 -1
- package/dist/create/matroska-seek.d.ts +6 -0
- package/dist/create/matroska-seek.js +32 -0
- package/dist/create/matroska-segment.d.ts +1 -0
- package/dist/create/matroska-segment.js +3 -2
- package/dist/create/matroska-trackentry.d.ts +9 -14
- package/dist/create/matroska-trackentry.js +79 -102
- package/dist/emit-available-info.d.ts +12 -0
- package/dist/emit-available-info.js +133 -0
- package/dist/esm/buffer.mjs +57 -0
- package/dist/esm/from-fetch.mjs +107 -0
- package/dist/esm/from-node.mjs +49 -0
- package/dist/esm/from-web-file.mjs +49 -0
- package/dist/esm/index.mjs +6822 -0
- package/dist/esm/web-fs.mjs +67 -0
- package/dist/get-audio-codec.d.ts +5 -5
- package/dist/get-audio-codec.js +44 -57
- package/dist/get-container.d.ts +4 -0
- package/dist/get-container.js +26 -0
- package/dist/get-duration.js +1 -1
- package/dist/get-fps.js +1 -1
- package/dist/get-sample-aspect-ratio.d.ts +1 -1
- package/dist/get-sample-aspect-ratio.js +19 -19
- package/dist/get-tracks.d.ts +13 -0
- package/dist/get-tracks.js +8 -8
- package/dist/get-video-codec.d.ts +5 -2
- package/dist/get-video-codec.js +111 -21
- package/dist/has-all-info.d.ts +2 -2
- package/dist/has-all-info.js +23 -9
- package/dist/index.d.ts +4 -1
- package/dist/options.d.ts +97 -30
- package/dist/parse-media.js +59 -69
- package/dist/parse-video.d.ts +2 -1
- package/dist/parse-video.js +3 -1
- package/dist/parser-context.d.ts +1 -0
- package/dist/parser-state.js +1 -2
- package/dist/readers/from-fetch.d.ts +12 -0
- package/dist/readers/from-fetch.js +83 -17
- package/dist/readers/from-node.js +14 -3
- package/dist/readers/from-web-file.js +15 -2
- package/dist/readers/reader.d.ts +7 -1
- package/dist/samples-from-moof.js +1 -1
- package/dist/truthy.d.ts +3 -0
- package/dist/truthy.js +7 -0
- package/dist/writers/buffer.d.ts +2 -0
- package/dist/writers/buffer.js +58 -0
- package/dist/writers/web-fs.d.ts +1 -0
- package/dist/writers/web-fs.js +42 -18
- package/dist/writers/writer.d.ts +4 -2
- package/fetch.js +2 -0
- package/node.js +2 -0
- package/package.json +43 -8
- package/web-file.js +2 -0
- package/web-fs.js +2 -0
- package/.eslintrc +0 -8
- package/dist/av1-codec-string.d.ts +0 -3
- package/dist/av1-codec-string.js +0 -91
- package/dist/boxes/iso-base-media/ftype.d.ts +0 -9
- package/dist/boxes/iso-base-media/ftype.js +0 -31
- package/dist/boxes/iso-base-media/stsd/avcc-hvcc.d.ts +0 -20
- package/dist/boxes/iso-base-media/stsd/avcc-hvcc.js +0 -73
- package/dist/boxes/iso-base-media/stts/stts.d.ts +0 -15
- package/dist/boxes/iso-base-media/stts/stts.js +0 -35
- package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.d.ts +0 -14
- package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.js +0 -67
- package/dist/boxes/webm/bitstream/av1/bitstream-frame.d.ts +0 -11
- package/dist/boxes/webm/bitstream/av1/bitstream-frame.js +0 -14
- package/dist/boxes/webm/bitstream/av1/chroma-sample-position.d.ts +0 -6
- package/dist/boxes/webm/bitstream/av1/chroma-sample-position.js +0 -9
- package/dist/boxes/webm/bitstream/av1/color-config.d.ts +0 -16
- package/dist/boxes/webm/bitstream/av1/color-config.js +0 -103
- package/dist/boxes/webm/bitstream/av1/color-primaries.d.ts +0 -14
- package/dist/boxes/webm/bitstream/av1/color-primaries.js +0 -17
- package/dist/boxes/webm/bitstream/av1/decoder-model-info.d.ts +0 -9
- package/dist/boxes/webm/bitstream/av1/decoder-model-info.js +0 -17
- package/dist/boxes/webm/bitstream/av1/frame.d.ts +0 -0
- package/dist/boxes/webm/bitstream/av1/frame.js +0 -1
- package/dist/boxes/webm/bitstream/av1/header-segment.d.ts +0 -51
- package/dist/boxes/webm/bitstream/av1/header-segment.js +0 -183
- package/dist/boxes/webm/bitstream/av1/matrix-coefficients.d.ts +0 -17
- package/dist/boxes/webm/bitstream/av1/matrix-coefficients.js +0 -20
- package/dist/boxes/webm/bitstream/av1/operating-parameters-info.d.ts +0 -10
- package/dist/boxes/webm/bitstream/av1/operating-parameters-info.js +0 -15
- package/dist/boxes/webm/bitstream/av1/temporal-point-info.d.ts +0 -5
- package/dist/boxes/webm/bitstream/av1/temporal-point-info.js +0 -8
- package/dist/boxes/webm/bitstream/av1/timing-info.d.ts +0 -8
- package/dist/boxes/webm/bitstream/av1/timing-info.js +0 -20
- package/dist/boxes/webm/bitstream/av1/transfer-characteristics.d.ts +0 -21
- package/dist/boxes/webm/bitstream/av1/transfer-characteristics.js +0 -24
- package/dist/boxes/webm/bitstream/av1/uvlc.d.ts +0 -2
- package/dist/boxes/webm/bitstream/av1/uvlc.js +0 -20
- package/dist/boxes/webm/bitstream/av1.d.ts +0 -20
- package/dist/boxes/webm/bitstream/av1.js +0 -118
- package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.d.ts +0 -0
- package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.js +0 -1
- package/dist/boxes/webm/segments/duration.d.ts +0 -6
- package/dist/boxes/webm/segments/duration.js +0 -19
- package/dist/boxes/webm/segments/info.d.ts +0 -9
- package/dist/boxes/webm/segments/info.js +0 -22
- package/dist/boxes/webm/segments/main.d.ts +0 -5
- package/dist/boxes/webm/segments/main.js +0 -2
- package/dist/boxes/webm/segments/muxing.d.ts +0 -6
- package/dist/boxes/webm/segments/muxing.js +0 -11
- package/dist/boxes/webm/segments/seek-head.d.ts +0 -9
- package/dist/boxes/webm/segments/seek-head.js +0 -22
- package/dist/boxes/webm/segments/seek-position.d.ts +0 -6
- package/dist/boxes/webm/segments/seek-position.js +0 -11
- package/dist/boxes/webm/segments/seek.d.ts +0 -13
- package/dist/boxes/webm/segments/seek.js +0 -35
- package/dist/boxes/webm/segments/timestamp-scale.d.ts +0 -6
- package/dist/boxes/webm/segments/timestamp-scale.js +0 -11
- package/dist/boxes/webm/segments/tracks.d.ts +0 -8
- package/dist/boxes/webm/segments/tracks.js +0 -21
- package/dist/boxes/webm/segments/unknown.d.ts +0 -6
- package/dist/boxes/webm/segments/unknown.js +0 -11
- package/dist/boxes/webm/segments/void.d.ts +0 -6
- package/dist/boxes/webm/segments/void.js +0 -11
- package/dist/boxes/webm/segments/writing.d.ts +0 -6
- package/dist/boxes/webm/segments/writing.js +0 -11
- package/dist/boxes/webm/tracks.d.ts +0 -8
- package/dist/boxes/webm/tracks.js +0 -21
- package/dist/combine-uint8array.d.ts +0 -1
- package/dist/combine-uint8array.js +0 -13
- package/dist/from-web.d.ts +0 -2
- package/dist/from-web.js +0 -45
- package/dist/get-video-metadata.d.ts +0 -2
- package/dist/get-video-metadata.js +0 -44
- package/dist/read-and-increment-offset.d.ts +0 -28
- package/dist/read-and-increment-offset.js +0 -177
- package/dist/understand-vorbis.d.ts +0 -1
- package/dist/understand-vorbis.js +0 -12
- package/input.webm +0 -0
- package/src/add-new-matroska-tracks.ts +0 -23
- package/src/boxes/iso-base-media/base-type.ts +0 -4
- package/src/boxes/iso-base-media/esds/decoder-specific-config.ts +0 -68
- package/src/boxes/iso-base-media/esds/esds-descriptors.ts +0 -135
- package/src/boxes/iso-base-media/esds/esds.ts +0 -49
- package/src/boxes/iso-base-media/ftyp.ts +0 -39
- package/src/boxes/iso-base-media/get-sample-positions-from-track.ts +0 -69
- package/src/boxes/iso-base-media/make-track.ts +0 -116
- package/src/boxes/iso-base-media/mdat/mdat.ts +0 -140
- package/src/boxes/iso-base-media/mdhd.ts +0 -59
- package/src/boxes/iso-base-media/moov/moov.ts +0 -43
- package/src/boxes/iso-base-media/mvhd.ts +0 -114
- package/src/boxes/iso-base-media/process-box.ts +0 -748
- package/src/boxes/iso-base-media/stsd/av1c.ts +0 -19
- package/src/boxes/iso-base-media/stsd/avcc.ts +0 -36
- package/src/boxes/iso-base-media/stsd/colr.ts +0 -49
- package/src/boxes/iso-base-media/stsd/ctts.ts +0 -64
- package/src/boxes/iso-base-media/stsd/hvcc.ts +0 -32
- package/src/boxes/iso-base-media/stsd/keys.ts +0 -27
- package/src/boxes/iso-base-media/stsd/mebx.ts +0 -54
- package/src/boxes/iso-base-media/stsd/pasp.ts +0 -32
- package/src/boxes/iso-base-media/stsd/samples.ts +0 -359
- package/src/boxes/iso-base-media/stsd/stco.ts +0 -52
- package/src/boxes/iso-base-media/stsd/stsc.ts +0 -61
- package/src/boxes/iso-base-media/stsd/stsd.ts +0 -55
- package/src/boxes/iso-base-media/stsd/stss.ts +0 -47
- package/src/boxes/iso-base-media/stsd/stsz.ts +0 -75
- package/src/boxes/iso-base-media/stsd/stts.ts +0 -62
- package/src/boxes/iso-base-media/tfdt.ts +0 -37
- package/src/boxes/iso-base-media/tfhd.ts +0 -66
- package/src/boxes/iso-base-media/tkhd.ts +0 -150
- package/src/boxes/iso-base-media/to-date.ts +0 -9
- package/src/boxes/iso-base-media/trak/trak.ts +0 -43
- package/src/boxes/iso-base-media/trun.ts +0 -74
- package/src/boxes/iso-base-media/void-box.ts +0 -4
- package/src/boxes/webm/allowed-partial-segments.ts +0 -1
- package/src/boxes/webm/av1-codec-private.ts +0 -113
- package/src/boxes/webm/description.ts +0 -104
- package/src/boxes/webm/ebml.ts +0 -98
- package/src/boxes/webm/get-ready-tracks.ts +0 -36
- package/src/boxes/webm/get-sample-from-block.ts +0 -125
- package/src/boxes/webm/get-track.ts +0 -257
- package/src/boxes/webm/make-header.ts +0 -253
- package/src/boxes/webm/parse-ebml.ts +0 -259
- package/src/boxes/webm/parse-webm-header.ts +0 -18
- package/src/boxes/webm/segments/all-segments.ts +0 -888
- package/src/boxes/webm/segments/block-simple-block-flags.ts +0 -52
- package/src/boxes/webm/segments/parse-children.ts +0 -144
- package/src/boxes/webm/segments/track-entry.ts +0 -38
- package/src/boxes/webm/segments.ts +0 -147
- package/src/boxes/webm/traversal.ts +0 -45
- package/src/buffer-iterator.ts +0 -555
- package/src/create/cluster-segment.ts +0 -62
- package/src/create/cluster.ts +0 -64
- package/src/create/create-media.ts +0 -136
- package/src/create/make-duration-with-padding.ts +0 -15
- package/src/create/matroska-header.ts +0 -63
- package/src/create/matroska-info.ts +0 -30
- package/src/create/matroska-segment.ts +0 -10
- package/src/create/matroska-trackentry.ts +0 -325
- package/src/create/timescale.ts +0 -1
- package/src/get-audio-codec.ts +0 -270
- package/src/get-dimensions.ts +0 -47
- package/src/get-duration.ts +0 -103
- package/src/get-fps.ts +0 -113
- package/src/get-sample-aspect-ratio.ts +0 -204
- package/src/get-sample-positions.ts +0 -93
- package/src/get-tracks.ts +0 -147
- package/src/get-video-codec.ts +0 -117
- package/src/has-all-info.ts +0 -81
- package/src/index.ts +0 -18
- package/src/make-hvc1-codec-strings.ts +0 -55
- package/src/options.ts +0 -118
- package/src/parse-media.ts +0 -183
- package/src/parse-result.ts +0 -79
- package/src/parse-video.ts +0 -83
- package/src/parser-context.ts +0 -10
- package/src/parser-state.ts +0 -178
- package/src/readers/from-fetch.ts +0 -90
- package/src/readers/from-node.ts +0 -51
- package/src/readers/from-web-file.ts +0 -49
- package/src/readers/reader.ts +0 -15
- package/src/samples-from-moof.ts +0 -102
- package/src/test/aspect-ratio.test.ts +0 -42
- package/src/test/av1.test.ts +0 -108
- package/src/test/create-matroska.test.ts +0 -287
- package/src/test/duration.test.ts +0 -18
- package/src/test/keys.test.ts +0 -47
- package/src/test/matroska.test.ts +0 -463
- package/src/test/mvhd.test.ts +0 -94
- package/src/test/parse-esds.test.ts +0 -98
- package/src/test/parse-stco.test.ts +0 -61
- package/src/test/parse-stsc.test.ts +0 -104
- package/src/test/parse-stsz.test.ts +0 -57
- package/src/test/parse-stts.test.ts +0 -38
- package/src/test/parse-video.test.ts +0 -101
- package/src/test/parse-webm.test.ts +0 -17
- package/src/test/samples-from-moof.test.ts +0 -2496
- package/src/test/stream-local.test.ts +0 -743
- package/src/test/stream-remote.test.ts +0 -59
- package/src/test/stream-samples.test.ts +0 -181
- package/src/test/stsd.test.ts +0 -265
- package/src/test/tkhd.test.ts +0 -87
- package/src/traversal.ts +0 -528
- package/src/webcodec-sample-types.ts +0 -29
- package/src/writers/web-fs.ts +0 -50
- package/src/writers/writer.ts +0 -12
- package/tsconfig.json +0 -14
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare class OffsetCounter {
|
|
2
|
-
#private;
|
|
3
|
-
constructor(initial: number);
|
|
4
|
-
increment(amount: number): void;
|
|
5
|
-
getOffset(): number;
|
|
6
|
-
}
|
|
7
|
-
export declare const getArrayBufferIterator: (data: ArrayBuffer, initialOffset: number) => {
|
|
8
|
-
view: DataView;
|
|
9
|
-
counter: OffsetCounter;
|
|
10
|
-
data: ArrayBuffer;
|
|
11
|
-
discard: (length: number) => void;
|
|
12
|
-
getSlice: (amount: number) => ArrayBuffer;
|
|
13
|
-
getAtom: () => string;
|
|
14
|
-
getMatroskaSegmentId: () => string;
|
|
15
|
-
getVint: (bytes: number) => number;
|
|
16
|
-
getUint8: () => number;
|
|
17
|
-
getEBML: () => number;
|
|
18
|
-
getInt8: () => number;
|
|
19
|
-
getUint16: () => number;
|
|
20
|
-
getInt16: () => number;
|
|
21
|
-
getUint32: () => number;
|
|
22
|
-
getFixedPoint1616Number: () => number;
|
|
23
|
-
getPascalString: () => number[];
|
|
24
|
-
getDecimalBytes(length: number): number;
|
|
25
|
-
getByteString(length: number): string;
|
|
26
|
-
getFloat64: () => number;
|
|
27
|
-
};
|
|
28
|
-
export type BufferIterator = ReturnType<typeof getArrayBufferIterator>;
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _OffsetCounter_offset;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getArrayBufferIterator = exports.OffsetCounter = void 0;
|
|
16
|
-
class OffsetCounter {
|
|
17
|
-
constructor(initial) {
|
|
18
|
-
_OffsetCounter_offset.set(this, void 0);
|
|
19
|
-
__classPrivateFieldSet(this, _OffsetCounter_offset, initial, "f");
|
|
20
|
-
}
|
|
21
|
-
increment(amount) {
|
|
22
|
-
if (amount < 0) {
|
|
23
|
-
throw new Error('Cannot increment by a negative amount');
|
|
24
|
-
}
|
|
25
|
-
__classPrivateFieldSet(this, _OffsetCounter_offset, __classPrivateFieldGet(this, _OffsetCounter_offset, "f") + amount, "f");
|
|
26
|
-
}
|
|
27
|
-
getOffset() {
|
|
28
|
-
return __classPrivateFieldGet(this, _OffsetCounter_offset, "f");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.OffsetCounter = OffsetCounter;
|
|
32
|
-
_OffsetCounter_offset = new WeakMap();
|
|
33
|
-
const makeOffsetCounter = (initial) => {
|
|
34
|
-
return new OffsetCounter(initial);
|
|
35
|
-
};
|
|
36
|
-
const getArrayBufferIterator = (data, initialOffset) => {
|
|
37
|
-
const view = new DataView(data);
|
|
38
|
-
const counter = makeOffsetCounter(initialOffset);
|
|
39
|
-
const getSlice = (amount) => {
|
|
40
|
-
const value = data.slice(counter.getOffset(), counter.getOffset() + amount);
|
|
41
|
-
counter.increment(amount);
|
|
42
|
-
return value;
|
|
43
|
-
};
|
|
44
|
-
const getUint8 = () => {
|
|
45
|
-
const val = view.getUint8(counter.getOffset());
|
|
46
|
-
counter.increment(1);
|
|
47
|
-
return val;
|
|
48
|
-
};
|
|
49
|
-
const getUint32 = () => {
|
|
50
|
-
const val = view.getUint32(counter.getOffset());
|
|
51
|
-
counter.increment(4);
|
|
52
|
-
return val;
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
view,
|
|
56
|
-
counter,
|
|
57
|
-
data,
|
|
58
|
-
discard: (length) => {
|
|
59
|
-
counter.increment(length);
|
|
60
|
-
},
|
|
61
|
-
getSlice,
|
|
62
|
-
getAtom: () => {
|
|
63
|
-
const atom = getSlice(4);
|
|
64
|
-
return new TextDecoder().decode(atom);
|
|
65
|
-
},
|
|
66
|
-
getMatroskaSegmentId: () => {
|
|
67
|
-
const first = getSlice(1);
|
|
68
|
-
const firstOneString = `0x${Array.from(new Uint8Array(first))
|
|
69
|
-
.map((b) => {
|
|
70
|
-
return b.toString(16).padStart(2, '0');
|
|
71
|
-
})
|
|
72
|
-
.join('')}`;
|
|
73
|
-
// Catch void block
|
|
74
|
-
const knownIdsWithOneLength = ['0xec', '0xae'];
|
|
75
|
-
if (knownIdsWithOneLength.includes(firstOneString)) {
|
|
76
|
-
return firstOneString;
|
|
77
|
-
}
|
|
78
|
-
const firstTwo = getSlice(1);
|
|
79
|
-
const knownIdsWithTwoLength = ['0x4dbb', '0x53ac', '0xec01'];
|
|
80
|
-
const firstTwoString = `${firstOneString}${Array.from(new Uint8Array(firstTwo))
|
|
81
|
-
.map((b) => {
|
|
82
|
-
return b.toString(16).padStart(2, '0');
|
|
83
|
-
})
|
|
84
|
-
.join('')}`;
|
|
85
|
-
if (knownIdsWithTwoLength.includes(firstTwoString)) {
|
|
86
|
-
return firstTwoString;
|
|
87
|
-
}
|
|
88
|
-
const knownIdsWithThreeLength = ['0x4d808c', '0x57418c', '0x448988'];
|
|
89
|
-
const firstThree = getSlice(1);
|
|
90
|
-
const firstThreeString = `${firstTwoString}${Array.from(new Uint8Array(firstThree))
|
|
91
|
-
.map((b) => {
|
|
92
|
-
return b.toString(16).padStart(2, '0');
|
|
93
|
-
})
|
|
94
|
-
.join('')}`;
|
|
95
|
-
if (knownIdsWithThreeLength.includes(firstThreeString)) {
|
|
96
|
-
return firstThreeString;
|
|
97
|
-
}
|
|
98
|
-
const segmentId = getSlice(1);
|
|
99
|
-
return `${firstThreeString}${Array.from(new Uint8Array(segmentId))
|
|
100
|
-
.map((b) => {
|
|
101
|
-
return b.toString(16).padStart(2, '0');
|
|
102
|
-
})
|
|
103
|
-
.join('')}`;
|
|
104
|
-
},
|
|
105
|
-
getVint: (bytes) => {
|
|
106
|
-
const slice = getSlice(bytes);
|
|
107
|
-
const d = [...Array.from(new Uint8Array(slice))];
|
|
108
|
-
const totalLength = d[0];
|
|
109
|
-
if (totalLength === 0) {
|
|
110
|
-
return 0;
|
|
111
|
-
}
|
|
112
|
-
// Calculate the actual length of the data based on the first set bit
|
|
113
|
-
let actualLength = 0;
|
|
114
|
-
while (((totalLength >> (7 - actualLength)) & 0x01) === 0) {
|
|
115
|
-
actualLength++;
|
|
116
|
-
}
|
|
117
|
-
actualLength += 1; // Include the first byte set as 1
|
|
118
|
-
// Combine the numbers to form the integer value
|
|
119
|
-
let value = 0;
|
|
120
|
-
// Mask the first byte properly then start combining
|
|
121
|
-
value = totalLength & (0xff >> actualLength);
|
|
122
|
-
for (let i = 1; i < actualLength; i++) {
|
|
123
|
-
value = (value << 8) | d[i];
|
|
124
|
-
}
|
|
125
|
-
return value;
|
|
126
|
-
},
|
|
127
|
-
getUint8,
|
|
128
|
-
getEBML: () => {
|
|
129
|
-
const val = getUint8();
|
|
130
|
-
// https://darkcoding.net/software/reading-mediarecorders-webm-opus-output/#:~:text=The%20first%20four%20bytes%20(%201A,%E2%80%93%20read%20on%20for%20why).
|
|
131
|
-
// You drop the initial 0 bits and the first 1 bit to get the value. 0x81 is 0b10000001, so there are zero inital 0 bits, meaning length one byte, and the value is 1. The 0x9F value for length of the EBML header we saw earlier is 0b10011111, still one byte, value is 0b0011111, which is 31 (the python repl is very helpful for these conversions).
|
|
132
|
-
const actualValue = val & 0x7f; // 0x7F is binary 01111111, which masks out the first bit
|
|
133
|
-
return actualValue;
|
|
134
|
-
},
|
|
135
|
-
getInt8: () => {
|
|
136
|
-
const val = view.getInt8(counter.getOffset());
|
|
137
|
-
counter.increment(1);
|
|
138
|
-
return val;
|
|
139
|
-
},
|
|
140
|
-
getUint16: () => {
|
|
141
|
-
const val = view.getUint16(counter.getOffset());
|
|
142
|
-
counter.increment(2);
|
|
143
|
-
return val;
|
|
144
|
-
},
|
|
145
|
-
getInt16: () => {
|
|
146
|
-
const val = view.getInt16(counter.getOffset());
|
|
147
|
-
counter.increment(2);
|
|
148
|
-
return val;
|
|
149
|
-
},
|
|
150
|
-
getUint32,
|
|
151
|
-
// https://developer.apple.com/documentation/quicktime-file-format/sound_sample_description_version_1
|
|
152
|
-
// A 32-bit unsigned fixed-point number (16.16) that indicates the rate at which the sound samples were obtained.
|
|
153
|
-
getFixedPoint1616Number: () => {
|
|
154
|
-
const val = getUint32();
|
|
155
|
-
return val / 2 ** 16;
|
|
156
|
-
},
|
|
157
|
-
getPascalString: () => {
|
|
158
|
-
const val = getSlice(32);
|
|
159
|
-
return [...Array.from(new Uint8Array(val))];
|
|
160
|
-
},
|
|
161
|
-
getDecimalBytes(length) {
|
|
162
|
-
const bytes = getSlice(length);
|
|
163
|
-
const numbers = [...Array.from(new Uint8Array(bytes))];
|
|
164
|
-
return numbers.reduce((acc, byte, index) => acc + (byte << (8 * (numbers.length - index - 1))), 0);
|
|
165
|
-
},
|
|
166
|
-
getByteString(length) {
|
|
167
|
-
const bytes = getSlice(length);
|
|
168
|
-
return new TextDecoder().decode(bytes);
|
|
169
|
-
},
|
|
170
|
-
getFloat64: () => {
|
|
171
|
-
const val = view.getFloat64(counter.getOffset());
|
|
172
|
-
counter.increment(8);
|
|
173
|
-
return val;
|
|
174
|
-
},
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
exports.getArrayBufferIterator = getArrayBufferIterator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare const understand: (src: string) => Promise<void>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const understand = async (src) => {
|
|
3
|
-
const content = await Bun.file(src).arrayBuffer();
|
|
4
|
-
const firstBit = new DataView(content).getUint8(0);
|
|
5
|
-
const offset = new DataView(content).getUint8(1);
|
|
6
|
-
const offset2 = new DataView(content).getUint8(2);
|
|
7
|
-
const globalOffset = firstBit + 1;
|
|
8
|
-
const header = new TextDecoder().decode(content.slice(globalOffset, globalOffset + offset));
|
|
9
|
-
const comment = new TextDecoder().decode(content.slice(globalOffset + offset, globalOffset + offset2));
|
|
10
|
-
const rest = new TextDecoder().decode(content.slice(globalOffset + offset2 + offset, globalOffset + offset2 + offset + 50));
|
|
11
|
-
console.log({ firstBit, offset, offset2, header, comment, rest });
|
|
12
|
-
};
|
package/input.webm
DELETED
|
Binary file
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type {Track} from './get-tracks';
|
|
2
|
-
import type {ParserContext} from './parser-context';
|
|
3
|
-
import type {ParserState} from './parser-state';
|
|
4
|
-
|
|
5
|
-
export const registerTrack = async ({
|
|
6
|
-
state,
|
|
7
|
-
options,
|
|
8
|
-
track,
|
|
9
|
-
}: {
|
|
10
|
-
state: ParserState;
|
|
11
|
-
options: ParserContext;
|
|
12
|
-
track: Track;
|
|
13
|
-
}) => {
|
|
14
|
-
if (track.type === 'video' && options.onVideoTrack) {
|
|
15
|
-
const callback = await options.onVideoTrack(track);
|
|
16
|
-
await state.registerVideoSampleCallback(track.trackId, callback ?? null);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (track.type === 'audio' && options.onAudioTrack) {
|
|
20
|
-
const callback = await options.onAudioTrack(track);
|
|
21
|
-
await state.registerAudioSampleCallback(track.trackId, callback ?? null);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
|
|
3
|
-
type UnknownDecoderSpecificConfig = {
|
|
4
|
-
type: 'unknown-decoder-specific-config';
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
type AudioSpecificConfig = {
|
|
8
|
-
type: 'audio-specific-config';
|
|
9
|
-
audioObjectType: number;
|
|
10
|
-
samplingFrequencyIndex: number;
|
|
11
|
-
channelConfiguration: number;
|
|
12
|
-
asBytes: Uint8Array;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type DecoderSpecificConfig =
|
|
16
|
-
| UnknownDecoderSpecificConfig
|
|
17
|
-
| AudioSpecificConfig;
|
|
18
|
-
|
|
19
|
-
export const parseDecoderSpecificConfig = (
|
|
20
|
-
iterator: BufferIterator,
|
|
21
|
-
): DecoderSpecificConfig => {
|
|
22
|
-
const layerTag = iterator.getUint8();
|
|
23
|
-
const layerSize = iterator.getPaddedFourByteNumber();
|
|
24
|
-
|
|
25
|
-
const start = iterator.counter.getOffset();
|
|
26
|
-
|
|
27
|
-
if (layerTag !== 5) {
|
|
28
|
-
iterator.discard(layerSize);
|
|
29
|
-
return {
|
|
30
|
-
type: 'unknown-decoder-specific-config',
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// https://csclub.uwaterloo.ca/~pbarfuss/ISO14496-3-2009.pdf
|
|
35
|
-
// 1.6.2.1 AudioSpecificConfig
|
|
36
|
-
|
|
37
|
-
const bytes = iterator.getSlice(layerSize);
|
|
38
|
-
iterator.counter.decrement(layerSize);
|
|
39
|
-
|
|
40
|
-
iterator.startReadingBits();
|
|
41
|
-
const audioObjectType = iterator.getBits(5);
|
|
42
|
-
const samplingFrequencyIndex = iterator.getBits(4);
|
|
43
|
-
if (samplingFrequencyIndex === 0xf) {
|
|
44
|
-
iterator.getBits(24);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const channelConfiguration = iterator.getBits(4);
|
|
48
|
-
iterator.stopReadingBits();
|
|
49
|
-
const read = iterator.counter.getOffset() - start;
|
|
50
|
-
if (read < layerSize) {
|
|
51
|
-
iterator.discard(layerSize - read);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Working around Chrome bug
|
|
55
|
-
// https://issues.chromium.org/issues/360083330#comment5
|
|
56
|
-
const patchedAsBytes =
|
|
57
|
-
bytes.byteLength === 2 && bytes[0] === 17 && bytes[1] === 136
|
|
58
|
-
? new Uint8Array([17, 144])
|
|
59
|
-
: bytes;
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
type: 'audio-specific-config',
|
|
63
|
-
audioObjectType,
|
|
64
|
-
samplingFrequencyIndex,
|
|
65
|
-
channelConfiguration,
|
|
66
|
-
asBytes: patchedAsBytes,
|
|
67
|
-
};
|
|
68
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-constant-condition */
|
|
2
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
3
|
-
import type {DecoderSpecificConfig} from './decoder-specific-config';
|
|
4
|
-
import {parseDecoderSpecificConfig} from './decoder-specific-config';
|
|
5
|
-
|
|
6
|
-
type AudioObjectType = 'aac' | 'mp3' | 'unknown';
|
|
7
|
-
|
|
8
|
-
type DecoderConfigDescriptor = {
|
|
9
|
-
type: 'decoder-config-descriptor';
|
|
10
|
-
objectTypeIndication: AudioObjectType;
|
|
11
|
-
asNumber: number;
|
|
12
|
-
streamType: number;
|
|
13
|
-
upStream: number;
|
|
14
|
-
bufferSizeDB: number;
|
|
15
|
-
maxBitrate: number;
|
|
16
|
-
avgBitrate: number;
|
|
17
|
-
decoderSpecificConfigs: DecoderSpecificConfig[];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const mapToObjectAudioIndicator = (num: number): AudioObjectType => {
|
|
21
|
-
// https://chromium.googlesource.com/chromium/src/media/+/master/formats/mp4/es_descriptor.h
|
|
22
|
-
// http://netmedia.zju.edu.cn/multimedia2013/mpeg-4/ISO%20IEC%2014496-1%20MPEG-4%20System%20Standard.pdf
|
|
23
|
-
// Page 42, table 8
|
|
24
|
-
if (num === 0x40) {
|
|
25
|
-
return 'aac';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (num === 0x6b) {
|
|
29
|
-
return 'mp3';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return 'unknown';
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
type SlConfigDescriptor = {
|
|
36
|
-
type: 'sl-config-descriptor';
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
type UnknownDescriptor = {
|
|
40
|
-
type: 'unknown-descriptor';
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type Descriptor =
|
|
44
|
-
| DecoderConfigDescriptor
|
|
45
|
-
| SlConfigDescriptor
|
|
46
|
-
| UnknownDescriptor;
|
|
47
|
-
|
|
48
|
-
type DescriptorAndNext = {
|
|
49
|
-
descriptor: Descriptor | null;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const processDescriptor = ({
|
|
53
|
-
iterator,
|
|
54
|
-
}: {
|
|
55
|
-
iterator: BufferIterator;
|
|
56
|
-
}): DescriptorAndNext => {
|
|
57
|
-
const tag = iterator.getUint8();
|
|
58
|
-
|
|
59
|
-
if (tag === 4) {
|
|
60
|
-
const size = iterator.getPaddedFourByteNumber();
|
|
61
|
-
const initialOffset = iterator.counter.getOffset();
|
|
62
|
-
|
|
63
|
-
const objectTypeIndication = iterator.getUint8();
|
|
64
|
-
iterator.startReadingBits();
|
|
65
|
-
const streamType = iterator.getBits(6);
|
|
66
|
-
const upStream = iterator.getBits(1);
|
|
67
|
-
// reserved
|
|
68
|
-
iterator.getBits(1);
|
|
69
|
-
const bufferSizeDB = iterator.getBits(24);
|
|
70
|
-
iterator.stopReadingBits();
|
|
71
|
-
const maxBitrate = iterator.getUint32();
|
|
72
|
-
const avgBitrate = iterator.getUint32();
|
|
73
|
-
|
|
74
|
-
const decoderSpecificConfigs: DecoderSpecificConfig[] = [];
|
|
75
|
-
|
|
76
|
-
while (size - (iterator.counter.getOffset() - initialOffset) >= 0) {
|
|
77
|
-
const decoderSpecificConfig = parseDecoderSpecificConfig(iterator);
|
|
78
|
-
decoderSpecificConfigs.push(decoderSpecificConfig);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
descriptor: {
|
|
83
|
-
type: 'decoder-config-descriptor',
|
|
84
|
-
objectTypeIndication: mapToObjectAudioIndicator(objectTypeIndication),
|
|
85
|
-
asNumber: objectTypeIndication,
|
|
86
|
-
bufferSizeDB,
|
|
87
|
-
streamType,
|
|
88
|
-
upStream,
|
|
89
|
-
avgBitrate,
|
|
90
|
-
maxBitrate,
|
|
91
|
-
decoderSpecificConfigs,
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (tag === 6) {
|
|
97
|
-
const size = iterator.getPaddedFourByteNumber();
|
|
98
|
-
|
|
99
|
-
iterator.discard(size);
|
|
100
|
-
return {
|
|
101
|
-
descriptor: {
|
|
102
|
-
type: 'sl-config-descriptor',
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
descriptor: null,
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const parseDescriptors = (
|
|
113
|
-
iterator: BufferIterator,
|
|
114
|
-
maxBytes: number,
|
|
115
|
-
): Descriptor[] => {
|
|
116
|
-
const descriptors: Descriptor[] = [];
|
|
117
|
-
const initialOffset = iterator.counter.getOffset();
|
|
118
|
-
|
|
119
|
-
while (
|
|
120
|
-
iterator.bytesRemaining() > 0 &&
|
|
121
|
-
iterator.counter.getOffset() - initialOffset < maxBytes
|
|
122
|
-
) {
|
|
123
|
-
const {descriptor} = processDescriptor({
|
|
124
|
-
iterator,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
if (descriptor) {
|
|
128
|
-
descriptors.push(descriptor);
|
|
129
|
-
} else {
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return descriptors;
|
|
135
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
import type {Descriptor} from './esds-descriptors';
|
|
3
|
-
import {parseDescriptors} from './esds-descriptors';
|
|
4
|
-
|
|
5
|
-
export interface EsdsBox {
|
|
6
|
-
type: 'esds-box';
|
|
7
|
-
version: number;
|
|
8
|
-
tag: number;
|
|
9
|
-
sizeOfInstance: number;
|
|
10
|
-
esId: number;
|
|
11
|
-
descriptors: Descriptor[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const parseEsds = ({
|
|
15
|
-
data,
|
|
16
|
-
size,
|
|
17
|
-
fileOffset,
|
|
18
|
-
}: {
|
|
19
|
-
data: BufferIterator;
|
|
20
|
-
size: number;
|
|
21
|
-
fileOffset: number;
|
|
22
|
-
}): EsdsBox => {
|
|
23
|
-
const version = data.getUint8();
|
|
24
|
-
// Flags, we discard them
|
|
25
|
-
data.discard(3);
|
|
26
|
-
const tag = data.getUint8();
|
|
27
|
-
|
|
28
|
-
const sizeOfInstance = data.getPaddedFourByteNumber();
|
|
29
|
-
const esId = data.getUint16();
|
|
30
|
-
|
|
31
|
-
// disard 1 byte, currently unknown
|
|
32
|
-
data.discard(1);
|
|
33
|
-
|
|
34
|
-
const remaining = size - (data.counter.getOffset() - fileOffset);
|
|
35
|
-
const descriptors = parseDescriptors(data, remaining);
|
|
36
|
-
|
|
37
|
-
const remainingNow = size - (data.counter.getOffset() - fileOffset);
|
|
38
|
-
|
|
39
|
-
data.discard(remainingNow);
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
type: 'esds-box',
|
|
43
|
-
version,
|
|
44
|
-
tag,
|
|
45
|
-
sizeOfInstance,
|
|
46
|
-
esId,
|
|
47
|
-
descriptors,
|
|
48
|
-
};
|
|
49
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../buffer-iterator';
|
|
2
|
-
import type {BaseBox} from './base-type';
|
|
3
|
-
|
|
4
|
-
export interface FtypBox extends BaseBox {
|
|
5
|
-
type: 'ftyp-box';
|
|
6
|
-
majorBrand: string;
|
|
7
|
-
minorVersion: number;
|
|
8
|
-
compatibleBrands: string[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const parseFtyp = ({
|
|
12
|
-
iterator,
|
|
13
|
-
size,
|
|
14
|
-
offset,
|
|
15
|
-
}: {
|
|
16
|
-
iterator: BufferIterator;
|
|
17
|
-
size: number;
|
|
18
|
-
offset: number;
|
|
19
|
-
}): FtypBox => {
|
|
20
|
-
const majorBrand = iterator.getByteString(4);
|
|
21
|
-
const minorVersion = iterator.getFourByteNumber();
|
|
22
|
-
|
|
23
|
-
const types = (size - iterator.counter.getOffset()) / 4;
|
|
24
|
-
const compatibleBrands: string[] = [];
|
|
25
|
-
for (let i = 0; i < types; i++) {
|
|
26
|
-
compatibleBrands.push(iterator.getByteString(4).trim());
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const offsetAtEnd = iterator.counter.getOffset();
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
type: 'ftyp-box',
|
|
33
|
-
majorBrand,
|
|
34
|
-
minorVersion,
|
|
35
|
-
compatibleBrands,
|
|
36
|
-
offset,
|
|
37
|
-
boxSize: offsetAtEnd - offset,
|
|
38
|
-
};
|
|
39
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {getTimescaleAndDuration} from '../../get-fps';
|
|
2
|
-
import type {SamplePosition} from '../../get-sample-positions';
|
|
3
|
-
import {getSamplePositions} from '../../get-sample-positions';
|
|
4
|
-
import type {IsoBaseMediaBox} from '../../parse-result';
|
|
5
|
-
import {getSamplesFromMoof} from '../../samples-from-moof';
|
|
6
|
-
import {
|
|
7
|
-
getCttsBox,
|
|
8
|
-
getStcoBox,
|
|
9
|
-
getStscBox,
|
|
10
|
-
getStssBox,
|
|
11
|
-
getStszBox,
|
|
12
|
-
getSttsBox,
|
|
13
|
-
getTkhdBox,
|
|
14
|
-
} from '../../traversal';
|
|
15
|
-
import type {TrakBox} from './trak/trak';
|
|
16
|
-
|
|
17
|
-
export const getSamplePositionsFromTrack = (
|
|
18
|
-
trakBox: TrakBox,
|
|
19
|
-
moofBox: IsoBaseMediaBox | null,
|
|
20
|
-
): SamplePosition[] => {
|
|
21
|
-
const stszBox = getStszBox(trakBox);
|
|
22
|
-
const stcoBox = getStcoBox(trakBox);
|
|
23
|
-
const stscBox = getStscBox(trakBox);
|
|
24
|
-
const stssBox = getStssBox(trakBox);
|
|
25
|
-
const sttsBox = getSttsBox(trakBox);
|
|
26
|
-
const tkhdBox = getTkhdBox(trakBox);
|
|
27
|
-
const cttsBox = getCttsBox(trakBox);
|
|
28
|
-
|
|
29
|
-
const timescaleAndDuration = getTimescaleAndDuration(trakBox);
|
|
30
|
-
|
|
31
|
-
if (!tkhdBox) {
|
|
32
|
-
throw new Error('Expected tkhd box in trak box');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!stszBox) {
|
|
36
|
-
throw new Error('Expected stsz box in trak box');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!stcoBox) {
|
|
40
|
-
throw new Error('Expected stco box in trak box');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!stscBox) {
|
|
44
|
-
throw new Error('Expected stsc box in trak box');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!sttsBox) {
|
|
48
|
-
throw new Error('Expected stts box in trak box');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!timescaleAndDuration) {
|
|
52
|
-
throw new Error('Expected timescale and duration in trak box');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let samplePositions = getSamplePositions({
|
|
56
|
-
stcoBox,
|
|
57
|
-
stscBox,
|
|
58
|
-
stszBox,
|
|
59
|
-
stssBox,
|
|
60
|
-
sttsBox,
|
|
61
|
-
cttsBox,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
if (samplePositions.length === 0 && moofBox) {
|
|
65
|
-
samplePositions = getSamplesFromMoof({moofBox, trackId: tkhdBox.trackId});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return samplePositions;
|
|
69
|
-
};
|