@remotion/media-parser 4.0.209 → 4.0.210
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 +2 -1
- package/dist/boxes/iso-base-media/mdat/mdat.js +8 -3
- 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 +20 -5
- 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 +44 -0
- package/dist/boxes/iso-base-media/traversal.js +211 -0
- package/dist/boxes/webm/color.d.ts +4 -0
- package/dist/boxes/webm/color.js +120 -0
- package/dist/boxes/webm/description.js +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/get-track.js +16 -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/traversal.d.ts +26 -1
- package/dist/boxes/webm/traversal.js +214 -1
- package/dist/create/cluster-segment.js +0 -2
- package/dist/create/cluster.d.ts +10 -2
- package/dist/create/cluster.js +16 -10
- package/dist/create/create-media.d.ts +4 -2
- package/dist/create/create-media.js +76 -14
- package/dist/create/cues.d.ts +0 -0
- package/dist/create/cues.js +1 -0
- 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 +50 -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 -94
- 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 +72 -0
- package/dist/esm/from-node.mjs +48 -0
- package/dist/esm/from-web-file.mjs +48 -0
- package/dist/esm/index.mjs +6689 -0
- package/dist/esm/web-fs.mjs +67 -0
- package/dist/get-audio-codec.d.ts +5 -5
- package/dist/get-audio-codec.js +41 -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 +3 -1
- package/dist/options.d.ts +97 -30
- package/dist/parse-media.js +43 -62
- package/dist/parse-video.d.ts +2 -1
- package/dist/parse-video.js +3 -1
- package/dist/parser-state.js +1 -2
- package/dist/readers/from-fetch.js +24 -4
- package/dist/readers/from-node.js +13 -3
- package/dist/readers/from-web-file.js +14 -2
- package/dist/readers/reader.d.ts +6 -1
- package/dist/samples-from-moof.js +1 -1
- package/dist/traversal.d.ts +0 -21
- package/dist/traversal.js +1 -158
- 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/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
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTrack = exports.getMatroskaAudioCodecWithoutConfigString = void 0;
|
|
4
|
+
const buffer_iterator_1 = require("../../buffer-iterator");
|
|
5
|
+
const make_hvc1_codec_strings_1 = require("../../make-hvc1-codec-strings");
|
|
6
|
+
const av1_codec_private_1 = require("./av1-codec-private");
|
|
7
|
+
const color_1 = require("./color");
|
|
8
|
+
const description_1 = require("./description");
|
|
9
|
+
const track_entry_1 = require("./segments/track-entry");
|
|
10
|
+
const traversal_1 = require("./traversal");
|
|
11
|
+
const getDescription = (track) => {
|
|
12
|
+
const codec = (0, traversal_1.getCodecSegment)(track);
|
|
13
|
+
if (!codec) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
if (codec.value === 'V_MPEG4/ISO/AVC' || codec.value === 'V_MPEGH/ISO/HEVC') {
|
|
17
|
+
const priv = (0, traversal_1.getPrivateData)(track);
|
|
18
|
+
if (priv) {
|
|
19
|
+
return priv;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
};
|
|
24
|
+
const getMatroskaVideoCodecWithoutConfigString = ({ codecSegment: codec, }) => {
|
|
25
|
+
if (codec.value === 'V_VP8') {
|
|
26
|
+
return 'vp8';
|
|
27
|
+
}
|
|
28
|
+
if (codec.value === 'V_VP9') {
|
|
29
|
+
return 'vp9';
|
|
30
|
+
}
|
|
31
|
+
if (codec.value === 'V_MPEG4/ISO/AVC') {
|
|
32
|
+
return 'h264';
|
|
33
|
+
}
|
|
34
|
+
if (codec.value === 'V_AV1') {
|
|
35
|
+
return 'av1';
|
|
36
|
+
}
|
|
37
|
+
if (codec.value === 'V_MPEGH/ISO/HEVC') {
|
|
38
|
+
return 'h265';
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`Unknown codec: ${codec.value}`);
|
|
41
|
+
};
|
|
42
|
+
const getMatroskaVideoCodecString = ({ track, codecSegment: codec, }) => {
|
|
43
|
+
if (codec.value === 'V_VP8') {
|
|
44
|
+
return 'vp8';
|
|
45
|
+
}
|
|
46
|
+
if (codec.value === 'V_VP9') {
|
|
47
|
+
const priv = (0, traversal_1.getPrivateData)(track);
|
|
48
|
+
if (priv) {
|
|
49
|
+
throw new Error('@remotion/media-parser cannot handle the private data for VP9. Do you have an example file you could send so we can implement it?');
|
|
50
|
+
}
|
|
51
|
+
return 'vp09.00.10.08';
|
|
52
|
+
}
|
|
53
|
+
if (codec.value === 'V_MPEG4/ISO/AVC') {
|
|
54
|
+
const priv = (0, traversal_1.getPrivateData)(track);
|
|
55
|
+
if (priv) {
|
|
56
|
+
return `avc1.${priv[1].toString(16).padStart(2, '0')}${priv[2].toString(16).padStart(2, '0')}${priv[3].toString(16).padStart(2, '0')}`;
|
|
57
|
+
}
|
|
58
|
+
throw new Error('Could not find a CodecPrivate field in TrackEntry');
|
|
59
|
+
}
|
|
60
|
+
if (codec.value === 'V_AV1') {
|
|
61
|
+
const priv = (0, traversal_1.getPrivateData)(track);
|
|
62
|
+
if (!priv) {
|
|
63
|
+
throw new Error('Expected private data in AV1 track');
|
|
64
|
+
}
|
|
65
|
+
return (0, av1_codec_private_1.parseAv1PrivateData)(priv, null);
|
|
66
|
+
}
|
|
67
|
+
if (codec.value === 'V_MPEGH/ISO/HEVC') {
|
|
68
|
+
const priv = (0, traversal_1.getPrivateData)(track);
|
|
69
|
+
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(priv, priv.length);
|
|
70
|
+
return 'hvc1.' + (0, make_hvc1_codec_strings_1.getHvc1CodecString)(iterator);
|
|
71
|
+
}
|
|
72
|
+
throw new Error(`Unknown codec: ${codec.value}`);
|
|
73
|
+
};
|
|
74
|
+
const getMatroskaAudioCodecWithoutConfigString = ({ track, }) => {
|
|
75
|
+
const codec = (0, traversal_1.getCodecSegment)(track);
|
|
76
|
+
if (!codec) {
|
|
77
|
+
throw new Error('Expected codec segment');
|
|
78
|
+
}
|
|
79
|
+
if (codec.value === 'A_OPUS') {
|
|
80
|
+
return 'opus';
|
|
81
|
+
}
|
|
82
|
+
if (codec.value === 'A_VORBIS') {
|
|
83
|
+
return 'vorbis';
|
|
84
|
+
}
|
|
85
|
+
if (codec.value === 'A_PCM/INT/LIT') {
|
|
86
|
+
// https://github.com/ietf-wg-cellar/matroska-specification/issues/142#issuecomment-330004950
|
|
87
|
+
// Audio samples MUST be considered as signed values, except if the audio bit depth is 8 which MUST be interpreted as unsigned values.
|
|
88
|
+
const bitDepth = (0, traversal_1.getBitDepth)(track);
|
|
89
|
+
if (bitDepth === null) {
|
|
90
|
+
throw new Error('Expected bit depth');
|
|
91
|
+
}
|
|
92
|
+
if (bitDepth === 8) {
|
|
93
|
+
return 'pcm-u8';
|
|
94
|
+
}
|
|
95
|
+
if (bitDepth === 16) {
|
|
96
|
+
return 'pcm-s16';
|
|
97
|
+
}
|
|
98
|
+
if (bitDepth === 24) {
|
|
99
|
+
return 'pcm-s24';
|
|
100
|
+
}
|
|
101
|
+
throw new Error('Unknown audio format');
|
|
102
|
+
}
|
|
103
|
+
if (codec.value === 'A_AAC') {
|
|
104
|
+
return `aac`;
|
|
105
|
+
}
|
|
106
|
+
if (codec.value === 'A_MPEG/L3') {
|
|
107
|
+
return 'mp3';
|
|
108
|
+
}
|
|
109
|
+
throw new Error(`Unknown codec: ${codec.value}`);
|
|
110
|
+
};
|
|
111
|
+
exports.getMatroskaAudioCodecWithoutConfigString = getMatroskaAudioCodecWithoutConfigString;
|
|
112
|
+
const getMatroskaAudioCodecString = (track) => {
|
|
113
|
+
const codec = (0, traversal_1.getCodecSegment)(track);
|
|
114
|
+
if (!codec) {
|
|
115
|
+
throw new Error('Expected codec segment');
|
|
116
|
+
}
|
|
117
|
+
if (codec.value === 'A_OPUS') {
|
|
118
|
+
return 'opus';
|
|
119
|
+
}
|
|
120
|
+
if (codec.value === 'A_VORBIS') {
|
|
121
|
+
return 'vorbis';
|
|
122
|
+
}
|
|
123
|
+
if (codec.value === 'A_PCM/INT/LIT') {
|
|
124
|
+
// https://github.com/ietf-wg-cellar/matroska-specification/issues/142#issuecomment-330004950
|
|
125
|
+
// Audio samples MUST be considered as signed values, except if the audio bit depth is 8 which MUST be interpreted as unsigned values.
|
|
126
|
+
const bitDepth = (0, traversal_1.getBitDepth)(track);
|
|
127
|
+
if (bitDepth === null) {
|
|
128
|
+
throw new Error('Expected bit depth');
|
|
129
|
+
}
|
|
130
|
+
if (bitDepth === 8) {
|
|
131
|
+
return 'pcm-u8';
|
|
132
|
+
}
|
|
133
|
+
return 'pcm-s' + bitDepth;
|
|
134
|
+
}
|
|
135
|
+
if (codec.value === 'A_AAC') {
|
|
136
|
+
const priv = (0, traversal_1.getPrivateData)(track);
|
|
137
|
+
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(priv, priv.length);
|
|
138
|
+
iterator.startReadingBits();
|
|
139
|
+
/**
|
|
140
|
+
* ChatGPT
|
|
141
|
+
* ▪ The first 5 bits represent the AOT.
|
|
142
|
+
▪ Common values:
|
|
143
|
+
◦ 1 for AAC Main
|
|
144
|
+
◦ 2 for AAC LC (Low Complexity)
|
|
145
|
+
◦ 3 for AAC SSR (Scalable Sample Rate)
|
|
146
|
+
◦ 4 for AAC LTP (Long Term Prediction)
|
|
147
|
+
◦ 5 for SBR (Spectral Band Replication)
|
|
148
|
+
◦ 29 for HE-AAC (which uses SBR with AAC LC)
|
|
149
|
+
*/
|
|
150
|
+
/**
|
|
151
|
+
* Fully qualified codec:
|
|
152
|
+
* This codec has multiple possible codec strings:
|
|
153
|
+
"mp4a.40.2" — MPEG-4 AAC LC
|
|
154
|
+
"mp4a.40.02" — MPEG-4 AAC LC, leading 0 for Aud-OTI compatibility
|
|
155
|
+
"mp4a.40.5" — MPEG-4 HE-AAC v1 (AAC LC + SBR)
|
|
156
|
+
"mp4a.40.05" — MPEG-4 HE-AAC v1 (AAC LC + SBR), leading 0 for Aud-OTI compatibility
|
|
157
|
+
"mp4a.40.29" — MPEG-4 HE-AAC v2 (AAC LC + SBR + PS)
|
|
158
|
+
"mp4a.67" — MPEG-2 AAC LC
|
|
159
|
+
*/
|
|
160
|
+
const profile = iterator.getBits(5);
|
|
161
|
+
iterator.stopReadingBits();
|
|
162
|
+
iterator.destroy();
|
|
163
|
+
return `mp4a.40.${profile.toString().padStart(2, '0')}`;
|
|
164
|
+
}
|
|
165
|
+
if (codec.value === 'A_MPEG/L3') {
|
|
166
|
+
return 'mp3';
|
|
167
|
+
}
|
|
168
|
+
throw new Error(`Unknown codec: ${codec.value}`);
|
|
169
|
+
};
|
|
170
|
+
const getTrack = ({ timescale, track, }) => {
|
|
171
|
+
const trackType = (0, traversal_1.getTrackTypeSegment)(track);
|
|
172
|
+
if (!trackType) {
|
|
173
|
+
throw new Error('Expected track type segment');
|
|
174
|
+
}
|
|
175
|
+
const trackId = (0, traversal_1.getTrackId)(track);
|
|
176
|
+
if ((0, track_entry_1.trackTypeToString)(trackType.value.value) === 'video') {
|
|
177
|
+
const width = (0, traversal_1.getWidthSegment)(track);
|
|
178
|
+
if (width === null) {
|
|
179
|
+
throw new Error('Expected width segment');
|
|
180
|
+
}
|
|
181
|
+
const height = (0, traversal_1.getHeightSegment)(track);
|
|
182
|
+
if (height === null) {
|
|
183
|
+
throw new Error('Expected height segment');
|
|
184
|
+
}
|
|
185
|
+
const displayHeight = (0, traversal_1.getDisplayHeightSegment)(track);
|
|
186
|
+
const displayWidth = (0, traversal_1.getDisplayWidthSegment)(track);
|
|
187
|
+
const codec = (0, traversal_1.getCodecSegment)(track);
|
|
188
|
+
if (!codec) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const codecPrivate = (0, traversal_1.getPrivateData)(track);
|
|
192
|
+
const codecString = getMatroskaVideoCodecString({
|
|
193
|
+
track,
|
|
194
|
+
codecSegment: codec,
|
|
195
|
+
});
|
|
196
|
+
const colour = (0, traversal_1.getColourSegment)(track);
|
|
197
|
+
if (!codecString) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
type: 'video',
|
|
202
|
+
trackId,
|
|
203
|
+
codec: codecString,
|
|
204
|
+
description: getDescription(track),
|
|
205
|
+
height: displayHeight ? displayHeight.value.value : height.value.value,
|
|
206
|
+
width: displayWidth ? displayWidth.value.value : width.value.value,
|
|
207
|
+
sampleAspectRatio: {
|
|
208
|
+
numerator: 1,
|
|
209
|
+
denominator: 1,
|
|
210
|
+
},
|
|
211
|
+
timescale,
|
|
212
|
+
codedHeight: height.value.value,
|
|
213
|
+
codedWidth: width.value.value,
|
|
214
|
+
displayAspectHeight: displayHeight
|
|
215
|
+
? displayHeight.value.value
|
|
216
|
+
: height.value.value,
|
|
217
|
+
displayAspectWidth: displayWidth
|
|
218
|
+
? displayWidth.value.value
|
|
219
|
+
: width.value.value,
|
|
220
|
+
rotation: 0,
|
|
221
|
+
trakBox: null,
|
|
222
|
+
codecPrivate,
|
|
223
|
+
color: colour
|
|
224
|
+
? (0, color_1.parseColorSegment)(colour)
|
|
225
|
+
: {
|
|
226
|
+
fullRange: null,
|
|
227
|
+
matrixCoefficients: null,
|
|
228
|
+
primaries: null,
|
|
229
|
+
transferCharacteristics: null,
|
|
230
|
+
},
|
|
231
|
+
codecWithoutConfig: getMatroskaVideoCodecWithoutConfigString({
|
|
232
|
+
codecSegment: codec,
|
|
233
|
+
}),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
if ((0, track_entry_1.trackTypeToString)(trackType.value.value) === 'audio') {
|
|
237
|
+
const sampleRate = (0, traversal_1.getSampleRate)(track);
|
|
238
|
+
const numberOfChannels = (0, traversal_1.getNumberOfChannels)(track);
|
|
239
|
+
const codecPrivate = (0, traversal_1.getPrivateData)(track);
|
|
240
|
+
if (sampleRate === null) {
|
|
241
|
+
throw new Error('Could not find sample rate or number of channels');
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
type: 'audio',
|
|
245
|
+
trackId,
|
|
246
|
+
codec: getMatroskaAudioCodecString(track),
|
|
247
|
+
timescale,
|
|
248
|
+
numberOfChannels,
|
|
249
|
+
sampleRate,
|
|
250
|
+
description: (0, description_1.getAudioDescription)(track),
|
|
251
|
+
trakBox: null,
|
|
252
|
+
codecPrivate,
|
|
253
|
+
codecWithoutConfig: (0, exports.getMatroskaAudioCodecWithoutConfigString)({
|
|
254
|
+
track,
|
|
255
|
+
}),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
};
|
|
260
|
+
exports.getTrack = getTrack;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.postprocessEbml = exports.parseEbml = void 0;
|
|
4
4
|
const add_new_matroska_tracks_1 = require("../../add-new-matroska-tracks");
|
|
5
5
|
const get_sample_from_block_1 = require("./get-sample-from-block");
|
|
6
|
-
const
|
|
6
|
+
const make_track_1 = require("./make-track");
|
|
7
7
|
const all_segments_1 = require("./segments/all-segments");
|
|
8
8
|
const parseEbml = async (iterator, parserContext) => {
|
|
9
9
|
const hex = iterator.getMatroskaSegmentId();
|
|
@@ -110,7 +110,7 @@ const postprocessEbml = async ({ offset, ebml, parserContext, }) => {
|
|
|
110
110
|
}
|
|
111
111
|
if (ebml.type === 'TrackEntry') {
|
|
112
112
|
parserContext.parserState.onTrackEntrySegment(ebml);
|
|
113
|
-
const track = (0,
|
|
113
|
+
const track = (0, make_track_1.getTrack)({
|
|
114
114
|
track: ebml,
|
|
115
115
|
timescale: parserContext.parserState.getTimescale(),
|
|
116
116
|
});
|
|
@@ -456,11 +456,11 @@ export declare const color: {
|
|
|
456
456
|
readonly name: "Colour";
|
|
457
457
|
readonly type: "children";
|
|
458
458
|
};
|
|
459
|
-
export declare const
|
|
459
|
+
export declare const transferCharacteristics: {
|
|
460
460
|
readonly name: "TransferCharacteristics";
|
|
461
461
|
readonly type: "uint";
|
|
462
462
|
};
|
|
463
|
-
export declare const
|
|
463
|
+
export declare const matrixCoefficients: {
|
|
464
464
|
readonly name: "MatrixCoefficients";
|
|
465
465
|
readonly type: "uint";
|
|
466
466
|
};
|
|
@@ -561,6 +561,11 @@ export declare const cluster: {
|
|
|
561
561
|
readonly type: "children";
|
|
562
562
|
};
|
|
563
563
|
export type CodecIdSegment = EbmlParsed<typeof codecID>;
|
|
564
|
+
export type ColourSegment = EbmlParsed<typeof color>;
|
|
565
|
+
export type TransferCharacteristicsSegment = EbmlParsed<typeof transferCharacteristics>;
|
|
566
|
+
export type PrimariesSegment = EbmlParsed<typeof primaries>;
|
|
567
|
+
export type RangeSegment = EbmlParsed<typeof range>;
|
|
568
|
+
export type MatrixCoefficientsSegment = EbmlParsed<typeof matrixCoefficients>;
|
|
564
569
|
export type TrackTypeSegment = EbmlParsed<typeof trackType>;
|
|
565
570
|
export type WidthSegment = EbmlParsed<typeof widthType>;
|
|
566
571
|
export type HeightSegment = EbmlParsed<typeof heightType>;
|
|
@@ -636,7 +641,35 @@ export declare const ebmlMap: {
|
|
|
636
641
|
};
|
|
637
642
|
readonly "0x1c53bb6b": {
|
|
638
643
|
readonly name: "Cues";
|
|
639
|
-
readonly type: "
|
|
644
|
+
readonly type: "children";
|
|
645
|
+
};
|
|
646
|
+
readonly "0xbb": {
|
|
647
|
+
readonly name: "CuePoint";
|
|
648
|
+
readonly type: "children";
|
|
649
|
+
};
|
|
650
|
+
readonly "0xb3": {
|
|
651
|
+
readonly name: "CueTime";
|
|
652
|
+
readonly type: "uint";
|
|
653
|
+
};
|
|
654
|
+
readonly "0xb7": {
|
|
655
|
+
readonly name: "CueTrackPositions";
|
|
656
|
+
readonly type: "children";
|
|
657
|
+
};
|
|
658
|
+
readonly "0xf1": {
|
|
659
|
+
readonly name: "CueClusterPosition";
|
|
660
|
+
readonly type: "uint";
|
|
661
|
+
};
|
|
662
|
+
readonly "0xf0": {
|
|
663
|
+
readonly name: "CueRelativePosition";
|
|
664
|
+
readonly type: "uint";
|
|
665
|
+
};
|
|
666
|
+
readonly "0x5378": {
|
|
667
|
+
readonly name: "CueBlockNumber";
|
|
668
|
+
readonly type: "uint";
|
|
669
|
+
};
|
|
670
|
+
readonly "0xf7": {
|
|
671
|
+
readonly name: "CueTrack";
|
|
672
|
+
readonly type: "uint";
|
|
640
673
|
};
|
|
641
674
|
readonly "0x4461": {
|
|
642
675
|
readonly name: "DateUTC";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultDuration = exports.language = exports.ChromaSitingVert = exports.ChromaSitingHorz = exports.range = exports.primaries = exports.
|
|
3
|
+
exports.defaultDuration = exports.language = exports.ChromaSitingVert = exports.ChromaSitingHorz = exports.range = exports.primaries = exports.matrixCoefficients = exports.transferCharacteristics = 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
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',
|
|
@@ -439,11 +439,11 @@ exports.color = {
|
|
|
439
439
|
name: 'Colour',
|
|
440
440
|
type: 'children',
|
|
441
441
|
};
|
|
442
|
-
exports.
|
|
442
|
+
exports.transferCharacteristics = {
|
|
443
443
|
name: 'TransferCharacteristics',
|
|
444
444
|
type: 'uint',
|
|
445
445
|
};
|
|
446
|
-
exports.
|
|
446
|
+
exports.matrixCoefficients = {
|
|
447
447
|
name: 'MatrixCoefficients',
|
|
448
448
|
type: 'uint',
|
|
449
449
|
};
|
|
@@ -555,7 +555,35 @@ exports.ebmlMap = {
|
|
|
555
555
|
[exports.matroskaElements.Void]: voidEbml,
|
|
556
556
|
[exports.matroskaElements.Cues]: {
|
|
557
557
|
name: 'Cues',
|
|
558
|
-
type: '
|
|
558
|
+
type: 'children',
|
|
559
|
+
},
|
|
560
|
+
[exports.matroskaElements.CuePoint]: {
|
|
561
|
+
name: 'CuePoint',
|
|
562
|
+
type: 'children',
|
|
563
|
+
},
|
|
564
|
+
[exports.matroskaElements.CueTime]: {
|
|
565
|
+
name: 'CueTime',
|
|
566
|
+
type: 'uint',
|
|
567
|
+
},
|
|
568
|
+
[exports.matroskaElements.CueTrackPositions]: {
|
|
569
|
+
name: 'CueTrackPositions',
|
|
570
|
+
type: 'children',
|
|
571
|
+
},
|
|
572
|
+
[exports.matroskaElements.CueClusterPosition]: {
|
|
573
|
+
name: 'CueClusterPosition',
|
|
574
|
+
type: 'uint',
|
|
575
|
+
},
|
|
576
|
+
[exports.matroskaElements.CueRelativePosition]: {
|
|
577
|
+
name: 'CueRelativePosition',
|
|
578
|
+
type: 'uint',
|
|
579
|
+
},
|
|
580
|
+
[exports.matroskaElements.CueBlockNumber]: {
|
|
581
|
+
name: 'CueBlockNumber',
|
|
582
|
+
type: 'uint',
|
|
583
|
+
},
|
|
584
|
+
[exports.matroskaElements.CueTrack]: {
|
|
585
|
+
name: 'CueTrack',
|
|
586
|
+
type: 'uint',
|
|
559
587
|
},
|
|
560
588
|
[exports.matroskaElements.DateUTC]: {
|
|
561
589
|
name: 'DateUTC',
|
|
@@ -654,8 +682,8 @@ exports.ebmlMap = {
|
|
|
654
682
|
name: 'Cluster',
|
|
655
683
|
type: 'children',
|
|
656
684
|
},
|
|
657
|
-
[exports.matroskaElements.TransferCharacteristics]: exports.
|
|
658
|
-
[exports.matroskaElements.MatrixCoefficients]: exports.
|
|
685
|
+
[exports.matroskaElements.TransferCharacteristics]: exports.transferCharacteristics,
|
|
686
|
+
[exports.matroskaElements.MatrixCoefficients]: exports.matrixCoefficients,
|
|
659
687
|
[exports.matroskaElements.Primaries]: exports.primaries,
|
|
660
688
|
[exports.matroskaElements.Range]: exports.range,
|
|
661
689
|
[exports.matroskaElements.ChromaSitingHorz]: exports.ChromaSitingHorz,
|
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
import type { AnySegment } from '../../parse-result';
|
|
2
|
-
import type { CodecIdSegment, MainSegment, TrackEntry } from './segments/all-segments';
|
|
2
|
+
import type { AudioSegment, ClusterSegment, CodecIdSegment, ColourSegment, DisplayHeightSegment, DisplayWidthSegment, HeightSegment, MainSegment, MatrixCoefficientsSegment, PrimariesSegment, RangeSegment, TimestampScaleSegment, TrackEntry, TrackTypeSegment, TransferCharacteristicsSegment, VideoSegment, WidthSegment } from './segments/all-segments';
|
|
3
3
|
export declare const getMainSegment: (segments: AnySegment[]) => MainSegment | null;
|
|
4
4
|
export declare const getTrackNumber: (track: TrackEntry) => import("./segments/all-segments").UintWithSize | null;
|
|
5
5
|
export declare const getTrackCodec: (track: TrackEntry) => CodecIdSegment | null;
|
|
6
6
|
export declare const getTrackTimestampScale: (track: TrackEntry) => import("./segments/all-segments").FloatWithSize | null;
|
|
7
7
|
export declare const getTrackByNumber: (tracks: TrackEntry[], id: number) => TrackEntry | undefined;
|
|
8
|
+
export declare const getTrackId: (track: TrackEntry) => number;
|
|
9
|
+
export declare const getCodecSegment: (track: TrackEntry) => CodecIdSegment | null;
|
|
10
|
+
export declare const getColourSegment: (track: TrackEntry) => ColourSegment | null;
|
|
11
|
+
export declare const getTransferCharacteristicsSegment: (color: ColourSegment) => TransferCharacteristicsSegment | null;
|
|
12
|
+
export declare const getMatrixCoefficientsSegment: (color: ColourSegment) => MatrixCoefficientsSegment | null;
|
|
13
|
+
export declare const getPrimariesSegment: (color: ColourSegment) => PrimariesSegment | null;
|
|
14
|
+
export declare const getRangeSegment: (color: ColourSegment) => RangeSegment | null;
|
|
15
|
+
export declare const getDisplayHeightSegment: (track: TrackEntry) => DisplayHeightSegment | null;
|
|
16
|
+
export declare const getTrackTypeSegment: (track: TrackEntry) => TrackTypeSegment | null;
|
|
17
|
+
export declare const getWidthSegment: (track: TrackEntry) => WidthSegment | null;
|
|
18
|
+
export declare const getHeightSegment: (track: TrackEntry) => HeightSegment | null;
|
|
19
|
+
export declare const getDisplayWidthSegment: (track: TrackEntry) => DisplayWidthSegment | null;
|
|
20
|
+
export declare const getTracksSegment: (segment: MainSegment) => {
|
|
21
|
+
type: "Tracks";
|
|
22
|
+
value: import("./segments/all-segments").PossibleEbml[];
|
|
23
|
+
minVintWidth: number | null;
|
|
24
|
+
} | null;
|
|
25
|
+
export declare const getTimescaleSegment: (segment: MainSegment) => TimestampScaleSegment | null;
|
|
26
|
+
export declare const getVideoSegment: (track: TrackEntry) => VideoSegment | null;
|
|
27
|
+
export declare const getAudioSegment: (track: TrackEntry) => AudioSegment | null;
|
|
28
|
+
export declare const getSampleRate: (track: TrackEntry) => number | null;
|
|
29
|
+
export declare const getNumberOfChannels: (track: TrackEntry) => number;
|
|
30
|
+
export declare const getBitDepth: (track: TrackEntry) => number | null;
|
|
31
|
+
export declare const getPrivateData: (track: TrackEntry) => Uint8Array | null;
|
|
32
|
+
export declare const getClusterSegment: (segment: MainSegment) => ClusterSegment | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTrackByNumber = exports.getTrackTimestampScale = exports.getTrackCodec = exports.getTrackNumber = exports.getMainSegment = void 0;
|
|
3
|
+
exports.getClusterSegment = exports.getPrivateData = exports.getBitDepth = exports.getNumberOfChannels = exports.getSampleRate = exports.getAudioSegment = exports.getVideoSegment = exports.getTimescaleSegment = exports.getTracksSegment = exports.getDisplayWidthSegment = exports.getHeightSegment = exports.getWidthSegment = exports.getTrackTypeSegment = exports.getDisplayHeightSegment = exports.getRangeSegment = exports.getPrimariesSegment = exports.getMatrixCoefficientsSegment = exports.getTransferCharacteristicsSegment = exports.getColourSegment = exports.getCodecSegment = exports.getTrackId = exports.getTrackByNumber = exports.getTrackTimestampScale = exports.getTrackCodec = exports.getTrackNumber = exports.getMainSegment = void 0;
|
|
4
4
|
const getMainSegment = (segments) => {
|
|
5
5
|
return segments.find((s) => s.type === 'Segment');
|
|
6
6
|
};
|
|
@@ -34,3 +34,216 @@ const getTrackByNumber = (tracks, id) => {
|
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
exports.getTrackByNumber = getTrackByNumber;
|
|
37
|
+
const getTrackId = (track) => {
|
|
38
|
+
const trackId = track.value.find((b) => b.type === 'TrackNumber');
|
|
39
|
+
if (!trackId || trackId.type !== 'TrackNumber') {
|
|
40
|
+
throw new Error('Expected track number segment');
|
|
41
|
+
}
|
|
42
|
+
return trackId.value.value;
|
|
43
|
+
};
|
|
44
|
+
exports.getTrackId = getTrackId;
|
|
45
|
+
const getCodecSegment = (track) => {
|
|
46
|
+
const codec = track.value.find((b) => b.type === 'CodecID');
|
|
47
|
+
if (!codec || codec.type !== 'CodecID') {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return codec;
|
|
51
|
+
};
|
|
52
|
+
exports.getCodecSegment = getCodecSegment;
|
|
53
|
+
const getColourSegment = (track) => {
|
|
54
|
+
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
55
|
+
if (!videoSegment) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const colour = videoSegment.value.find((b) => b.type === 'Colour');
|
|
59
|
+
if (!colour || colour.type !== 'Colour') {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return colour;
|
|
63
|
+
};
|
|
64
|
+
exports.getColourSegment = getColourSegment;
|
|
65
|
+
const getTransferCharacteristicsSegment = (color) => {
|
|
66
|
+
if (!color || color.type !== 'Colour') {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const box = color.value.find((b) => b.type === 'TransferCharacteristics');
|
|
70
|
+
if (!box || box.type !== 'TransferCharacteristics') {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return box;
|
|
74
|
+
};
|
|
75
|
+
exports.getTransferCharacteristicsSegment = getTransferCharacteristicsSegment;
|
|
76
|
+
const getMatrixCoefficientsSegment = (color) => {
|
|
77
|
+
if (!color || color.type !== 'Colour') {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const box = color.value.find((b) => b.type === 'MatrixCoefficients');
|
|
81
|
+
if (!box || box.type !== 'MatrixCoefficients') {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return box;
|
|
85
|
+
};
|
|
86
|
+
exports.getMatrixCoefficientsSegment = getMatrixCoefficientsSegment;
|
|
87
|
+
const getPrimariesSegment = (color) => {
|
|
88
|
+
if (!color || color.type !== 'Colour') {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const box = color.value.find((b) => b.type === 'Primaries');
|
|
92
|
+
if (!box || box.type !== 'Primaries') {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return box;
|
|
96
|
+
};
|
|
97
|
+
exports.getPrimariesSegment = getPrimariesSegment;
|
|
98
|
+
const getRangeSegment = (color) => {
|
|
99
|
+
if (!color || color.type !== 'Colour') {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const box = color.value.find((b) => b.type === 'Range');
|
|
103
|
+
if (!box || box.type !== 'Range') {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return box;
|
|
107
|
+
};
|
|
108
|
+
exports.getRangeSegment = getRangeSegment;
|
|
109
|
+
const getDisplayHeightSegment = (track) => {
|
|
110
|
+
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
111
|
+
if (!videoSegment) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const displayHeight = videoSegment.value.find((b) => b.type === 'DisplayHeight');
|
|
115
|
+
if (!displayHeight || displayHeight.type !== 'DisplayHeight') {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return displayHeight;
|
|
119
|
+
};
|
|
120
|
+
exports.getDisplayHeightSegment = getDisplayHeightSegment;
|
|
121
|
+
const getTrackTypeSegment = (track) => {
|
|
122
|
+
const trackType = track.value.find((b) => b.type === 'TrackType');
|
|
123
|
+
if (!trackType || trackType.type !== 'TrackType') {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return trackType;
|
|
127
|
+
};
|
|
128
|
+
exports.getTrackTypeSegment = getTrackTypeSegment;
|
|
129
|
+
const getWidthSegment = (track) => {
|
|
130
|
+
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
131
|
+
if (!videoSegment) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const width = videoSegment.value.find((b) => b.type === 'PixelWidth');
|
|
135
|
+
if (!width || width.type !== 'PixelWidth') {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
return width;
|
|
139
|
+
};
|
|
140
|
+
exports.getWidthSegment = getWidthSegment;
|
|
141
|
+
const getHeightSegment = (track) => {
|
|
142
|
+
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
143
|
+
if (!videoSegment) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const height = videoSegment.value.find((b) => b.type === 'PixelHeight');
|
|
147
|
+
if (!height || height.type !== 'PixelHeight') {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return height;
|
|
151
|
+
};
|
|
152
|
+
exports.getHeightSegment = getHeightSegment;
|
|
153
|
+
const getDisplayWidthSegment = (track) => {
|
|
154
|
+
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
155
|
+
if (!videoSegment) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
const displayWidth = videoSegment.value.find((b) => b.type === 'DisplayWidth');
|
|
159
|
+
if (!displayWidth || displayWidth.type !== 'DisplayWidth') {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
return displayWidth;
|
|
163
|
+
};
|
|
164
|
+
exports.getDisplayWidthSegment = getDisplayWidthSegment;
|
|
165
|
+
const getTracksSegment = (segment) => {
|
|
166
|
+
const tracksSegment = segment.value.find((b) => b.type === 'Tracks');
|
|
167
|
+
if (!tracksSegment || tracksSegment.type !== 'Tracks') {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return tracksSegment;
|
|
171
|
+
};
|
|
172
|
+
exports.getTracksSegment = getTracksSegment;
|
|
173
|
+
const getTimescaleSegment = (segment) => {
|
|
174
|
+
const infoSegment = segment.value.find((b) => b.type === 'Info');
|
|
175
|
+
if (!infoSegment || infoSegment.type !== 'Info') {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const timescale = infoSegment.value.find((b) => b.type === 'TimestampScale');
|
|
179
|
+
if (!timescale || timescale.type !== 'TimestampScale') {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return timescale;
|
|
183
|
+
};
|
|
184
|
+
exports.getTimescaleSegment = getTimescaleSegment;
|
|
185
|
+
const getVideoSegment = (track) => {
|
|
186
|
+
const videoSegment = track.value.find((b) => b.type === 'Video');
|
|
187
|
+
if (!videoSegment || videoSegment.type !== 'Video') {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
return videoSegment !== null && videoSegment !== void 0 ? videoSegment : null;
|
|
191
|
+
};
|
|
192
|
+
exports.getVideoSegment = getVideoSegment;
|
|
193
|
+
const getAudioSegment = (track) => {
|
|
194
|
+
const audioSegment = track.value.find((b) => b.type === 'Audio');
|
|
195
|
+
if (!audioSegment || audioSegment.type !== 'Audio') {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return audioSegment !== null && audioSegment !== void 0 ? audioSegment : null;
|
|
199
|
+
};
|
|
200
|
+
exports.getAudioSegment = getAudioSegment;
|
|
201
|
+
const getSampleRate = (track) => {
|
|
202
|
+
const audioSegment = (0, exports.getAudioSegment)(track);
|
|
203
|
+
if (!audioSegment) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const samplingFrequency = audioSegment.value.find((b) => b.type === 'SamplingFrequency');
|
|
207
|
+
if (!samplingFrequency || samplingFrequency.type !== 'SamplingFrequency') {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
return samplingFrequency.value.value;
|
|
211
|
+
};
|
|
212
|
+
exports.getSampleRate = getSampleRate;
|
|
213
|
+
const getNumberOfChannels = (track) => {
|
|
214
|
+
const audioSegment = (0, exports.getAudioSegment)(track);
|
|
215
|
+
if (!audioSegment) {
|
|
216
|
+
throw new Error('Could not find audio segment');
|
|
217
|
+
}
|
|
218
|
+
const channels = audioSegment.value.find((b) => b.type === 'Channels');
|
|
219
|
+
if (!channels || channels.type !== 'Channels') {
|
|
220
|
+
return 1;
|
|
221
|
+
}
|
|
222
|
+
return channels.value.value;
|
|
223
|
+
};
|
|
224
|
+
exports.getNumberOfChannels = getNumberOfChannels;
|
|
225
|
+
const getBitDepth = (track) => {
|
|
226
|
+
const audioSegment = (0, exports.getAudioSegment)(track);
|
|
227
|
+
if (!audioSegment) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
const bitDepth = audioSegment.value.find((b) => b.type === 'BitDepth');
|
|
231
|
+
if (!bitDepth || bitDepth.type !== 'BitDepth') {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
return bitDepth.value.value;
|
|
235
|
+
};
|
|
236
|
+
exports.getBitDepth = getBitDepth;
|
|
237
|
+
const getPrivateData = (track) => {
|
|
238
|
+
const privateData = track.value.find((b) => b.type === 'CodecPrivate');
|
|
239
|
+
if (!privateData || privateData.type !== 'CodecPrivate') {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
return privateData.value;
|
|
243
|
+
};
|
|
244
|
+
exports.getPrivateData = getPrivateData;
|
|
245
|
+
const getClusterSegment = (segment) => {
|
|
246
|
+
const clusterSegment = segment.value.find((b) => b.type === 'Cluster');
|
|
247
|
+
return clusterSegment !== null && clusterSegment !== void 0 ? clusterSegment : null;
|
|
248
|
+
};
|
|
249
|
+
exports.getClusterSegment = getClusterSegment;
|
|
@@ -26,8 +26,6 @@ const makeSimpleBlock = ({ bytes, trackNumber, timecodeRelativeToCluster, keyfra
|
|
|
26
26
|
const headerByte = (Number(keyframe) << 7) | (Number(invisible) << 3) | (lacing << 1);
|
|
27
27
|
const body = (0, make_header_1.combineUint8Arrays)([
|
|
28
28
|
(0, ebml_1.getVariableInt)(trackNumber, null),
|
|
29
|
-
// TODO: Cannot encode long videos because of uint16 overflow
|
|
30
|
-
// need to make new cluster
|
|
31
29
|
(0, make_header_1.serializeUint16)(timecodeRelativeToCluster),
|
|
32
30
|
new Uint8Array([headerByte]),
|
|
33
31
|
bytes,
|