@remotion/media-parser 4.0.206 → 4.0.208
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 +3 -0
- package/dist/av1-codec-string.js +91 -0
- 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/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/ctts.js +8 -1
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +6 -3
- package/dist/boxes/iso-base-media/stsd/samples.js +6 -6
- package/dist/boxes/iso-base-media/stts/stts.d.ts +15 -0
- package/dist/boxes/iso-base-media/stts/stts.js +35 -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/frame.d.ts +0 -0
- package/dist/boxes/webm/bitstream/av1/frame.js +1 -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/make-header.d.ts +6 -2
- package/dist/boxes/webm/make-header.js +102 -18
- package/dist/boxes/webm/parse-ebml.js +3 -1
- package/dist/boxes/webm/segments/all-segments.d.ts +70 -12
- package/dist/boxes/webm/segments/all-segments.js +43 -5
- package/dist/boxes/webm/segments/duration.d.ts +6 -0
- package/dist/boxes/webm/segments/duration.js +19 -0
- package/dist/boxes/webm/segments/info.d.ts +9 -0
- package/dist/boxes/webm/segments/info.js +22 -0
- package/dist/boxes/webm/segments/main.d.ts +5 -0
- package/dist/boxes/webm/segments/main.js +2 -0
- package/dist/boxes/webm/segments/muxing.d.ts +6 -0
- package/dist/boxes/webm/segments/muxing.js +11 -0
- package/dist/boxes/webm/segments/seek-head.d.ts +9 -0
- package/dist/boxes/webm/segments/seek-head.js +22 -0
- package/dist/boxes/webm/segments/seek-position.d.ts +6 -0
- package/dist/boxes/webm/segments/seek-position.js +11 -0
- package/dist/boxes/webm/segments/seek.d.ts +13 -0
- package/dist/boxes/webm/segments/seek.js +35 -0
- package/dist/boxes/webm/segments/timestamp-scale.d.ts +6 -0
- package/dist/boxes/webm/segments/timestamp-scale.js +11 -0
- package/dist/boxes/webm/segments/tracks.d.ts +8 -0
- package/dist/boxes/webm/segments/tracks.js +21 -0
- package/dist/boxes/webm/segments/unknown.d.ts +6 -0
- package/dist/boxes/webm/segments/unknown.js +11 -0
- package/dist/boxes/webm/segments/void.d.ts +6 -0
- package/dist/boxes/webm/segments/void.js +11 -0
- package/dist/boxes/webm/segments/writing.d.ts +6 -0
- package/dist/boxes/webm/segments/writing.js +11 -0
- package/dist/boxes/webm/tracks.d.ts +8 -0
- package/dist/boxes/webm/tracks.js +21 -0
- package/dist/combine-uint8array.d.ts +1 -0
- package/dist/combine-uint8array.js +13 -0
- package/dist/create/cluster-segment.d.ts +10 -0
- package/dist/create/cluster-segment.js +41 -0
- package/dist/create/create-media.d.ts +13 -0
- package/dist/create/create-media.js +108 -0
- package/dist/create/matroska-header.d.ts +1 -0
- package/dist/create/matroska-header.js +66 -0
- package/dist/create/matroska-info.d.ts +4 -0
- package/dist/create/matroska-info.js +41 -0
- package/dist/create/matroska-segment.d.ts +2 -0
- package/dist/create/matroska-segment.js +12 -0
- package/dist/create/matroska-trackentry.d.ts +32 -0
- package/dist/create/matroska-trackentry.js +266 -0
- package/dist/from-web.d.ts +2 -0
- package/dist/from-web.js +45 -0
- package/dist/get-video-metadata.d.ts +2 -0
- package/dist/get-video-metadata.js +44 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -1
- package/dist/options.d.ts +1 -1
- package/dist/parse-media.js +1 -1
- package/dist/read-and-increment-offset.d.ts +28 -0
- package/dist/read-and-increment-offset.js +177 -0
- package/dist/readers/from-fetch.d.ts +2 -0
- package/dist/readers/from-fetch.js +64 -0
- package/dist/readers/from-node.d.ts +2 -0
- package/dist/readers/from-node.js +40 -0
- package/dist/readers/from-web-file.d.ts +2 -0
- package/dist/readers/from-web-file.js +39 -0
- package/dist/readers/reader.d.ts +11 -0
- package/dist/readers/reader.js +2 -0
- package/dist/traversal.d.ts +1 -1
- package/dist/understand-vorbis.d.ts +1 -0
- package/dist/understand-vorbis.js +12 -0
- package/dist/writers/web-fs.d.ts +2 -0
- package/dist/writers/web-fs.js +44 -0
- package/dist/writers/writer.d.ts +11 -0
- package/dist/writers/writer.js +2 -0
- package/package.json +13 -8
- package/src/boxes/iso-base-media/stsd/ctts.ts +10 -1
- package/src/boxes/iso-base-media/stsd/samples.ts +12 -9
- package/src/boxes/webm/make-header.ts +132 -24
- package/src/boxes/webm/parse-ebml.ts +4 -1
- package/src/boxes/webm/segments/all-segments.ts +67 -7
- package/src/create/cluster-segment.ts +62 -0
- package/src/create/create-media.ts +172 -0
- package/src/create/matroska-header.ts +63 -0
- package/src/create/matroska-info.ts +46 -0
- package/src/create/matroska-segment.ts +10 -0
- package/src/create/matroska-trackentry.ts +325 -0
- package/src/index.ts +9 -0
- package/src/options.ts +1 -1
- package/src/parse-media.ts +1 -1
- package/src/test/av1.test.ts +1 -1
- package/src/test/create-matroska.test.ts +31 -6
- package/src/test/duration.test.ts +1 -1
- package/src/test/matroska.test.ts +35 -5
- package/src/test/parse-video.test.ts +1 -1
- package/src/test/parse-webm.test.ts +1 -1
- package/src/test/stream-local.test.ts +1 -1
- package/src/test/stream-samples.test.ts +1 -1
- package/src/writers/web-fs.ts +50 -0
- package/src/writers/writer.ts +12 -0
- package/tsconfig.tsbuildinfo +1 -1
- /package/src/{from-fetch.ts → readers/from-fetch.ts} +0 -0
- /package/src/{from-node.ts → readers/from-node.ts} +0 -0
- /package/src/{from-web-file.ts → readers/from-web-file.ts} +0 -0
- /package/src/{reader.ts → readers/reader.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.combineUint8Arrays = exports.makeMatroskaBytes = exports.webmPattern = void 0;
|
|
3
|
+
exports.serializeUint16 = exports.combineUint8Arrays = exports.padMatroskaBytes = exports.makeMatroskaBytes = exports.matroskaToHex = exports.webmPattern = void 0;
|
|
4
4
|
const ebml_1 = require("./ebml");
|
|
5
5
|
const all_segments_1 = require("./segments/all-segments");
|
|
6
6
|
exports.webmPattern = new Uint8Array([0x1a, 0x45, 0xdf, 0xa3]);
|
|
@@ -12,6 +12,7 @@ const matroskaToHex = (matrId) => {
|
|
|
12
12
|
}
|
|
13
13
|
return numbers;
|
|
14
14
|
};
|
|
15
|
+
exports.matroskaToHex = matroskaToHex;
|
|
15
16
|
function putUintDynamic(number, minimumLength) {
|
|
16
17
|
if (number < 0) {
|
|
17
18
|
throw new Error('This function is designed for non-negative integers only.');
|
|
@@ -25,26 +26,51 @@ function putUintDynamic(number, minimumLength) {
|
|
|
25
26
|
}
|
|
26
27
|
return bytes;
|
|
27
28
|
}
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
29
|
+
const makeFromStructure = (fields) => {
|
|
30
|
+
if ('bytes' in fields) {
|
|
30
31
|
return fields;
|
|
31
32
|
}
|
|
32
33
|
const arrays = [];
|
|
33
34
|
const struct = all_segments_1.ebmlMap[(0, all_segments_1.getIdForName)(fields.type)];
|
|
34
35
|
if (struct.type === 'uint8array') {
|
|
35
|
-
return
|
|
36
|
+
return {
|
|
37
|
+
bytes: fields.value,
|
|
38
|
+
offsets: { offset: 0, children: [], field: fields.type },
|
|
39
|
+
};
|
|
36
40
|
}
|
|
37
41
|
if (struct.type === 'children') {
|
|
42
|
+
const children = [];
|
|
43
|
+
let bytesWritten = 0;
|
|
38
44
|
for (const item of fields.value) {
|
|
39
|
-
|
|
45
|
+
const { bytes, offsets } = (0, exports.makeMatroskaBytes)(item);
|
|
46
|
+
arrays.push(bytes);
|
|
47
|
+
children.push((0, all_segments_1.incrementOffsetAndChildren)(offsets, bytesWritten));
|
|
48
|
+
bytesWritten += bytes.byteLength;
|
|
40
49
|
}
|
|
41
|
-
return
|
|
50
|
+
return {
|
|
51
|
+
bytes: (0, exports.combineUint8Arrays)(arrays),
|
|
52
|
+
offsets: { offset: 0, children, field: fields.type },
|
|
53
|
+
};
|
|
42
54
|
}
|
|
43
55
|
if (struct.type === 'string') {
|
|
44
|
-
return
|
|
56
|
+
return {
|
|
57
|
+
bytes: new TextEncoder().encode(fields.value),
|
|
58
|
+
offsets: {
|
|
59
|
+
children: [],
|
|
60
|
+
offset: 0,
|
|
61
|
+
field: fields.type,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
45
64
|
}
|
|
46
65
|
if (struct.type === 'uint') {
|
|
47
|
-
return
|
|
66
|
+
return {
|
|
67
|
+
bytes: putUintDynamic(fields.value.value, fields.value.byteLength),
|
|
68
|
+
offsets: {
|
|
69
|
+
children: [],
|
|
70
|
+
offset: 0,
|
|
71
|
+
field: fields.type,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
48
74
|
}
|
|
49
75
|
if (struct.type === 'hex-string') {
|
|
50
76
|
const hex = fields.value.substring(2);
|
|
@@ -53,33 +79,84 @@ const makeFromHeaderStructure = (fields) => {
|
|
|
53
79
|
const byte = parseInt(hex.substring(i, i + 2), 16);
|
|
54
80
|
arr[i / 2] = byte;
|
|
55
81
|
}
|
|
56
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
bytes: arr,
|
|
84
|
+
offsets: {
|
|
85
|
+
children: [],
|
|
86
|
+
offset: 0,
|
|
87
|
+
field: fields.type,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
57
90
|
}
|
|
58
91
|
if (struct.type === 'float') {
|
|
59
92
|
const value = fields.value;
|
|
60
93
|
if (value.size === '32') {
|
|
61
94
|
const dataView = new DataView(new ArrayBuffer(4));
|
|
62
95
|
dataView.setFloat32(0, value.value);
|
|
63
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
bytes: new Uint8Array(dataView.buffer),
|
|
98
|
+
offsets: {
|
|
99
|
+
children: [],
|
|
100
|
+
offset: 0,
|
|
101
|
+
field: fields.type,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
64
104
|
}
|
|
65
105
|
const dataView2 = new DataView(new ArrayBuffer(8));
|
|
66
106
|
dataView2.setFloat64(0, value.value);
|
|
67
|
-
return
|
|
107
|
+
return {
|
|
108
|
+
bytes: new Uint8Array(dataView2.buffer),
|
|
109
|
+
offsets: {
|
|
110
|
+
children: [],
|
|
111
|
+
offset: 0,
|
|
112
|
+
field: fields.type,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
68
115
|
}
|
|
69
116
|
throw new Error('Unexpected type');
|
|
70
117
|
};
|
|
71
118
|
const makeMatroskaBytes = (fields) => {
|
|
72
|
-
if (
|
|
119
|
+
if ('bytes' in fields) {
|
|
73
120
|
return fields;
|
|
74
121
|
}
|
|
75
|
-
const value =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
122
|
+
const value = makeFromStructure(fields);
|
|
123
|
+
const header = (0, exports.matroskaToHex)((0, all_segments_1.getIdForName)(fields.type));
|
|
124
|
+
const size = (0, ebml_1.getVariableInt)(value.bytes.length, fields.minVintWidth);
|
|
125
|
+
const bytes = (0, exports.combineUint8Arrays)([header, size, value.bytes]);
|
|
126
|
+
return {
|
|
127
|
+
bytes,
|
|
128
|
+
offsets: {
|
|
129
|
+
offset: value.offsets.offset,
|
|
130
|
+
field: value.offsets.field,
|
|
131
|
+
children: value.offsets.children.map((c) => {
|
|
132
|
+
return (0, all_segments_1.incrementOffsetAndChildren)(c, header.byteLength + size.byteLength);
|
|
133
|
+
}),
|
|
134
|
+
},
|
|
135
|
+
};
|
|
81
136
|
};
|
|
82
137
|
exports.makeMatroskaBytes = makeMatroskaBytes;
|
|
138
|
+
const padMatroskaBytes = (fields, totalLength) => {
|
|
139
|
+
const regular = (0, exports.makeMatroskaBytes)(fields);
|
|
140
|
+
const paddingLength = totalLength -
|
|
141
|
+
regular.bytes.byteLength -
|
|
142
|
+
(0, exports.matroskaToHex)(all_segments_1.matroskaElements.Void).byteLength;
|
|
143
|
+
if (paddingLength < 0) {
|
|
144
|
+
throw new Error('ooops');
|
|
145
|
+
}
|
|
146
|
+
const padding = (0, exports.makeMatroskaBytes)({
|
|
147
|
+
type: 'Void',
|
|
148
|
+
value: new Uint8Array(paddingLength).fill(0),
|
|
149
|
+
minVintWidth: null,
|
|
150
|
+
});
|
|
151
|
+
return [
|
|
152
|
+
regular,
|
|
153
|
+
{
|
|
154
|
+
bytes: padding.bytes,
|
|
155
|
+
offsets: (0, all_segments_1.incrementOffsetAndChildren)(padding.offsets, regular.bytes.length),
|
|
156
|
+
},
|
|
157
|
+
];
|
|
158
|
+
};
|
|
159
|
+
exports.padMatroskaBytes = padMatroskaBytes;
|
|
83
160
|
const combineUint8Arrays = (arrays) => {
|
|
84
161
|
if (arrays.length === 0) {
|
|
85
162
|
return new Uint8Array([]);
|
|
@@ -100,3 +177,10 @@ const combineUint8Arrays = (arrays) => {
|
|
|
100
177
|
return result;
|
|
101
178
|
};
|
|
102
179
|
exports.combineUint8Arrays = combineUint8Arrays;
|
|
180
|
+
function serializeUint16(value) {
|
|
181
|
+
const buffer = new ArrayBuffer(2);
|
|
182
|
+
const view = new DataView(buffer);
|
|
183
|
+
view.setUint16(0, value);
|
|
184
|
+
return new Uint8Array(buffer);
|
|
185
|
+
}
|
|
186
|
+
exports.serializeUint16 = serializeUint16;
|
|
@@ -23,8 +23,10 @@ const parseEbml = async (iterator, parserContext) => {
|
|
|
23
23
|
if (hasInMap.type === 'uint') {
|
|
24
24
|
const beforeUintOffset = iterator.counter.getOffset();
|
|
25
25
|
const value = size === 0 ? 0 : iterator.getUint(size);
|
|
26
|
+
const { name } = hasInMap;
|
|
26
27
|
return {
|
|
27
|
-
|
|
28
|
+
// To work around TS limit
|
|
29
|
+
type: name,
|
|
28
30
|
value: {
|
|
29
31
|
value,
|
|
30
32
|
byteLength: iterator.counter.getOffset() - beforeUintOffset,
|
|
@@ -312,8 +312,8 @@ export declare const ebmlReadVersion: {
|
|
|
312
312
|
type: "uint";
|
|
313
313
|
};
|
|
314
314
|
export declare const ebmlMaxIdLength: {
|
|
315
|
-
name: "EBMLMaxIDLength";
|
|
316
|
-
type: "uint";
|
|
315
|
+
readonly name: "EBMLMaxIDLength";
|
|
316
|
+
readonly type: "uint";
|
|
317
317
|
};
|
|
318
318
|
export declare const ebmlMaxSizeLength: {
|
|
319
319
|
name: "EBMLMaxSizeLength";
|
|
@@ -454,7 +454,31 @@ export declare const trackUID: {
|
|
|
454
454
|
};
|
|
455
455
|
export declare const color: {
|
|
456
456
|
readonly name: "Colour";
|
|
457
|
-
readonly type: "
|
|
457
|
+
readonly type: "children";
|
|
458
|
+
};
|
|
459
|
+
export declare const transfer: {
|
|
460
|
+
readonly name: "TransferCharacteristics";
|
|
461
|
+
readonly type: "uint";
|
|
462
|
+
};
|
|
463
|
+
export declare const matrix: {
|
|
464
|
+
readonly name: "MatrixCoefficients";
|
|
465
|
+
readonly type: "uint";
|
|
466
|
+
};
|
|
467
|
+
export declare const primaries: {
|
|
468
|
+
readonly name: "Primaries";
|
|
469
|
+
readonly type: "uint";
|
|
470
|
+
};
|
|
471
|
+
export declare const range: {
|
|
472
|
+
readonly name: "Range";
|
|
473
|
+
readonly type: "uint";
|
|
474
|
+
};
|
|
475
|
+
export declare const ChromaSitingHorz: {
|
|
476
|
+
readonly name: "ChromaSitingHorz";
|
|
477
|
+
readonly type: "uint";
|
|
478
|
+
};
|
|
479
|
+
export declare const ChromaSitingVert: {
|
|
480
|
+
readonly name: "ChromaSitingVert";
|
|
481
|
+
readonly type: "uint";
|
|
458
482
|
};
|
|
459
483
|
export declare const language: {
|
|
460
484
|
readonly name: "Language";
|
|
@@ -486,7 +510,7 @@ export declare const videoSegment: {
|
|
|
486
510
|
};
|
|
487
511
|
export declare const flagDefault: {
|
|
488
512
|
readonly name: "FlagDefault";
|
|
489
|
-
readonly type: "
|
|
513
|
+
readonly type: "uint";
|
|
490
514
|
};
|
|
491
515
|
export declare const referenceBlock: {
|
|
492
516
|
readonly name: "ReferenceBlock";
|
|
@@ -559,19 +583,19 @@ export type FloatWithSize = {
|
|
|
559
583
|
};
|
|
560
584
|
export type UintWithSize = {
|
|
561
585
|
value: number;
|
|
562
|
-
byteLength: number;
|
|
586
|
+
byteLength: number | null;
|
|
563
587
|
};
|
|
564
588
|
export type EbmlValue<T extends Ebml, Child = PossibleEbml> = T extends EbmlWithUint ? UintWithSize : T extends EbmlWithString ? string : T extends EbmlWithFloat ? FloatWithSize : T extends EbmlWithHexString ? string : T extends EbmlWithUint8Array ? Uint8Array : T extends EbmlWithChildren ? Child[] : never;
|
|
565
589
|
export type EbmlValueOrUint8Array<T extends Ebml> = Uint8Array | EbmlValue<T, PossibleEbmlOrUint8Array>;
|
|
566
590
|
export type EbmlParsed<T extends Ebml> = {
|
|
567
591
|
type: T['name'];
|
|
568
592
|
value: EbmlValue<T>;
|
|
569
|
-
minVintWidth: number;
|
|
593
|
+
minVintWidth: number | null;
|
|
570
594
|
};
|
|
571
595
|
export type EbmlParsedOrUint8Array<T extends Ebml> = {
|
|
572
596
|
type: T['name'];
|
|
573
597
|
value: EbmlValueOrUint8Array<T>;
|
|
574
|
-
minVintWidth: number;
|
|
598
|
+
minVintWidth: number | null;
|
|
575
599
|
};
|
|
576
600
|
export declare const ebmlMap: {
|
|
577
601
|
readonly "0x1a45dfa3": {
|
|
@@ -599,8 +623,8 @@ export declare const ebmlMap: {
|
|
|
599
623
|
type: "uint";
|
|
600
624
|
};
|
|
601
625
|
readonly "0x42f2": {
|
|
602
|
-
name: "EBMLMaxIDLength";
|
|
603
|
-
type: "uint";
|
|
626
|
+
readonly name: "EBMLMaxIDLength";
|
|
627
|
+
readonly type: "uint";
|
|
604
628
|
};
|
|
605
629
|
readonly "0x42f3": {
|
|
606
630
|
name: "EBMLMaxSizeLength";
|
|
@@ -764,7 +788,7 @@ export declare const ebmlMap: {
|
|
|
764
788
|
};
|
|
765
789
|
readonly "0x55b0": {
|
|
766
790
|
readonly name: "Colour";
|
|
767
|
-
readonly type: "
|
|
791
|
+
readonly type: "children";
|
|
768
792
|
};
|
|
769
793
|
readonly "0x22b59c": {
|
|
770
794
|
readonly name: "Language";
|
|
@@ -796,7 +820,7 @@ export declare const ebmlMap: {
|
|
|
796
820
|
};
|
|
797
821
|
readonly "0x88": {
|
|
798
822
|
readonly name: "FlagDefault";
|
|
799
|
-
readonly type: "
|
|
823
|
+
readonly type: "uint";
|
|
800
824
|
};
|
|
801
825
|
readonly "0xfb": {
|
|
802
826
|
readonly name: "ReferenceBlock";
|
|
@@ -834,12 +858,46 @@ export declare const ebmlMap: {
|
|
|
834
858
|
readonly name: "Cluster";
|
|
835
859
|
readonly type: "children";
|
|
836
860
|
};
|
|
861
|
+
readonly "0x55ba": {
|
|
862
|
+
readonly name: "TransferCharacteristics";
|
|
863
|
+
readonly type: "uint";
|
|
864
|
+
};
|
|
865
|
+
readonly "0x55b1": {
|
|
866
|
+
readonly name: "MatrixCoefficients";
|
|
867
|
+
readonly type: "uint";
|
|
868
|
+
};
|
|
869
|
+
readonly "0x55bb": {
|
|
870
|
+
readonly name: "Primaries";
|
|
871
|
+
readonly type: "uint";
|
|
872
|
+
};
|
|
873
|
+
readonly "0x55b9": {
|
|
874
|
+
readonly name: "Range";
|
|
875
|
+
readonly type: "uint";
|
|
876
|
+
};
|
|
877
|
+
readonly "0x55b7": {
|
|
878
|
+
readonly name: "ChromaSitingHorz";
|
|
879
|
+
readonly type: "uint";
|
|
880
|
+
};
|
|
881
|
+
readonly "0x55b8": {
|
|
882
|
+
readonly name: "ChromaSitingVert";
|
|
883
|
+
readonly type: "uint";
|
|
884
|
+
};
|
|
837
885
|
};
|
|
838
886
|
export type PossibleEbml = Prettify<{
|
|
839
887
|
[key in keyof typeof ebmlMap]: EbmlParsed<(typeof ebmlMap)[key]>;
|
|
840
888
|
}[keyof typeof ebmlMap]>;
|
|
889
|
+
export type OffsetAndChildren = {
|
|
890
|
+
offset: number;
|
|
891
|
+
children: OffsetAndChildren[];
|
|
892
|
+
field: keyof typeof matroskaElements;
|
|
893
|
+
};
|
|
894
|
+
export declare const incrementOffsetAndChildren: (offset: OffsetAndChildren, increment: number) => OffsetAndChildren;
|
|
895
|
+
export type BytesAndOffset = {
|
|
896
|
+
bytes: Uint8Array;
|
|
897
|
+
offsets: OffsetAndChildren;
|
|
898
|
+
};
|
|
841
899
|
export type PossibleEbmlOrUint8Array = Prettify<{
|
|
842
900
|
[key in keyof typeof ebmlMap]: EbmlParsedOrUint8Array<(typeof ebmlMap)[key]>;
|
|
843
|
-
}[keyof typeof ebmlMap]> |
|
|
901
|
+
}[keyof typeof ebmlMap]> | BytesAndOffset;
|
|
844
902
|
export type EbmlMapKey = keyof typeof ebmlMap;
|
|
845
903
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.ebmlMap = exports.cluster = exports.segment = exports.blockGroup = exports.simpleBlock = exports.block = exports.timestampEntry = exports.tracks = exports.trackEntry = exports.trackTimestampScale = exports.codecName = exports.blockElement = exports.referenceBlock = void 0;
|
|
3
|
+
exports.defaultDuration = exports.language = exports.ChromaSitingVert = exports.ChromaSitingHorz = exports.range = exports.primaries = exports.matrix = exports.transfer = exports.color = exports.trackUID = exports.trackNumber = exports.tags = exports.tagSegment = exports.flagLacing = exports.displayHeight = exports.displayWidth = exports.bitDepth = exports.interlaced = exports.alphaMode = exports.channels = exports.samplingFrequency = exports.titleType = exports.infoType = exports.writingApp = exports.timestampScale = exports.duration = exports.muxingApp = exports.heightType = exports.widthType = exports.trackType = exports.codecID = exports.voidHeader = exports.seekHead = exports.seek = exports.seekPosition = exports.seekId = exports.matroskaHeader = exports.docTypeReadVersion = exports.docTypeVersion = exports.docType = exports.ebmlMaxSizeLength = exports.ebmlMaxIdLength = exports.ebmlReadVersion = exports.ebmlVersion = exports.getIdForName = exports.getSegmentName = exports.knownIdsWithThreeLength = exports.knownIdsWithTwoLength = exports.knownIdsWithOneLength = exports.matroskaElements = void 0;
|
|
4
|
+
exports.incrementOffsetAndChildren = exports.ebmlMap = exports.cluster = exports.segment = exports.blockGroup = exports.simpleBlock = exports.block = exports.timestampEntry = exports.tracks = exports.trackEntry = exports.trackTimestampScale = exports.codecName = exports.blockElement = exports.referenceBlock = exports.flagDefault = exports.videoSegment = exports.audioSegment = exports.maxBlockAdditionIdSegment = exports.blockAdditionsSegment = exports.codecPrivate = void 0;
|
|
5
5
|
exports.matroskaElements = {
|
|
6
6
|
Header: '0x1a45dfa3',
|
|
7
7
|
EBMLMaxIDLength: '0x42f2',
|
|
@@ -437,7 +437,31 @@ exports.trackUID = {
|
|
|
437
437
|
};
|
|
438
438
|
exports.color = {
|
|
439
439
|
name: 'Colour',
|
|
440
|
-
type: '
|
|
440
|
+
type: 'children',
|
|
441
|
+
};
|
|
442
|
+
exports.transfer = {
|
|
443
|
+
name: 'TransferCharacteristics',
|
|
444
|
+
type: 'uint',
|
|
445
|
+
};
|
|
446
|
+
exports.matrix = {
|
|
447
|
+
name: 'MatrixCoefficients',
|
|
448
|
+
type: 'uint',
|
|
449
|
+
};
|
|
450
|
+
exports.primaries = {
|
|
451
|
+
name: 'Primaries',
|
|
452
|
+
type: 'uint',
|
|
453
|
+
};
|
|
454
|
+
exports.range = {
|
|
455
|
+
name: 'Range',
|
|
456
|
+
type: 'uint',
|
|
457
|
+
};
|
|
458
|
+
exports.ChromaSitingHorz = {
|
|
459
|
+
name: 'ChromaSitingHorz',
|
|
460
|
+
type: 'uint',
|
|
461
|
+
};
|
|
462
|
+
exports.ChromaSitingVert = {
|
|
463
|
+
name: 'ChromaSitingVert',
|
|
464
|
+
type: 'uint',
|
|
441
465
|
};
|
|
442
466
|
exports.language = {
|
|
443
467
|
name: 'Language',
|
|
@@ -469,7 +493,7 @@ exports.videoSegment = {
|
|
|
469
493
|
};
|
|
470
494
|
exports.flagDefault = {
|
|
471
495
|
name: 'FlagDefault',
|
|
472
|
-
type: '
|
|
496
|
+
type: 'uint',
|
|
473
497
|
};
|
|
474
498
|
exports.referenceBlock = {
|
|
475
499
|
name: 'ReferenceBlock',
|
|
@@ -630,4 +654,18 @@ exports.ebmlMap = {
|
|
|
630
654
|
name: 'Cluster',
|
|
631
655
|
type: 'children',
|
|
632
656
|
},
|
|
633
|
-
|
|
657
|
+
[exports.matroskaElements.TransferCharacteristics]: exports.transfer,
|
|
658
|
+
[exports.matroskaElements.MatrixCoefficients]: exports.matrix,
|
|
659
|
+
[exports.matroskaElements.Primaries]: exports.primaries,
|
|
660
|
+
[exports.matroskaElements.Range]: exports.range,
|
|
661
|
+
[exports.matroskaElements.ChromaSitingHorz]: exports.ChromaSitingHorz,
|
|
662
|
+
[exports.matroskaElements.ChromaSitingVert]: exports.ChromaSitingVert,
|
|
663
|
+
};
|
|
664
|
+
const incrementOffsetAndChildren = (offset, increment) => {
|
|
665
|
+
return {
|
|
666
|
+
offset: offset.offset + increment,
|
|
667
|
+
children: offset.children.map((c) => (0, exports.incrementOffsetAndChildren)(c, increment)),
|
|
668
|
+
field: offset.field,
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
exports.incrementOffsetAndChildren = incrementOffsetAndChildren;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseDurationSegment = void 0;
|
|
4
|
+
const parseDurationSegment = (iterator, length) => {
|
|
5
|
+
if (length === 8) {
|
|
6
|
+
return {
|
|
7
|
+
type: 'duration-segment',
|
|
8
|
+
duration: iterator.getFloat64(),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
if (length === 4) {
|
|
12
|
+
return {
|
|
13
|
+
type: 'duration-segment',
|
|
14
|
+
duration: iterator.getFloat32(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
throw new Error('Expected duration segment to be 4 or 8 bytes, but it is ' + length);
|
|
18
|
+
};
|
|
19
|
+
exports.parseDurationSegment = parseDurationSegment;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { ParserContext } from '../../../parser-context';
|
|
3
|
+
import type { MatroskaSegment } from '../segments';
|
|
4
|
+
export type InfoSegment = {
|
|
5
|
+
type: 'info-segment';
|
|
6
|
+
length: number;
|
|
7
|
+
children: MatroskaSegment[];
|
|
8
|
+
};
|
|
9
|
+
export declare const parseInfoSegment: (iterator: BufferIterator, length: number, parserContext: ParserContext) => Promise<InfoSegment>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseInfoSegment = void 0;
|
|
4
|
+
const parse_children_1 = require("./parse-children");
|
|
5
|
+
const parseInfoSegment = async (iterator, length, parserContext) => {
|
|
6
|
+
const children = await (0, parse_children_1.expectChildren)({
|
|
7
|
+
iterator,
|
|
8
|
+
length,
|
|
9
|
+
initialChildren: [],
|
|
10
|
+
wrap: null,
|
|
11
|
+
parserContext,
|
|
12
|
+
});
|
|
13
|
+
if (children.status === 'incomplete') {
|
|
14
|
+
throw new Error('Incomplete children');
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
type: 'info-segment',
|
|
18
|
+
length,
|
|
19
|
+
children: children.segments,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.parseInfoSegment = parseInfoSegment;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseMuxingSegment = void 0;
|
|
4
|
+
const parseMuxingSegment = (iterator, length) => {
|
|
5
|
+
const value = iterator.getByteString(length);
|
|
6
|
+
return {
|
|
7
|
+
type: 'muxing-app-segment',
|
|
8
|
+
value,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.parseMuxingSegment = parseMuxingSegment;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { ParserContext } from '../../../parser-context';
|
|
3
|
+
import { type MatroskaSegment } from '../segments';
|
|
4
|
+
export type SeekHeadSegment = {
|
|
5
|
+
type: 'seek-head-segment';
|
|
6
|
+
children: MatroskaSegment[];
|
|
7
|
+
length: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const parseSeekHeadSegment: (iterator: BufferIterator, length: number, parserContext: ParserContext) => Promise<SeekHeadSegment>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSeekHeadSegment = void 0;
|
|
4
|
+
const parse_children_1 = require("./parse-children");
|
|
5
|
+
const parseSeekHeadSegment = async (iterator, length, parserContext) => {
|
|
6
|
+
const children = await (0, parse_children_1.expectChildren)({
|
|
7
|
+
iterator,
|
|
8
|
+
length,
|
|
9
|
+
initialChildren: [],
|
|
10
|
+
wrap: null,
|
|
11
|
+
parserContext,
|
|
12
|
+
});
|
|
13
|
+
if (children.status === 'incomplete') {
|
|
14
|
+
throw new Error('Incomplete children');
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
type: 'seek-head-segment',
|
|
18
|
+
length,
|
|
19
|
+
children: children.segments,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.parseSeekHeadSegment = parseSeekHeadSegment;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
export type SeekPositionSegment = {
|
|
3
|
+
type: 'seek-position-segment';
|
|
4
|
+
seekPosition: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const parseSeekPositionSegment: (iterator: BufferIterator, length: number) => SeekPositionSegment;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSeekPositionSegment = void 0;
|
|
4
|
+
const parseSeekPositionSegment = (iterator, length) => {
|
|
5
|
+
const seekPosition = iterator.getUint(length);
|
|
6
|
+
return {
|
|
7
|
+
type: 'seek-position-segment',
|
|
8
|
+
seekPosition,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.parseSeekPositionSegment = parseSeekPositionSegment;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { ParserContext } from '../../../parser-context';
|
|
3
|
+
import type { MatroskaSegment } from '../segments';
|
|
4
|
+
export type SeekSegment = {
|
|
5
|
+
type: 'seek-segment';
|
|
6
|
+
children: MatroskaSegment[];
|
|
7
|
+
};
|
|
8
|
+
export declare const parseSeekSegment: (iterator: BufferIterator, length: number, parserContext: ParserContext) => Promise<SeekSegment>;
|
|
9
|
+
export type SeekIdSegment = {
|
|
10
|
+
type: 'seek-id-segment';
|
|
11
|
+
seekId: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const parseSeekIdSegment: (iterator: BufferIterator, length: number) => SeekIdSegment;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSeekIdSegment = exports.parseSeekSegment = void 0;
|
|
4
|
+
const parse_children_1 = require("./parse-children");
|
|
5
|
+
const parseSeekSegment = async (iterator, length, parserContext) => {
|
|
6
|
+
const children = await (0, parse_children_1.expectChildren)({
|
|
7
|
+
iterator,
|
|
8
|
+
length,
|
|
9
|
+
initialChildren: [],
|
|
10
|
+
wrap: null,
|
|
11
|
+
parserContext,
|
|
12
|
+
});
|
|
13
|
+
if (children.status === 'incomplete') {
|
|
14
|
+
throw new Error('Incomplete children');
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
type: 'seek-segment',
|
|
18
|
+
children: children.segments,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.parseSeekSegment = parseSeekSegment;
|
|
22
|
+
const parseSeekIdSegment = (iterator, length) => {
|
|
23
|
+
const seekId = '0x' +
|
|
24
|
+
[...iterator.getSlice(length)]
|
|
25
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
26
|
+
.join('');
|
|
27
|
+
if (seekId === null) {
|
|
28
|
+
throw new Error('Not enough bytes to parse seek id');
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
type: 'seek-id-segment',
|
|
32
|
+
seekId,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.parseSeekIdSegment = parseSeekIdSegment;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
export type TimestampScaleSegment = {
|
|
3
|
+
type: 'timestamp-scale-segment';
|
|
4
|
+
timestampScale: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const parseTimestampScaleSegment: (iterator: BufferIterator) => TimestampScaleSegment;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTimestampScaleSegment = void 0;
|
|
4
|
+
const parseTimestampScaleSegment = (iterator) => {
|
|
5
|
+
const timestampScale = iterator.getUint(3);
|
|
6
|
+
return {
|
|
7
|
+
type: 'timestamp-scale-segment',
|
|
8
|
+
timestampScale,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
exports.parseTimestampScaleSegment = parseTimestampScaleSegment;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../../buffer-iterator';
|
|
2
|
+
import type { ParserContext } from '../../../parser-context';
|
|
3
|
+
import type { MatroskaSegment } from '../segments';
|
|
4
|
+
export type TracksSegment = {
|
|
5
|
+
type: 'tracks-segment';
|
|
6
|
+
children: MatroskaSegment[];
|
|
7
|
+
};
|
|
8
|
+
export declare const parseTracksSegment: (iterator: BufferIterator, length: number, parserContext: ParserContext) => Promise<TracksSegment>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTracksSegment = void 0;
|
|
4
|
+
const parse_children_1 = require("./parse-children");
|
|
5
|
+
const parseTracksSegment = async (iterator, length, parserContext) => {
|
|
6
|
+
const children = await (0, parse_children_1.expectChildren)({
|
|
7
|
+
iterator,
|
|
8
|
+
length,
|
|
9
|
+
initialChildren: [],
|
|
10
|
+
wrap: null,
|
|
11
|
+
parserContext,
|
|
12
|
+
});
|
|
13
|
+
if (children.status === 'incomplete') {
|
|
14
|
+
throw new Error('Incomplete children');
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
type: 'tracks-segment',
|
|
18
|
+
children: children.segments,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.parseTracksSegment = parseTracksSegment;
|