@remotion/media-parser 4.0.226 → 4.0.228
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/boxes/iso-base-media/mdat/mdat.js +0 -1
- package/dist/boxes/iso-base-media/process-box.js +1 -0
- package/dist/boxes/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/get-sample-from-block.js +1 -1
- package/dist/boxes/webm/make-header.js +1 -0
- package/dist/boxes/webm/parse-ebml.js +1 -1
- package/dist/boxes/webm/segments/parse-children.js +1 -0
- package/dist/buffer-iterator.js +1 -0
- package/dist/create/create-media.d.ts +5 -1
- package/dist/create/create-media.js +10 -5
- package/dist/esm/from-fetch.mjs +1 -1
- package/dist/esm/index.mjs +134 -90
- package/dist/esm/web-fs.mjs +7 -1
- package/dist/get-audio-codec.d.ts +1 -1
- package/dist/get-audio-codec.js +20 -20
- package/dist/get-container.js +1 -1
- package/dist/get-dimensions.js +1 -1
- package/dist/get-duration.js +1 -1
- package/dist/get-fps.js +1 -1
- package/dist/get-video-codec.d.ts +2 -2
- package/dist/get-video-codec.js +87 -87
- package/dist/index.d.ts +16 -2
- package/dist/index.js +2 -0
- package/dist/log.d.ts +10 -0
- package/dist/log.js +37 -0
- package/dist/options.d.ts +6 -3
- package/dist/parse-media.js +0 -1
- package/dist/readers/from-fetch.js +1 -1
- package/dist/writers/web-fs.js +7 -1
- package/eslint.config.mjs +7 -0
- package/package.json +6 -5
|
@@ -38,6 +38,7 @@ const getChildren = async ({ boxType, iterator, bytesRemainingInBox, options, li
|
|
|
38
38
|
boxType === 'traf' ||
|
|
39
39
|
boxType === 'stsb';
|
|
40
40
|
if (parseChildren) {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
41
42
|
const parsed = await (0, exports.parseBoxes)({
|
|
42
43
|
iterator,
|
|
43
44
|
maxBytes: bytesRemainingInBox,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const measureEBMLVarInt: (value: number) =>
|
|
1
|
+
export declare const measureEBMLVarInt: (value: number) => 1 | 2 | 5 | 3 | 6 | 4;
|
|
2
2
|
export declare const getVariableInt: (value: number, minWidth: number | null) => Uint8Array;
|
|
@@ -30,7 +30,7 @@ const getSampleFromBlock = (ebml, parserContext, offset) => {
|
|
|
30
30
|
if (!codec) {
|
|
31
31
|
throw new Error(`Could not find codec for track ${trackNumber}`);
|
|
32
32
|
}
|
|
33
|
-
const remainingNow = ebml.value.length -
|
|
33
|
+
const remainingNow = ebml.value.length - iterator.counter.getOffset();
|
|
34
34
|
if (codec.startsWith('V_')) {
|
|
35
35
|
const partialVideoSample = {
|
|
36
36
|
data: iterator.getSlice(remainingNow),
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.combineUint8Arrays = exports.padMatroskaBytes = exports.makeMatroskaBytes = exports.matroskaToHex = exports.webmPattern = void 0;
|
|
4
4
|
exports.serializeUint16 = serializeUint16;
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
5
6
|
const ebml_1 = require("./ebml");
|
|
6
7
|
const all_segments_1 = require("./segments/all-segments");
|
|
7
8
|
exports.webmPattern = new Uint8Array([0x1a, 0x45, 0xdf, 0xa3]);
|
|
@@ -77,13 +77,13 @@ const parseEbml = async (iterator, parserContext) => {
|
|
|
77
77
|
if (hasInMap.type === 'children') {
|
|
78
78
|
const children = [];
|
|
79
79
|
const startOffset = iterator.counter.getOffset();
|
|
80
|
-
// eslint-disable-next-line no-constant-condition
|
|
81
80
|
while (true) {
|
|
82
81
|
if (size === 0) {
|
|
83
82
|
break;
|
|
84
83
|
}
|
|
85
84
|
const offset = iterator.counter.getOffset();
|
|
86
85
|
const value = await (0, exports.parseEbml)(iterator, parserContext);
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
87
87
|
const remapped = await (0, exports.postprocessEbml)({
|
|
88
88
|
offset,
|
|
89
89
|
ebml: value,
|
|
@@ -51,6 +51,7 @@ const continueParsingfunction = ({ result, iterator, children, wrap, parserConte
|
|
|
51
51
|
segments: wrap ? [wrap(children)] : children,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
54
55
|
return (0, exports.expectChildren)({
|
|
55
56
|
iterator,
|
|
56
57
|
length: length - (iterator.counter.getOffset() - offset),
|
package/dist/buffer-iterator.js
CHANGED
|
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _OffsetCounter_offset, _OffsetCounter_discardedBytes;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getArrayBufferIterator = exports.OffsetCounter = void 0;
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
16
17
|
const make_header_1 = require("./boxes/webm/make-header");
|
|
17
18
|
const all_segments_1 = require("./boxes/webm/segments/all-segments");
|
|
18
19
|
class OffsetCounter {
|
|
@@ -12,4 +12,8 @@ export type MediaFn = {
|
|
|
12
12
|
addWaitForFinishPromise: (promise: () => Promise<void>) => void;
|
|
13
13
|
waitForFinish: () => Promise<void>;
|
|
14
14
|
};
|
|
15
|
-
export declare const createMedia: (writer
|
|
15
|
+
export declare const createMedia: ({ writer, onBytesProgress, onMillisecondsProgress, }: {
|
|
16
|
+
writer: WriterInterface;
|
|
17
|
+
onBytesProgress: (totalBytes: number) => void;
|
|
18
|
+
onMillisecondsProgress: (totalMilliseconds: number) => void;
|
|
19
|
+
}) => Promise<MediaFn>;
|
|
@@ -13,7 +13,7 @@ const matroska_seek_1 = require("./matroska-seek");
|
|
|
13
13
|
const matroska_segment_1 = require("./matroska-segment");
|
|
14
14
|
const matroska_trackentry_1 = require("./matroska-trackentry");
|
|
15
15
|
const timescale_1 = require("./timescale");
|
|
16
|
-
const createMedia = async (writer) => {
|
|
16
|
+
const createMedia = async ({ writer, onBytesProgress, onMillisecondsProgress, }) => {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
18
|
const header = (0, matroska_header_1.makeMatroskaHeader)();
|
|
19
19
|
const w = await writer.createContent();
|
|
@@ -59,11 +59,13 @@ const createMedia = async (writer) => {
|
|
|
59
59
|
const updateSeekWrite = async () => {
|
|
60
60
|
const updatedSeek = (0, matroska_seek_1.createMatroskaSeekHead)(seeks);
|
|
61
61
|
await w.updateDataAt(seekHeadOffset, (0, make_header_1.combineUint8Arrays)(updatedSeek.map((b) => b.bytes)));
|
|
62
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
62
63
|
};
|
|
63
64
|
const segmentOffset = w.getWrittenByteCount();
|
|
64
65
|
const updateSegmentSize = async (size) => {
|
|
65
66
|
const data = (0, ebml_1.getVariableInt)(size, matroska_segment_1.MATROSKA_SEGMENT_MIN_VINT_WIDTH);
|
|
66
67
|
await w.updateDataAt(segmentOffset + (0, make_header_1.matroskaToHex)(all_segments_1.matroskaElements.Segment).byteLength, data);
|
|
68
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
67
69
|
};
|
|
68
70
|
await w.write(matroskaSegment.bytes);
|
|
69
71
|
const clusterOffset = w.getWrittenByteCount();
|
|
@@ -85,6 +87,11 @@ const createMedia = async (writer) => {
|
|
|
85
87
|
currentCluster = await (0, cluster_1.makeCluster)(w, smallestProgress);
|
|
86
88
|
return { cluster: currentCluster, isNew: true, smallestProgress };
|
|
87
89
|
};
|
|
90
|
+
const updateDuration = async (newDuration) => {
|
|
91
|
+
const blocks = (0, make_duration_with_padding_1.makeDurationWithPadding)(newDuration);
|
|
92
|
+
await w.updateDataAt(durationOffset, blocks.bytes);
|
|
93
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
94
|
+
};
|
|
88
95
|
const addSample = async (chunk, trackNumber, isVideo) => {
|
|
89
96
|
var _a;
|
|
90
97
|
trackNumberProgresses[trackNumber] = chunk.timestamp;
|
|
@@ -104,10 +111,8 @@ const createMedia = async (writer) => {
|
|
|
104
111
|
trackNumber,
|
|
105
112
|
});
|
|
106
113
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const blocks = (0, make_duration_with_padding_1.makeDurationWithPadding)(newDuration);
|
|
110
|
-
await w.updateDataAt(durationOffset, blocks.bytes);
|
|
114
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
115
|
+
onMillisecondsProgress(newDuration);
|
|
111
116
|
};
|
|
112
117
|
const addTrack = async (track) => {
|
|
113
118
|
currentTracks.push(track);
|
package/dist/esm/from-fetch.mjs
CHANGED
|
@@ -55,7 +55,7 @@ var fetchReader = {
|
|
|
55
55
|
const parsedContentRange = contentRange ? parseContentRange(contentRange) : null;
|
|
56
56
|
const { supportsContentRange } = validateContentRangeAndDetectIfSupported(actualRange, parsedContentRange, res.status);
|
|
57
57
|
signal?.addEventListener("abort", () => {
|
|
58
|
-
controller.abort();
|
|
58
|
+
controller.abort(new Error("Aborted by user"));
|
|
59
59
|
}, { once: true });
|
|
60
60
|
if (res.status.toString().startsWith("4") || res.status.toString().startsWith("5")) {
|
|
61
61
|
throw new Error(`Server returned status code ${res.status} for ${src} and range ${actualRange}`);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -55,7 +55,7 @@ var fetchReader = {
|
|
|
55
55
|
const parsedContentRange = contentRange ? parseContentRange(contentRange) : null;
|
|
56
56
|
const { supportsContentRange } = validateContentRangeAndDetectIfSupported(actualRange, parsedContentRange, res.status);
|
|
57
57
|
signal?.addEventListener("abort", () => {
|
|
58
|
-
controller.abort();
|
|
58
|
+
controller.abort(new Error("Aborted by user"));
|
|
59
59
|
}, { once: true });
|
|
60
60
|
if (res.status.toString().startsWith("4") || res.status.toString().startsWith("5")) {
|
|
61
61
|
throw new Error(`Server returned status code ${res.status} for ${src} and range ${actualRange}`);
|
|
@@ -1815,7 +1815,11 @@ var makeMatroskaTracks = (tracks2) => {
|
|
|
1815
1815
|
};
|
|
1816
1816
|
|
|
1817
1817
|
// src/create/create-media.ts
|
|
1818
|
-
var createMedia = async (
|
|
1818
|
+
var createMedia = async ({
|
|
1819
|
+
writer,
|
|
1820
|
+
onBytesProgress,
|
|
1821
|
+
onMillisecondsProgress
|
|
1822
|
+
}) => {
|
|
1819
1823
|
const header = makeMatroskaHeader();
|
|
1820
1824
|
const w = await writer.createContent();
|
|
1821
1825
|
await w.write(header.bytes);
|
|
@@ -1859,11 +1863,13 @@ var createMedia = async (writer) => {
|
|
|
1859
1863
|
const updateSeekWrite = async () => {
|
|
1860
1864
|
const updatedSeek = createMatroskaSeekHead(seeks);
|
|
1861
1865
|
await w.updateDataAt(seekHeadOffset, combineUint8Arrays(updatedSeek.map((b) => b.bytes)));
|
|
1866
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
1862
1867
|
};
|
|
1863
1868
|
const segmentOffset = w.getWrittenByteCount();
|
|
1864
1869
|
const updateSegmentSize = async (size) => {
|
|
1865
1870
|
const data = getVariableInt(size, MATROSKA_SEGMENT_MIN_VINT_WIDTH);
|
|
1866
1871
|
await w.updateDataAt(segmentOffset + matroskaToHex(matroskaElements.Segment).byteLength, data);
|
|
1872
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
1867
1873
|
};
|
|
1868
1874
|
await w.write(matroskaSegment.bytes);
|
|
1869
1875
|
const clusterOffset = w.getWrittenByteCount();
|
|
@@ -1888,6 +1894,11 @@ var createMedia = async (writer) => {
|
|
|
1888
1894
|
currentCluster = await makeCluster(w, smallestProgress);
|
|
1889
1895
|
return { cluster: currentCluster, isNew: true, smallestProgress };
|
|
1890
1896
|
};
|
|
1897
|
+
const updateDuration = async (newDuration) => {
|
|
1898
|
+
const blocks = makeDurationWithPadding(newDuration);
|
|
1899
|
+
await w.updateDataAt(durationOffset, blocks.bytes);
|
|
1900
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
1901
|
+
};
|
|
1891
1902
|
const addSample = async (chunk, trackNumber2, isVideo) => {
|
|
1892
1903
|
trackNumberProgresses[trackNumber2] = chunk.timestamp;
|
|
1893
1904
|
const { cluster, isNew, smallestProgress } = await getClusterOrMakeNew({
|
|
@@ -1905,10 +1916,8 @@ var createMedia = async (writer) => {
|
|
|
1905
1916
|
trackNumber: trackNumber2
|
|
1906
1917
|
});
|
|
1907
1918
|
}
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
const blocks = makeDurationWithPadding(newDuration);
|
|
1911
|
-
await w.updateDataAt(durationOffset, blocks.bytes);
|
|
1919
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
1920
|
+
onMillisecondsProgress(newDuration);
|
|
1912
1921
|
};
|
|
1913
1922
|
const addTrack = async (track) => {
|
|
1914
1923
|
currentTracks.push(track);
|
|
@@ -1959,6 +1968,40 @@ var createMedia = async (writer) => {
|
|
|
1959
1968
|
};
|
|
1960
1969
|
};
|
|
1961
1970
|
|
|
1971
|
+
// src/log.ts
|
|
1972
|
+
var logLevels = ["trace", "verbose", "info", "warn", "error"];
|
|
1973
|
+
var getNumberForLogLevel = (level) => {
|
|
1974
|
+
return logLevels.indexOf(level);
|
|
1975
|
+
};
|
|
1976
|
+
var isEqualOrBelowLogLevel = (currentLevel, level) => {
|
|
1977
|
+
return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
|
|
1978
|
+
};
|
|
1979
|
+
var Log = {
|
|
1980
|
+
trace: (logLevel, ...args) => {
|
|
1981
|
+
if (isEqualOrBelowLogLevel(logLevel, "trace")) {
|
|
1982
|
+
return console.log(...args);
|
|
1983
|
+
}
|
|
1984
|
+
},
|
|
1985
|
+
verbose: (logLevel, ...args) => {
|
|
1986
|
+
if (isEqualOrBelowLogLevel(logLevel, "verbose")) {
|
|
1987
|
+
return console.log(...args);
|
|
1988
|
+
}
|
|
1989
|
+
},
|
|
1990
|
+
info: (logLevel, ...args) => {
|
|
1991
|
+
if (isEqualOrBelowLogLevel(logLevel, "info")) {
|
|
1992
|
+
return console.log(...args);
|
|
1993
|
+
}
|
|
1994
|
+
},
|
|
1995
|
+
warn: (logLevel, ...args) => {
|
|
1996
|
+
if (isEqualOrBelowLogLevel(logLevel, "warn")) {
|
|
1997
|
+
return console.warn(...args);
|
|
1998
|
+
}
|
|
1999
|
+
},
|
|
2000
|
+
error: (...args) => {
|
|
2001
|
+
return console.error(...args);
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
|
|
1962
2005
|
// src/boxes/iso-base-media/traversal.ts
|
|
1963
2006
|
var getMoovBox = (segments) => {
|
|
1964
2007
|
const moovBox = segments.find((s) => s.type === "moov-box");
|
|
@@ -2194,16 +2237,31 @@ var getFps = (segments) => {
|
|
|
2194
2237
|
var hasFps = (boxes) => {
|
|
2195
2238
|
try {
|
|
2196
2239
|
return getFps(boxes) !== null;
|
|
2197
|
-
} catch
|
|
2240
|
+
} catch {
|
|
2198
2241
|
return false;
|
|
2199
2242
|
}
|
|
2200
2243
|
};
|
|
2201
2244
|
|
|
2202
2245
|
// src/get-audio-codec.ts
|
|
2246
|
+
var getAudioCodec = (boxes, parserState) => {
|
|
2247
|
+
const tracks2 = getTracks(boxes, parserState);
|
|
2248
|
+
const allTracks = tracks2.audioTracks.length + tracks2.otherTracks.length + tracks2.videoTracks.length;
|
|
2249
|
+
if (allTracks === 0) {
|
|
2250
|
+
throw new Error("No tracks yet");
|
|
2251
|
+
}
|
|
2252
|
+
const audioTrack = tracks2.audioTracks[0];
|
|
2253
|
+
if (!audioTrack) {
|
|
2254
|
+
return null;
|
|
2255
|
+
}
|
|
2256
|
+
if (audioTrack.type === "audio") {
|
|
2257
|
+
return audioTrack.codecWithoutConfig;
|
|
2258
|
+
}
|
|
2259
|
+
return null;
|
|
2260
|
+
};
|
|
2203
2261
|
var hasAudioCodec = (boxes, state) => {
|
|
2204
2262
|
try {
|
|
2205
2263
|
return getAudioCodec(boxes, state) !== null;
|
|
2206
|
-
} catch
|
|
2264
|
+
} catch {
|
|
2207
2265
|
return false;
|
|
2208
2266
|
}
|
|
2209
2267
|
};
|
|
@@ -2342,21 +2400,6 @@ var getAudioCodecFromTrack = (track) => {
|
|
|
2342
2400
|
}
|
|
2343
2401
|
return getAudioCodecFromAudioCodecInfo(audioSample);
|
|
2344
2402
|
};
|
|
2345
|
-
var getAudioCodec = (boxes, parserState) => {
|
|
2346
|
-
const tracks2 = getTracks(boxes, parserState);
|
|
2347
|
-
const allTracks = tracks2.audioTracks.length + tracks2.otherTracks.length + tracks2.videoTracks.length;
|
|
2348
|
-
if (allTracks === 0) {
|
|
2349
|
-
throw new Error("No tracks yet");
|
|
2350
|
-
}
|
|
2351
|
-
const audioTrack = tracks2.audioTracks[0];
|
|
2352
|
-
if (!audioTrack) {
|
|
2353
|
-
return null;
|
|
2354
|
-
}
|
|
2355
|
-
if (audioTrack.type === "audio") {
|
|
2356
|
-
return audioTrack.codecWithoutConfig;
|
|
2357
|
-
}
|
|
2358
|
-
return null;
|
|
2359
|
-
};
|
|
2360
2403
|
|
|
2361
2404
|
// src/get-sample-aspect-ratio.ts
|
|
2362
2405
|
function gcd(a, b) {
|
|
@@ -2982,68 +3025,6 @@ var parseAv1PrivateData = (data, colrAtom) => {
|
|
|
2982
3025
|
};
|
|
2983
3026
|
|
|
2984
3027
|
// src/get-video-codec.ts
|
|
2985
|
-
var hasVideoCodec = (boxes) => {
|
|
2986
|
-
try {
|
|
2987
|
-
return getVideoCodec(boxes) !== null;
|
|
2988
|
-
} catch (e) {
|
|
2989
|
-
return false;
|
|
2990
|
-
}
|
|
2991
|
-
};
|
|
2992
|
-
var getVideoPrivateData = (trakBox) => {
|
|
2993
|
-
const videoSample = getStsdVideoConfig(trakBox);
|
|
2994
|
-
const avccBox = getAvccBox(trakBox);
|
|
2995
|
-
const hvccBox = getHvccBox(trakBox);
|
|
2996
|
-
const av1cBox = getAv1CBox(trakBox);
|
|
2997
|
-
if (!videoSample) {
|
|
2998
|
-
return null;
|
|
2999
|
-
}
|
|
3000
|
-
if (avccBox) {
|
|
3001
|
-
return avccBox.privateData;
|
|
3002
|
-
}
|
|
3003
|
-
if (hvccBox) {
|
|
3004
|
-
return hvccBox.privateData;
|
|
3005
|
-
}
|
|
3006
|
-
if (av1cBox) {
|
|
3007
|
-
return av1cBox.privateData;
|
|
3008
|
-
}
|
|
3009
|
-
return null;
|
|
3010
|
-
};
|
|
3011
|
-
var getIsoBmColrConfig = (trakBox) => {
|
|
3012
|
-
const videoSample = getStsdVideoConfig(trakBox);
|
|
3013
|
-
if (!videoSample) {
|
|
3014
|
-
return null;
|
|
3015
|
-
}
|
|
3016
|
-
const colrAtom = getColrBox(videoSample);
|
|
3017
|
-
if (!colrAtom) {
|
|
3018
|
-
return null;
|
|
3019
|
-
}
|
|
3020
|
-
return {
|
|
3021
|
-
fullRange: colrAtom.fullRangeFlag,
|
|
3022
|
-
matrixCoefficients: colrAtom.matrixIndex === 1 ? "bt709" : colrAtom.matrixIndex === 5 ? "bt470bg" : colrAtom.matrixIndex === 6 ? "smpte170m" : null,
|
|
3023
|
-
primaries: colrAtom.primaries === 1 ? "bt709" : colrAtom.primaries === 5 ? "bt470bg" : colrAtom.primaries === 6 ? "smpte170m" : null,
|
|
3024
|
-
transferCharacteristics: colrAtom.transfer === 1 ? "bt709" : colrAtom.transfer === 6 ? "smpte170m" : colrAtom.transfer === 13 ? "iec61966-2-1" : null
|
|
3025
|
-
};
|
|
3026
|
-
};
|
|
3027
|
-
var getVideoCodecString = (trakBox) => {
|
|
3028
|
-
const videoSample = getStsdVideoConfig(trakBox);
|
|
3029
|
-
const avccBox = getAvccBox(trakBox);
|
|
3030
|
-
const hvccBox = getHvccBox(trakBox);
|
|
3031
|
-
const av1cBox = getAv1CBox(trakBox);
|
|
3032
|
-
if (!videoSample) {
|
|
3033
|
-
return null;
|
|
3034
|
-
}
|
|
3035
|
-
if (avccBox) {
|
|
3036
|
-
return `${videoSample.format}.${avccBox.configurationString}`;
|
|
3037
|
-
}
|
|
3038
|
-
if (hvccBox) {
|
|
3039
|
-
return `${videoSample.format}.${hvccBox.configurationString}`;
|
|
3040
|
-
}
|
|
3041
|
-
if (av1cBox) {
|
|
3042
|
-
const colrAtom = getColrBox(videoSample);
|
|
3043
|
-
return parseAv1PrivateData(av1cBox.privateData, colrAtom);
|
|
3044
|
-
}
|
|
3045
|
-
return videoSample.format;
|
|
3046
|
-
};
|
|
3047
3028
|
var getVideoCodecFromIsoTrak = (trakBox) => {
|
|
3048
3029
|
const stsdBox = getStsdBox(trakBox);
|
|
3049
3030
|
if (stsdBox && stsdBox.type === "stsd-box") {
|
|
@@ -3126,6 +3107,68 @@ var getVideoCodec = (boxes) => {
|
|
|
3126
3107
|
}
|
|
3127
3108
|
return null;
|
|
3128
3109
|
};
|
|
3110
|
+
var hasVideoCodec = (boxes) => {
|
|
3111
|
+
try {
|
|
3112
|
+
return getVideoCodec(boxes) !== null;
|
|
3113
|
+
} catch {
|
|
3114
|
+
return false;
|
|
3115
|
+
}
|
|
3116
|
+
};
|
|
3117
|
+
var getVideoPrivateData = (trakBox) => {
|
|
3118
|
+
const videoSample = getStsdVideoConfig(trakBox);
|
|
3119
|
+
const avccBox = getAvccBox(trakBox);
|
|
3120
|
+
const hvccBox = getHvccBox(trakBox);
|
|
3121
|
+
const av1cBox = getAv1CBox(trakBox);
|
|
3122
|
+
if (!videoSample) {
|
|
3123
|
+
return null;
|
|
3124
|
+
}
|
|
3125
|
+
if (avccBox) {
|
|
3126
|
+
return avccBox.privateData;
|
|
3127
|
+
}
|
|
3128
|
+
if (hvccBox) {
|
|
3129
|
+
return hvccBox.privateData;
|
|
3130
|
+
}
|
|
3131
|
+
if (av1cBox) {
|
|
3132
|
+
return av1cBox.privateData;
|
|
3133
|
+
}
|
|
3134
|
+
return null;
|
|
3135
|
+
};
|
|
3136
|
+
var getIsoBmColrConfig = (trakBox) => {
|
|
3137
|
+
const videoSample = getStsdVideoConfig(trakBox);
|
|
3138
|
+
if (!videoSample) {
|
|
3139
|
+
return null;
|
|
3140
|
+
}
|
|
3141
|
+
const colrAtom = getColrBox(videoSample);
|
|
3142
|
+
if (!colrAtom) {
|
|
3143
|
+
return null;
|
|
3144
|
+
}
|
|
3145
|
+
return {
|
|
3146
|
+
fullRange: colrAtom.fullRangeFlag,
|
|
3147
|
+
matrixCoefficients: colrAtom.matrixIndex === 1 ? "bt709" : colrAtom.matrixIndex === 5 ? "bt470bg" : colrAtom.matrixIndex === 6 ? "smpte170m" : null,
|
|
3148
|
+
primaries: colrAtom.primaries === 1 ? "bt709" : colrAtom.primaries === 5 ? "bt470bg" : colrAtom.primaries === 6 ? "smpte170m" : null,
|
|
3149
|
+
transferCharacteristics: colrAtom.transfer === 1 ? "bt709" : colrAtom.transfer === 6 ? "smpte170m" : colrAtom.transfer === 13 ? "iec61966-2-1" : null
|
|
3150
|
+
};
|
|
3151
|
+
};
|
|
3152
|
+
var getVideoCodecString = (trakBox) => {
|
|
3153
|
+
const videoSample = getStsdVideoConfig(trakBox);
|
|
3154
|
+
const avccBox = getAvccBox(trakBox);
|
|
3155
|
+
const hvccBox = getHvccBox(trakBox);
|
|
3156
|
+
const av1cBox = getAv1CBox(trakBox);
|
|
3157
|
+
if (!videoSample) {
|
|
3158
|
+
return null;
|
|
3159
|
+
}
|
|
3160
|
+
if (avccBox) {
|
|
3161
|
+
return `${videoSample.format}.${avccBox.configurationString}`;
|
|
3162
|
+
}
|
|
3163
|
+
if (hvccBox) {
|
|
3164
|
+
return `${videoSample.format}.${hvccBox.configurationString}`;
|
|
3165
|
+
}
|
|
3166
|
+
if (av1cBox) {
|
|
3167
|
+
const colrAtom = getColrBox(videoSample);
|
|
3168
|
+
return parseAv1PrivateData(av1cBox.privateData, colrAtom);
|
|
3169
|
+
}
|
|
3170
|
+
return videoSample.format;
|
|
3171
|
+
};
|
|
3129
3172
|
|
|
3130
3173
|
// src/boxes/iso-base-media/make-track.ts
|
|
3131
3174
|
var makeBaseMediaTrack = (trakBox) => {
|
|
@@ -3673,7 +3716,7 @@ var getContainer = (segments) => {
|
|
|
3673
3716
|
var hasContainer = (boxes) => {
|
|
3674
3717
|
try {
|
|
3675
3718
|
return getContainer(boxes) !== null;
|
|
3676
|
-
} catch
|
|
3719
|
+
} catch {
|
|
3677
3720
|
return false;
|
|
3678
3721
|
}
|
|
3679
3722
|
};
|
|
@@ -3696,7 +3739,7 @@ var getDimensions = (boxes, state) => {
|
|
|
3696
3739
|
var hasDimensions = (boxes, state) => {
|
|
3697
3740
|
try {
|
|
3698
3741
|
return getDimensions(boxes, state) !== null;
|
|
3699
|
-
} catch
|
|
3742
|
+
} catch {
|
|
3700
3743
|
return false;
|
|
3701
3744
|
}
|
|
3702
3745
|
};
|
|
@@ -3929,7 +3972,7 @@ var hasDuration = (boxes, parserState) => {
|
|
|
3929
3972
|
try {
|
|
3930
3973
|
const duration2 = getDuration(boxes, parserState);
|
|
3931
3974
|
return getDuration(boxes, parserState) !== null && duration2 !== 0;
|
|
3932
|
-
} catch
|
|
3975
|
+
} catch {
|
|
3933
3976
|
return false;
|
|
3934
3977
|
}
|
|
3935
3978
|
};
|
|
@@ -6094,7 +6137,7 @@ var getSampleFromBlock = (ebml, parserContext, offset) => {
|
|
|
6094
6137
|
if (!codec) {
|
|
6095
6138
|
throw new Error(`Could not find codec for track ${trackNumber2}`);
|
|
6096
6139
|
}
|
|
6097
|
-
const remainingNow = ebml.value.length -
|
|
6140
|
+
const remainingNow = ebml.value.length - iterator.counter.getOffset();
|
|
6098
6141
|
if (codec.startsWith("V_")) {
|
|
6099
6142
|
const partialVideoSample = {
|
|
6100
6143
|
data: iterator.getSlice(remainingNow),
|
|
@@ -6818,7 +6861,8 @@ var parseMedia = async ({
|
|
|
6818
6861
|
};
|
|
6819
6862
|
// src/index.ts
|
|
6820
6863
|
var MediaParserInternals = {
|
|
6821
|
-
createMedia
|
|
6864
|
+
createMedia,
|
|
6865
|
+
Log
|
|
6822
6866
|
};
|
|
6823
6867
|
export {
|
|
6824
6868
|
parseMedia,
|
package/dist/esm/web-fs.mjs
CHANGED
|
@@ -30,7 +30,7 @@ var createContent = async () => {
|
|
|
30
30
|
save: async () => {
|
|
31
31
|
try {
|
|
32
32
|
await writable.close();
|
|
33
|
-
} catch
|
|
33
|
+
} catch {
|
|
34
34
|
}
|
|
35
35
|
const newHandle = await directoryHandle.getFileHandle(filename, {
|
|
36
36
|
create: true
|
|
@@ -54,6 +54,12 @@ var webFsWriter = {
|
|
|
54
54
|
createContent
|
|
55
55
|
};
|
|
56
56
|
var canUseWebFsWriter = async () => {
|
|
57
|
+
if (!("storage" in navigator)) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (!("getDirectory" in navigator.storage)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
57
63
|
const directoryHandle = await navigator.storage.getDirectory();
|
|
58
64
|
const fileHandle = await directoryHandle.getFileHandle("remotion-probe-web-fs-support", {
|
|
59
65
|
create: true
|
|
@@ -3,6 +3,7 @@ import type { TrakBox } from './boxes/iso-base-media/trak/trak';
|
|
|
3
3
|
import { type MediaParserAudioCodec } from './get-tracks';
|
|
4
4
|
import type { AnySegment } from './parse-result';
|
|
5
5
|
import type { ParserState } from './parser-state';
|
|
6
|
+
export declare const getAudioCodec: (boxes: AnySegment[], parserState: ParserState) => MediaParserAudioCodec | null;
|
|
6
7
|
export declare const hasAudioCodec: (boxes: AnySegment[], state: ParserState) => boolean;
|
|
7
8
|
type AudioCodecInfo = {
|
|
8
9
|
format: string;
|
|
@@ -19,5 +20,4 @@ export declare const getAudioCodecStringFromTrak: (trak: TrakBox) => {
|
|
|
19
20
|
description: Uint8Array | undefined;
|
|
20
21
|
};
|
|
21
22
|
export declare const getAudioCodecFromTrack: (track: TrakBox) => MediaParserAudioCodec;
|
|
22
|
-
export declare const getAudioCodec: (boxes: AnySegment[], parserState: ParserState) => MediaParserAudioCodec | null;
|
|
23
23
|
export {};
|
package/dist/get-audio-codec.js
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getAudioCodecFromTrack = exports.getAudioCodecStringFromTrak = exports.getAudioCodecFromIso = exports.getAudioCodecFromTrak = exports.getSampleRate = exports.getNumberOfChannelsFromTrak = exports.hasAudioCodec = exports.getAudioCodec = void 0;
|
|
4
4
|
const traversal_1 = require("./boxes/iso-base-media/traversal");
|
|
5
5
|
const get_fps_1 = require("./get-fps");
|
|
6
6
|
const get_tracks_1 = require("./get-tracks");
|
|
7
|
+
const getAudioCodec = (boxes, parserState) => {
|
|
8
|
+
const tracks = (0, get_tracks_1.getTracks)(boxes, parserState);
|
|
9
|
+
const allTracks = tracks.audioTracks.length +
|
|
10
|
+
tracks.otherTracks.length +
|
|
11
|
+
tracks.videoTracks.length;
|
|
12
|
+
if (allTracks === 0) {
|
|
13
|
+
throw new Error('No tracks yet');
|
|
14
|
+
}
|
|
15
|
+
const audioTrack = tracks.audioTracks[0];
|
|
16
|
+
if (!audioTrack) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (audioTrack.type === 'audio') {
|
|
20
|
+
return audioTrack.codecWithoutConfig;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
exports.getAudioCodec = getAudioCodec;
|
|
7
25
|
const hasAudioCodec = (boxes, state) => {
|
|
8
26
|
try {
|
|
9
27
|
return (0, exports.getAudioCodec)(boxes, state) !== null;
|
|
10
28
|
}
|
|
11
|
-
catch (
|
|
29
|
+
catch (_a) {
|
|
12
30
|
return false;
|
|
13
31
|
}
|
|
14
32
|
};
|
|
@@ -166,21 +184,3 @@ const getAudioCodecFromTrack = (track) => {
|
|
|
166
184
|
return getAudioCodecFromAudioCodecInfo(audioSample);
|
|
167
185
|
};
|
|
168
186
|
exports.getAudioCodecFromTrack = getAudioCodecFromTrack;
|
|
169
|
-
const getAudioCodec = (boxes, parserState) => {
|
|
170
|
-
const tracks = (0, get_tracks_1.getTracks)(boxes, parserState);
|
|
171
|
-
const allTracks = tracks.audioTracks.length +
|
|
172
|
-
tracks.otherTracks.length +
|
|
173
|
-
tracks.videoTracks.length;
|
|
174
|
-
if (allTracks === 0) {
|
|
175
|
-
throw new Error('No tracks yet');
|
|
176
|
-
}
|
|
177
|
-
const audioTrack = tracks.audioTracks[0];
|
|
178
|
-
if (!audioTrack) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
if (audioTrack.type === 'audio') {
|
|
182
|
-
return audioTrack.codecWithoutConfig;
|
|
183
|
-
}
|
|
184
|
-
return null;
|
|
185
|
-
};
|
|
186
|
-
exports.getAudioCodec = getAudioCodec;
|
package/dist/get-container.js
CHANGED
package/dist/get-dimensions.js
CHANGED
package/dist/get-duration.js
CHANGED
|
@@ -69,7 +69,7 @@ const hasDuration = (boxes, parserState) => {
|
|
|
69
69
|
const duration = (0, exports.getDuration)(boxes, parserState);
|
|
70
70
|
return (0, exports.getDuration)(boxes, parserState) !== null && duration !== 0;
|
|
71
71
|
}
|
|
72
|
-
catch (
|
|
72
|
+
catch (_a) {
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
};
|
package/dist/get-fps.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TrakBox } from './boxes/iso-base-media/trak/trak';
|
|
2
2
|
import type { MediaParserVideoCodec, VideoTrackColorParams } from './get-tracks';
|
|
3
3
|
import type { AnySegment } from './parse-result';
|
|
4
|
+
export declare const getVideoCodecFromIsoTrak: (trakBox: TrakBox) => "h264" | "av1" | "h265" | "prores";
|
|
5
|
+
export declare const getVideoCodec: (boxes: AnySegment[]) => MediaParserVideoCodec | null;
|
|
4
6
|
export declare const hasVideoCodec: (boxes: AnySegment[]) => boolean;
|
|
5
7
|
export declare const getVideoPrivateData: (trakBox: TrakBox) => Uint8Array | null;
|
|
6
8
|
export declare const getIsoBmColrConfig: (trakBox: TrakBox) => VideoTrackColorParams | null;
|
|
7
9
|
export declare const getVideoCodecString: (trakBox: TrakBox) => string | null;
|
|
8
|
-
export declare const getVideoCodecFromIsoTrak: (trakBox: TrakBox) => "h264" | "av1" | "h265" | "prores";
|
|
9
|
-
export declare const getVideoCodec: (boxes: AnySegment[]) => MediaParserVideoCodec | null;
|
package/dist/get-video-codec.js
CHANGED
|
@@ -1,96 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getVideoCodecString = exports.getIsoBmColrConfig = exports.getVideoPrivateData = exports.hasVideoCodec = exports.getVideoCodec = exports.getVideoCodecFromIsoTrak = void 0;
|
|
4
4
|
const traversal_1 = require("./boxes/iso-base-media/traversal");
|
|
5
5
|
const av1_codec_private_1 = require("./boxes/webm/av1-codec-private");
|
|
6
6
|
const get_fps_1 = require("./get-fps");
|
|
7
7
|
const get_sample_aspect_ratio_1 = require("./get-sample-aspect-ratio");
|
|
8
|
-
const hasVideoCodec = (boxes) => {
|
|
9
|
-
try {
|
|
10
|
-
return (0, exports.getVideoCodec)(boxes) !== null;
|
|
11
|
-
}
|
|
12
|
-
catch (e) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
exports.hasVideoCodec = hasVideoCodec;
|
|
17
|
-
const getVideoPrivateData = (trakBox) => {
|
|
18
|
-
const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
|
|
19
|
-
const avccBox = (0, get_sample_aspect_ratio_1.getAvccBox)(trakBox);
|
|
20
|
-
const hvccBox = (0, get_sample_aspect_ratio_1.getHvccBox)(trakBox);
|
|
21
|
-
const av1cBox = (0, get_sample_aspect_ratio_1.getAv1CBox)(trakBox);
|
|
22
|
-
if (!videoSample) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
if (avccBox) {
|
|
26
|
-
return avccBox.privateData;
|
|
27
|
-
}
|
|
28
|
-
if (hvccBox) {
|
|
29
|
-
return hvccBox.privateData;
|
|
30
|
-
}
|
|
31
|
-
if (av1cBox) {
|
|
32
|
-
return av1cBox.privateData;
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
};
|
|
36
|
-
exports.getVideoPrivateData = getVideoPrivateData;
|
|
37
|
-
const getIsoBmColrConfig = (trakBox) => {
|
|
38
|
-
const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
|
|
39
|
-
if (!videoSample) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
const colrAtom = (0, get_sample_aspect_ratio_1.getColrBox)(videoSample);
|
|
43
|
-
if (!colrAtom) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
// https://github.com/bbc/qtff-parameter-editor
|
|
47
|
-
return {
|
|
48
|
-
fullRange: colrAtom.fullRangeFlag,
|
|
49
|
-
matrixCoefficients: colrAtom.matrixIndex === 1
|
|
50
|
-
? 'bt709'
|
|
51
|
-
: colrAtom.matrixIndex === 5
|
|
52
|
-
? 'bt470bg'
|
|
53
|
-
: colrAtom.matrixIndex === 6
|
|
54
|
-
? 'smpte170m'
|
|
55
|
-
: null,
|
|
56
|
-
primaries: colrAtom.primaries === 1
|
|
57
|
-
? 'bt709'
|
|
58
|
-
: colrAtom.primaries === 5
|
|
59
|
-
? 'bt470bg'
|
|
60
|
-
: colrAtom.primaries === 6
|
|
61
|
-
? 'smpte170m'
|
|
62
|
-
: null,
|
|
63
|
-
transferCharacteristics: colrAtom.transfer === 1
|
|
64
|
-
? 'bt709'
|
|
65
|
-
: colrAtom.transfer === 6
|
|
66
|
-
? 'smpte170m'
|
|
67
|
-
: colrAtom.transfer === 13
|
|
68
|
-
? 'iec61966-2-1'
|
|
69
|
-
: null,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
exports.getIsoBmColrConfig = getIsoBmColrConfig;
|
|
73
|
-
const getVideoCodecString = (trakBox) => {
|
|
74
|
-
const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
|
|
75
|
-
const avccBox = (0, get_sample_aspect_ratio_1.getAvccBox)(trakBox);
|
|
76
|
-
const hvccBox = (0, get_sample_aspect_ratio_1.getHvccBox)(trakBox);
|
|
77
|
-
const av1cBox = (0, get_sample_aspect_ratio_1.getAv1CBox)(trakBox);
|
|
78
|
-
if (!videoSample) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
if (avccBox) {
|
|
82
|
-
return `${videoSample.format}.${avccBox.configurationString}`;
|
|
83
|
-
}
|
|
84
|
-
if (hvccBox) {
|
|
85
|
-
return `${videoSample.format}.${hvccBox.configurationString}`;
|
|
86
|
-
}
|
|
87
|
-
if (av1cBox) {
|
|
88
|
-
const colrAtom = (0, get_sample_aspect_ratio_1.getColrBox)(videoSample);
|
|
89
|
-
return (0, av1_codec_private_1.parseAv1PrivateData)(av1cBox.privateData, colrAtom);
|
|
90
|
-
}
|
|
91
|
-
return videoSample.format;
|
|
92
|
-
};
|
|
93
|
-
exports.getVideoCodecString = getVideoCodecString;
|
|
94
8
|
const getVideoCodecFromIsoTrak = (trakBox) => {
|
|
95
9
|
const stsdBox = (0, traversal_1.getStsdBox)(trakBox);
|
|
96
10
|
if (stsdBox && stsdBox.type === 'stsd-box') {
|
|
@@ -183,3 +97,89 @@ const getVideoCodec = (boxes) => {
|
|
|
183
97
|
return null;
|
|
184
98
|
};
|
|
185
99
|
exports.getVideoCodec = getVideoCodec;
|
|
100
|
+
const hasVideoCodec = (boxes) => {
|
|
101
|
+
try {
|
|
102
|
+
return (0, exports.getVideoCodec)(boxes) !== null;
|
|
103
|
+
}
|
|
104
|
+
catch (_a) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
exports.hasVideoCodec = hasVideoCodec;
|
|
109
|
+
const getVideoPrivateData = (trakBox) => {
|
|
110
|
+
const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
|
|
111
|
+
const avccBox = (0, get_sample_aspect_ratio_1.getAvccBox)(trakBox);
|
|
112
|
+
const hvccBox = (0, get_sample_aspect_ratio_1.getHvccBox)(trakBox);
|
|
113
|
+
const av1cBox = (0, get_sample_aspect_ratio_1.getAv1CBox)(trakBox);
|
|
114
|
+
if (!videoSample) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
if (avccBox) {
|
|
118
|
+
return avccBox.privateData;
|
|
119
|
+
}
|
|
120
|
+
if (hvccBox) {
|
|
121
|
+
return hvccBox.privateData;
|
|
122
|
+
}
|
|
123
|
+
if (av1cBox) {
|
|
124
|
+
return av1cBox.privateData;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
};
|
|
128
|
+
exports.getVideoPrivateData = getVideoPrivateData;
|
|
129
|
+
const getIsoBmColrConfig = (trakBox) => {
|
|
130
|
+
const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
|
|
131
|
+
if (!videoSample) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const colrAtom = (0, get_sample_aspect_ratio_1.getColrBox)(videoSample);
|
|
135
|
+
if (!colrAtom) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
// https://github.com/bbc/qtff-parameter-editor
|
|
139
|
+
return {
|
|
140
|
+
fullRange: colrAtom.fullRangeFlag,
|
|
141
|
+
matrixCoefficients: colrAtom.matrixIndex === 1
|
|
142
|
+
? 'bt709'
|
|
143
|
+
: colrAtom.matrixIndex === 5
|
|
144
|
+
? 'bt470bg'
|
|
145
|
+
: colrAtom.matrixIndex === 6
|
|
146
|
+
? 'smpte170m'
|
|
147
|
+
: null,
|
|
148
|
+
primaries: colrAtom.primaries === 1
|
|
149
|
+
? 'bt709'
|
|
150
|
+
: colrAtom.primaries === 5
|
|
151
|
+
? 'bt470bg'
|
|
152
|
+
: colrAtom.primaries === 6
|
|
153
|
+
? 'smpte170m'
|
|
154
|
+
: null,
|
|
155
|
+
transferCharacteristics: colrAtom.transfer === 1
|
|
156
|
+
? 'bt709'
|
|
157
|
+
: colrAtom.transfer === 6
|
|
158
|
+
? 'smpte170m'
|
|
159
|
+
: colrAtom.transfer === 13
|
|
160
|
+
? 'iec61966-2-1'
|
|
161
|
+
: null,
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
exports.getIsoBmColrConfig = getIsoBmColrConfig;
|
|
165
|
+
const getVideoCodecString = (trakBox) => {
|
|
166
|
+
const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
|
|
167
|
+
const avccBox = (0, get_sample_aspect_ratio_1.getAvccBox)(trakBox);
|
|
168
|
+
const hvccBox = (0, get_sample_aspect_ratio_1.getHvccBox)(trakBox);
|
|
169
|
+
const av1cBox = (0, get_sample_aspect_ratio_1.getAv1CBox)(trakBox);
|
|
170
|
+
if (!videoSample) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
if (avccBox) {
|
|
174
|
+
return `${videoSample.format}.${avccBox.configurationString}`;
|
|
175
|
+
}
|
|
176
|
+
if (hvccBox) {
|
|
177
|
+
return `${videoSample.format}.${hvccBox.configurationString}`;
|
|
178
|
+
}
|
|
179
|
+
if (av1cBox) {
|
|
180
|
+
const colrAtom = (0, get_sample_aspect_ratio_1.getColrBox)(videoSample);
|
|
181
|
+
return (0, av1_codec_private_1.parseAv1PrivateData)(av1cBox.privateData, colrAtom);
|
|
182
|
+
}
|
|
183
|
+
return videoSample.format;
|
|
184
|
+
};
|
|
185
|
+
exports.getVideoCodecString = getVideoCodecString;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import type { LogLevel } from './log';
|
|
2
|
+
export { WriterInterface } from './writers/writer';
|
|
1
3
|
export { AudioTrack, MediaParserAudioCodec, MediaParserVideoCodec, OtherTrack, Track, VideoTrack, VideoTrackColorParams, } from './get-tracks';
|
|
2
|
-
export type { Options, ParseMediaContainer, ParseMediaFields, ParseMediaResult, TracksField, } from './options';
|
|
4
|
+
export type { Options, ParseMediaContainer, ParseMediaDynamicOptions, ParseMediaFields, ParseMediaOptions, ParseMediaResult, TracksField, } from './options';
|
|
3
5
|
export { parseMedia } from './parse-media';
|
|
4
6
|
export { AudioSample, OnAudioSample, OnAudioTrack, OnVideoSample, OnVideoTrack, VideoSample, } from './webcodec-sample-types';
|
|
5
7
|
export type { MediaFn } from './create/create-media';
|
|
6
8
|
export { Dimensions } from './get-dimensions';
|
|
7
9
|
export type { ReaderInterface } from './readers/reader';
|
|
10
|
+
export type { LogLevel };
|
|
8
11
|
export declare const MediaParserInternals: {
|
|
9
|
-
createMedia: (
|
|
12
|
+
createMedia: ({ writer, onBytesProgress, onMillisecondsProgress, }: {
|
|
13
|
+
writer: import("./writers/writer").WriterInterface;
|
|
14
|
+
onBytesProgress: (totalBytes: number) => void;
|
|
15
|
+
onMillisecondsProgress: (totalMilliseconds: number) => void;
|
|
16
|
+
}) => Promise<import("./create/create-media").MediaFn>;
|
|
17
|
+
Log: {
|
|
18
|
+
trace: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
19
|
+
verbose: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
20
|
+
info: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
21
|
+
warn: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
22
|
+
error: (...args: Parameters<typeof console.log>) => void;
|
|
23
|
+
};
|
|
10
24
|
};
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MediaParserInternals = exports.parseMedia = void 0;
|
|
4
4
|
const create_media_1 = require("./create/create-media");
|
|
5
|
+
const log_1 = require("./log");
|
|
5
6
|
var parse_media_1 = require("./parse-media");
|
|
6
7
|
Object.defineProperty(exports, "parseMedia", { enumerable: true, get: function () { return parse_media_1.parseMedia; } });
|
|
7
8
|
exports.MediaParserInternals = {
|
|
8
9
|
createMedia: create_media_1.createMedia,
|
|
10
|
+
Log: log_1.Log,
|
|
9
11
|
};
|
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const logLevels: readonly ["trace", "verbose", "info", "warn", "error"];
|
|
2
|
+
export type LogLevel = (typeof logLevels)[number];
|
|
3
|
+
export declare const isEqualOrBelowLogLevel: (currentLevel: LogLevel, level: LogLevel) => boolean;
|
|
4
|
+
export declare const Log: {
|
|
5
|
+
trace: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
6
|
+
verbose: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
7
|
+
info: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
8
|
+
warn: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
9
|
+
error: (...args: Parameters<typeof console.log>) => void;
|
|
10
|
+
};
|
package/dist/log.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Log = exports.isEqualOrBelowLogLevel = exports.logLevels = void 0;
|
|
4
|
+
/* eslint-disable no-console */
|
|
5
|
+
exports.logLevels = ['trace', 'verbose', 'info', 'warn', 'error'];
|
|
6
|
+
const getNumberForLogLevel = (level) => {
|
|
7
|
+
return exports.logLevels.indexOf(level);
|
|
8
|
+
};
|
|
9
|
+
const isEqualOrBelowLogLevel = (currentLevel, level) => {
|
|
10
|
+
return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
|
|
11
|
+
};
|
|
12
|
+
exports.isEqualOrBelowLogLevel = isEqualOrBelowLogLevel;
|
|
13
|
+
exports.Log = {
|
|
14
|
+
trace: (logLevel, ...args) => {
|
|
15
|
+
if ((0, exports.isEqualOrBelowLogLevel)(logLevel, 'trace')) {
|
|
16
|
+
return console.log(...args);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
verbose: (logLevel, ...args) => {
|
|
20
|
+
if ((0, exports.isEqualOrBelowLogLevel)(logLevel, 'verbose')) {
|
|
21
|
+
return console.log(...args);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
info: (logLevel, ...args) => {
|
|
25
|
+
if ((0, exports.isEqualOrBelowLogLevel)(logLevel, 'info')) {
|
|
26
|
+
return console.log(...args);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
warn: (logLevel, ...args) => {
|
|
30
|
+
if ((0, exports.isEqualOrBelowLogLevel)(logLevel, 'warn')) {
|
|
31
|
+
return console.warn(...args);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
error: (...args) => {
|
|
35
|
+
return console.error(...args);
|
|
36
|
+
},
|
|
37
|
+
};
|
package/dist/options.d.ts
CHANGED
|
@@ -107,11 +107,14 @@ export type ParseMediaResult<Fields extends Options<ParseMediaFields>> = (Fields
|
|
|
107
107
|
} : {}) & (Fields['container'] extends true ? {
|
|
108
108
|
container: ParseMediaContainer | null;
|
|
109
109
|
} : {});
|
|
110
|
-
export type
|
|
111
|
-
src: string | File;
|
|
110
|
+
export type ParseMediaDynamicOptions<F extends Options<ParseMediaFields>> = {
|
|
112
111
|
fields?: F;
|
|
112
|
+
} & ParseMediaCallbacks<F>;
|
|
113
|
+
export type ParseMediaOptions<F extends Options<ParseMediaFields>> = {
|
|
114
|
+
src: string | File;
|
|
113
115
|
reader?: ReaderInterface;
|
|
114
116
|
onAudioTrack?: OnAudioTrack;
|
|
115
117
|
onVideoTrack?: OnVideoTrack;
|
|
116
118
|
signal?: AbortSignal;
|
|
117
|
-
} &
|
|
119
|
+
} & ParseMediaDynamicOptions<F>;
|
|
120
|
+
export type ParseMedia = <F extends Options<ParseMediaFields>>(options: ParseMediaOptions<F>) => Promise<ParseMediaResult<F>>;
|
package/dist/parse-media.js
CHANGED
|
@@ -37,7 +37,6 @@ const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.
|
|
|
37
37
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
38
38
|
throw new Error('Aborted');
|
|
39
39
|
}
|
|
40
|
-
// eslint-disable-next-line no-constant-condition
|
|
41
40
|
while (true) {
|
|
42
41
|
const result = await currentReader.reader.read();
|
|
43
42
|
if (iterator) {
|
|
@@ -80,7 +80,7 @@ exports.fetchReader = {
|
|
|
80
80
|
: null;
|
|
81
81
|
const { supportsContentRange } = validateContentRangeAndDetectIfSupported(actualRange, parsedContentRange, res.status);
|
|
82
82
|
signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', () => {
|
|
83
|
-
controller.abort();
|
|
83
|
+
controller.abort(new Error('Aborted by user'));
|
|
84
84
|
}, { once: true });
|
|
85
85
|
if (res.status.toString().startsWith('4') ||
|
|
86
86
|
res.status.toString().startsWith('5')) {
|
package/dist/writers/web-fs.js
CHANGED
|
@@ -33,7 +33,7 @@ const createContent = async () => {
|
|
|
33
33
|
try {
|
|
34
34
|
await writable.close();
|
|
35
35
|
}
|
|
36
|
-
catch (
|
|
36
|
+
catch (_a) {
|
|
37
37
|
// Ignore, could already be closed
|
|
38
38
|
}
|
|
39
39
|
const newHandle = await directoryHandle.getFileHandle(filename, {
|
|
@@ -58,6 +58,12 @@ exports.webFsWriter = {
|
|
|
58
58
|
createContent,
|
|
59
59
|
};
|
|
60
60
|
const canUseWebFsWriter = async () => {
|
|
61
|
+
if (!('storage' in navigator)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (!('getDirectory' in navigator.storage)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
61
67
|
const directoryHandle = await navigator.storage.getDirectory();
|
|
62
68
|
const fileHandle = await directoryHandle.getFileHandle('remotion-probe-web-fs-support', {
|
|
63
69
|
create: true,
|
package/package.json
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/media-parser"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/media-parser",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.228",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@types/wicg-file-system-access": "2023.10.5",
|
|
11
|
-
"
|
|
11
|
+
"eslint": "9.14.0",
|
|
12
|
+
"@remotion/renderer": "4.0.228",
|
|
13
|
+
"@remotion/eslint-config-internal": "4.0.228"
|
|
12
14
|
},
|
|
13
15
|
"publishConfig": {
|
|
14
16
|
"access": "public"
|
|
@@ -87,9 +89,8 @@
|
|
|
87
89
|
"description": "A pure JavaScript library for parsing video files",
|
|
88
90
|
"scripts": {
|
|
89
91
|
"formatting": "prettier src --check",
|
|
90
|
-
"lint": "eslint src
|
|
92
|
+
"lint": "eslint src",
|
|
91
93
|
"test": "bun test src/test",
|
|
92
|
-
"
|
|
93
|
-
"make": "bun --env-file=../.env.bundle bundle.ts"
|
|
94
|
+
"make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"
|
|
94
95
|
}
|
|
95
96
|
}
|