@remotion/media-parser 4.0.201 → 4.0.204
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/av1-codec-string.d.ts +0 -5
- package/dist/av1-codec-string.js +1 -18
- 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/get-sample-positions-from-track.d.ts +4 -0
- package/dist/boxes/iso-base-media/get-sample-positions-from-track.js +48 -0
- package/dist/boxes/iso-base-media/mvhd.js +2 -2
- package/dist/boxes/iso-base-media/stsd/keys.js +1 -1
- package/dist/boxes/iso-base-media/tfdt.d.ts +12 -0
- package/dist/boxes/iso-base-media/tfdt.js +20 -0
- package/dist/boxes/iso-base-media/tfhd.d.ts +16 -0
- package/dist/boxes/iso-base-media/tfhd.js +41 -0
- package/dist/boxes/iso-base-media/trun.d.ts +21 -0
- package/dist/boxes/iso-base-media/trun.js +44 -0
- package/dist/boxes/webm/av1-codec-private.js +1 -1
- package/dist/boxes/webm/bitstream/av1.js +1 -10
- package/dist/boxes/webm/description.d.ts +2 -2
- package/dist/boxes/webm/description.js +2 -2
- package/dist/boxes/webm/ebml.d.ts +2 -2
- package/dist/boxes/webm/ebml.js +23 -1
- package/dist/boxes/webm/get-ready-tracks.d.ts +1 -1
- package/dist/boxes/webm/get-ready-tracks.js +3 -3
- package/dist/boxes/webm/get-sample-from-block.d.ts +17 -0
- package/dist/boxes/webm/get-sample-from-block.js +78 -0
- package/dist/boxes/webm/get-track.d.ts +2 -2
- package/dist/boxes/webm/get-track.js +26 -25
- package/dist/boxes/webm/make-header.d.ts +3 -8
- package/dist/boxes/webm/make-header.js +43 -20
- package/dist/boxes/webm/parse-ebml.d.ts +9 -4
- package/dist/boxes/webm/parse-ebml.js +122 -13
- package/dist/boxes/webm/segments/all-segments.d.ts +421 -107
- package/dist/boxes/webm/segments/all-segments.js +260 -33
- package/dist/boxes/webm/segments/track-entry.d.ts +3 -191
- package/dist/boxes/webm/segments/track-entry.js +2 -456
- package/dist/boxes/webm/segments.d.ts +3 -16
- package/dist/boxes/webm/segments.js +12 -196
- package/dist/boxes/webm/tracks.d.ts +8 -0
- package/dist/boxes/webm/tracks.js +21 -0
- package/dist/boxes/webm/traversal.d.ts +5 -6
- package/dist/boxes/webm/traversal.js +6 -6
- package/dist/buffer-iterator.d.ts +1 -1
- package/dist/buffer-iterator.js +3 -3
- package/dist/from-web.js +6 -15
- package/dist/get-audio-codec.d.ts +1 -1
- package/dist/get-audio-codec.js +13 -13
- package/dist/get-duration.js +12 -14
- package/dist/get-tracks.js +2 -2
- package/dist/get-video-codec.js +13 -13
- package/dist/get-video-metadata.d.ts +2 -0
- package/dist/get-video-metadata.js +44 -0
- package/dist/parse-media.js +4 -1
- package/dist/parser-context.d.ts +1 -0
- package/dist/parser-state.js +3 -2
- package/dist/read-and-increment-offset.d.ts +28 -0
- package/dist/read-and-increment-offset.js +177 -0
- package/dist/samples-from-moof.d.ts +6 -0
- package/dist/samples-from-moof.js +74 -0
- package/dist/traversal.d.ts +19 -17
- package/dist/traversal.js +38 -39
- package/dist/understand-vorbis.d.ts +1 -0
- package/dist/understand-vorbis.js +12 -0
- package/input.webm +0 -0
- package/package.json +2 -2
- package/src/boxes/iso-base-media/get-sample-positions-from-track.ts +69 -0
- package/src/boxes/iso-base-media/make-track.ts +4 -45
- package/src/boxes/iso-base-media/mdat/mdat.ts +33 -24
- package/src/boxes/iso-base-media/mdhd.ts +10 -7
- package/src/boxes/iso-base-media/mvhd.ts +17 -16
- package/src/boxes/iso-base-media/process-box.ts +42 -0
- package/src/boxes/iso-base-media/stsd/keys.ts +1 -1
- package/src/boxes/iso-base-media/tfdt.ts +37 -0
- package/src/boxes/iso-base-media/tfhd.ts +66 -0
- package/src/boxes/iso-base-media/tkhd.ts +11 -13
- package/src/boxes/iso-base-media/trun.ts +74 -0
- package/src/boxes/webm/av1-codec-private.ts +1 -1
- package/src/boxes/webm/description.ts +7 -4
- package/src/boxes/webm/ebml.ts +24 -4
- package/src/boxes/webm/get-ready-tracks.ts +4 -4
- package/src/boxes/webm/get-sample-from-block.ts +125 -0
- package/src/boxes/webm/get-track.ts +40 -33
- package/src/boxes/webm/make-header.ts +58 -51
- package/src/boxes/webm/parse-ebml.ts +170 -16
- package/src/boxes/webm/segments/all-segments.ts +379 -62
- package/src/boxes/webm/segments/track-entry.ts +3 -846
- package/src/boxes/webm/segments.ts +18 -410
- package/src/boxes/webm/traversal.ts +17 -17
- package/src/buffer-iterator.ts +8 -6
- package/src/get-audio-codec.ts +14 -16
- package/src/get-duration.ts +55 -21
- package/src/get-tracks.ts +6 -6
- package/src/get-video-codec.ts +13 -15
- package/src/has-all-info.ts +1 -1
- package/src/parse-media.ts +7 -2
- package/src/parse-result.ts +7 -1
- package/src/parser-context.ts +1 -0
- package/src/parser-state.ts +2 -2
- package/src/samples-from-moof.ts +101 -0
- package/src/test/create-matroska.test.ts +237 -23
- package/src/test/matroska.test.ts +283 -348
- package/src/test/mvhd.test.ts +1 -1
- package/src/test/parse-esds.test.ts +2 -2
- package/src/test/parse-stco.test.ts +2 -2
- package/src/test/parse-stsc.test.ts +2 -2
- package/src/test/parse-stsz.test.ts +2 -2
- package/src/test/parse-stts.test.ts +1 -1
- package/src/test/samples-from-moof.test.ts +2496 -0
- package/src/test/stream-local.test.ts +28 -30
- package/src/test/stream-samples.test.ts +153 -231
- package/src/test/stsd.test.ts +4 -2
- package/src/test/tkhd.test.ts +1 -1
- package/src/traversal.ts +118 -86
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/bitstream/av1.d.ts +0 -2
- package/dist/bitstream/av1.js +0 -12
- package/dist/boxes/iso-base-media/avcc-hvcc.d.ts +0 -20
- package/dist/boxes/iso-base-media/avcc-hvcc.js +0 -73
- package/dist/boxes/iso-base-media/avcc.d.ts +0 -18
- package/dist/boxes/iso-base-media/avcc.js +0 -27
- 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/from-input-type-file.d.ts +0 -2
- package/dist/from-input-type-file.js +0 -37
- package/dist/get-codec.d.ts +0 -4
- package/dist/get-codec.js +0 -22
- package/dist/web-file.d.ts +0 -2
- package/dist/web-file.js +0 -37
- package/src/boxes/webm/segments/duration.ts +0 -29
- package/src/boxes/webm/segments/info.ts +0 -34
- package/src/boxes/webm/segments/main.ts +0 -6
- package/src/boxes/webm/segments/muxing.ts +0 -18
- package/src/boxes/webm/segments/seek-head.ts +0 -34
- package/src/boxes/webm/segments/seek-position.ts +0 -18
- package/src/boxes/webm/segments/seek.ts +0 -55
- package/src/boxes/webm/segments/timestamp-scale.ts +0 -17
- package/src/boxes/webm/segments/tracks.ts +0 -32
- package/src/boxes/webm/segments/void.ts +0 -18
- package/src/boxes/webm/segments/writing.ts +0 -18
- package/src/combine-uint8array.ts +0 -13
- /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/dist/{sample-aspect-ratio.d.ts → boxes/webm/bitstream/h264/get-h264-descriptor.d.ts} +0 -0
- /package/dist/{sample-aspect-ratio.js → boxes/webm/bitstream/h264/get-h264-descriptor.js} +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseHvcc = exports.parseAvcc = void 0;
|
|
4
|
-
const parseAvcc = ({ data, size, }) => {
|
|
5
|
-
const confVersion = data.getUint8();
|
|
6
|
-
if (confVersion !== 1) {
|
|
7
|
-
throw new Error(`Unsupported AVCC version ${confVersion}`);
|
|
8
|
-
}
|
|
9
|
-
const profile = data.getUint8();
|
|
10
|
-
const profileCompatibility = data.getUint8();
|
|
11
|
-
const level = data.getUint8();
|
|
12
|
-
const str = `${profile.toString(16).padStart(2, '0')}${profileCompatibility.toString(16).padStart(2, '0')}${level.toString(16).padStart(2, '0')}`;
|
|
13
|
-
data.counter.decrement(4);
|
|
14
|
-
return {
|
|
15
|
-
type: 'avcc-box',
|
|
16
|
-
data: data.getSlice(size - 8),
|
|
17
|
-
configurationString: str,
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
exports.parseAvcc = parseAvcc;
|
|
21
|
-
const parseHvcc = ({ data, size, offset, }) => {
|
|
22
|
-
const raw = data.getSlice(size - 8);
|
|
23
|
-
data.counter.decrement(size - 8);
|
|
24
|
-
const configurationVersion = data.getUint8();
|
|
25
|
-
if (configurationVersion !== 1) {
|
|
26
|
-
throw new Error(`Unsupported HVCC version ${configurationVersion}`);
|
|
27
|
-
}
|
|
28
|
-
const generalProfileSpaceTierFlagAndIdc = data.getUint8();
|
|
29
|
-
let generalProfileCompatibility = data.getUint32();
|
|
30
|
-
// unsigned int(2) general_profile_space;
|
|
31
|
-
// unsigned int(1) general_tier_flag;
|
|
32
|
-
// unsigned int(5) general_profile_idc;
|
|
33
|
-
const generalProfileSpace = generalProfileSpaceTierFlagAndIdc >> 6;
|
|
34
|
-
const generalTierFlag = generalProfileSpaceTierFlagAndIdc >> 5;
|
|
35
|
-
const generalProfileIdc = generalProfileSpaceTierFlagAndIdc >> 0;
|
|
36
|
-
// general_constraint_indicator_flags(48)
|
|
37
|
-
const generalConstraintIndicator = data.getSlice(6);
|
|
38
|
-
const generalLevelIdc = data.getUint8();
|
|
39
|
-
let reversedGeneralProfileSpace = 0;
|
|
40
|
-
for (let i = 0; i < 32; i++) {
|
|
41
|
-
reversedGeneralProfileSpace |= generalProfileCompatibility & 1;
|
|
42
|
-
if (i === 31)
|
|
43
|
-
break;
|
|
44
|
-
reversedGeneralProfileSpace <<= 1;
|
|
45
|
-
generalProfileCompatibility >>= 1;
|
|
46
|
-
}
|
|
47
|
-
const profileSpaceChar = generalProfileSpace === 0
|
|
48
|
-
? ''
|
|
49
|
-
: generalProfileSpace === 1
|
|
50
|
-
? 'A'
|
|
51
|
-
: generalProfileSpace === 2
|
|
52
|
-
? 'B'
|
|
53
|
-
: 'C';
|
|
54
|
-
const generalTierChar = generalTierFlag === 0 ? 'L' : 'H';
|
|
55
|
-
let hasByte = false;
|
|
56
|
-
let generalConstraintString = '';
|
|
57
|
-
for (let i = 5; i >= 0; i--) {
|
|
58
|
-
if (generalConstraintIndicator[i] || hasByte) {
|
|
59
|
-
generalConstraintString =
|
|
60
|
-
generalConstraintIndicator[i].toString(16) + generalConstraintString;
|
|
61
|
-
hasByte = true;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const constraintString = `${profileSpaceChar}${generalProfileIdc.toString(16)}.${reversedGeneralProfileSpace.toString(16)}.${generalTierChar}${generalLevelIdc}.${generalConstraintString}`;
|
|
65
|
-
const remaining = size - (data.counter.getOffset() - offset);
|
|
66
|
-
data.discard(remaining);
|
|
67
|
-
return {
|
|
68
|
-
type: 'hvcc-box',
|
|
69
|
-
data: raw,
|
|
70
|
-
configurationString: constraintString,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
exports.parseHvcc = parseHvcc;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
export interface AvccBox {
|
|
3
|
-
type: 'avcc-box';
|
|
4
|
-
data: Uint8Array;
|
|
5
|
-
configurationString: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const parseAvcc: ({ data, size, }: {
|
|
8
|
-
data: BufferIterator;
|
|
9
|
-
size: number;
|
|
10
|
-
}) => AvccBox;
|
|
11
|
-
export interface HvccBox {
|
|
12
|
-
type: 'hvcc-box';
|
|
13
|
-
data: Uint8Array;
|
|
14
|
-
}
|
|
15
|
-
export declare const parseHvcc: ({ data, size, }: {
|
|
16
|
-
data: BufferIterator;
|
|
17
|
-
size: number;
|
|
18
|
-
}) => HvccBox;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseHvcc = exports.parseAvcc = void 0;
|
|
4
|
-
const parseAvcc = ({ data, size, }) => {
|
|
5
|
-
const confVersion = data.getUint8();
|
|
6
|
-
if (confVersion !== 1) {
|
|
7
|
-
throw new Error(`Unsupported AVCC version ${confVersion}`);
|
|
8
|
-
}
|
|
9
|
-
const profile = data.getUint8();
|
|
10
|
-
const profileCompatibility = data.getUint8();
|
|
11
|
-
const level = data.getUint8();
|
|
12
|
-
const str = `${profile.toString(16).padStart(2, '0')}${profileCompatibility.toString(16).padStart(2, '0')}${level.toString(16).padStart(2, '0')}`;
|
|
13
|
-
data.counter.decrement(4);
|
|
14
|
-
return {
|
|
15
|
-
type: 'avcc-box',
|
|
16
|
-
data: data.getSlice(size - 8),
|
|
17
|
-
configurationString: str,
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
exports.parseAvcc = parseAvcc;
|
|
21
|
-
const parseHvcc = ({ data, size, }) => {
|
|
22
|
-
return {
|
|
23
|
-
type: 'hvcc-box',
|
|
24
|
-
data: data.getSlice(size - 8),
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
exports.parseHvcc = parseHvcc;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
type AudioObjectType = 'aac' | 'mp3' | 'unknown';
|
|
3
|
-
type DecoderConfigDescriptor = {
|
|
4
|
-
type: 'decoder-config-descriptor';
|
|
5
|
-
objectTypeIndication: AudioObjectType;
|
|
6
|
-
};
|
|
7
|
-
type SlConfigDescriptor = {
|
|
8
|
-
type: 'sl-config-descriptor';
|
|
9
|
-
};
|
|
10
|
-
type UnknownDescriptor = {
|
|
11
|
-
type: 'unknown-descriptor';
|
|
12
|
-
};
|
|
13
|
-
export type Descriptor = DecoderConfigDescriptor | SlConfigDescriptor | UnknownDescriptor;
|
|
14
|
-
type DescriptorAndNext = {
|
|
15
|
-
descriptor: Descriptor | null;
|
|
16
|
-
};
|
|
17
|
-
export declare const processDescriptor: ({ iterator, }: {
|
|
18
|
-
iterator: BufferIterator;
|
|
19
|
-
}) => DescriptorAndNext;
|
|
20
|
-
export declare const parseDescriptors: (iterator: BufferIterator, maxBytes: number) => Descriptor[];
|
|
21
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseDescriptors = exports.processDescriptor = void 0;
|
|
4
|
-
const mapToObjectAudioIndicator = (num) => {
|
|
5
|
-
// https://chromium.googlesource.com/chromium/src/media/+/master/formats/mp4/es_descriptor.h
|
|
6
|
-
// http://netmedia.zju.edu.cn/multimedia2013/mpeg-4/ISO%20IEC%2014496-1%20MPEG-4%20System%20Standard.pdf
|
|
7
|
-
// Page 42, table 8
|
|
8
|
-
if (num === 0x40) {
|
|
9
|
-
return 'aac';
|
|
10
|
-
}
|
|
11
|
-
if (num === 0x6b) {
|
|
12
|
-
return 'mp3';
|
|
13
|
-
}
|
|
14
|
-
return 'unknown';
|
|
15
|
-
};
|
|
16
|
-
const processDescriptor = ({ iterator, }) => {
|
|
17
|
-
const tag = iterator.getUint8();
|
|
18
|
-
if (tag === 4) {
|
|
19
|
-
const size = iterator.getPaddedFourByteNumber();
|
|
20
|
-
const initialOffset = iterator.counter.getOffset();
|
|
21
|
-
const objectTypeIndication = iterator.getUint8();
|
|
22
|
-
const remaining = size - (iterator.counter.getOffset() - initialOffset);
|
|
23
|
-
iterator.discard(remaining);
|
|
24
|
-
return {
|
|
25
|
-
descriptor: {
|
|
26
|
-
type: 'decoder-config-descriptor',
|
|
27
|
-
objectTypeIndication: mapToObjectAudioIndicator(objectTypeIndication),
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (tag === 6) {
|
|
32
|
-
const size = iterator.getPaddedFourByteNumber();
|
|
33
|
-
iterator.discard(size);
|
|
34
|
-
return {
|
|
35
|
-
descriptor: {
|
|
36
|
-
type: 'sl-config-descriptor',
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
descriptor: null,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
exports.processDescriptor = processDescriptor;
|
|
45
|
-
const parseDescriptors = (iterator, maxBytes) => {
|
|
46
|
-
const descriptors = [];
|
|
47
|
-
const initialOffset = iterator.counter.getOffset();
|
|
48
|
-
while (iterator.bytesRemaining() > 0 &&
|
|
49
|
-
iterator.counter.getOffset() - initialOffset < maxBytes) {
|
|
50
|
-
const { descriptor } = (0, exports.processDescriptor)({
|
|
51
|
-
iterator,
|
|
52
|
-
});
|
|
53
|
-
if (descriptor) {
|
|
54
|
-
descriptors.push(descriptor);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return descriptors;
|
|
61
|
-
};
|
|
62
|
-
exports.parseDescriptors = parseDescriptors;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
import type { Descriptor } from './esds-descriptors';
|
|
3
|
-
export interface EsdsBox {
|
|
4
|
-
type: 'esds-box';
|
|
5
|
-
version: number;
|
|
6
|
-
tag: number;
|
|
7
|
-
sizeOfInstance: number;
|
|
8
|
-
esId: number;
|
|
9
|
-
descriptors: Descriptor[];
|
|
10
|
-
}
|
|
11
|
-
export declare const parseEsds: ({ data, size, fileOffset, }: {
|
|
12
|
-
data: BufferIterator;
|
|
13
|
-
size: number;
|
|
14
|
-
fileOffset: number;
|
|
15
|
-
}) => EsdsBox;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseEsds = void 0;
|
|
4
|
-
const esds_descriptors_1 = require("./esds-descriptors");
|
|
5
|
-
const parseEsds = ({ data, size, fileOffset, }) => {
|
|
6
|
-
const version = data.getUint8();
|
|
7
|
-
// Flags, we discard them
|
|
8
|
-
data.discard(3);
|
|
9
|
-
const tag = data.getUint8();
|
|
10
|
-
const sizeOfInstance = data.getPaddedFourByteNumber();
|
|
11
|
-
const esId = data.getUint16();
|
|
12
|
-
// disard 1 byte, currently unknown
|
|
13
|
-
data.discard(1);
|
|
14
|
-
const remaining = size - (data.counter.getOffset() - fileOffset);
|
|
15
|
-
const descriptors = (0, esds_descriptors_1.parseDescriptors)(data, remaining);
|
|
16
|
-
const remainingNow = size - (data.counter.getOffset() - fileOffset);
|
|
17
|
-
data.discard(remainingNow);
|
|
18
|
-
return {
|
|
19
|
-
type: 'esds-box',
|
|
20
|
-
version,
|
|
21
|
-
tag,
|
|
22
|
-
sizeOfInstance,
|
|
23
|
-
esId,
|
|
24
|
-
descriptors,
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
exports.parseEsds = parseEsds;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inputTypeFileReader = void 0;
|
|
4
|
-
exports.inputTypeFileReader = {
|
|
5
|
-
read: (file, range) => {
|
|
6
|
-
if (typeof file === 'string') {
|
|
7
|
-
throw new Error('`inputTypeFileReader` only supports `File` objects');
|
|
8
|
-
}
|
|
9
|
-
if (range !== null) {
|
|
10
|
-
throw new Error('`inputTypeFileReader` does not support `range`');
|
|
11
|
-
}
|
|
12
|
-
const part = range === null
|
|
13
|
-
? file
|
|
14
|
-
: typeof range === 'number'
|
|
15
|
-
? file.slice(range)
|
|
16
|
-
: file.slice(range[0], range[1]);
|
|
17
|
-
const reader = new FileReader();
|
|
18
|
-
reader.readAsArrayBuffer(file);
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
reader.onload = () => {
|
|
21
|
-
resolve({
|
|
22
|
-
reader: part.stream().getReader(),
|
|
23
|
-
contentLength: file.size,
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
reader.onerror = (error) => {
|
|
27
|
-
reject(error);
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
getLength: (src) => {
|
|
32
|
-
if (typeof src === 'string') {
|
|
33
|
-
throw new Error('`inputTypeFileReader` only supports `File` objects');
|
|
34
|
-
}
|
|
35
|
-
return Promise.resolve(src.size);
|
|
36
|
-
},
|
|
37
|
-
};
|
package/dist/get-codec.d.ts
DELETED
package/dist/get-codec.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVideoCodec = exports.hasVideoCodec = void 0;
|
|
4
|
-
const hasVideoCodec = (boxes) => {
|
|
5
|
-
try {
|
|
6
|
-
return boxes.some((b) => b.type === 'ftyp-box');
|
|
7
|
-
}
|
|
8
|
-
catch (err) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
exports.hasVideoCodec = hasVideoCodec;
|
|
13
|
-
const getVideoCodec = (boxes) => {
|
|
14
|
-
const ftypBox = boxes.find((b) => b.type === 'ftyp-box');
|
|
15
|
-
if (ftypBox && ftypBox.type === 'ftyp-box') {
|
|
16
|
-
if (ftypBox.compatibleBrands.find((b) => b === 'avc1')) {
|
|
17
|
-
return 'h264';
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
};
|
|
22
|
-
exports.getVideoCodec = getVideoCodec;
|
package/dist/web-file.d.ts
DELETED
package/dist/web-file.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inputTypeFileReader = void 0;
|
|
4
|
-
exports.inputTypeFileReader = {
|
|
5
|
-
read: (file, range) => {
|
|
6
|
-
if (typeof file === 'string') {
|
|
7
|
-
throw new Error('`inputTypeFileReader` only supports `File` objects');
|
|
8
|
-
}
|
|
9
|
-
if (range !== null) {
|
|
10
|
-
throw new Error('`inputTypeFileReader` does not support `range`');
|
|
11
|
-
}
|
|
12
|
-
const part = range === null
|
|
13
|
-
? file
|
|
14
|
-
: typeof range === 'number'
|
|
15
|
-
? file.slice(range)
|
|
16
|
-
: file.slice(range[0], range[1]);
|
|
17
|
-
const reader = new FileReader();
|
|
18
|
-
reader.readAsArrayBuffer(file);
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
reader.onload = () => {
|
|
21
|
-
resolve({
|
|
22
|
-
reader: part.stream().getReader(),
|
|
23
|
-
contentLength: file.size,
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
reader.onerror = (error) => {
|
|
27
|
-
reject(error);
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
getLength: (src) => {
|
|
32
|
-
if (typeof src === 'string') {
|
|
33
|
-
throw new Error('`inputTypeFileReader` only supports `File` objects');
|
|
34
|
-
}
|
|
35
|
-
return Promise.resolve(src.size);
|
|
36
|
-
},
|
|
37
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
|
|
3
|
-
export type DurationSegment = {
|
|
4
|
-
type: 'duration-segment';
|
|
5
|
-
duration: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const parseDurationSegment = (
|
|
9
|
-
iterator: BufferIterator,
|
|
10
|
-
length: number,
|
|
11
|
-
): DurationSegment => {
|
|
12
|
-
if (length === 8) {
|
|
13
|
-
return {
|
|
14
|
-
type: 'duration-segment',
|
|
15
|
-
duration: iterator.getFloat64(),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (length === 4) {
|
|
20
|
-
return {
|
|
21
|
-
type: 'duration-segment',
|
|
22
|
-
duration: iterator.getFloat32(),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
throw new Error(
|
|
27
|
-
'Expected duration segment to be 4 or 8 bytes, but it is ' + length,
|
|
28
|
-
);
|
|
29
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
import type {ParserContext} from '../../../parser-context';
|
|
3
|
-
import type {MatroskaSegment} from '../segments';
|
|
4
|
-
import {expectChildren} from './parse-children';
|
|
5
|
-
|
|
6
|
-
export type InfoSegment = {
|
|
7
|
-
type: 'info-segment';
|
|
8
|
-
length: number;
|
|
9
|
-
children: MatroskaSegment[];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const parseInfoSegment = async (
|
|
13
|
-
iterator: BufferIterator,
|
|
14
|
-
length: number,
|
|
15
|
-
parserContext: ParserContext,
|
|
16
|
-
): Promise<InfoSegment> => {
|
|
17
|
-
const children = await expectChildren({
|
|
18
|
-
iterator,
|
|
19
|
-
length,
|
|
20
|
-
initialChildren: [],
|
|
21
|
-
wrap: null,
|
|
22
|
-
parserContext,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (children.status === 'incomplete') {
|
|
26
|
-
throw new Error('Incomplete children');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
type: 'info-segment',
|
|
31
|
-
length,
|
|
32
|
-
children: children.segments as MatroskaSegment[],
|
|
33
|
-
};
|
|
34
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
|
|
3
|
-
export type MuxingAppSegment = {
|
|
4
|
-
type: 'muxing-app-segment';
|
|
5
|
-
value: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const parseMuxingSegment = (
|
|
9
|
-
iterator: BufferIterator,
|
|
10
|
-
length: number,
|
|
11
|
-
): MuxingAppSegment => {
|
|
12
|
-
const value = iterator.getByteString(length);
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
type: 'muxing-app-segment',
|
|
16
|
-
value,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
import type {ParserContext} from '../../../parser-context';
|
|
3
|
-
import {type MatroskaSegment} from '../segments';
|
|
4
|
-
import {expectChildren} from './parse-children';
|
|
5
|
-
|
|
6
|
-
export type SeekHeadSegment = {
|
|
7
|
-
type: 'seek-head-segment';
|
|
8
|
-
children: MatroskaSegment[];
|
|
9
|
-
length: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const parseSeekHeadSegment = async (
|
|
13
|
-
iterator: BufferIterator,
|
|
14
|
-
length: number,
|
|
15
|
-
parserContext: ParserContext,
|
|
16
|
-
): Promise<SeekHeadSegment> => {
|
|
17
|
-
const children = await expectChildren({
|
|
18
|
-
iterator,
|
|
19
|
-
length,
|
|
20
|
-
initialChildren: [],
|
|
21
|
-
wrap: null,
|
|
22
|
-
parserContext,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (children.status === 'incomplete') {
|
|
26
|
-
throw new Error('Incomplete children');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
type: 'seek-head-segment',
|
|
31
|
-
length,
|
|
32
|
-
children: children.segments as MatroskaSegment[],
|
|
33
|
-
};
|
|
34
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
|
|
3
|
-
export type SeekPositionSegment = {
|
|
4
|
-
type: 'seek-position-segment';
|
|
5
|
-
seekPosition: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const parseSeekPositionSegment = (
|
|
9
|
-
iterator: BufferIterator,
|
|
10
|
-
length: number,
|
|
11
|
-
): SeekPositionSegment => {
|
|
12
|
-
const seekPosition = iterator.getUint(length);
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
type: 'seek-position-segment',
|
|
16
|
-
seekPosition,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
import type {ParserContext} from '../../../parser-context';
|
|
3
|
-
import type {MatroskaSegment} from '../segments';
|
|
4
|
-
import {expectChildren} from './parse-children';
|
|
5
|
-
|
|
6
|
-
export type SeekSegment = {
|
|
7
|
-
type: 'seek-segment';
|
|
8
|
-
children: MatroskaSegment[];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const parseSeekSegment = async (
|
|
12
|
-
iterator: BufferIterator,
|
|
13
|
-
length: number,
|
|
14
|
-
parserContext: ParserContext,
|
|
15
|
-
): Promise<SeekSegment> => {
|
|
16
|
-
const children = await expectChildren({
|
|
17
|
-
iterator,
|
|
18
|
-
length,
|
|
19
|
-
initialChildren: [],
|
|
20
|
-
wrap: null,
|
|
21
|
-
parserContext,
|
|
22
|
-
});
|
|
23
|
-
if (children.status === 'incomplete') {
|
|
24
|
-
throw new Error('Incomplete children');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
type: 'seek-segment',
|
|
29
|
-
children: children.segments as MatroskaSegment[],
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type SeekIdSegment = {
|
|
34
|
-
type: 'seek-id-segment';
|
|
35
|
-
seekId: string;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const parseSeekIdSegment = (
|
|
39
|
-
iterator: BufferIterator,
|
|
40
|
-
length: number,
|
|
41
|
-
): SeekIdSegment => {
|
|
42
|
-
const seekId =
|
|
43
|
-
'0x' +
|
|
44
|
-
[...iterator.getSlice(length)]
|
|
45
|
-
.map((b) => b.toString(16).padStart(2, '0'))
|
|
46
|
-
.join('');
|
|
47
|
-
if (seekId === null) {
|
|
48
|
-
throw new Error('Not enough bytes to parse seek id');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
type: 'seek-id-segment',
|
|
53
|
-
seekId,
|
|
54
|
-
};
|
|
55
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
|
|
3
|
-
export type TimestampScaleSegment = {
|
|
4
|
-
type: 'timestamp-scale-segment';
|
|
5
|
-
timestampScale: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const parseTimestampScaleSegment = (
|
|
9
|
-
iterator: BufferIterator,
|
|
10
|
-
): TimestampScaleSegment => {
|
|
11
|
-
const timestampScale = iterator.getUint(3);
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
type: 'timestamp-scale-segment',
|
|
15
|
-
timestampScale,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
import type {ParserContext} from '../../../parser-context';
|
|
3
|
-
import type {MatroskaSegment} from '../segments';
|
|
4
|
-
import {expectChildren} from './parse-children';
|
|
5
|
-
|
|
6
|
-
export type TracksSegment = {
|
|
7
|
-
type: 'tracks-segment';
|
|
8
|
-
children: MatroskaSegment[];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const parseTracksSegment = async (
|
|
12
|
-
iterator: BufferIterator,
|
|
13
|
-
length: number,
|
|
14
|
-
parserContext: ParserContext,
|
|
15
|
-
): Promise<TracksSegment> => {
|
|
16
|
-
const children = await expectChildren({
|
|
17
|
-
iterator,
|
|
18
|
-
length,
|
|
19
|
-
initialChildren: [],
|
|
20
|
-
wrap: null,
|
|
21
|
-
parserContext,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (children.status === 'incomplete') {
|
|
25
|
-
throw new Error('Incomplete children');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
type: 'tracks-segment',
|
|
30
|
-
children: children.segments as MatroskaSegment[],
|
|
31
|
-
};
|
|
32
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
|
|
3
|
-
export type VoidSegment = {
|
|
4
|
-
type: 'void-segment';
|
|
5
|
-
length: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const parseVoidSegment = (
|
|
9
|
-
iterator: BufferIterator,
|
|
10
|
-
length: number,
|
|
11
|
-
): VoidSegment => {
|
|
12
|
-
iterator.discard(length);
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
type: 'void-segment',
|
|
16
|
-
length,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type {BufferIterator} from '../../../buffer-iterator';
|
|
2
|
-
|
|
3
|
-
export type WritingAppSegment = {
|
|
4
|
-
type: 'writing-app-segment';
|
|
5
|
-
value: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const parseWritingSegment = (
|
|
9
|
-
iterator: BufferIterator,
|
|
10
|
-
length: number,
|
|
11
|
-
): WritingAppSegment => {
|
|
12
|
-
const value = iterator.getByteString(length);
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
type: 'writing-app-segment',
|
|
16
|
-
value,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const combineUint8Arrays = (
|
|
2
|
-
array1: Uint8Array | null,
|
|
3
|
-
array2: Uint8Array,
|
|
4
|
-
) => {
|
|
5
|
-
if (!array1) {
|
|
6
|
-
return array2;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const combined = new Uint8Array(array1.length + array2.length);
|
|
10
|
-
combined.set(array1);
|
|
11
|
-
combined.set(array2, array1.length);
|
|
12
|
-
return combined;
|
|
13
|
-
};
|
|
File without changes
|
|
File without changes
|
/package/dist/{sample-aspect-ratio.d.ts → boxes/webm/bitstream/h264/get-h264-descriptor.d.ts}
RENAMED
|
File without changes
|