@remotion/media-parser 4.0.230 → 4.0.231
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/webm/parse-webm-header.js +23 -4
- package/dist/boxes/webm/segments/parse-children.d.ts +12 -7
- package/dist/boxes/webm/segments/parse-children.js +67 -57
- package/dist/boxes/webm/segments.d.ts +8 -3
- package/dist/boxes/webm/segments.js +70 -39
- package/dist/create/iso-base-media/create-iso-base-media.d.ts +1 -1
- package/dist/create/iso-base-media/create-iso-base-media.js +4 -5
- package/dist/create/matroska/cluster.d.ts +7 -1
- package/dist/create/matroska/cluster.js +8 -5
- package/dist/create/matroska/create-matroska-media.d.ts +1 -1
- package/dist/create/matroska/create-matroska-media.js +27 -10
- package/dist/create/media-fn.d.ts +1 -0
- package/dist/emit-available-info.d.ts +1 -1
- package/dist/emit-available-info.js +23 -10
- package/dist/esm/buffer.mjs +2 -2
- package/dist/esm/index.mjs +591 -465
- package/dist/esm/web-fs.mjs +2 -2
- package/dist/get-audio-codec.d.ts +1 -1
- package/dist/get-audio-codec.js +2 -7
- package/dist/get-duration.d.ts +5 -0
- package/dist/get-duration.js +7 -3
- package/dist/get-fps.js +7 -0
- package/dist/get-video-codec.d.ts +2 -2
- package/dist/get-video-codec.js +2 -6
- package/dist/has-all-info.d.ts +1 -1
- package/dist/has-all-info.js +8 -8
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -1
- package/dist/options.d.ts +8 -1
- package/dist/parse-media.js +41 -14
- package/dist/parse-result.d.ts +15 -0
- package/dist/parse-video.d.ts +1 -1
- package/dist/parse-video.js +3 -0
- package/dist/readers/reader.d.ts +2 -2
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/writers/buffer-implementation/writer.d.ts +2 -2
- package/dist/writers/buffer-implementation/writer.js +2 -2
- package/dist/writers/web-fs.js +2 -3
- package/dist/writers/writer.d.ts +5 -3
- package/package.json +3 -3
package/dist/esm/web-fs.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/writers/web-fs.ts
|
|
2
|
-
var createContent = async () => {
|
|
2
|
+
var createContent = async ({ filename }) => {
|
|
3
3
|
const directoryHandle = await navigator.storage.getDirectory();
|
|
4
|
-
|
|
4
|
+
directoryHandle.removeEntry(filename);
|
|
5
5
|
const fileHandle = await directoryHandle.getFileHandle(filename, {
|
|
6
6
|
create: true
|
|
7
7
|
});
|
|
@@ -4,7 +4,7 @@ import { type MediaParserAudioCodec } from './get-tracks';
|
|
|
4
4
|
import type { AnySegment } from './parse-result';
|
|
5
5
|
import type { ParserState } from './parser-state';
|
|
6
6
|
export declare const getAudioCodec: (boxes: AnySegment[], parserState: ParserState) => MediaParserAudioCodec | null;
|
|
7
|
-
export declare const hasAudioCodec: (boxes: AnySegment[]
|
|
7
|
+
export declare const hasAudioCodec: (boxes: AnySegment[]) => boolean;
|
|
8
8
|
type AudioCodecInfo = {
|
|
9
9
|
format: string;
|
|
10
10
|
primarySpecificator: number | null;
|
package/dist/get-audio-codec.js
CHANGED
|
@@ -22,13 +22,8 @@ const getAudioCodec = (boxes, parserState) => {
|
|
|
22
22
|
return null;
|
|
23
23
|
};
|
|
24
24
|
exports.getAudioCodec = getAudioCodec;
|
|
25
|
-
const hasAudioCodec = (boxes
|
|
26
|
-
|
|
27
|
-
return (0, exports.getAudioCodec)(boxes, state) !== null;
|
|
28
|
-
}
|
|
29
|
-
catch (_a) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
25
|
+
const hasAudioCodec = (boxes) => {
|
|
26
|
+
return (0, get_tracks_1.hasTracks)(boxes);
|
|
32
27
|
};
|
|
33
28
|
exports.hasAudioCodec = hasAudioCodec;
|
|
34
29
|
const getCodecSpecificatorFromEsdsBox = ({ child, }) => {
|
package/dist/get-duration.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { AnySegment } from './parse-result';
|
|
2
2
|
import type { ParserState } from './parser-state';
|
|
3
|
+
export declare const isMatroska: (boxes: AnySegment[]) => {
|
|
4
|
+
type: "Segment";
|
|
5
|
+
value: import("./boxes/webm/segments/all-segments").PossibleEbml[];
|
|
6
|
+
minVintWidth: number | null;
|
|
7
|
+
} | undefined;
|
|
3
8
|
export declare const getDuration: (boxes: AnySegment[], parserState: ParserState) => number | null;
|
|
4
9
|
export declare const hasDuration: (boxes: AnySegment[], parserState: ParserState) => boolean;
|
package/dist/get-duration.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasDuration = exports.getDuration = void 0;
|
|
3
|
+
exports.hasDuration = exports.getDuration = exports.isMatroska = void 0;
|
|
4
4
|
const get_sample_positions_from_track_1 = require("./boxes/iso-base-media/get-sample-positions-from-track");
|
|
5
5
|
const traversal_1 = require("./boxes/iso-base-media/traversal");
|
|
6
6
|
const get_tracks_1 = require("./get-tracks");
|
|
@@ -28,9 +28,13 @@ const getDurationFromMatroska = (segments) => {
|
|
|
28
28
|
}
|
|
29
29
|
return (duration.value.value / timestampScale.value.value) * 1000;
|
|
30
30
|
};
|
|
31
|
-
const
|
|
31
|
+
const isMatroska = (boxes) => {
|
|
32
32
|
const matroskaBox = boxes.find((b) => b.type === 'Segment');
|
|
33
|
-
|
|
33
|
+
return matroskaBox;
|
|
34
|
+
};
|
|
35
|
+
exports.isMatroska = isMatroska;
|
|
36
|
+
const getDuration = (boxes, parserState) => {
|
|
37
|
+
if ((0, exports.isMatroska)(boxes)) {
|
|
34
38
|
return getDurationFromMatroska(boxes);
|
|
35
39
|
}
|
|
36
40
|
const moovBox = (0, traversal_1.getMoovBox)(boxes);
|
package/dist/get-fps.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasFps = exports.getFps = exports.getFpsFromMp4TrakBox = exports.getTimescaleAndDuration = exports.trakBoxContainsVideo = exports.trakBoxContainsAudio = void 0;
|
|
4
4
|
const traversal_1 = require("./boxes/iso-base-media/traversal");
|
|
5
|
+
const get_duration_1 = require("./get-duration");
|
|
5
6
|
const calculateFps = ({ sttsBox, timeScale, durationInSamples, }) => {
|
|
6
7
|
let totalSamples = 0;
|
|
7
8
|
for (const sample of sttsBox.sampleDistribution) {
|
|
@@ -74,6 +75,12 @@ const getFps = (segments) => {
|
|
|
74
75
|
exports.getFps = getFps;
|
|
75
76
|
const hasFps = (boxes) => {
|
|
76
77
|
try {
|
|
78
|
+
// Matroska has no FPS metadata
|
|
79
|
+
// Not bothering to parse
|
|
80
|
+
// Idea: `guaranteedFps` field
|
|
81
|
+
if ((0, get_duration_1.isMatroska)(boxes)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
77
84
|
return (0, exports.getFps)(boxes) !== null;
|
|
78
85
|
}
|
|
79
86
|
catch (_a) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TrakBox } from './boxes/iso-base-media/trak/trak';
|
|
2
|
-
import type
|
|
2
|
+
import { type MediaParserVideoCodec, type VideoTrackColorParams } from './get-tracks';
|
|
3
3
|
import type { AnySegment } from './parse-result';
|
|
4
|
-
export declare const getVideoCodecFromIsoTrak: (trakBox: TrakBox) => "
|
|
4
|
+
export declare const getVideoCodecFromIsoTrak: (trakBox: TrakBox) => "h265" | "h264" | "av1" | "prores";
|
|
5
5
|
export declare const getVideoCodec: (boxes: AnySegment[]) => MediaParserVideoCodec | null;
|
|
6
6
|
export declare const hasVideoCodec: (boxes: AnySegment[]) => boolean;
|
|
7
7
|
export declare const getVideoPrivateData: (trakBox: TrakBox) => Uint8Array | null;
|
package/dist/get-video-codec.js
CHANGED
|
@@ -5,6 +5,7 @@ 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 get_tracks_1 = require("./get-tracks");
|
|
8
9
|
const getVideoCodecFromIsoTrak = (trakBox) => {
|
|
9
10
|
const stsdBox = (0, traversal_1.getStsdBox)(trakBox);
|
|
10
11
|
if (stsdBox && stsdBox.type === 'stsd-box') {
|
|
@@ -98,12 +99,7 @@ const getVideoCodec = (boxes) => {
|
|
|
98
99
|
};
|
|
99
100
|
exports.getVideoCodec = getVideoCodec;
|
|
100
101
|
const hasVideoCodec = (boxes) => {
|
|
101
|
-
|
|
102
|
-
return (0, exports.getVideoCodec)(boxes) !== null;
|
|
103
|
-
}
|
|
104
|
-
catch (_a) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
102
|
+
return (0, get_tracks_1.hasTracks)(boxes);
|
|
107
103
|
};
|
|
108
104
|
exports.hasVideoCodec = hasVideoCodec;
|
|
109
105
|
const getVideoPrivateData = (trakBox) => {
|
package/dist/has-all-info.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Options, ParseMediaFields } from './options';
|
|
2
2
|
import type { ParseResult } from './parse-result';
|
|
3
3
|
import type { ParserState } from './parser-state';
|
|
4
|
-
export declare const getAvailableInfo: (options: Options<ParseMediaFields>, parseResult: ParseResult, state: ParserState) => Record<keyof Options<ParseMediaFields>, boolean>;
|
|
4
|
+
export declare const getAvailableInfo: (options: Options<ParseMediaFields>, parseResult: ParseResult | null, state: ParserState) => Record<keyof Options<ParseMediaFields>, boolean>;
|
package/dist/has-all-info.js
CHANGED
|
@@ -12,27 +12,27 @@ const getAvailableInfo = (options, parseResult, state) => {
|
|
|
12
12
|
const keys = Object.entries(options).filter(([, value]) => value);
|
|
13
13
|
const infos = keys.map(([key]) => {
|
|
14
14
|
if (key === 'boxes') {
|
|
15
|
-
return parseResult.status === 'done';
|
|
15
|
+
return Boolean(parseResult && parseResult.status === 'done');
|
|
16
16
|
}
|
|
17
17
|
if (key === 'durationInSeconds') {
|
|
18
|
-
return (0, get_duration_1.hasDuration)(parseResult.segments, state);
|
|
18
|
+
return Boolean(parseResult && (0, get_duration_1.hasDuration)(parseResult.segments, state));
|
|
19
19
|
}
|
|
20
20
|
if (key === 'dimensions' ||
|
|
21
21
|
key === 'rotation' ||
|
|
22
22
|
key === 'unrotatedDimensions') {
|
|
23
|
-
return (0, get_dimensions_1.hasDimensions)(parseResult.segments, state);
|
|
23
|
+
return Boolean(parseResult && (0, get_dimensions_1.hasDimensions)(parseResult.segments, state));
|
|
24
24
|
}
|
|
25
25
|
if (key === 'fps') {
|
|
26
|
-
return (0, get_fps_1.hasFps)(parseResult.segments);
|
|
26
|
+
return Boolean(parseResult && (0, get_fps_1.hasFps)(parseResult.segments));
|
|
27
27
|
}
|
|
28
28
|
if (key === 'videoCodec') {
|
|
29
|
-
return (0, get_video_codec_1.hasVideoCodec)(parseResult.segments);
|
|
29
|
+
return Boolean(parseResult && (0, get_video_codec_1.hasVideoCodec)(parseResult.segments));
|
|
30
30
|
}
|
|
31
31
|
if (key === 'audioCodec') {
|
|
32
|
-
return (0, get_audio_codec_1.hasAudioCodec)(parseResult.segments
|
|
32
|
+
return Boolean(parseResult && (0, get_audio_codec_1.hasAudioCodec)(parseResult.segments));
|
|
33
33
|
}
|
|
34
34
|
if (key === 'tracks') {
|
|
35
|
-
return (0, get_tracks_1.hasTracks)(parseResult.segments);
|
|
35
|
+
return Boolean(parseResult && (0, get_tracks_1.hasTracks)(parseResult.segments));
|
|
36
36
|
}
|
|
37
37
|
if (key === 'internalStats') {
|
|
38
38
|
return false;
|
|
@@ -44,7 +44,7 @@ const getAvailableInfo = (options, parseResult, state) => {
|
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
46
|
if (key === 'container') {
|
|
47
|
-
return (0, get_container_1.hasContainer)(parseResult.segments);
|
|
47
|
+
return Boolean(parseResult && (0, get_container_1.hasContainer)(parseResult.segments));
|
|
48
48
|
}
|
|
49
49
|
throw new Error(`Unknown key: ${key}`);
|
|
50
50
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LogLevel } from './log';
|
|
2
2
|
export { WriterInterface } from './writers/writer';
|
|
3
3
|
export { AudioTrack, MediaParserAudioCodec, MediaParserVideoCodec, OtherTrack, Track, VideoTrack, VideoTrackColorParams, } from './get-tracks';
|
|
4
|
-
export type { Options, ParseMediaContainer, ParseMediaDynamicOptions, ParseMediaFields, ParseMediaOptions, ParseMediaResult, TracksField, } from './options';
|
|
4
|
+
export type { Options, ParseMediaContainer, ParseMediaDynamicOptions, ParseMediaFields, ParseMediaOnProgress, ParseMediaOptions, ParseMediaProgress, ParseMediaResult, TracksField, } from './options';
|
|
5
5
|
export { parseMedia } from './parse-media';
|
|
6
6
|
export { AudioOrVideoSample, OnAudioSample, OnAudioTrack, OnVideoSample, OnVideoTrack, } from './webcodec-sample-types';
|
|
7
7
|
export type { MediaFn } from './create/media-fn';
|
|
@@ -9,8 +9,8 @@ export { Dimensions } from './get-dimensions';
|
|
|
9
9
|
export type { ReaderInterface } from './readers/reader';
|
|
10
10
|
export type { LogLevel };
|
|
11
11
|
export declare const MediaParserInternals: {
|
|
12
|
-
createMatroskaMedia: ({ writer, onBytesProgress, onMillisecondsProgress, }: import("./create/media-fn").MediaFnGeneratorInput) => Promise<import("./create/media-fn").MediaFn>;
|
|
13
|
-
createIsoBaseMedia: ({ writer, onBytesProgress, onMillisecondsProgress, logLevel, }: import("./create/media-fn").MediaFnGeneratorInput) => Promise<import("./create/media-fn").MediaFn>;
|
|
12
|
+
createMatroskaMedia: ({ writer, onBytesProgress, onMillisecondsProgress, filename, logLevel, }: import("./create/media-fn").MediaFnGeneratorInput) => Promise<import("./create/media-fn").MediaFn>;
|
|
13
|
+
createIsoBaseMedia: ({ writer, onBytesProgress, onMillisecondsProgress, logLevel, filename, }: import("./create/media-fn").MediaFnGeneratorInput) => Promise<import("./create/media-fn").MediaFn>;
|
|
14
14
|
Log: {
|
|
15
15
|
trace: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
16
16
|
verbose: (logLevel: LogLevel, ...args: Parameters<typeof console.log>) => void;
|
|
@@ -19,3 +19,4 @@ export declare const MediaParserInternals: {
|
|
|
19
19
|
error: (...args: Parameters<typeof console.log>) => void;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
export { VERSION } from './version';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaParserInternals = exports.parseMedia = void 0;
|
|
3
|
+
exports.VERSION = exports.MediaParserInternals = exports.parseMedia = void 0;
|
|
4
4
|
const create_iso_base_media_1 = require("./create/iso-base-media/create-iso-base-media");
|
|
5
5
|
const create_matroska_media_1 = require("./create/matroska/create-matroska-media");
|
|
6
6
|
const log_1 = require("./log");
|
|
@@ -11,3 +11,5 @@ exports.MediaParserInternals = {
|
|
|
11
11
|
createIsoBaseMedia: create_iso_base_media_1.createIsoBaseMedia,
|
|
12
12
|
Log: log_1.Log,
|
|
13
13
|
};
|
|
14
|
+
var version_1 = require("./version");
|
|
15
|
+
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
package/dist/options.d.ts
CHANGED
|
@@ -111,12 +111,19 @@ export type ParseMediaResult<Fields extends Options<ParseMediaFields>> = (Fields
|
|
|
111
111
|
export type ParseMediaDynamicOptions<F extends Options<ParseMediaFields>> = {
|
|
112
112
|
fields?: F;
|
|
113
113
|
} & ParseMediaCallbacks<F>;
|
|
114
|
+
export type ParseMediaProgress = {
|
|
115
|
+
bytes: number;
|
|
116
|
+
percentage: number | null;
|
|
117
|
+
totalBytes: number | null;
|
|
118
|
+
};
|
|
119
|
+
export type ParseMediaOnProgress = (progress: ParseMediaProgress) => void | Promise<void>;
|
|
114
120
|
export type ParseMediaOptions<F extends Options<ParseMediaFields>> = {
|
|
115
|
-
src: string |
|
|
121
|
+
src: string | Blob;
|
|
116
122
|
reader?: ReaderInterface;
|
|
117
123
|
onAudioTrack?: OnAudioTrack;
|
|
118
124
|
onVideoTrack?: OnVideoTrack;
|
|
119
125
|
signal?: AbortSignal;
|
|
120
126
|
logLevel?: LogLevel;
|
|
127
|
+
onParseProgress?: ParseMediaOnProgress;
|
|
121
128
|
} & ParseMediaDynamicOptions<F>;
|
|
122
129
|
export type ParseMedia = <F extends Options<ParseMediaFields>>(options: ParseMediaOptions<F>) => Promise<ParseMediaResult<F>>;
|
package/dist/parse-media.js
CHANGED
|
@@ -4,10 +4,11 @@ exports.parseMedia = void 0;
|
|
|
4
4
|
const buffer_iterator_1 = require("./buffer-iterator");
|
|
5
5
|
const emit_available_info_1 = require("./emit-available-info");
|
|
6
6
|
const has_all_info_1 = require("./has-all-info");
|
|
7
|
+
const log_1 = require("./log");
|
|
7
8
|
const parse_video_1 = require("./parse-video");
|
|
8
9
|
const parser_state_1 = require("./parser-state");
|
|
9
10
|
const from_fetch_1 = require("./readers/from-fetch");
|
|
10
|
-
const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.fetchReader, onAudioTrack, onVideoTrack, signal, logLevel = 'info', ...more }) => {
|
|
11
|
+
const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.fetchReader, onAudioTrack, onVideoTrack, signal, logLevel = 'info', onParseProgress, ...more }) => {
|
|
11
12
|
const state = (0, parser_state_1.makeParserState)({
|
|
12
13
|
hasAudioCallbacks: onAudioTrack !== null,
|
|
13
14
|
hasVideoCallbacks: onVideoTrack !== null,
|
|
@@ -23,8 +24,15 @@ const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.
|
|
|
23
24
|
const moreFields = more;
|
|
24
25
|
let iterator = null;
|
|
25
26
|
let parseResult = null;
|
|
27
|
+
const canSkipVideoData = !onVideoTrack && !onAudioTrack;
|
|
28
|
+
if (canSkipVideoData) {
|
|
29
|
+
log_1.Log.verbose(logLevel, 'Only parsing metadata, because no onVideoTrack and onAudioTrack callbacks were passed.');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
log_1.Log.verbose(logLevel, 'Parsing video data, because onVideoTrack/onAudioTrack callbacks were passed.');
|
|
33
|
+
}
|
|
26
34
|
const options = {
|
|
27
|
-
canSkipVideoData
|
|
35
|
+
canSkipVideoData,
|
|
28
36
|
onAudioTrack: onAudioTrack !== null && onAudioTrack !== void 0 ? onAudioTrack : null,
|
|
29
37
|
onVideoTrack: onVideoTrack !== null && onVideoTrack !== void 0 ? onVideoTrack : null,
|
|
30
38
|
parserState: state,
|
|
@@ -33,6 +41,26 @@ const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.
|
|
|
33
41
|
process.env.KEEP_SAMPLES === 'true'),
|
|
34
42
|
supportsContentRange,
|
|
35
43
|
};
|
|
44
|
+
const hasAllInfo = () => {
|
|
45
|
+
if (parseResult === null) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const availableInfo = (0, has_all_info_1.getAvailableInfo)(fields !== null && fields !== void 0 ? fields : {}, parseResult, state);
|
|
49
|
+
return Object.values(availableInfo).every(Boolean);
|
|
50
|
+
};
|
|
51
|
+
const triggerInfoEmit = () => {
|
|
52
|
+
const availableInfo = (0, has_all_info_1.getAvailableInfo)(fields !== null && fields !== void 0 ? fields : {}, parseResult, state);
|
|
53
|
+
(0, emit_available_info_1.emitAvailableInfo)({
|
|
54
|
+
hasInfo: availableInfo,
|
|
55
|
+
moreFields,
|
|
56
|
+
parseResult,
|
|
57
|
+
state,
|
|
58
|
+
returnValue,
|
|
59
|
+
contentLength,
|
|
60
|
+
name,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
triggerInfoEmit();
|
|
36
64
|
while (parseResult === null || parseResult.status === 'incomplete') {
|
|
37
65
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
38
66
|
throw new Error('Aborted');
|
|
@@ -60,7 +88,16 @@ const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.
|
|
|
60
88
|
if (!iterator) {
|
|
61
89
|
throw new Error('Unexpected null');
|
|
62
90
|
}
|
|
91
|
+
await (onParseProgress === null || onParseProgress === void 0 ? void 0 : onParseProgress({
|
|
92
|
+
bytes: iterator.counter.getOffset(),
|
|
93
|
+
percentage: contentLength
|
|
94
|
+
? iterator.counter.getOffset() / contentLength
|
|
95
|
+
: null,
|
|
96
|
+
totalBytes: contentLength,
|
|
97
|
+
}));
|
|
98
|
+
triggerInfoEmit();
|
|
63
99
|
if (parseResult && parseResult.status === 'incomplete') {
|
|
100
|
+
log_1.Log.verbose(logLevel, 'Continuing parsing of file, currently at position', iterator.counter.getOffset(), (0, has_all_info_1.getAvailableInfo)(fields !== null && fields !== void 0 ? fields : {}, parseResult, state));
|
|
64
101
|
parseResult = await parseResult.continueParsing();
|
|
65
102
|
}
|
|
66
103
|
else {
|
|
@@ -71,20 +108,9 @@ const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.
|
|
|
71
108
|
logLevel,
|
|
72
109
|
});
|
|
73
110
|
}
|
|
74
|
-
const availableInfo = (0, has_all_info_1.getAvailableInfo)(fields !== null && fields !== void 0 ? fields : {}, parseResult, state);
|
|
75
|
-
const hasAllInfo = Object.values(availableInfo).every(Boolean);
|
|
76
|
-
(0, emit_available_info_1.emitAvailableInfo)({
|
|
77
|
-
hasInfo: availableInfo,
|
|
78
|
-
moreFields,
|
|
79
|
-
parseResult,
|
|
80
|
-
state,
|
|
81
|
-
returnValue,
|
|
82
|
-
contentLength,
|
|
83
|
-
name,
|
|
84
|
-
});
|
|
85
111
|
// TODO Better: Check if no active listeners are registered
|
|
86
112
|
// Also maybe check for canSkipVideoData
|
|
87
|
-
if (hasAllInfo && !onVideoTrack && !onAudioTrack) {
|
|
113
|
+
if (hasAllInfo() && !onVideoTrack && !onAudioTrack) {
|
|
88
114
|
break;
|
|
89
115
|
}
|
|
90
116
|
if (parseResult &&
|
|
@@ -99,6 +125,7 @@ const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.
|
|
|
99
125
|
iterator.skipTo(parseResult.skipTo, true);
|
|
100
126
|
}
|
|
101
127
|
}
|
|
128
|
+
log_1.Log.verbose(logLevel, 'Finished parsing file');
|
|
102
129
|
// Force assign
|
|
103
130
|
(0, emit_available_info_1.emitAvailableInfo)({
|
|
104
131
|
hasInfo: Object.keys(fields !== null && fields !== void 0 ? fields : {}).reduce((acc, key) => {
|
package/dist/parse-result.d.ts
CHANGED
|
@@ -44,3 +44,18 @@ export type ParseResult = {
|
|
|
44
44
|
skipTo: number | null;
|
|
45
45
|
continueParsing: () => Promise<ParseResult>;
|
|
46
46
|
};
|
|
47
|
+
export type MatroskaParseResult = {
|
|
48
|
+
status: 'done';
|
|
49
|
+
} | {
|
|
50
|
+
status: 'incomplete';
|
|
51
|
+
skipTo: number | null;
|
|
52
|
+
continueParsing: () => Promise<MatroskaParseResult>;
|
|
53
|
+
};
|
|
54
|
+
export type ExpectSegmentParseResult = {
|
|
55
|
+
status: 'done';
|
|
56
|
+
segment: MatroskaSegment;
|
|
57
|
+
} | {
|
|
58
|
+
status: 'incomplete';
|
|
59
|
+
segment: MatroskaSegment | null;
|
|
60
|
+
continueParsing: () => Promise<ExpectSegmentParseResult>;
|
|
61
|
+
};
|
package/dist/parse-video.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BufferIterator } from './buffer-iterator';
|
|
2
|
-
import type
|
|
2
|
+
import { type LogLevel } from './log';
|
|
3
3
|
import type { IsoBaseMediaBox, ParseResult } from './parse-result';
|
|
4
4
|
import type { ParserContext } from './parser-context';
|
|
5
5
|
export type PartialMdatBox = {
|
package/dist/parse-video.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseVideo = void 0;
|
|
4
4
|
const process_box_1 = require("./boxes/iso-base-media/process-box");
|
|
5
5
|
const parse_webm_header_1 = require("./boxes/webm/parse-webm-header");
|
|
6
|
+
const log_1 = require("./log");
|
|
6
7
|
const parseVideo = ({ iterator, options, signal, logLevel, }) => {
|
|
7
8
|
if (iterator.bytesRemaining() === 0) {
|
|
8
9
|
return Promise.resolve({
|
|
@@ -23,6 +24,7 @@ const parseVideo = ({ iterator, options, signal, logLevel, }) => {
|
|
|
23
24
|
throw new Error('AVI files are not yet supported');
|
|
24
25
|
}
|
|
25
26
|
if (iterator.isIsoBaseMedia()) {
|
|
27
|
+
log_1.Log.verbose(logLevel, 'Detected ISO Base Media container');
|
|
26
28
|
return (0, process_box_1.parseBoxes)({
|
|
27
29
|
iterator,
|
|
28
30
|
maxBytes: Infinity,
|
|
@@ -35,6 +37,7 @@ const parseVideo = ({ iterator, options, signal, logLevel, }) => {
|
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
if (iterator.isWebm()) {
|
|
40
|
+
log_1.Log.verbose(logLevel, 'Detected Matroska container');
|
|
38
41
|
return Promise.resolve((0, parse_webm_header_1.parseWebm)(iterator, options));
|
|
39
42
|
}
|
|
40
43
|
if (iterator.isMp3()) {
|
package/dist/readers/reader.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ type ReadResult = {
|
|
|
8
8
|
name: string;
|
|
9
9
|
supportsContentRange: boolean;
|
|
10
10
|
};
|
|
11
|
-
type ReadContent = (src: string |
|
|
12
|
-
type GetLength = (src: string |
|
|
11
|
+
type ReadContent = (src: string | Blob, range: [number, number] | number | null, signal: AbortSignal | undefined) => Promise<ReadResult>;
|
|
12
|
+
type GetLength = (src: string | Blob) => Promise<number>;
|
|
13
13
|
export type ReaderInterface = {
|
|
14
14
|
read: ReadContent;
|
|
15
15
|
getLength: GetLength;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "4.0.231";
|
package/dist/version.js
ADDED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createContent:
|
|
1
|
+
import type { CreateContent } from '../writer';
|
|
2
|
+
export declare const createContent: CreateContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createContent = void 0;
|
|
4
|
-
const createContent = () => {
|
|
4
|
+
const createContent = ({ filename, mimeType }) => {
|
|
5
5
|
const buf = new ArrayBuffer(0, {
|
|
6
6
|
// TODO: Educate that the buffer is limited to 2GB
|
|
7
7
|
maxByteLength: 2000000000,
|
|
@@ -34,7 +34,7 @@ const createContent = () => {
|
|
|
34
34
|
const arr = new Uint8Array(buf);
|
|
35
35
|
return Promise.resolve(
|
|
36
36
|
// TODO: Unhardcode MIME type and file name
|
|
37
|
-
new File([arr.slice()],
|
|
37
|
+
new File([arr.slice()], filename, { type: mimeType }));
|
|
38
38
|
},
|
|
39
39
|
remove() {
|
|
40
40
|
removed = true;
|
package/dist/writers/web-fs.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.canUseWebFsWriter = exports.webFsWriter = void 0;
|
|
4
|
-
const createContent = async () => {
|
|
4
|
+
const createContent = async ({ filename }) => {
|
|
5
5
|
const directoryHandle = await navigator.storage.getDirectory();
|
|
6
|
-
|
|
7
|
-
const filename = `media-parser-${Math.random().toString().replace('0.', '')}.webm`;
|
|
6
|
+
directoryHandle.removeEntry(filename);
|
|
8
7
|
const fileHandle = await directoryHandle.getFileHandle(filename, {
|
|
9
8
|
create: true,
|
|
10
9
|
});
|
package/dist/writers/writer.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export type Writer = {
|
|
2
2
|
write: (arr: Uint8Array) => Promise<void>;
|
|
3
|
-
save: () => Promise<
|
|
3
|
+
save: () => Promise<Blob>;
|
|
4
4
|
getWrittenByteCount: () => number;
|
|
5
5
|
updateDataAt: (position: number, data: Uint8Array) => Promise<void>;
|
|
6
6
|
waitForFinish: () => Promise<void>;
|
|
7
7
|
remove: () => Promise<void>;
|
|
8
8
|
};
|
|
9
|
-
type CreateContent = (
|
|
9
|
+
export type CreateContent = (options: {
|
|
10
|
+
filename: string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
}) => Promise<Writer>;
|
|
10
13
|
export type WriterInterface = {
|
|
11
14
|
createContent: CreateContent;
|
|
12
15
|
};
|
|
13
|
-
export {};
|
package/package.json
CHANGED
|
@@ -3,14 +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.231",
|
|
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/example-videos": "4.0.
|
|
13
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
12
|
+
"@remotion/example-videos": "4.0.231",
|
|
13
|
+
"@remotion/eslint-config-internal": "4.0.231"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|