@remotion/webcodecs 4.0.227 → 4.0.229
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-config.js +3 -0
- package/dist/audio-decoder.d.ts +3 -3
- package/dist/audio-decoder.js +23 -29
- package/dist/audio-encoder.d.ts +3 -2
- package/dist/audio-encoder.js +17 -29
- package/dist/auto-select-writer.d.ts +3 -0
- package/dist/auto-select-writer.js +20 -0
- package/dist/calculate-progress.d.ts +4 -0
- package/dist/calculate-progress.js +10 -0
- package/dist/can-copy-audio-track.d.ts +8 -0
- package/dist/can-copy-audio-track.js +10 -0
- package/dist/can-copy-video-track.d.ts +8 -0
- package/dist/can-copy-video-track.js +13 -0
- package/dist/can-reencode-audio-track.d.ts +7 -0
- package/dist/can-reencode-audio-track.js +21 -0
- package/dist/can-reencode-audio.d.ts +7 -0
- package/dist/can-reencode-audio.js +21 -0
- package/dist/can-reencode-video-track.d.ts +6 -0
- package/dist/can-reencode-video-track.js +15 -0
- package/dist/can-reencode-video.d.ts +6 -0
- package/dist/can-reencode-video.js +15 -0
- package/dist/codec-id.d.ts +7 -2
- package/dist/codec-id.js +7 -0
- package/dist/convert-encoded-chunk.d.ts +2 -0
- package/dist/convert-encoded-chunk.js +15 -0
- package/dist/convert-media.d.ts +25 -9
- package/dist/convert-media.js +69 -15
- package/dist/esm/index.mjs +602 -297
- package/dist/event-emitter.d.ts +25 -0
- package/dist/event-emitter.js +23 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +12 -1
- package/dist/io-manager/event-emitter.d.ts +27 -0
- package/dist/io-manager/event-emitter.js +24 -0
- package/dist/io-manager/io-synchronizer.d.ts +12 -0
- package/dist/io-manager/io-synchronizer.js +95 -0
- package/dist/log.d.ts +10 -0
- package/dist/log.js +6 -0
- package/dist/on-audio-track.d.ts +6 -5
- package/dist/on-audio-track.js +23 -21
- package/dist/on-frame.d.ts +11 -0
- package/dist/on-frame.js +32 -0
- package/dist/on-video-track.d.ts +8 -6
- package/dist/on-video-track.js +30 -21
- package/dist/polyfill-encoded-audio-chunk.d.ts +3 -0
- package/dist/polyfill-encoded-audio-chunk.js +5 -0
- package/dist/resolve-audio-action.d.ts +15 -11
- package/dist/resolve-audio-action.js +23 -21
- package/dist/resolve-video-action.d.ts +14 -11
- package/dist/resolve-video-action.js +17 -24
- package/dist/video-decoder.d.ts +3 -3
- package/dist/video-decoder.js +23 -28
- package/dist/video-encoder-config.d.ts +6 -1
- package/dist/video-encoder-config.js +6 -1
- package/dist/video-encoder.d.ts +4 -3
- package/dist/video-encoder.js +26 -29
- package/dist/wait-until-return.d.ts +4 -0
- package/dist/wait-until-return.js +14 -0
- package/dist/with-resolvers.d.ts +5 -0
- package/dist/with-resolvers.js +16 -1
- package/package.json +4 -4
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
3
|
+
exports.defaultResolveAudioAction = void 0;
|
|
4
|
+
const can_copy_audio_track_1 = require("./can-copy-audio-track");
|
|
5
|
+
const can_reencode_audio_track_1 = require("./can-reencode-audio-track");
|
|
6
|
+
const log_1 = require("./log");
|
|
7
|
+
const DEFAULT_BITRATE = 128000;
|
|
8
|
+
const defaultResolveAudioAction = async ({ track, audioCodec, logLevel, container, }) => {
|
|
9
|
+
const bitrate = DEFAULT_BITRATE;
|
|
10
|
+
const canCopy = (0, can_copy_audio_track_1.canCopyAudioTrack)({
|
|
11
|
+
inputCodec: track.codecWithoutConfig,
|
|
12
|
+
outputCodec: audioCodec,
|
|
13
|
+
container,
|
|
14
|
+
});
|
|
11
15
|
if (canCopy) {
|
|
12
|
-
|
|
16
|
+
log_1.Log.verbose(logLevel, `Track ${track.trackId} (audio): Can copy = ${canCopy}, action = copy`);
|
|
17
|
+
return Promise.resolve({ type: 'copy' });
|
|
13
18
|
}
|
|
19
|
+
const canReencode = await (0, can_reencode_audio_track_1.canReencodeAudioTrack)({
|
|
20
|
+
audioCodec,
|
|
21
|
+
track,
|
|
22
|
+
bitrate,
|
|
23
|
+
});
|
|
14
24
|
if (canReencode) {
|
|
15
|
-
|
|
25
|
+
log_1.Log.verbose(logLevel, `Track ${track.trackId} (audio): Can re-encode = ${canReencode}, can copy = ${canCopy}, action = reencode`);
|
|
26
|
+
return Promise.resolve({ type: 'reencode', bitrate, audioCodec });
|
|
16
27
|
}
|
|
28
|
+
log_1.Log.verbose(logLevel, `Track ${track.trackId} (audio): Can re-encode = ${canReencode}, can copy = ${canCopy}, action = drop`);
|
|
17
29
|
// TODO: Make a fail option?
|
|
18
|
-
return 'drop';
|
|
30
|
+
return Promise.resolve({ type: 'drop' });
|
|
19
31
|
};
|
|
20
32
|
exports.defaultResolveAudioAction = defaultResolveAudioAction;
|
|
21
|
-
const resolveAudioAction = async ({ audioDecoderConfig, audioEncoderConfig, track, audioCodec, resolverFunction, }) => {
|
|
22
|
-
const canReencode = Boolean(audioDecoderConfig && audioEncoderConfig);
|
|
23
|
-
const canCopy = canCopyAudioTrack(track.codecWithoutConfig, audioCodec);
|
|
24
|
-
const resolved = await resolverFunction({
|
|
25
|
-
canReencode,
|
|
26
|
-
canCopy,
|
|
27
|
-
});
|
|
28
|
-
return resolved;
|
|
29
|
-
};
|
|
30
|
-
exports.resolveAudioAction = resolveAudioAction;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import type { VideoTrack } from '@remotion/media-parser';
|
|
1
|
+
import type { LogLevel, VideoTrack } from '@remotion/media-parser';
|
|
2
2
|
import type { ConvertMediaVideoCodec } from './codec-id';
|
|
3
|
-
|
|
3
|
+
import type { ConvertMediaContainer } from './convert-media';
|
|
4
|
+
export type VideoOperation = {
|
|
5
|
+
type: 'reencode';
|
|
6
|
+
videoCodec: ConvertMediaVideoCodec;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'copy';
|
|
9
|
+
} | {
|
|
10
|
+
type: 'drop';
|
|
11
|
+
};
|
|
4
12
|
export type ResolveVideoActionFn = (options: {
|
|
5
|
-
canReencode: boolean;
|
|
6
|
-
canCopy: boolean;
|
|
7
|
-
}) => VideoOperation | Promise<VideoOperation>;
|
|
8
|
-
export declare const defaultResolveVideoAction: ResolveVideoActionFn;
|
|
9
|
-
export declare const resolveVideoAction: ({ videoDecoderConfig, videoEncoderConfig, track, videoCodec, resolverFunction, }: {
|
|
10
|
-
videoDecoderConfig: VideoDecoderConfig | null;
|
|
11
|
-
videoEncoderConfig: VideoEncoderConfig | null;
|
|
12
13
|
videoCodec: ConvertMediaVideoCodec;
|
|
13
14
|
track: VideoTrack;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
logLevel: LogLevel;
|
|
16
|
+
container: ConvertMediaContainer;
|
|
17
|
+
}) => VideoOperation | Promise<VideoOperation>;
|
|
18
|
+
export declare const defaultResolveVideoAction: ResolveVideoActionFn;
|
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
const defaultResolveVideoAction = ({ canReencode, canCopy, }) => {
|
|
3
|
+
exports.defaultResolveVideoAction = void 0;
|
|
4
|
+
const can_copy_video_track_1 = require("./can-copy-video-track");
|
|
5
|
+
const can_reencode_video_track_1 = require("./can-reencode-video-track");
|
|
6
|
+
const log_1 = require("./log");
|
|
7
|
+
const defaultResolveVideoAction = async ({ track, videoCodec, logLevel, container, }) => {
|
|
8
|
+
const canCopy = (0, can_copy_video_track_1.canCopyVideoTrack)({
|
|
9
|
+
inputCodec: track.codecWithoutConfig,
|
|
10
|
+
outputCodec: videoCodec,
|
|
11
|
+
container,
|
|
12
|
+
});
|
|
14
13
|
if (canCopy) {
|
|
15
|
-
|
|
14
|
+
log_1.Log.verbose(logLevel, `Track ${track.trackId} (video): Can copy, therefore copying`);
|
|
15
|
+
return Promise.resolve({ type: 'copy' });
|
|
16
16
|
}
|
|
17
|
+
const canReencode = await (0, can_reencode_video_track_1.canReencodeVideoTrack)({ videoCodec, track });
|
|
17
18
|
if (canReencode) {
|
|
18
|
-
|
|
19
|
+
log_1.Log.verbose(logLevel, `Track ${track.trackId} (video): Cannot copy, but re-enconde, therefore re-encoding`);
|
|
20
|
+
return Promise.resolve({ type: 'reencode', videoCodec });
|
|
19
21
|
}
|
|
22
|
+
log_1.Log.verbose(logLevel, `Track ${track.trackId} (video): Can neither copy nor re-encode, therefore dropping`);
|
|
20
23
|
// TODO: Make a fail option?
|
|
21
|
-
return 'drop';
|
|
24
|
+
return Promise.resolve({ type: 'drop' });
|
|
22
25
|
};
|
|
23
26
|
exports.defaultResolveVideoAction = defaultResolveVideoAction;
|
|
24
|
-
const resolveVideoAction = async ({ videoDecoderConfig, videoEncoderConfig, track, videoCodec, resolverFunction, }) => {
|
|
25
|
-
const canReencode = Boolean(videoDecoderConfig && videoEncoderConfig);
|
|
26
|
-
const canCopy = canCopyVideoTrack(track.codecWithoutConfig, videoCodec);
|
|
27
|
-
const resolved = await resolverFunction({
|
|
28
|
-
canReencode,
|
|
29
|
-
canCopy,
|
|
30
|
-
});
|
|
31
|
-
return resolved;
|
|
32
|
-
};
|
|
33
|
-
exports.resolveVideoAction = resolveVideoAction;
|
package/dist/video-decoder.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { VideoSample } from '@remotion/media-parser';
|
|
1
|
+
import type { LogLevel, VideoSample } from '@remotion/media-parser';
|
|
2
2
|
export type WebCodecsVideoDecoder = {
|
|
3
3
|
processSample: (videoSample: VideoSample) => Promise<void>;
|
|
4
4
|
waitForFinish: () => Promise<void>;
|
|
5
5
|
close: () => void;
|
|
6
|
-
getQueueSize: () => number;
|
|
7
6
|
flush: () => Promise<void>;
|
|
8
7
|
};
|
|
9
|
-
export declare const createVideoDecoder: ({ onFrame, onError, signal, config, }: {
|
|
8
|
+
export declare const createVideoDecoder: ({ onFrame, onError, signal, config, logLevel, }: {
|
|
10
9
|
onFrame: (frame: VideoFrame) => Promise<void>;
|
|
11
10
|
onError: (error: DOMException) => void;
|
|
12
11
|
signal: AbortSignal;
|
|
13
12
|
config: VideoDecoderConfig;
|
|
13
|
+
logLevel: LogLevel;
|
|
14
14
|
}) => WebCodecsVideoDecoder;
|
package/dist/video-decoder.js
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createVideoDecoder = void 0;
|
|
4
|
-
const
|
|
4
|
+
const io_synchronizer_1 = require("./io-manager/io-synchronizer");
|
|
5
|
+
const createVideoDecoder = ({ onFrame, onError, signal, config, logLevel, }) => {
|
|
6
|
+
const ioSynchronizer = (0, io_synchronizer_1.makeIoSynchronizer)(logLevel, 'Video decoder');
|
|
5
7
|
let outputQueue = Promise.resolve();
|
|
6
|
-
let outputQueueSize = 0;
|
|
7
|
-
let dequeueResolver = () => { };
|
|
8
8
|
const videoDecoder = new VideoDecoder({
|
|
9
9
|
output(inputFrame) {
|
|
10
|
-
|
|
10
|
+
ioSynchronizer.onOutput(inputFrame.timestamp);
|
|
11
|
+
const abortHandler = () => {
|
|
12
|
+
inputFrame.close();
|
|
13
|
+
};
|
|
14
|
+
signal.addEventListener('abort', abortHandler, { once: true });
|
|
11
15
|
outputQueue = outputQueue
|
|
12
|
-
.then(() => onFrame(inputFrame))
|
|
13
16
|
.then(() => {
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
if (signal.aborted) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
return onFrame(inputFrame);
|
|
21
|
+
})
|
|
22
|
+
.then(() => {
|
|
23
|
+
ioSynchronizer.onProcessed();
|
|
24
|
+
signal.removeEventListener('abort', abortHandler);
|
|
16
25
|
return Promise.resolve();
|
|
26
|
+
})
|
|
27
|
+
.catch((err) => {
|
|
28
|
+
inputFrame.close();
|
|
29
|
+
onError(err);
|
|
17
30
|
});
|
|
18
31
|
},
|
|
19
32
|
error(error) {
|
|
@@ -32,38 +45,21 @@ const createVideoDecoder = ({ onFrame, onError, signal, config, }) => {
|
|
|
32
45
|
close();
|
|
33
46
|
};
|
|
34
47
|
signal.addEventListener('abort', onAbort);
|
|
35
|
-
const getQueueSize = () => {
|
|
36
|
-
return videoDecoder.decodeQueueSize + outputQueueSize;
|
|
37
|
-
};
|
|
38
48
|
videoDecoder.configure(config);
|
|
39
|
-
const waitForDequeue = async () => {
|
|
40
|
-
await new Promise((r) => {
|
|
41
|
-
dequeueResolver = r;
|
|
42
|
-
videoDecoder.addEventListener('dequeue', () => r(), {
|
|
43
|
-
once: true,
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
const waitForFinish = async () => {
|
|
48
|
-
while (getQueueSize() > 0) {
|
|
49
|
-
await waitForDequeue();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
49
|
const processSample = async (sample) => {
|
|
53
50
|
if (videoDecoder.state === 'closed') {
|
|
54
51
|
return;
|
|
55
52
|
}
|
|
56
|
-
while (getQueueSize() > 10) {
|
|
57
|
-
await waitForDequeue();
|
|
58
|
-
}
|
|
59
53
|
// @ts-expect-error - can have changed in the meanwhile
|
|
60
54
|
if (videoDecoder.state === 'closed') {
|
|
61
55
|
return;
|
|
62
56
|
}
|
|
57
|
+
await ioSynchronizer.waitFor({ unemitted: 20, _unprocessed: 2 });
|
|
63
58
|
if (sample.type === 'key') {
|
|
64
59
|
await videoDecoder.flush();
|
|
65
60
|
}
|
|
66
61
|
videoDecoder.decode(new EncodedVideoChunk(sample));
|
|
62
|
+
ioSynchronizer.inputItem(sample.timestamp, sample.type === 'key');
|
|
67
63
|
};
|
|
68
64
|
let inputQueue = Promise.resolve();
|
|
69
65
|
return {
|
|
@@ -73,12 +69,11 @@ const createVideoDecoder = ({ onFrame, onError, signal, config, }) => {
|
|
|
73
69
|
},
|
|
74
70
|
waitForFinish: async () => {
|
|
75
71
|
await videoDecoder.flush();
|
|
76
|
-
await waitForFinish();
|
|
72
|
+
await ioSynchronizer.waitForFinish();
|
|
77
73
|
await outputQueue;
|
|
78
74
|
await inputQueue;
|
|
79
75
|
},
|
|
80
76
|
close,
|
|
81
|
-
getQueueSize,
|
|
82
77
|
flush: async () => {
|
|
83
78
|
await videoDecoder.flush();
|
|
84
79
|
},
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ConvertMediaVideoCodec } from './codec-id';
|
|
2
|
+
export declare const getVideoEncoderConfig: ({ width, height, codec, }: {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
codec: ConvertMediaVideoCodec;
|
|
6
|
+
}) => Promise<VideoEncoderConfig | null>;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVideoEncoderConfig = void 0;
|
|
4
|
-
const getVideoEncoderConfig = async (
|
|
4
|
+
const getVideoEncoderConfig = async ({ width, height, codec, }) => {
|
|
5
5
|
if (typeof VideoEncoder === 'undefined') {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
|
+
const config = {
|
|
9
|
+
codec: codec === 'vp9' ? 'vp09.00.10.08' : codec,
|
|
10
|
+
height,
|
|
11
|
+
width,
|
|
12
|
+
};
|
|
8
13
|
const hardware = {
|
|
9
14
|
...config,
|
|
10
15
|
hardwareAcceleration: 'prefer-hardware',
|
package/dist/video-encoder.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import type { LogLevel } from '@remotion/media-parser';
|
|
1
2
|
export type WebCodecsVideoEncoder = {
|
|
2
|
-
encodeFrame: (videoFrame: VideoFrame) => Promise<void>;
|
|
3
|
+
encodeFrame: (videoFrame: VideoFrame, timestamp: number) => Promise<void>;
|
|
3
4
|
waitForFinish: () => Promise<void>;
|
|
4
5
|
close: () => void;
|
|
5
|
-
getQueueSize: () => number;
|
|
6
6
|
flush: () => Promise<void>;
|
|
7
7
|
};
|
|
8
|
-
export declare const createVideoEncoder: ({ onChunk, onError, signal, config, }: {
|
|
8
|
+
export declare const createVideoEncoder: ({ onChunk, onError, signal, config, logLevel, }: {
|
|
9
9
|
onChunk: (chunk: EncodedVideoChunk) => Promise<void>;
|
|
10
10
|
onError: (error: DOMException) => void;
|
|
11
11
|
signal: AbortSignal;
|
|
12
12
|
config: VideoEncoderConfig;
|
|
13
|
+
logLevel: LogLevel;
|
|
13
14
|
}) => WebCodecsVideoEncoder;
|
package/dist/video-encoder.js
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createVideoEncoder = void 0;
|
|
4
|
-
const
|
|
4
|
+
const io_synchronizer_1 = require("./io-manager/io-synchronizer");
|
|
5
|
+
const createVideoEncoder = ({ onChunk, onError, signal, config, logLevel, }) => {
|
|
5
6
|
if (signal.aborted) {
|
|
6
7
|
throw new Error('Not creating video encoder, already aborted');
|
|
7
8
|
}
|
|
9
|
+
const ioSynchronizer = (0, io_synchronizer_1.makeIoSynchronizer)(logLevel, 'Video encoder');
|
|
8
10
|
let outputQueue = Promise.resolve();
|
|
9
|
-
let outputQueueSize = 0;
|
|
10
|
-
let dequeueResolver = () => { };
|
|
11
11
|
const encoder = new VideoEncoder({
|
|
12
12
|
error(error) {
|
|
13
13
|
onError(error);
|
|
14
14
|
},
|
|
15
15
|
output(chunk) {
|
|
16
|
-
|
|
16
|
+
if (chunk.duration === null) {
|
|
17
|
+
throw new Error('Duration is null');
|
|
18
|
+
}
|
|
19
|
+
const timestamp = chunk.timestamp + chunk.duration;
|
|
20
|
+
ioSynchronizer.onOutput(timestamp);
|
|
17
21
|
outputQueue = outputQueue
|
|
18
|
-
.then(() => onChunk(chunk))
|
|
19
22
|
.then(() => {
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
if (signal.aborted) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return onChunk(chunk);
|
|
27
|
+
})
|
|
28
|
+
.then(() => {
|
|
29
|
+
ioSynchronizer.onProcessed();
|
|
22
30
|
return Promise.resolve();
|
|
31
|
+
})
|
|
32
|
+
.catch((err) => {
|
|
33
|
+
onError(err);
|
|
23
34
|
});
|
|
24
35
|
},
|
|
25
36
|
});
|
|
@@ -35,38 +46,25 @@ const createVideoEncoder = ({ onChunk, onError, signal, config, }) => {
|
|
|
35
46
|
close();
|
|
36
47
|
};
|
|
37
48
|
signal.addEventListener('abort', onAbort);
|
|
38
|
-
const getQueueSize = () => {
|
|
39
|
-
return encoder.encodeQueueSize + outputQueueSize;
|
|
40
|
-
};
|
|
41
49
|
encoder.configure(config);
|
|
42
50
|
let framesProcessed = 0;
|
|
43
|
-
const waitForDequeue = async () => {
|
|
44
|
-
await new Promise((r) => {
|
|
45
|
-
dequeueResolver = r;
|
|
46
|
-
encoder.addEventListener('dequeue', () => r(), {
|
|
47
|
-
once: true,
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
const waitForFinish = async () => {
|
|
52
|
-
while (getQueueSize() > 0) {
|
|
53
|
-
await waitForDequeue();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
51
|
const encodeFrame = async (frame) => {
|
|
57
52
|
if (encoder.state === 'closed') {
|
|
58
53
|
return;
|
|
59
54
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
await ioSynchronizer.waitFor({
|
|
56
|
+
unemitted: 2,
|
|
57
|
+
_unprocessed: 2,
|
|
58
|
+
});
|
|
63
59
|
// @ts-expect-error - can have changed in the meanwhile
|
|
64
60
|
if (encoder.state === 'closed') {
|
|
65
61
|
return;
|
|
66
62
|
}
|
|
63
|
+
const keyFrame = framesProcessed % 40 === 0;
|
|
67
64
|
encoder.encode(frame, {
|
|
68
|
-
keyFrame
|
|
65
|
+
keyFrame,
|
|
69
66
|
});
|
|
67
|
+
ioSynchronizer.inputItem(frame.timestamp, keyFrame);
|
|
70
68
|
framesProcessed++;
|
|
71
69
|
};
|
|
72
70
|
let inputQueue = Promise.resolve();
|
|
@@ -78,10 +76,9 @@ const createVideoEncoder = ({ onChunk, onError, signal, config, }) => {
|
|
|
78
76
|
waitForFinish: async () => {
|
|
79
77
|
await encoder.flush();
|
|
80
78
|
await outputQueue;
|
|
81
|
-
await waitForFinish();
|
|
79
|
+
await ioSynchronizer.waitForFinish();
|
|
82
80
|
},
|
|
83
81
|
close,
|
|
84
|
-
getQueueSize,
|
|
85
82
|
flush: async () => {
|
|
86
83
|
await encoder.flush();
|
|
87
84
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitUntilReturn = void 0;
|
|
4
|
+
const with_resolvers_1 = require("./with-resolvers");
|
|
5
|
+
const waitUntilReturn = () => {
|
|
6
|
+
const { promise, resolve } = (0, with_resolvers_1.withResolvers)();
|
|
7
|
+
return {
|
|
8
|
+
waitForReturn: () => promise,
|
|
9
|
+
isReturning: () => {
|
|
10
|
+
resolve(undefined);
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.waitUntilReturn = waitUntilReturn;
|
package/dist/with-resolvers.d.ts
CHANGED
|
@@ -3,3 +3,8 @@ export declare const withResolvers: <T>() => {
|
|
|
3
3
|
resolve: (value: T | PromiseLike<T>) => void;
|
|
4
4
|
reject: (reason?: any) => void;
|
|
5
5
|
};
|
|
6
|
+
export declare const withResolversAndWaitForReturn: <T>() => {
|
|
7
|
+
getPromiseToImmediatelyReturn: () => Promise<T>;
|
|
8
|
+
reject: (reason: unknown) => void;
|
|
9
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
10
|
+
};
|
package/dist/with-resolvers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withResolvers = void 0;
|
|
3
|
+
exports.withResolversAndWaitForReturn = exports.withResolvers = void 0;
|
|
4
4
|
const withResolvers = function () {
|
|
5
5
|
let resolve;
|
|
6
6
|
let reject;
|
|
@@ -11,3 +11,18 @@ const withResolvers = function () {
|
|
|
11
11
|
return { promise, resolve: resolve, reject: reject };
|
|
12
12
|
};
|
|
13
13
|
exports.withResolvers = withResolvers;
|
|
14
|
+
const withResolversAndWaitForReturn = () => {
|
|
15
|
+
const { promise, reject, resolve } = (0, exports.withResolvers)();
|
|
16
|
+
const { promise: returnPromise, resolve: resolveReturn } = (0, exports.withResolvers)();
|
|
17
|
+
return {
|
|
18
|
+
getPromiseToImmediatelyReturn: () => {
|
|
19
|
+
resolveReturn(undefined);
|
|
20
|
+
return promise;
|
|
21
|
+
},
|
|
22
|
+
reject: (reason) => {
|
|
23
|
+
returnPromise.then(() => reject(reason));
|
|
24
|
+
},
|
|
25
|
+
resolve,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.withResolversAndWaitForReturn = withResolversAndWaitForReturn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/webcodecs",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.229",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"author": "Jonny Burger <jonny@remotion.dev>",
|
|
18
|
-
"license": "
|
|
18
|
+
"license": "Remotion License (See https://remotion.dev/docs/webcodecs#license)",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@remotion/media-parser": "4.0.
|
|
20
|
+
"@remotion/media-parser": "4.0.229"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/dom-webcodecs": "0.1.11",
|
|
25
25
|
"eslint": "9.14.0",
|
|
26
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
26
|
+
"@remotion/eslint-config-internal": "4.0.229"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [],
|
|
29
29
|
"publishConfig": {
|