@remotion/media-parser 4.0.244 → 4.0.246
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/LICENSE.md +1 -1
- package/dist/boxes/avc/create-sps-pps-data.js +10 -4
- package/dist/boxes/iso-base-media/mdat/mdat.js +17 -5
- package/dist/boxes/iso-base-media/process-box.js +0 -3
- package/dist/boxes/iso-base-media/to-date.d.ts +0 -1
- package/dist/boxes/iso-base-media/to-date.js +1 -9
- package/dist/boxes/transport-stream/adts-header.d.ts +1 -1
- package/dist/boxes/transport-stream/discard-rest-of-packet.d.ts +1 -1
- package/dist/boxes/transport-stream/parse-stream-packet.js +4 -4
- package/dist/boxes/webm/color.d.ts +0 -1
- package/dist/boxes/webm/color.js +1 -83
- package/dist/boxes/webm/parse-ebml.js +8 -10
- package/dist/boxes/webm/segments/all-segments.d.ts +24 -21
- package/dist/boxes/webm/segments/all-segments.js +17 -19
- package/dist/combine-uint8-arrays.d.ts +1 -0
- package/dist/combine-uint8-arrays.js +23 -0
- package/dist/emit-available-info.js +1 -11
- package/dist/esm/index.mjs +7470 -9782
- package/dist/file-types/detect-file-type.js +2 -2
- package/dist/index.d.ts +787 -27
- package/dist/index.js +19 -13
- package/dist/parse-media.js +0 -3
- package/dist/state/parser-state.d.ts +1 -3
- package/dist/state/parser-state.js +1 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -15
- package/buffer.js +0 -2
- package/dist/boxes/avc/codec-private.d.ts +0 -2
- package/dist/boxes/avc/codec-private.js +0 -28
- package/dist/boxes/webm/ebml.d.ts +0 -2
- package/dist/boxes/webm/ebml.js +0 -94
- package/dist/boxes/webm/make-header.d.ts +0 -8
- package/dist/boxes/webm/make-header.js +0 -187
- package/dist/create/event-emitter.d.ts +0 -31
- package/dist/create/event-emitter.js +0 -25
- package/dist/create/iso-base-media/codec-specific/avc1.d.ts +0 -2
- package/dist/create/iso-base-media/codec-specific/avc1.js +0 -48
- package/dist/create/iso-base-media/codec-specific/create-codec-specific-data.d.ts +0 -22
- package/dist/create/iso-base-media/codec-specific/create-codec-specific-data.js +0 -36
- package/dist/create/iso-base-media/codec-specific/mp4a.d.ts +0 -2
- package/dist/create/iso-base-media/codec-specific/mp4a.js +0 -74
- package/dist/create/iso-base-media/create-colr.d.ts +0 -6
- package/dist/create/iso-base-media/create-colr.js +0 -26
- package/dist/create/iso-base-media/create-ftyp.d.ts +0 -10
- package/dist/create/iso-base-media/create-ftyp.js +0 -22
- package/dist/create/iso-base-media/create-ilst.d.ts +0 -1
- package/dist/create/iso-base-media/create-ilst.js +0 -14
- package/dist/create/iso-base-media/create-iso-base-media.d.ts +0 -2
- package/dist/create/iso-base-media/create-iso-base-media.js +0 -184
- package/dist/create/iso-base-media/create-mdia.d.ts +0 -5
- package/dist/create/iso-base-media/create-mdia.js +0 -18
- package/dist/create/iso-base-media/create-moov.d.ts +0 -5
- package/dist/create/iso-base-media/create-moov.js +0 -18
- package/dist/create/iso-base-media/create-mvhd.d.ts +0 -10
- package/dist/create/iso-base-media/create-mvhd.js +0 -48
- package/dist/create/iso-base-media/create-trak.d.ts +0 -4
- package/dist/create/iso-base-media/create-trak.js +0 -17
- package/dist/create/iso-base-media/create-udta.d.ts +0 -1
- package/dist/create/iso-base-media/create-udta.js +0 -14
- package/dist/create/iso-base-media/create-url.d.ts +0 -1
- package/dist/create/iso-base-media/create-url.js +0 -16
- package/dist/create/iso-base-media/example-stts.d.ts +0 -3
- package/dist/create/iso-base-media/example-stts.js +0 -2797
- package/dist/create/iso-base-media/ilst/create-cmt.d.ts +0 -1
- package/dist/create/iso-base-media/ilst/create-cmt.js +0 -26
- package/dist/create/iso-base-media/ilst/create-too.d.ts +0 -1
- package/dist/create/iso-base-media/ilst/create-too.js +0 -27
- package/dist/create/iso-base-media/mdia/create-mdhd.d.ts +0 -6
- package/dist/create/iso-base-media/mdia/create-mdhd.js +0 -33
- package/dist/create/iso-base-media/mp4-header.d.ts +0 -6
- package/dist/create/iso-base-media/mp4-header.js +0 -48
- package/dist/create/iso-base-media/primitives.d.ts +0 -15
- package/dist/create/iso-base-media/primitives.js +0 -133
- package/dist/create/iso-base-media/serialize-track.d.ts +0 -9
- package/dist/create/iso-base-media/serialize-track.js +0 -63
- package/dist/create/iso-base-media/trak/create-tkhd.d.ts +0 -27
- package/dist/create/iso-base-media/trak/create-tkhd.js +0 -97
- package/dist/create/iso-base-media/trak/mdia/create-minf.d.ts +0 -4
- package/dist/create/iso-base-media/trak/mdia/create-minf.js +0 -19
- package/dist/create/iso-base-media/trak/mdia/minf/create-dinf.d.ts +0 -1
- package/dist/create/iso-base-media/trak/mdia/minf/create-dinf.js +0 -22
- package/dist/create/iso-base-media/trak/mdia/minf/create-smhd.d.ts +0 -1
- package/dist/create/iso-base-media/trak/mdia/minf/create-smhd.js +0 -20
- package/dist/create/iso-base-media/trak/mdia/minf/create-stbl.d.ts +0 -6
- package/dist/create/iso-base-media/trak/mdia/minf/create-stbl.js +0 -41
- package/dist/create/iso-base-media/trak/mdia/minf/create-vmhd.d.ts +0 -1
- package/dist/create/iso-base-media/trak/mdia/minf/create-vmhd.js +0 -20
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.d.ts +0 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.js +0 -45
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stco.d.ts +0 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stco.js +0 -28
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.d.ts +0 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.js +0 -56
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stss.d.ts +0 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stss.js +0 -23
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.d.ts +0 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.js +0 -25
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stts.d.ts +0 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stts.js +0 -51
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avc1.d.ts +0 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avc1.js +0 -20
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avcc.d.ts +0 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avcc.js +0 -16
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-pasp.d.ts +0 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-pasp.js +0 -13
- package/dist/create/iso-base-media/udta/create-meta.d.ts +0 -4
- package/dist/create/iso-base-media/udta/create-meta.js +0 -20
- package/dist/create/iso-base-media/udta/meta/create-hdlr.d.ts +0 -1
- package/dist/create/iso-base-media/udta/meta/create-hdlr.js +0 -32
- package/dist/create/make-track-info.d.ts +0 -20
- package/dist/create/make-track-info.js +0 -2
- package/dist/create/matroska/cluster-segment.d.ts +0 -10
- package/dist/create/matroska/cluster-segment.js +0 -39
- package/dist/create/matroska/cluster.d.ts +0 -25
- package/dist/create/matroska/cluster.js +0 -77
- package/dist/create/matroska/create-matroska-media.d.ts +0 -2
- package/dist/create/matroska/create-matroska-media.js +0 -189
- package/dist/create/matroska/make-duration-with-padding.d.ts +0 -1
- package/dist/create/matroska/make-duration-with-padding.js +0 -15
- package/dist/create/matroska/matroska-cues.d.ts +0 -6
- package/dist/create/matroska/matroska-cues.js +0 -49
- package/dist/create/matroska/matroska-header.d.ts +0 -1
- package/dist/create/matroska/matroska-header.js +0 -66
- package/dist/create/matroska/matroska-info.d.ts +0 -3
- package/dist/create/matroska/matroska-info.js +0 -33
- package/dist/create/matroska/matroska-seek.d.ts +0 -6
- package/dist/create/matroska/matroska-seek.js +0 -32
- package/dist/create/matroska/matroska-segment.d.ts +0 -3
- package/dist/create/matroska/matroska-segment.js +0 -13
- package/dist/create/matroska/matroska-trackentry.d.ts +0 -10
- package/dist/create/matroska/matroska-trackentry.js +0 -249
- package/dist/create/media-fn.d.ts +0 -32
- package/dist/create/media-fn.js +0 -2
- package/dist/create/progress-tracker.d.ts +0 -9
- package/dist/create/progress-tracker.js +0 -67
- package/dist/create/timescale.d.ts +0 -1
- package/dist/create/timescale.js +0 -4
- package/dist/create/wav/create-wav.d.ts +0 -2
- package/dist/create/wav/create-wav.js +0 -110
- package/dist/create/with-resolvers.d.ts +0 -10
- package/dist/create/with-resolvers.js +0 -28
- package/dist/errors/detect-file-type.d.ts +0 -1
- package/dist/errors/detect-file-type.js +0 -88
- package/dist/errors/file-types.d.ts +0 -1
- package/dist/errors/file-types.js +0 -88
- package/dist/esm/buffer.mjs +0 -56
- package/dist/esm/web-fs.mjs +0 -73
- package/dist/file-types/get-jpeg-dimensions.d.ts +0 -4
- package/dist/file-types/get-jpeg-dimensions.js +0 -32
- package/dist/file-types.d.ts +0 -1
- package/dist/file-types.js +0 -88
- package/dist/parser-context.d.ts +0 -10
- package/dist/parser-context.js +0 -2
- package/dist/probing/detect-file-type.d.ts +0 -1
- package/dist/probing/detect-file-type.js +0 -88
- package/dist/probing/get-jpeg-dimensions.d.ts +0 -4
- package/dist/probing/get-jpeg-dimensions.js +0 -32
- package/dist/state/tracks-and-samples.d.ts +0 -0
- package/dist/state/tracks-and-samples.js +0 -1
- package/dist/writers/buffer-implementation/writer.d.ts +0 -2
- package/dist/writers/buffer-implementation/writer.js +0 -54
- package/dist/writers/buffer.d.ts +0 -2
- package/dist/writers/buffer.js +0 -7
- package/dist/writers/web-fs.d.ts +0 -3
- package/dist/writers/web-fs.js +0 -74
- package/dist/writers/writer.d.ts +0 -15
- package/dist/writers/writer.js +0 -2
- package/web-fs.js +0 -2
package/LICENSE.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSpsPpsData = void 0;
|
|
4
|
-
const
|
|
4
|
+
const combine_uint8_arrays_1 = require("../../combine-uint8-arrays");
|
|
5
|
+
function serializeUint16(value) {
|
|
6
|
+
const buffer = new ArrayBuffer(2);
|
|
7
|
+
const view = new DataView(buffer);
|
|
8
|
+
view.setUint16(0, value);
|
|
9
|
+
return new Uint8Array(buffer);
|
|
10
|
+
}
|
|
5
11
|
const createSpsPpsData = (avc1Profile) => {
|
|
6
|
-
return (0,
|
|
12
|
+
return (0, combine_uint8_arrays_1.combineUint8Arrays)([
|
|
7
13
|
new Uint8Array([
|
|
8
14
|
// https://gist.github.com/uupaa/8493378ec15f644a3d2b
|
|
9
15
|
1, // version
|
|
@@ -14,13 +20,13 @@ const createSpsPpsData = (avc1Profile) => {
|
|
|
14
20
|
0xe1,
|
|
15
21
|
]),
|
|
16
22
|
// sequence parameter set length
|
|
17
|
-
|
|
23
|
+
serializeUint16(avc1Profile.sps.sps.length),
|
|
18
24
|
// sequence parameter set
|
|
19
25
|
avc1Profile.sps.sps,
|
|
20
26
|
// num of PPS
|
|
21
27
|
new Uint8Array([0x01]),
|
|
22
28
|
// picture parameter set length
|
|
23
|
-
|
|
29
|
+
serializeUint16(avc1Profile.pps.pps.length),
|
|
24
30
|
// PPS
|
|
25
31
|
avc1Profile.pps.pps,
|
|
26
32
|
]);
|
|
@@ -77,7 +77,7 @@ const parseMdat = async ({ data, size, fileOffset, existingBoxes, state, signal,
|
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
79
|
const bytes = data.getSlice(samplesWithIndex.samplePosition.size);
|
|
80
|
-
const { cts, dts, duration } = samplesWithIndex.samplePosition;
|
|
80
|
+
const { cts, dts, duration, isKeyframe, offset } = samplesWithIndex.samplePosition;
|
|
81
81
|
if (samplesWithIndex.track.type === 'audio') {
|
|
82
82
|
await state.callbacks.onAudioSample(samplesWithIndex.track.trackId, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
83
83
|
data: bytes,
|
|
@@ -86,12 +86,24 @@ const parseMdat = async ({ data, size, fileOffset, existingBoxes, state, signal,
|
|
|
86
86
|
cts,
|
|
87
87
|
dts,
|
|
88
88
|
trackId: samplesWithIndex.track.trackId,
|
|
89
|
-
type:
|
|
90
|
-
offset
|
|
89
|
+
type: isKeyframe ? 'key' : 'delta',
|
|
90
|
+
offset,
|
|
91
91
|
timescale: samplesWithIndex.track.timescale,
|
|
92
92
|
}, samplesWithIndex.track.timescale));
|
|
93
93
|
}
|
|
94
94
|
if (samplesWithIndex.track.type === 'video') {
|
|
95
|
+
// https://remotion-assets.s3.eu-central-1.amazonaws.com/example-videos/sei_checkpoint.mp4
|
|
96
|
+
// Position in file 0x0001aba615
|
|
97
|
+
// https://github.com/remotion-dev/remotion/issues/4680
|
|
98
|
+
// In Chrome, we may not treat recovery points as keyframes
|
|
99
|
+
// otherwise "a keyframe is required after flushing"
|
|
100
|
+
const nalUnitType = bytes[4] & 0b00011111;
|
|
101
|
+
let isRecoveryPoint = false;
|
|
102
|
+
// SEI (Supplemental enhancement information)
|
|
103
|
+
if (nalUnitType === 6) {
|
|
104
|
+
const seiType = bytes[5];
|
|
105
|
+
isRecoveryPoint = seiType === 6;
|
|
106
|
+
}
|
|
95
107
|
await state.callbacks.onVideoSample(samplesWithIndex.track.trackId, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
96
108
|
data: bytes,
|
|
97
109
|
timestamp: cts,
|
|
@@ -99,8 +111,8 @@ const parseMdat = async ({ data, size, fileOffset, existingBoxes, state, signal,
|
|
|
99
111
|
cts,
|
|
100
112
|
dts,
|
|
101
113
|
trackId: samplesWithIndex.track.trackId,
|
|
102
|
-
type:
|
|
103
|
-
offset
|
|
114
|
+
type: isKeyframe && !isRecoveryPoint ? 'key' : 'delta',
|
|
115
|
+
offset,
|
|
104
116
|
timescale: samplesWithIndex.track.timescale,
|
|
105
117
|
}, samplesWithIndex.track.timescale));
|
|
106
118
|
}
|
|
@@ -612,9 +612,6 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
612
612
|
initialBoxes = initialBoxes.filter((b) => b.type !== 'mdat-box');
|
|
613
613
|
initialBoxes.push(result.box);
|
|
614
614
|
iterator.allowDiscard();
|
|
615
|
-
if (result.box.status !== 'samples-processed') {
|
|
616
|
-
throw new Error('unexpected');
|
|
617
|
-
}
|
|
618
615
|
break;
|
|
619
616
|
}
|
|
620
617
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toUnixTimestamp = void 0;
|
|
4
4
|
const toUnixTimestamp = (value) => {
|
|
5
5
|
if (value === 0) {
|
|
6
6
|
return null;
|
|
@@ -9,11 +9,3 @@ const toUnixTimestamp = (value) => {
|
|
|
9
9
|
return Math.floor(value + baseDate.getTime() / 1000) * 1000;
|
|
10
10
|
};
|
|
11
11
|
exports.toUnixTimestamp = toUnixTimestamp;
|
|
12
|
-
const fromUnixTimestamp = (value) => {
|
|
13
|
-
if (value === null) {
|
|
14
|
-
return 0;
|
|
15
|
-
}
|
|
16
|
-
const baseDate = new Date('1904-01-01T00:00:00Z');
|
|
17
|
-
return Math.floor(value / 1000 - baseDate.getTime() / 1000);
|
|
18
|
-
};
|
|
19
|
-
exports.fromUnixTimestamp = fromUnixTimestamp;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
2
|
export declare const discardRestOfPacket: (iterator: BufferIterator) => void;
|
|
3
|
-
export declare const getRestOfPacket: (iterator: BufferIterator) => Uint8Array
|
|
3
|
+
export declare const getRestOfPacket: (iterator: BufferIterator) => Uint8Array;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseStream = void 0;
|
|
4
|
-
const
|
|
4
|
+
const combine_uint8_arrays_1 = require("../../combine-uint8-arrays");
|
|
5
5
|
const adts_header_1 = require("./adts-header");
|
|
6
6
|
const discard_rest_of_packet_1 = require("./discard-rest-of-packet");
|
|
7
7
|
const find_separator_1 = require("./find-separator");
|
|
@@ -21,7 +21,7 @@ const parseAdtsStream = async ({ restOfPacket, transportStreamEntry, streamBuffe
|
|
|
21
21
|
const bytesToTake = expectedLength
|
|
22
22
|
? Math.min(restOfPacket.length, expectedLength - streamBuffer.buffer.byteLength)
|
|
23
23
|
: restOfPacket.length;
|
|
24
|
-
streamBuffer.buffer = (0,
|
|
24
|
+
streamBuffer.buffer = (0, combine_uint8_arrays_1.combineUint8Arrays)([
|
|
25
25
|
streamBuffer.buffer,
|
|
26
26
|
restOfPacket.slice(0, bytesToTake),
|
|
27
27
|
]);
|
|
@@ -45,7 +45,7 @@ const parseAvcStream = async ({ restOfPacket, transportStreamEntry, streamBuffer
|
|
|
45
45
|
const streamBuffer = streamBuffers.get(transportStreamEntry.pid);
|
|
46
46
|
if (indexOfSeparator === -1) {
|
|
47
47
|
if (streamBuffer) {
|
|
48
|
-
streamBuffer.buffer = (0,
|
|
48
|
+
streamBuffer.buffer = (0, combine_uint8_arrays_1.combineUint8Arrays)([
|
|
49
49
|
streamBuffer.buffer,
|
|
50
50
|
restOfPacket,
|
|
51
51
|
]);
|
|
@@ -60,7 +60,7 @@ const parseAvcStream = async ({ restOfPacket, transportStreamEntry, streamBuffer
|
|
|
60
60
|
}
|
|
61
61
|
if (streamBuffer) {
|
|
62
62
|
const packet = restOfPacket.slice(0, indexOfSeparator);
|
|
63
|
-
streamBuffer.buffer = (0,
|
|
63
|
+
streamBuffer.buffer = (0, combine_uint8_arrays_1.combineUint8Arrays)([streamBuffer.buffer, packet]);
|
|
64
64
|
await (0, process_stream_buffers_1.processStreamBuffer)({
|
|
65
65
|
state,
|
|
66
66
|
streamBuffer,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { VideoTrackColorParams } from '../../get-tracks';
|
|
2
2
|
import type { ColourSegment } from './segments/all-segments';
|
|
3
3
|
export declare const parseColorSegment: (colourSegment: ColourSegment) => VideoTrackColorParams;
|
|
4
|
-
export declare const makeMatroskaColorBytes: ({ transferCharacteristics, matrixCoefficients, primaries, fullRange, }: VideoTrackColorParams) => import("./segments/all-segments").BytesAndOffset;
|
package/dist/boxes/webm/color.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const truthy_1 = require("../../truthy");
|
|
5
|
-
const make_header_1 = require("./make-header");
|
|
3
|
+
exports.parseColorSegment = void 0;
|
|
6
4
|
const traversal_1 = require("./traversal");
|
|
7
5
|
const parseColorSegment = (colourSegment) => {
|
|
8
6
|
const transferCharacteristics = (0, traversal_1.getTransferCharacteristicsSegment)(colourSegment);
|
|
@@ -45,83 +43,3 @@ const parseColorSegment = (colourSegment) => {
|
|
|
45
43
|
};
|
|
46
44
|
};
|
|
47
45
|
exports.parseColorSegment = parseColorSegment;
|
|
48
|
-
const makeMatroskaColorBytes = ({ transferCharacteristics, matrixCoefficients, primaries, fullRange, }) => {
|
|
49
|
-
const rangeValue = transferCharacteristics && matrixCoefficients
|
|
50
|
-
? 3
|
|
51
|
-
: fullRange === true
|
|
52
|
-
? 2
|
|
53
|
-
: fullRange === false
|
|
54
|
-
? 1
|
|
55
|
-
: 0;
|
|
56
|
-
// https://datatracker.ietf.org/doc/draft-ietf-cellar-matroska/
|
|
57
|
-
// 5.1.4.1.28.27
|
|
58
|
-
const primariesValue = primaries === 'bt709'
|
|
59
|
-
? 1
|
|
60
|
-
: primaries === 'smpte170m'
|
|
61
|
-
? 6
|
|
62
|
-
: primaries === 'bt470bg'
|
|
63
|
-
? 5
|
|
64
|
-
: 2;
|
|
65
|
-
const transferChracteristicsValue = transferCharacteristics === 'bt709'
|
|
66
|
-
? 1
|
|
67
|
-
: transferCharacteristics === 'smpte170m'
|
|
68
|
-
? 6
|
|
69
|
-
: transferCharacteristics === 'iec61966-2-1'
|
|
70
|
-
? 13
|
|
71
|
-
: 2;
|
|
72
|
-
if (matrixCoefficients === 'rgb') {
|
|
73
|
-
throw new Error('Cannot encode Matroska in RGB');
|
|
74
|
-
}
|
|
75
|
-
const matrixCoefficientsValue = matrixCoefficients === 'bt709'
|
|
76
|
-
? 1
|
|
77
|
-
: matrixCoefficients === 'bt470bg'
|
|
78
|
-
? 5
|
|
79
|
-
: matrixCoefficients === 'smpte170m'
|
|
80
|
-
? 6
|
|
81
|
-
: 2;
|
|
82
|
-
return (0, make_header_1.makeMatroskaBytes)({
|
|
83
|
-
type: 'Colour',
|
|
84
|
-
minVintWidth: null,
|
|
85
|
-
value: [
|
|
86
|
-
transferChracteristicsValue === 2
|
|
87
|
-
? null
|
|
88
|
-
: {
|
|
89
|
-
type: 'TransferCharacteristics',
|
|
90
|
-
value: {
|
|
91
|
-
value: transferChracteristicsValue,
|
|
92
|
-
byteLength: null,
|
|
93
|
-
},
|
|
94
|
-
minVintWidth: null,
|
|
95
|
-
},
|
|
96
|
-
matrixCoefficientsValue === 2
|
|
97
|
-
? null
|
|
98
|
-
: {
|
|
99
|
-
type: 'MatrixCoefficients',
|
|
100
|
-
value: {
|
|
101
|
-
value: matrixCoefficientsValue,
|
|
102
|
-
byteLength: null,
|
|
103
|
-
},
|
|
104
|
-
minVintWidth: null,
|
|
105
|
-
},
|
|
106
|
-
primariesValue === 2
|
|
107
|
-
? null
|
|
108
|
-
: {
|
|
109
|
-
type: 'Primaries',
|
|
110
|
-
value: {
|
|
111
|
-
value: primariesValue,
|
|
112
|
-
byteLength: null,
|
|
113
|
-
},
|
|
114
|
-
minVintWidth: null,
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
type: 'Range',
|
|
118
|
-
value: {
|
|
119
|
-
value: rangeValue,
|
|
120
|
-
byteLength: null,
|
|
121
|
-
},
|
|
122
|
-
minVintWidth: null,
|
|
123
|
-
},
|
|
124
|
-
].filter(truthy_1.truthy),
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
exports.makeMatroskaColorBytes = makeMatroskaColorBytes;
|
|
@@ -128,7 +128,7 @@ const postprocessEbml = async ({ offset, ebml, state, }) => {
|
|
|
128
128
|
}
|
|
129
129
|
if (ebml.type === 'Block' || ebml.type === 'SimpleBlock') {
|
|
130
130
|
const sample = (0, get_sample_from_block_1.getSampleFromBlock)(ebml, state, offset);
|
|
131
|
-
if (sample.type === 'video-sample'
|
|
131
|
+
if (sample.type === 'video-sample') {
|
|
132
132
|
await state.callbacks.onVideoSample(sample.videoSample.trackId, sample.videoSample);
|
|
133
133
|
return {
|
|
134
134
|
type: 'Block',
|
|
@@ -136,7 +136,7 @@ const postprocessEbml = async ({ offset, ebml, state, }) => {
|
|
|
136
136
|
minVintWidth: ebml.minVintWidth,
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
if (sample.type === 'audio-sample'
|
|
139
|
+
if (sample.type === 'audio-sample') {
|
|
140
140
|
await state.callbacks.onAudioSample(sample.audioSample.trackId, sample.audioSample);
|
|
141
141
|
return {
|
|
142
142
|
type: 'Block',
|
|
@@ -144,7 +144,7 @@ const postprocessEbml = async ({ offset, ebml, state, }) => {
|
|
|
144
144
|
minVintWidth: ebml.minVintWidth,
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
if (sample.type === 'no-sample'
|
|
147
|
+
if (sample.type === 'no-sample') {
|
|
148
148
|
return {
|
|
149
149
|
type: 'Block',
|
|
150
150
|
value: new Uint8Array([]),
|
|
@@ -172,13 +172,11 @@ const postprocessEbml = async ({ offset, ebml, state, }) => {
|
|
|
172
172
|
};
|
|
173
173
|
await state.callbacks.onVideoSample(sample.partialVideoSample.trackId, completeFrame);
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
};
|
|
181
|
-
}
|
|
175
|
+
return {
|
|
176
|
+
type: 'BlockGroup',
|
|
177
|
+
value: [],
|
|
178
|
+
minVintWidth: ebml.minVintWidth,
|
|
179
|
+
};
|
|
182
180
|
}
|
|
183
181
|
return ebml;
|
|
184
182
|
};
|
|
@@ -274,7 +274,6 @@ export declare const knownIdsWithOneLength: string[];
|
|
|
274
274
|
export declare const knownIdsWithTwoLength: string[];
|
|
275
275
|
export declare const knownIdsWithThreeLength: string[];
|
|
276
276
|
export declare const getSegmentName: (id: string) => string | undefined;
|
|
277
|
-
export declare const getIdForName: (name: string) => EbmlMapKey;
|
|
278
277
|
export type MatroskaKey = keyof typeof matroskaElements;
|
|
279
278
|
export type MatroskaElement = (typeof matroskaElements)[MatroskaKey];
|
|
280
279
|
type EbmlType = 'string';
|
|
@@ -352,6 +351,14 @@ export declare const _name: {
|
|
|
352
351
|
readonly name: "Name";
|
|
353
352
|
readonly type: "string";
|
|
354
353
|
};
|
|
354
|
+
export declare const minCache: {
|
|
355
|
+
readonly name: "MinCache";
|
|
356
|
+
readonly type: "uint";
|
|
357
|
+
};
|
|
358
|
+
export declare const maxCache: {
|
|
359
|
+
readonly name: "MaxCache";
|
|
360
|
+
readonly type: "uint";
|
|
361
|
+
};
|
|
355
362
|
export declare const seekPosition: {
|
|
356
363
|
readonly name: "SeekPosition";
|
|
357
364
|
readonly type: "uint";
|
|
@@ -440,6 +447,10 @@ export declare const displayHeight: {
|
|
|
440
447
|
readonly name: "DisplayHeight";
|
|
441
448
|
readonly type: "uint";
|
|
442
449
|
};
|
|
450
|
+
export declare const displayUnit: {
|
|
451
|
+
readonly name: "DisplayUnit";
|
|
452
|
+
readonly type: "uint";
|
|
453
|
+
};
|
|
443
454
|
export declare const flagLacing: {
|
|
444
455
|
readonly name: "FlagLacing";
|
|
445
456
|
readonly type: "uint";
|
|
@@ -619,17 +630,11 @@ export type UintWithSize = {
|
|
|
619
630
|
byteLength: number | null;
|
|
620
631
|
};
|
|
621
632
|
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;
|
|
622
|
-
export type EbmlValueOrUint8Array<T extends Ebml> = Uint8Array | EbmlValue<T, PossibleEbmlOrUint8Array>;
|
|
623
633
|
export type EbmlParsed<T extends Ebml> = {
|
|
624
634
|
type: T['name'];
|
|
625
635
|
value: EbmlValue<T>;
|
|
626
636
|
minVintWidth: number | null;
|
|
627
637
|
};
|
|
628
|
-
export type EbmlParsedOrUint8Array<T extends Ebml> = {
|
|
629
|
-
type: T['name'];
|
|
630
|
-
value: EbmlValueOrUint8Array<T>;
|
|
631
|
-
minVintWidth: number | null;
|
|
632
|
-
};
|
|
633
638
|
export declare const ebmlMap: {
|
|
634
639
|
readonly "0x1a45dfa3": {
|
|
635
640
|
readonly name: "Header";
|
|
@@ -771,6 +776,14 @@ export declare const ebmlMap: {
|
|
|
771
776
|
readonly name: "Name";
|
|
772
777
|
readonly type: "string";
|
|
773
778
|
};
|
|
779
|
+
readonly "0x6de7": {
|
|
780
|
+
readonly name: "MinCache";
|
|
781
|
+
readonly type: "uint";
|
|
782
|
+
};
|
|
783
|
+
readonly "0x6df8": {
|
|
784
|
+
readonly name: "MaxCache";
|
|
785
|
+
readonly type: "uint";
|
|
786
|
+
};
|
|
774
787
|
readonly "0x53ac": {
|
|
775
788
|
readonly name: "SeekPosition";
|
|
776
789
|
readonly type: "uint";
|
|
@@ -851,6 +864,10 @@ export declare const ebmlMap: {
|
|
|
851
864
|
readonly name: "DisplayWidth";
|
|
852
865
|
readonly type: "uint";
|
|
853
866
|
};
|
|
867
|
+
readonly "0x54b2": {
|
|
868
|
+
readonly name: "DisplayUnit";
|
|
869
|
+
readonly type: "uint";
|
|
870
|
+
};
|
|
854
871
|
readonly "0x9c": {
|
|
855
872
|
readonly name: "FlagLacing";
|
|
856
873
|
readonly type: "uint";
|
|
@@ -975,18 +992,4 @@ export declare const ebmlMap: {
|
|
|
975
992
|
export type PossibleEbml = Prettify<{
|
|
976
993
|
[key in keyof typeof ebmlMap]: EbmlParsed<(typeof ebmlMap)[key]>;
|
|
977
994
|
}[keyof typeof ebmlMap]>;
|
|
978
|
-
export type OffsetAndChildren = {
|
|
979
|
-
offset: number;
|
|
980
|
-
children: OffsetAndChildren[];
|
|
981
|
-
field: keyof typeof matroskaElements;
|
|
982
|
-
};
|
|
983
|
-
export declare const incrementOffsetAndChildren: (offset: OffsetAndChildren, increment: number) => OffsetAndChildren;
|
|
984
|
-
export type BytesAndOffset = {
|
|
985
|
-
bytes: Uint8Array;
|
|
986
|
-
offsets: OffsetAndChildren;
|
|
987
|
-
};
|
|
988
|
-
export type PossibleEbmlOrUint8Array = Prettify<{
|
|
989
|
-
[key in keyof typeof ebmlMap]: EbmlParsedOrUint8Array<(typeof ebmlMap)[key]>;
|
|
990
|
-
}[keyof typeof ebmlMap]> | BytesAndOffset;
|
|
991
|
-
export type EbmlMapKey = keyof typeof ebmlMap;
|
|
992
995
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.range = exports.primaries = exports.matrixCoefficients = exports.transferCharacteristics = exports.color = exports.trackUID = exports.trackNumber = exports.tags = exports.tagSegment = exports.flagLacing = exports.displayUnit = exports.displayHeight = exports.displayWidth = exports.bitDepth = exports.interlaced = exports.alphaMode = exports.channels = exports.samplingFrequency = exports.tagTrackUidType = 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.maxCache = exports.minCache = exports._name = exports.seekId = exports.matroskaHeader = exports.docTypeReadVersion = exports.docTypeVersion = exports.docType = exports.ebmlMaxSizeLength = exports.ebmlMaxIdLength = exports.ebmlReadVersion = exports.ebmlVersion = exports.getSegmentName = exports.knownIdsWithThreeLength = exports.knownIdsWithTwoLength = exports.knownIdsWithOneLength = exports.matroskaElements = void 0;
|
|
4
|
+
exports.ebmlMap = exports.tagStringType = exports.tagNameType = exports.simpleTagType = exports.targetsType = exports.cluster = exports.segment = exports.blockGroup = exports.simpleBlock = exports.block = exports.timestampEntry = exports.tracks = exports.trackEntry = exports.trackTimestampScale = exports.codecName = exports.blockElement = exports.blockDurationSegment = exports.referenceBlock = exports.flagDefault = exports.videoSegment = exports.audioSegment = exports.maxBlockAdditionIdSegment = exports.blockAdditionsSegment = exports.codecPrivate = exports.defaultDuration = exports.language = exports.ChromaSitingVert = exports.ChromaSitingHorz = void 0;
|
|
5
5
|
exports.matroskaElements = {
|
|
6
6
|
Header: '0x1a45dfa3',
|
|
7
7
|
EBMLMaxIDLength: '0x42f2',
|
|
@@ -282,15 +282,6 @@ const getSegmentName = (id) => {
|
|
|
282
282
|
return (_a = Object.entries(exports.matroskaElements).find(([, value]) => value === id)) === null || _a === void 0 ? void 0 : _a[0];
|
|
283
283
|
};
|
|
284
284
|
exports.getSegmentName = getSegmentName;
|
|
285
|
-
const getIdForName = (name) => {
|
|
286
|
-
var _a;
|
|
287
|
-
const value = (_a = Object.entries(exports.matroskaElements).find(([key]) => key === name)) === null || _a === void 0 ? void 0 : _a[1];
|
|
288
|
-
if (!value) {
|
|
289
|
-
throw new Error(`Could not find id for name ${name}`);
|
|
290
|
-
}
|
|
291
|
-
return value;
|
|
292
|
-
};
|
|
293
|
-
exports.getIdForName = getIdForName;
|
|
294
285
|
exports.ebmlVersion = {
|
|
295
286
|
name: 'EBMLVersion',
|
|
296
287
|
type: 'uint',
|
|
@@ -335,6 +326,14 @@ exports._name = {
|
|
|
335
326
|
name: 'Name',
|
|
336
327
|
type: 'string',
|
|
337
328
|
};
|
|
329
|
+
exports.minCache = {
|
|
330
|
+
name: 'MinCache',
|
|
331
|
+
type: 'uint',
|
|
332
|
+
};
|
|
333
|
+
exports.maxCache = {
|
|
334
|
+
name: 'MaxCache',
|
|
335
|
+
type: 'uint',
|
|
336
|
+
};
|
|
338
337
|
exports.seekPosition = {
|
|
339
338
|
name: 'SeekPosition',
|
|
340
339
|
type: 'uint',
|
|
@@ -423,6 +422,10 @@ exports.displayHeight = {
|
|
|
423
422
|
name: 'DisplayHeight',
|
|
424
423
|
type: 'uint',
|
|
425
424
|
};
|
|
425
|
+
exports.displayUnit = {
|
|
426
|
+
name: 'DisplayUnit',
|
|
427
|
+
type: 'uint',
|
|
428
|
+
};
|
|
426
429
|
exports.flagLacing = {
|
|
427
430
|
name: 'FlagLacing',
|
|
428
431
|
type: 'uint',
|
|
@@ -652,6 +655,8 @@ exports.ebmlMap = {
|
|
|
652
655
|
[exports.matroskaElements.Seek]: exports.seek,
|
|
653
656
|
[exports.matroskaElements.SeekID]: exports.seekId,
|
|
654
657
|
[exports.matroskaElements.Name]: exports._name,
|
|
658
|
+
[exports.matroskaElements.MinCache]: exports.minCache,
|
|
659
|
+
[exports.matroskaElements.MaxCache]: exports.maxCache,
|
|
655
660
|
[exports.matroskaElements.SeekPosition]: exports.seekPosition,
|
|
656
661
|
[exports.matroskaElements.Crc32]: {
|
|
657
662
|
name: 'Crc32',
|
|
@@ -684,6 +689,7 @@ exports.ebmlMap = {
|
|
|
684
689
|
[exports.matroskaElements.BitDepth]: exports.bitDepth,
|
|
685
690
|
[exports.matroskaElements.DisplayHeight]: exports.displayHeight,
|
|
686
691
|
[exports.matroskaElements.DisplayWidth]: exports.displayWidth,
|
|
692
|
+
[exports.matroskaElements.DisplayUnit]: exports.displayUnit,
|
|
687
693
|
[exports.matroskaElements.FlagLacing]: exports.flagLacing,
|
|
688
694
|
[exports.matroskaElements.Tags]: exports.tags,
|
|
689
695
|
[exports.matroskaElements.Tag]: exports.tagSegment,
|
|
@@ -724,11 +730,3 @@ exports.ebmlMap = {
|
|
|
724
730
|
[exports.matroskaElements.ChromaSitingHorz]: exports.ChromaSitingHorz,
|
|
725
731
|
[exports.matroskaElements.ChromaSitingVert]: exports.ChromaSitingVert,
|
|
726
732
|
};
|
|
727
|
-
const incrementOffsetAndChildren = (offset, increment) => {
|
|
728
|
-
return {
|
|
729
|
-
offset: offset.offset + increment,
|
|
730
|
-
children: offset.children.map((c) => (0, exports.incrementOffsetAndChildren)(c, increment)),
|
|
731
|
-
field: offset.field,
|
|
732
|
-
};
|
|
733
|
-
};
|
|
734
|
-
exports.incrementOffsetAndChildren = incrementOffsetAndChildren;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const combineUint8Arrays: (arrays: Uint8Array[]) => Uint8Array;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.combineUint8Arrays = void 0;
|
|
4
|
+
const combineUint8Arrays = (arrays) => {
|
|
5
|
+
if (arrays.length === 0) {
|
|
6
|
+
return new Uint8Array([]);
|
|
7
|
+
}
|
|
8
|
+
if (arrays.length === 1) {
|
|
9
|
+
return arrays[0];
|
|
10
|
+
}
|
|
11
|
+
let totalLength = 0;
|
|
12
|
+
for (const array of arrays) {
|
|
13
|
+
totalLength += array.length;
|
|
14
|
+
}
|
|
15
|
+
const result = new Uint8Array(totalLength);
|
|
16
|
+
let offset = 0;
|
|
17
|
+
for (const array of arrays) {
|
|
18
|
+
result.set(array, offset);
|
|
19
|
+
offset += array.length;
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
exports.combineUint8Arrays = combineUint8Arrays;
|
|
@@ -41,16 +41,6 @@ const emitAvailableInfo = ({ hasInfo, parseResult, callbacks, state, returnValue
|
|
|
41
41
|
}
|
|
42
42
|
emittedFields.durationInSeconds = true;
|
|
43
43
|
}
|
|
44
|
-
if (!emittedFields.slowDurationInSeconds) {
|
|
45
|
-
const durationInSeconds = (0, get_duration_1.getDuration)(segments, state);
|
|
46
|
-
if (durationInSeconds !== null) {
|
|
47
|
-
(_c = callbacks.onSlowDurationInSeconds) === null || _c === void 0 ? void 0 : _c.call(callbacks, durationInSeconds);
|
|
48
|
-
if (fieldsInReturnValue.slowDurationInSeconds) {
|
|
49
|
-
returnValue.slowDurationInSeconds = durationInSeconds;
|
|
50
|
-
}
|
|
51
|
-
emittedFields.slowDurationInSeconds = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
44
|
}
|
|
55
45
|
continue;
|
|
56
46
|
}
|
|
@@ -59,7 +49,7 @@ const emitAvailableInfo = ({ hasInfo, parseResult, callbacks, state, returnValue
|
|
|
59
49
|
!emittedFields.slowDurationInSeconds &&
|
|
60
50
|
parseResult &&
|
|
61
51
|
segments) {
|
|
62
|
-
const slowDurationInSeconds = state.slowDurationAndFps.getSlowDurationInSeconds();
|
|
52
|
+
const slowDurationInSeconds = (_c = (0, get_duration_1.getDuration)(segments, state)) !== null && _c !== void 0 ? _c : state.slowDurationAndFps.getSlowDurationInSeconds();
|
|
63
53
|
(_d = callbacks.onSlowDurationInSeconds) === null || _d === void 0 ? void 0 : _d.call(callbacks, slowDurationInSeconds);
|
|
64
54
|
if (fieldsInReturnValue.slowDurationInSeconds) {
|
|
65
55
|
returnValue.slowDurationInSeconds = slowDurationInSeconds;
|