@remotion/webcodecs 4.0.297 → 4.0.300
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/audio-decoder.d.ts +4 -4
- package/dist/audio-decoder.js +8 -6
- package/dist/audio-encoder.d.ts +2 -2
- package/dist/audio-encoder.js +6 -4
- package/dist/auto-select-writer.d.ts +2 -3
- package/dist/can-copy-video-track.d.ts +2 -2
- package/dist/can-copy-video-track.js +3 -5
- package/dist/can-reencode-audio-track.d.ts +2 -2
- package/dist/can-reencode-video-track.d.ts +2 -2
- package/dist/convert-encoded-chunk.d.ts +2 -2
- package/dist/convert-media.d.ts +7 -8
- package/dist/convert-media.js +8 -8
- package/dist/create/iso-base-media/example-stts.d.ts +3 -3
- package/dist/create/iso-base-media/mp4-header.d.ts +2 -2
- package/dist/create/iso-base-media/serialize-track.d.ts +2 -2
- package/dist/create/iso-base-media/trak/mdia/minf/create-stbl.d.ts +2 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.d.ts +2 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stco.d.ts +2 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.d.ts +2 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stss.d.ts +2 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.d.ts +2 -2
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stts.d.ts +2 -2
- package/dist/create/make-track-info.d.ts +2 -2
- package/dist/create/matroska/cluster.d.ts +7 -8
- package/dist/create/matroska/color.d.ts +2 -2
- package/dist/create/matroska/color.js +83 -26
- package/dist/create/matroska/matroska-seek.d.ts +2 -2
- package/dist/create/matroska/matroska-trackentry.d.ts +2 -2
- package/dist/create/matroska/matroska-utils.d.ts +7 -3
- package/dist/create/media-fn.d.ts +4 -5
- package/dist/esm/buffer.mjs +4 -1
- package/dist/esm/index.mjs +147 -62
- package/dist/esm/web-fs.mjs +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/io-manager/io-synchronizer.js +3 -3
- package/dist/log.d.ts +6 -6
- package/dist/on-audio-track-handler.d.ts +3 -3
- package/dist/on-audio-track.d.ts +3 -3
- package/dist/on-audio-track.js +5 -5
- package/dist/on-frame.d.ts +2 -2
- package/dist/on-video-track-handler.d.ts +3 -3
- package/dist/on-video-track.d.ts +3 -3
- package/dist/on-video-track.js +6 -6
- package/dist/resizing/calculate-new-size.d.ts +4 -4
- package/dist/resizing/mode.d.ts +0 -4
- package/dist/rotation.d.ts +3 -3
- package/dist/sort-video-frames.js +3 -3
- package/dist/video-decoder.d.ts +3 -3
- package/dist/video-decoder.js +6 -5
- package/dist/video-encoder.d.ts +2 -2
- package/dist/video-encoder.js +6 -4
- package/dist/wav-audio-encoder.js +1 -1
- package/dist/webcodecs-controller.d.ts +1 -3
- package/dist/webcodecs-controller.js +1 -2
- package/dist/writers/buffer-implementation/writer.d.ts +2 -2
- package/dist/writers/buffer-implementation/writer.js +2 -4
- package/dist/writers/buffer.d.ts +2 -2
- package/dist/writers/web-fs.d.ts +2 -2
- package/dist/writers/web-fs.js +1 -1
- package/package.json +5 -5
package/dist/audio-decoder.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediaParserAudioSample, MediaParserAudioTrack, MediaParserLogLevel } from '@remotion/media-parser';
|
|
2
2
|
import type { ProgressTracker } from './create/progress-tracker';
|
|
3
3
|
import type { WebCodecsController } from './webcodecs-controller';
|
|
4
4
|
export type WebCodecsAudioDecoder = {
|
|
5
|
-
processSample: (audioSample:
|
|
5
|
+
processSample: (audioSample: MediaParserAudioSample) => Promise<void>;
|
|
6
6
|
waitForFinish: () => Promise<void>;
|
|
7
7
|
close: () => void;
|
|
8
8
|
flush: () => Promise<void>;
|
|
@@ -12,8 +12,8 @@ export type CreateAudioDecoderInit = {
|
|
|
12
12
|
onError: (error: DOMException) => void;
|
|
13
13
|
controller: WebCodecsController;
|
|
14
14
|
config: AudioDecoderConfig;
|
|
15
|
-
logLevel:
|
|
16
|
-
track:
|
|
15
|
+
logLevel: MediaParserLogLevel;
|
|
16
|
+
track: MediaParserAudioTrack;
|
|
17
17
|
progressTracker: ProgressTracker;
|
|
18
18
|
};
|
|
19
19
|
export declare const createAudioDecoder: ({ onFrame, onError, controller, config, logLevel, track, progressTracker, }: CreateAudioDecoderInit) => WebCodecsAudioDecoder;
|
package/dist/audio-decoder.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.createAudioDecoder = void 0;
|
|
|
4
4
|
const get_wave_audio_decoder_1 = require("./get-wave-audio-decoder");
|
|
5
5
|
const io_synchronizer_1 = require("./io-manager/io-synchronizer");
|
|
6
6
|
const createAudioDecoder = ({ onFrame, onError, controller, config, logLevel, track, progressTracker, }) => {
|
|
7
|
-
if (controller._internals.signal.aborted) {
|
|
7
|
+
if (controller._internals._mediaParserController._internals.signal.aborted) {
|
|
8
8
|
throw new Error('Not creating audio decoder, already aborted');
|
|
9
9
|
}
|
|
10
10
|
if (config.codec === 'pcm-s16') {
|
|
@@ -22,19 +22,20 @@ const createAudioDecoder = ({ onFrame, onError, controller, config, logLevel, tr
|
|
|
22
22
|
const abortHandler = () => {
|
|
23
23
|
frame.close();
|
|
24
24
|
};
|
|
25
|
-
controller._internals.signal.addEventListener('abort', abortHandler, {
|
|
25
|
+
controller._internals._mediaParserController._internals.signal.addEventListener('abort', abortHandler, {
|
|
26
26
|
once: true,
|
|
27
27
|
});
|
|
28
28
|
outputQueue = outputQueue
|
|
29
29
|
.then(() => {
|
|
30
|
-
if (controller._internals.signal
|
|
30
|
+
if (controller._internals._mediaParserController._internals.signal
|
|
31
|
+
.aborted) {
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
return onFrame(frame);
|
|
34
35
|
})
|
|
35
36
|
.then(() => {
|
|
36
37
|
ioSynchronizer.onProcessed();
|
|
37
|
-
controller._internals.signal.removeEventListener('abort', abortHandler);
|
|
38
|
+
controller._internals._mediaParserController._internals.signal.removeEventListener('abort', abortHandler);
|
|
38
39
|
return Promise.resolve();
|
|
39
40
|
})
|
|
40
41
|
.catch((err) => {
|
|
@@ -47,8 +48,9 @@ const createAudioDecoder = ({ onFrame, onError, controller, config, logLevel, tr
|
|
|
47
48
|
},
|
|
48
49
|
});
|
|
49
50
|
const close = () => {
|
|
51
|
+
controller._internals._mediaParserController._internals.signal.removeEventListener('abort',
|
|
50
52
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
51
|
-
|
|
53
|
+
onAbort);
|
|
52
54
|
if (audioDecoder.state === 'closed') {
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
@@ -57,7 +59,7 @@ const createAudioDecoder = ({ onFrame, onError, controller, config, logLevel, tr
|
|
|
57
59
|
const onAbort = () => {
|
|
58
60
|
close();
|
|
59
61
|
};
|
|
60
|
-
controller._internals.signal.addEventListener('abort', onAbort);
|
|
62
|
+
controller._internals._mediaParserController._internals.signal.addEventListener('abort', onAbort);
|
|
61
63
|
audioDecoder.configure(config);
|
|
62
64
|
const processSample = async (audioSample) => {
|
|
63
65
|
if (audioDecoder.state === 'closed') {
|
package/dist/audio-encoder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MediaParserLogLevel } from '@remotion/media-parser';
|
|
2
2
|
import type { ProgressTracker } from './create/progress-tracker';
|
|
3
3
|
import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
|
|
4
4
|
import type { WebCodecsController } from './webcodecs-controller';
|
|
@@ -14,7 +14,7 @@ export type AudioEncoderInit = {
|
|
|
14
14
|
codec: ConvertMediaAudioCodec;
|
|
15
15
|
controller: WebCodecsController;
|
|
16
16
|
config: AudioEncoderConfig;
|
|
17
|
-
logLevel:
|
|
17
|
+
logLevel: MediaParserLogLevel;
|
|
18
18
|
onNewAudioSampleRate: (sampleRate: number) => void;
|
|
19
19
|
progressTracker: ProgressTracker;
|
|
20
20
|
};
|
package/dist/audio-encoder.js
CHANGED
|
@@ -5,7 +5,7 @@ const media_parser_1 = require("@remotion/media-parser");
|
|
|
5
5
|
const io_synchronizer_1 = require("./io-manager/io-synchronizer");
|
|
6
6
|
const wav_audio_encoder_1 = require("./wav-audio-encoder");
|
|
7
7
|
const createAudioEncoder = ({ onChunk, onError, codec, controller, config: audioEncoderConfig, logLevel, onNewAudioSampleRate, progressTracker, }) => {
|
|
8
|
-
if (controller._internals.signal.aborted) {
|
|
8
|
+
if (controller._internals._mediaParserController._internals.signal.aborted) {
|
|
9
9
|
throw new media_parser_1.MediaParserAbortError('Not creating audio encoder, already aborted');
|
|
10
10
|
}
|
|
11
11
|
if (codec === 'wav') {
|
|
@@ -26,7 +26,8 @@ const createAudioEncoder = ({ onChunk, onError, codec, controller, config: audio
|
|
|
26
26
|
ioSynchronizer.onOutput(chunk.timestamp);
|
|
27
27
|
prom = prom
|
|
28
28
|
.then(() => {
|
|
29
|
-
if (controller._internals.signal
|
|
29
|
+
if (controller._internals._mediaParserController._internals.signal
|
|
30
|
+
.aborted) {
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
return onChunk(chunk);
|
|
@@ -44,8 +45,9 @@ const createAudioEncoder = ({ onChunk, onError, codec, controller, config: audio
|
|
|
44
45
|
},
|
|
45
46
|
});
|
|
46
47
|
const close = () => {
|
|
48
|
+
controller._internals._mediaParserController._internals.signal.removeEventListener('abort',
|
|
47
49
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
48
|
-
|
|
50
|
+
onAbort);
|
|
49
51
|
if (encoder.state === 'closed') {
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
@@ -54,7 +56,7 @@ const createAudioEncoder = ({ onChunk, onError, codec, controller, config: audio
|
|
|
54
56
|
const onAbort = () => {
|
|
55
57
|
close();
|
|
56
58
|
};
|
|
57
|
-
controller._internals.signal.addEventListener('abort', onAbort);
|
|
59
|
+
controller._internals._mediaParserController._internals.signal.addEventListener('abort', onAbort);
|
|
58
60
|
if (codec !== 'opus' && codec !== 'aac') {
|
|
59
61
|
throw new Error('Only `codec: "opus"` and `codec: "aac"` is supported currently');
|
|
60
62
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare const autoSelectWriter: (writer: WriterInterface | undefined, logLevel: LogLevel) => Promise<WriterInterface>;
|
|
1
|
+
import type { MediaParserInternalTypes, MediaParserLogLevel } from '@remotion/media-parser';
|
|
2
|
+
export declare const autoSelectWriter: (writer: MediaParserInternalTypes["WriterInterface"] | undefined, logLevel: MediaParserLogLevel) => Promise<MediaParserInternalTypes["WriterInterface"]>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { MediaParserContainer,
|
|
1
|
+
import type { MediaParserContainer, MediaParserVideoTrack } from '@remotion/media-parser';
|
|
2
2
|
import type { ConvertMediaContainer } from './get-available-containers';
|
|
3
3
|
import type { ResizeOperation } from './resizing/mode';
|
|
4
4
|
export declare const canCopyVideoTrack: ({ outputContainer, rotationToApply, inputContainer, resizeOperation, inputTrack, }: {
|
|
5
5
|
inputContainer: MediaParserContainer;
|
|
6
|
-
inputTrack:
|
|
6
|
+
inputTrack: MediaParserVideoTrack;
|
|
7
7
|
rotationToApply: number;
|
|
8
8
|
outputContainer: ConvertMediaContainer;
|
|
9
9
|
resizeOperation: ResizeOperation | null;
|
|
@@ -12,7 +12,7 @@ const canCopyVideoTrack = ({ outputContainer, rotationToApply, inputContainer, r
|
|
|
12
12
|
height: inputTrack.height,
|
|
13
13
|
resizeOperation,
|
|
14
14
|
rotation: rotationToApply,
|
|
15
|
-
videoCodec: inputTrack.
|
|
15
|
+
videoCodec: inputTrack.codecEnum,
|
|
16
16
|
width: inputTrack.width,
|
|
17
17
|
});
|
|
18
18
|
if (newDimensions.height !== inputTrack.height ||
|
|
@@ -20,12 +20,10 @@ const canCopyVideoTrack = ({ outputContainer, rotationToApply, inputContainer, r
|
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
if (outputContainer === 'webm') {
|
|
23
|
-
return
|
|
24
|
-
inputTrack.codecWithoutConfig === 'vp9');
|
|
23
|
+
return inputTrack.codecEnum === 'vp8' || inputTrack.codecEnum === 'vp9';
|
|
25
24
|
}
|
|
26
25
|
if (outputContainer === 'mp4') {
|
|
27
|
-
return ((inputTrack.
|
|
28
|
-
inputTrack.codecWithoutConfig === 'h265') &&
|
|
26
|
+
return ((inputTrack.codecEnum === 'h264' || inputTrack.codecEnum === 'h265') &&
|
|
29
27
|
(inputContainer === 'mp4' ||
|
|
30
28
|
inputContainer === 'avi' ||
|
|
31
29
|
(inputContainer === 'm3u8' && inputTrack.m3uStreamFormat === 'mp4')));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediaParserAudioTrack } from '@remotion/media-parser';
|
|
2
2
|
import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
|
|
3
3
|
export declare const canReencodeAudioTrack: ({ track, audioCodec, bitrate, sampleRate, }: {
|
|
4
|
-
track:
|
|
4
|
+
track: MediaParserAudioTrack;
|
|
5
5
|
audioCodec: ConvertMediaAudioCodec;
|
|
6
6
|
bitrate: number;
|
|
7
7
|
sampleRate: number | null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediaParserVideoTrack } from '@remotion/media-parser';
|
|
2
2
|
import type { ConvertMediaVideoCodec } from './get-available-video-codecs';
|
|
3
3
|
import type { ResizeOperation } from './resizing/mode';
|
|
4
4
|
export declare const canReencodeVideoTrack: ({ videoCodec, track, resizeOperation, rotate, }: {
|
|
5
5
|
videoCodec: ConvertMediaVideoCodec;
|
|
6
|
-
track:
|
|
6
|
+
track: MediaParserVideoTrack;
|
|
7
7
|
resizeOperation: ResizeOperation | null;
|
|
8
8
|
rotate: number | null;
|
|
9
9
|
}) => Promise<boolean>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const convertEncodedChunk: (chunk: EncodedAudioChunk | EncodedVideoChunk, trackId: number) =>
|
|
1
|
+
import type { MediaParserAudioSample, MediaParserVideoSample } from '@remotion/media-parser';
|
|
2
|
+
export declare const convertEncodedChunk: <T extends MediaParserAudioSample | MediaParserVideoSample>(chunk: EncodedAudioChunk | EncodedVideoChunk, trackId: number) => T;
|
package/dist/convert-media.d.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025 Remotion AG
|
|
3
3
|
* For licensing, see: https://remotion.dev/docs/webcodecs#license
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
6
|
-
import type { ParseMediaCallbacks } from '@remotion/media-parser';
|
|
5
|
+
import type { MediaParserAudioTrack, MediaParserInternalTypes, MediaParserLogLevel, MediaParserVideoTrack, Options, ParseMediaFields, ParseMediaOptions } from '@remotion/media-parser';
|
|
7
6
|
import type { ConvertMediaAudioCodec } from './get-available-audio-codecs';
|
|
8
7
|
import { type ConvertMediaContainer } from './get-available-containers';
|
|
9
8
|
import { type ConvertMediaVideoCodec } from './get-available-video-codecs';
|
|
@@ -29,13 +28,13 @@ export type ConvertMediaResult = {
|
|
|
29
28
|
export type ConvertMediaOnProgress = (state: ConvertMediaProgress) => void;
|
|
30
29
|
export type ConvertMediaOnVideoFrame = (options: {
|
|
31
30
|
frame: VideoFrame;
|
|
32
|
-
track:
|
|
31
|
+
track: MediaParserVideoTrack;
|
|
33
32
|
}) => Promise<VideoFrame> | VideoFrame;
|
|
34
33
|
export type ConvertMediaOnAudioData = (options: {
|
|
35
34
|
audioData: AudioData;
|
|
36
|
-
track:
|
|
35
|
+
track: MediaParserAudioTrack;
|
|
37
36
|
}) => Promise<AudioData> | AudioData;
|
|
38
|
-
export declare const convertMedia: <F extends Options<ParseMediaFields>>({ src, onVideoFrame, onAudioData, onProgress: onProgressDoNotCallDirectly, audioCodec, container, videoCodec, controller, onAudioTrack: userAudioResolver, onVideoTrack: userVideoResolver, reader, fields, logLevel, writer, progressIntervalInMs, rotate, apiKey, resize, onAudioCodec, onContainer, onDimensions, onDurationInSeconds, onFps, onImages, onInternalStats, onIsHdr, onKeyframes, onLocation, onMetadata, onMimeType, onName, onNumberOfAudioChannels, onRotation, onSampleRate, onSize, onSlowAudioBitrate, onSlowDurationInSeconds, onSlowFps, onSlowKeyframes, onSlowNumberOfFrames, onSlowVideoBitrate,
|
|
37
|
+
export declare const convertMedia: <F extends Options<ParseMediaFields>>({ src, onVideoFrame, onAudioData, onProgress: onProgressDoNotCallDirectly, audioCodec, container, videoCodec, controller, onAudioTrack: userAudioResolver, onVideoTrack: userVideoResolver, reader, fields, logLevel, writer, progressIntervalInMs, rotate, apiKey, resize, onAudioCodec, onContainer, onDimensions, onDurationInSeconds, onFps, onImages, onInternalStats, onIsHdr, onKeyframes, onLocation, onMetadata, onMimeType, onName, onNumberOfAudioChannels, onRotation, onSampleRate, onSize, onSlowAudioBitrate, onSlowDurationInSeconds, onSlowFps, onSlowKeyframes, onSlowNumberOfFrames, onSlowVideoBitrate, onSlowStructure, onTracks, onUnrotatedDimensions, onVideoCodec, onM3uStreams, selectM3uStream, selectM3uAssociatedPlaylists, expectedDurationInSeconds, expectedFrameRate, seekingHints, ...more }: {
|
|
39
38
|
src: ParseMediaOptions<F>["src"];
|
|
40
39
|
container: ConvertMediaContainer;
|
|
41
40
|
onVideoFrame?: ConvertMediaOnVideoFrame;
|
|
@@ -51,12 +50,12 @@ export declare const convertMedia: <F extends Options<ParseMediaFields>>({ src,
|
|
|
51
50
|
expectedDurationInSeconds?: number | null;
|
|
52
51
|
expectedFrameRate?: number | null;
|
|
53
52
|
reader?: ParseMediaOptions<F>["reader"];
|
|
54
|
-
logLevel?:
|
|
55
|
-
writer?: WriterInterface;
|
|
53
|
+
logLevel?: MediaParserLogLevel;
|
|
54
|
+
writer?: MediaParserInternalTypes["WriterInterface"];
|
|
56
55
|
progressIntervalInMs?: number;
|
|
57
56
|
rotate?: number;
|
|
58
57
|
resize?: ResizeOperation;
|
|
59
58
|
apiKey?: string | null;
|
|
60
59
|
fields?: F;
|
|
61
60
|
seekingHints?: ParseMediaOptions<F>["seekingHints"];
|
|
62
|
-
} & ParseMediaCallbacks) => Promise<ConvertMediaResult>;
|
|
61
|
+
} & MediaParserInternalTypes["ParseMediaCallbacks"]) => Promise<ConvertMediaResult>;
|
package/dist/convert-media.js
CHANGED
|
@@ -21,8 +21,8 @@ const select_container_creator_1 = require("./select-container-creator");
|
|
|
21
21
|
const send_telemetry_event_1 = require("./send-telemetry-event");
|
|
22
22
|
const throttled_state_update_1 = require("./throttled-state-update");
|
|
23
23
|
const webcodecs_controller_1 = require("./webcodecs-controller");
|
|
24
|
-
const convertMedia = async function ({ src, onVideoFrame, onAudioData, onProgress: onProgressDoNotCallDirectly, audioCodec, container, videoCodec, controller = (0, webcodecs_controller_1.webcodecsController)(), onAudioTrack: userAudioResolver, onVideoTrack: userVideoResolver, reader, fields, logLevel = 'info', writer, progressIntervalInMs, rotate, apiKey, resize, onAudioCodec, onContainer, onDimensions, onDurationInSeconds, onFps, onImages, onInternalStats, onIsHdr, onKeyframes, onLocation, onMetadata, onMimeType, onName, onNumberOfAudioChannels, onRotation, onSampleRate, onSize, onSlowAudioBitrate, onSlowDurationInSeconds, onSlowFps, onSlowKeyframes, onSlowNumberOfFrames, onSlowVideoBitrate,
|
|
25
|
-
if (controller._internals.signal.aborted) {
|
|
24
|
+
const convertMedia = async function ({ src, onVideoFrame, onAudioData, onProgress: onProgressDoNotCallDirectly, audioCodec, container, videoCodec, controller = (0, webcodecs_controller_1.webcodecsController)(), onAudioTrack: userAudioResolver, onVideoTrack: userVideoResolver, reader, fields, logLevel = 'info', writer, progressIntervalInMs, rotate, apiKey, resize, onAudioCodec, onContainer, onDimensions, onDurationInSeconds, onFps, onImages, onInternalStats, onIsHdr, onKeyframes, onLocation, onMetadata, onMimeType, onName, onNumberOfAudioChannels, onRotation, onSampleRate, onSize, onSlowAudioBitrate, onSlowDurationInSeconds, onSlowFps, onSlowKeyframes, onSlowNumberOfFrames, onSlowVideoBitrate, onSlowStructure, onTracks, onUnrotatedDimensions, onVideoCodec, onM3uStreams, selectM3uStream, selectM3uAssociatedPlaylists, expectedDurationInSeconds, expectedFrameRate, seekingHints, ...more }) {
|
|
25
|
+
if (controller._internals._mediaParserController._internals.signal.aborted) {
|
|
26
26
|
return Promise.reject(new media_parser_1.MediaParserAbortError('Aborted'));
|
|
27
27
|
}
|
|
28
28
|
if (get_available_containers_1.availableContainers.indexOf(container) === -1) {
|
|
@@ -34,19 +34,19 @@ const convertMedia = async function ({ src, onVideoFrame, onAudioData, onProgres
|
|
|
34
34
|
const { resolve, reject, getPromiseToImmediatelyReturn } = (0, with_resolvers_1.withResolversAndWaitForReturn)();
|
|
35
35
|
const abortConversion = (errCause) => {
|
|
36
36
|
reject(errCause);
|
|
37
|
-
if (!controller._internals.signal.aborted) {
|
|
37
|
+
if (!controller._internals._mediaParserController._internals.signal.aborted) {
|
|
38
38
|
controller.abort();
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
const onUserAbort = () => {
|
|
42
42
|
abortConversion(new media_parser_1.MediaParserAbortError('Conversion aborted by user'));
|
|
43
43
|
};
|
|
44
|
-
controller._internals.signal.addEventListener('abort', onUserAbort);
|
|
44
|
+
controller._internals._mediaParserController._internals.signal.addEventListener('abort', onUserAbort);
|
|
45
45
|
const creator = (0, select_container_creator_1.selectContainerCreator)(container);
|
|
46
46
|
const throttledState = (0, throttled_state_update_1.throttledStateUpdate)({
|
|
47
47
|
updateFn: onProgressDoNotCallDirectly ?? null,
|
|
48
48
|
everyMilliseconds: progressIntervalInMs ?? 100,
|
|
49
|
-
signal: controller._internals.signal,
|
|
49
|
+
signal: controller._internals._mediaParserController._internals.signal,
|
|
50
50
|
});
|
|
51
51
|
const progressTracker = (0, progress_tracker_1.makeProgressTracker)();
|
|
52
52
|
const state = await creator({
|
|
@@ -111,7 +111,7 @@ const convertMedia = async function ({ src, onVideoFrame, onAudioData, onProgres
|
|
|
111
111
|
src,
|
|
112
112
|
onVideoTrack,
|
|
113
113
|
onAudioTrack,
|
|
114
|
-
controller: controller._mediaParserController,
|
|
114
|
+
controller: controller._internals._mediaParserController,
|
|
115
115
|
fields: {
|
|
116
116
|
...fields,
|
|
117
117
|
durationInSeconds: true,
|
|
@@ -166,7 +166,7 @@ const convertMedia = async function ({ src, onVideoFrame, onAudioData, onProgres
|
|
|
166
166
|
onSlowKeyframes: onSlowKeyframes ?? null,
|
|
167
167
|
onSlowNumberOfFrames: onSlowNumberOfFrames ?? null,
|
|
168
168
|
onSlowVideoBitrate: onSlowVideoBitrate ?? null,
|
|
169
|
-
|
|
169
|
+
onSlowStructure: onSlowStructure ?? null,
|
|
170
170
|
onTracks: onTracks ?? null,
|
|
171
171
|
onUnrotatedDimensions: onUnrotatedDimensions ?? null,
|
|
172
172
|
onVideoCodec: onVideoCodec ?? null,
|
|
@@ -203,7 +203,7 @@ const convertMedia = async function ({ src, onVideoFrame, onAudioData, onProgres
|
|
|
203
203
|
throttledState.stopAndGetLastProgress();
|
|
204
204
|
});
|
|
205
205
|
return getPromiseToImmediatelyReturn().finally(() => {
|
|
206
|
-
controller._internals.signal.removeEventListener('abort', onUserAbort);
|
|
206
|
+
controller._internals._mediaParserController._internals.signal.removeEventListener('abort', onUserAbort);
|
|
207
207
|
});
|
|
208
208
|
};
|
|
209
209
|
exports.convertMedia = convertMedia;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const exampleVideoSamplePositions: SamplePosition[];
|
|
3
|
-
export declare const exampleAudioSamplePositions: SamplePosition[];
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
|
+
export declare const exampleVideoSamplePositions: MediaParserInternalTypes['SamplePosition'][];
|
|
3
|
+
export declare const exampleAudioSamplePositions: MediaParserInternalTypes['SamplePosition'][];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediaParserLogLevel } from '@remotion/media-parser';
|
|
2
2
|
import type { IsoBaseMediaTrackData } from './serialize-track';
|
|
3
3
|
export declare const createPaddedMoovAtom: ({ durationInUnits, trackInfo, timescale, expectedDurationInSeconds, logLevel, expectedFrameRate, }: {
|
|
4
4
|
durationInUnits: number;
|
|
5
5
|
trackInfo: IsoBaseMediaTrackData[];
|
|
6
6
|
timescale: number;
|
|
7
7
|
expectedDurationInSeconds: number | null;
|
|
8
|
-
logLevel:
|
|
8
|
+
logLevel: MediaParserLogLevel;
|
|
9
9
|
expectedFrameRate: number | null;
|
|
10
10
|
}) => Uint8Array<ArrayBufferLike>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
2
|
import type { MakeTrackAudio, MakeTrackVideo } from '../make-track-info';
|
|
3
3
|
export type IsoBaseMediaTrackData = {
|
|
4
4
|
track: MakeTrackVideo | MakeTrackAudio;
|
|
5
5
|
durationInUnits: number;
|
|
6
|
-
samplePositions: SamplePosition[];
|
|
6
|
+
samplePositions: MediaParserInternalTypes['SamplePosition'][];
|
|
7
7
|
timescale: number;
|
|
8
8
|
};
|
|
9
9
|
export declare const serializeTrack: ({ track, durationInUnits, samplePositions, timescale, }: IsoBaseMediaTrackData) => Uint8Array<ArrayBufferLike>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
2
|
export declare const createStbl: ({ samplePositions, codecSpecificData, isVideo, }: {
|
|
3
|
-
samplePositions: SamplePosition[];
|
|
3
|
+
samplePositions: MediaParserInternalTypes["SamplePosition"][];
|
|
4
4
|
codecSpecificData: Uint8Array;
|
|
5
5
|
isVideo: boolean;
|
|
6
6
|
}) => Uint8Array<ArrayBufferLike>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createCttsBox: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike> | null;
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
|
+
export declare const createCttsBox: (samplePositions: MediaParserInternalTypes["SamplePosition"][]) => Uint8Array<ArrayBufferLike> | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createStcoAtom: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
|
+
export declare const createStcoAtom: (samplePositions: MediaParserInternalTypes["SamplePosition"][]) => Uint8Array<ArrayBufferLike>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createStsc: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
|
+
export declare const createStsc: (samplePositions: MediaParserInternalTypes["SamplePosition"][]) => Uint8Array<ArrayBufferLike>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createStss: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
|
+
export declare const createStss: (samplePositions: MediaParserInternalTypes["SamplePosition"][]) => Uint8Array<ArrayBufferLike>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createStsz: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
|
+
export declare const createStsz: (samplePositions: MediaParserInternalTypes["SamplePosition"][]) => Uint8Array<ArrayBufferLike>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createSttsAtom: (samplePositions: SamplePosition[]) => Uint8Array<ArrayBufferLike>;
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
|
+
export declare const createSttsAtom: (samplePositions: MediaParserInternalTypes["SamplePosition"][]) => Uint8Array<ArrayBufferLike>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MediaParserAudioCodec, MediaParserVideoCodec
|
|
1
|
+
import type { MediaParserAdvancedColor, MediaParserAudioCodec, MediaParserVideoCodec } from '@remotion/media-parser';
|
|
2
2
|
export type MakeTrackAudio = {
|
|
3
3
|
trackNumber: number;
|
|
4
4
|
codec: MediaParserAudioCodec;
|
|
@@ -9,7 +9,7 @@ export type MakeTrackAudio = {
|
|
|
9
9
|
timescale: number;
|
|
10
10
|
};
|
|
11
11
|
export type MakeTrackVideo = {
|
|
12
|
-
color:
|
|
12
|
+
color: MediaParserAdvancedColor;
|
|
13
13
|
width: number;
|
|
14
14
|
height: number;
|
|
15
15
|
trackNumber: number;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type
|
|
3
|
-
import type { LogLevel } from '../../log';
|
|
1
|
+
import type { MediaParserInternalTypes, MediaParserLogLevel } from '@remotion/media-parser';
|
|
2
|
+
import { type MediaParserAudioSample, type MediaParserVideoSample } from '@remotion/media-parser';
|
|
4
3
|
export declare const timestampToClusterTimestamp: (timestamp: number, timescale: number) => number;
|
|
5
4
|
export declare const canFitInCluster: ({ clusterStartTimestamp, chunk, timescale, }: {
|
|
6
5
|
clusterStartTimestamp: number;
|
|
7
|
-
chunk:
|
|
6
|
+
chunk: MediaParserAudioSample | MediaParserVideoSample;
|
|
8
7
|
timescale: number;
|
|
9
8
|
}) => boolean;
|
|
10
9
|
export declare const makeCluster: ({ writer, clusterStartTimestamp, timescale, logLevel, }: {
|
|
11
|
-
writer: Writer;
|
|
10
|
+
writer: MediaParserInternalTypes["Writer"];
|
|
12
11
|
clusterStartTimestamp: number;
|
|
13
12
|
timescale: number;
|
|
14
|
-
logLevel:
|
|
13
|
+
logLevel: MediaParserLogLevel;
|
|
15
14
|
}) => Promise<{
|
|
16
|
-
addSample: (chunk:
|
|
15
|
+
addSample: (chunk: MediaParserAudioSample | MediaParserVideoSample, trackNumber: number) => Promise<{
|
|
17
16
|
timecodeRelativeToCluster: number;
|
|
18
17
|
}>;
|
|
19
18
|
shouldMakeNewCluster: ({ isVideo, chunk, newT, }: {
|
|
20
19
|
newT: number;
|
|
21
|
-
chunk:
|
|
20
|
+
chunk: MediaParserAudioSample | MediaParserVideoSample;
|
|
22
21
|
isVideo: boolean;
|
|
23
22
|
}) => boolean;
|
|
24
23
|
startTimestamp: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const makeMatroskaColorBytes: ({ transferCharacteristics, matrixCoefficients, primaries, fullRange, }:
|
|
1
|
+
import type { MediaParserAdvancedColor } from '@remotion/media-parser';
|
|
2
|
+
export declare const makeMatroskaColorBytes: ({ transfer: transferCharacteristics, matrix: matrixCoefficients, primaries, fullRange, }: MediaParserAdvancedColor) => import("./matroska-utils").BytesAndOffset;
|
|
@@ -3,45 +3,102 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.makeMatroskaColorBytes = void 0;
|
|
4
4
|
const truthy_1 = require("../../truthy");
|
|
5
5
|
const matroska_utils_1 = require("./matroska-utils");
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const getRangeValue = ({ transferCharacteristics, matrixCoefficients, fullRange, }) => {
|
|
7
|
+
return transferCharacteristics && matrixCoefficients
|
|
8
8
|
? 3
|
|
9
9
|
: fullRange === true
|
|
10
10
|
? 2
|
|
11
11
|
: fullRange === false
|
|
12
12
|
? 1
|
|
13
13
|
: 0;
|
|
14
|
+
};
|
|
15
|
+
// https://w3c.github.io/webcodecs/#videocolorprimaries
|
|
16
|
+
const getPrimariesValue = (primaries) => {
|
|
17
|
+
if (primaries === null) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
if (primaries === 'bt709') {
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
if (primaries === 'bt470bg') {
|
|
24
|
+
return 5;
|
|
25
|
+
}
|
|
26
|
+
if (primaries === 'smpte170m') {
|
|
27
|
+
return 6;
|
|
28
|
+
}
|
|
29
|
+
if (primaries === 'bt2020') {
|
|
30
|
+
return 9;
|
|
31
|
+
}
|
|
32
|
+
if (primaries === 'smpte432') {
|
|
33
|
+
return 12;
|
|
34
|
+
}
|
|
35
|
+
throw new Error('Unknown primaries ' + primaries);
|
|
36
|
+
};
|
|
37
|
+
const getTransferCharacteristicsValue = (transferCharacteristics) => {
|
|
38
|
+
if (transferCharacteristics === null) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (transferCharacteristics === 'bt709') {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
if (transferCharacteristics === 'smpte170m') {
|
|
45
|
+
return 6;
|
|
46
|
+
}
|
|
47
|
+
if (transferCharacteristics === 'iec61966-2-1') {
|
|
48
|
+
return 13;
|
|
49
|
+
}
|
|
50
|
+
if (transferCharacteristics === 'linear') {
|
|
51
|
+
return 8;
|
|
52
|
+
}
|
|
53
|
+
if (transferCharacteristics === 'pq') {
|
|
54
|
+
return 16;
|
|
55
|
+
}
|
|
56
|
+
if (transferCharacteristics === 'hlg') {
|
|
57
|
+
return 18;
|
|
58
|
+
}
|
|
59
|
+
throw new Error('Unknown transfer characteristics ' +
|
|
60
|
+
transferCharacteristics);
|
|
61
|
+
};
|
|
62
|
+
const getMatrixCoefficientsValue = (matrixCoefficients) => {
|
|
63
|
+
if (matrixCoefficients === null) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (matrixCoefficients === 'rgb') {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
if (matrixCoefficients === 'bt709') {
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
72
|
+
if (matrixCoefficients === 'bt470bg') {
|
|
73
|
+
return 5;
|
|
74
|
+
}
|
|
75
|
+
if (matrixCoefficients === 'smpte170m') {
|
|
76
|
+
return 6;
|
|
77
|
+
}
|
|
78
|
+
if (matrixCoefficients === 'bt2020-ncl') {
|
|
79
|
+
return 9;
|
|
80
|
+
}
|
|
81
|
+
throw new Error('Unknown matrix coefficients ' + matrixCoefficients);
|
|
82
|
+
};
|
|
83
|
+
const makeMatroskaColorBytes = ({ transfer: transferCharacteristics, matrix: matrixCoefficients, primaries, fullRange, }) => {
|
|
84
|
+
const rangeValue = getRangeValue({
|
|
85
|
+
transferCharacteristics,
|
|
86
|
+
matrixCoefficients,
|
|
87
|
+
fullRange,
|
|
88
|
+
});
|
|
14
89
|
// https://datatracker.ietf.org/doc/draft-ietf-cellar-matroska/
|
|
15
90
|
// 5.1.4.1.28.27
|
|
16
|
-
const primariesValue = primaries
|
|
17
|
-
|
|
18
|
-
: primaries === 'smpte170m'
|
|
19
|
-
? 6
|
|
20
|
-
: primaries === 'bt470bg'
|
|
21
|
-
? 5
|
|
22
|
-
: 2;
|
|
23
|
-
const transferChracteristicsValue = transferCharacteristics === 'bt709'
|
|
24
|
-
? 1
|
|
25
|
-
: transferCharacteristics === 'smpte170m'
|
|
26
|
-
? 6
|
|
27
|
-
: transferCharacteristics === 'iec61966-2-1'
|
|
28
|
-
? 13
|
|
29
|
-
: 2;
|
|
91
|
+
const primariesValue = getPrimariesValue(primaries);
|
|
92
|
+
const transferChracteristicsValue = getTransferCharacteristicsValue(transferCharacteristics);
|
|
30
93
|
if (matrixCoefficients === 'rgb') {
|
|
31
94
|
throw new Error('Cannot encode Matroska in RGB');
|
|
32
95
|
}
|
|
33
|
-
const matrixCoefficientsValue = matrixCoefficients
|
|
34
|
-
? 1
|
|
35
|
-
: matrixCoefficients === 'bt470bg'
|
|
36
|
-
? 5
|
|
37
|
-
: matrixCoefficients === 'smpte170m'
|
|
38
|
-
? 6
|
|
39
|
-
: 2;
|
|
96
|
+
const matrixCoefficientsValue = getMatrixCoefficientsValue(matrixCoefficients);
|
|
40
97
|
return (0, matroska_utils_1.makeMatroskaBytes)({
|
|
41
98
|
type: 'Colour',
|
|
42
99
|
minVintWidth: null,
|
|
43
100
|
value: [
|
|
44
|
-
transferChracteristicsValue ===
|
|
101
|
+
transferChracteristicsValue === null
|
|
45
102
|
? null
|
|
46
103
|
: {
|
|
47
104
|
type: 'TransferCharacteristics',
|
|
@@ -51,7 +108,7 @@ const makeMatroskaColorBytes = ({ transferCharacteristics, matrixCoefficients, p
|
|
|
51
108
|
},
|
|
52
109
|
minVintWidth: null,
|
|
53
110
|
},
|
|
54
|
-
matrixCoefficientsValue ===
|
|
111
|
+
matrixCoefficientsValue === null
|
|
55
112
|
? null
|
|
56
113
|
: {
|
|
57
114
|
type: 'MatrixCoefficients',
|
|
@@ -61,7 +118,7 @@ const makeMatroskaColorBytes = ({ transferCharacteristics, matrixCoefficients, p
|
|
|
61
118
|
},
|
|
62
119
|
minVintWidth: null,
|
|
63
120
|
},
|
|
64
|
-
primariesValue ===
|
|
121
|
+
primariesValue === null
|
|
65
122
|
? null
|
|
66
123
|
: {
|
|
67
124
|
type: 'Primaries',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediaParserInternalTypes } from '@remotion/media-parser';
|
|
2
2
|
export type Seek = {
|
|
3
|
-
hexString: MatroskaElement;
|
|
3
|
+
hexString: MediaParserInternalTypes['MatroskaElement'];
|
|
4
4
|
byte: number;
|
|
5
5
|
};
|
|
6
6
|
export declare const createMatroskaSeekHead: (seeks: Seek[]) => import("./matroska-utils").BytesAndOffset[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediaParserAdvancedColor } from '@remotion/media-parser';
|
|
2
2
|
import type { MakeTrackAudio, MakeTrackVideo } from '../make-track-info';
|
|
3
3
|
export declare const makeMatroskaVideoBytes: ({ color, width, height, }: {
|
|
4
|
-
color:
|
|
4
|
+
color: MediaParserAdvancedColor;
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
7
|
}) => import("./matroska-utils").BytesAndOffset;
|