@remotion/web-renderer 4.0.383 → 4.0.384
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/add-sample.d.ts +3 -0
- package/dist/add-sample.js +20 -0
- package/dist/artifact.d.ts +4 -5
- package/dist/artifact.js +12 -15
- package/dist/audio.d.ts +2 -0
- package/dist/audio.js +45 -0
- package/dist/esm/index.mjs +1275 -54
- package/dist/get-audio-encoding-config.d.ts +2 -0
- package/dist/get-audio-encoding-config.js +18 -0
- package/dist/render-media-on-web.js +30 -8
- package/dist/render-still-on-web.js +5 -5
- package/package.json +6 -6
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { canEncodeAudio, QUALITY_MEDIUM, } from 'mediabunny';
|
|
2
|
+
export const getDefaultAudioEncodingConfig = async () => {
|
|
3
|
+
const preferredDefaultAudioEncodingConfig = {
|
|
4
|
+
codec: 'aac',
|
|
5
|
+
bitrate: QUALITY_MEDIUM,
|
|
6
|
+
};
|
|
7
|
+
if (await canEncodeAudio(preferredDefaultAudioEncodingConfig.codec, preferredDefaultAudioEncodingConfig)) {
|
|
8
|
+
return preferredDefaultAudioEncodingConfig;
|
|
9
|
+
}
|
|
10
|
+
const backupDefaultAudioEncodingConfig = {
|
|
11
|
+
codec: 'opus',
|
|
12
|
+
bitrate: QUALITY_MEDIUM,
|
|
13
|
+
};
|
|
14
|
+
if (await canEncodeAudio(backupDefaultAudioEncodingConfig.codec, backupDefaultAudioEncodingConfig)) {
|
|
15
|
+
return backupDefaultAudioEncodingConfig;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { BufferTarget, Output,
|
|
1
|
+
import { AudioSampleSource, BufferTarget, Output, VideoSampleSource, } from 'mediabunny';
|
|
2
2
|
import { Internals } from 'remotion';
|
|
3
|
+
import { addAudioSample, addVideoSampleAndCloseFrame } from './add-sample';
|
|
3
4
|
import { handleArtifacts } from './artifact';
|
|
5
|
+
import { onlyInlineAudio } from './audio';
|
|
4
6
|
import { createScaffold } from './create-scaffold';
|
|
5
7
|
import { getRealFrameRange } from './frame-range';
|
|
8
|
+
import { getDefaultAudioEncodingConfig } from './get-audio-encoding-config';
|
|
6
9
|
import { codecToMediabunnyCodec, containerToMediabunnyContainer, getDefaultVideoCodecForContainer, getQualityForWebRendererQuality, } from './mediabunny-mappings';
|
|
7
10
|
import { createFrame } from './take-screenshot';
|
|
8
11
|
import { createThrottledProgressCallback } from './throttle-progress';
|
|
@@ -55,10 +58,7 @@ const internalRenderMediaOnWeb = async ({ composition, inputProps, delayRenderTi
|
|
|
55
58
|
defaultCodec: resolved.defaultCodec,
|
|
56
59
|
defaultOutName: resolved.defaultOutName,
|
|
57
60
|
});
|
|
58
|
-
const artifactsHandler = handleArtifacts(
|
|
59
|
-
ref: collectAssets,
|
|
60
|
-
onArtifact,
|
|
61
|
-
});
|
|
61
|
+
const artifactsHandler = handleArtifacts();
|
|
62
62
|
cleanupFns.push(() => {
|
|
63
63
|
cleanupScaffold();
|
|
64
64
|
});
|
|
@@ -100,6 +100,16 @@ const internalRenderMediaOnWeb = async ({ composition, inputProps, delayRenderTi
|
|
|
100
100
|
videoSampleSource.close();
|
|
101
101
|
});
|
|
102
102
|
output.addVideoTrack(videoSampleSource);
|
|
103
|
+
// TODO: Should be able to customize
|
|
104
|
+
const defaultAudioEncodingConfig = await getDefaultAudioEncodingConfig();
|
|
105
|
+
if (!defaultAudioEncodingConfig) {
|
|
106
|
+
return Promise.reject(new Error('No default audio encoding config found'));
|
|
107
|
+
}
|
|
108
|
+
const audioSampleSource = new AudioSampleSource(defaultAudioEncodingConfig);
|
|
109
|
+
cleanupFns.push(() => {
|
|
110
|
+
audioSampleSource.close();
|
|
111
|
+
});
|
|
112
|
+
output.addAudioTrack(audioSampleSource);
|
|
103
113
|
await output.start();
|
|
104
114
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
105
115
|
throw new Error('renderMediaOnWeb() was cancelled');
|
|
@@ -125,7 +135,16 @@ const internalRenderMediaOnWeb = async ({ composition, inputProps, delayRenderTi
|
|
|
125
135
|
width: resolved.width,
|
|
126
136
|
height: resolved.height,
|
|
127
137
|
});
|
|
128
|
-
|
|
138
|
+
const assets = collectAssets.current.collectAssets();
|
|
139
|
+
if (onArtifact) {
|
|
140
|
+
await artifactsHandler.handle({
|
|
141
|
+
imageData,
|
|
142
|
+
frame: i,
|
|
143
|
+
assets,
|
|
144
|
+
onArtifact,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const audio = onlyInlineAudio(assets);
|
|
129
148
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
130
149
|
throw new Error('renderMediaOnWeb() was cancelled');
|
|
131
150
|
}
|
|
@@ -147,10 +166,12 @@ const internalRenderMediaOnWeb = async ({ composition, inputProps, delayRenderTi
|
|
|
147
166
|
expectedTimestamp: timestamp,
|
|
148
167
|
});
|
|
149
168
|
}
|
|
150
|
-
await
|
|
169
|
+
await Promise.all([
|
|
170
|
+
addVideoSampleAndCloseFrame(frameToEncode, videoSampleSource),
|
|
171
|
+
audio ? addAudioSample(audio, audioSampleSource) : Promise.resolve(),
|
|
172
|
+
]);
|
|
151
173
|
progress.encodedFrames++;
|
|
152
174
|
throttledOnProgress === null || throttledOnProgress === void 0 ? void 0 : throttledOnProgress({ ...progress });
|
|
153
|
-
frameToEncode.close();
|
|
154
175
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
155
176
|
throw new Error('renderMediaOnWeb() was cancelled');
|
|
156
177
|
}
|
|
@@ -158,6 +179,7 @@ const internalRenderMediaOnWeb = async ({ composition, inputProps, delayRenderTi
|
|
|
158
179
|
// Call progress one final time to ensure final state is reported
|
|
159
180
|
onProgress === null || onProgress === void 0 ? void 0 : onProgress({ ...progress });
|
|
160
181
|
videoSampleSource.close();
|
|
182
|
+
audioSampleSource.close();
|
|
161
183
|
await output.finalize();
|
|
162
184
|
return output.target.buffer;
|
|
163
185
|
}
|
|
@@ -37,10 +37,7 @@ async function internalRenderStillOnWeb({ frame, delayRenderTimeoutInMillisecond
|
|
|
37
37
|
defaultCodec: resolved.defaultCodec,
|
|
38
38
|
defaultOutName: resolved.defaultOutName,
|
|
39
39
|
});
|
|
40
|
-
const artifactsHandler = handleArtifacts(
|
|
41
|
-
ref: collectAssets,
|
|
42
|
-
onArtifact,
|
|
43
|
-
});
|
|
40
|
+
const artifactsHandler = handleArtifacts();
|
|
44
41
|
try {
|
|
45
42
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
46
43
|
throw new Error('renderStillOnWeb() was cancelled');
|
|
@@ -60,7 +57,10 @@ async function internalRenderStillOnWeb({ frame, delayRenderTimeoutInMillisecond
|
|
|
60
57
|
height: resolved.height,
|
|
61
58
|
imageFormat,
|
|
62
59
|
});
|
|
63
|
-
|
|
60
|
+
const assets = collectAssets.current.collectAssets();
|
|
61
|
+
if (onArtifact) {
|
|
62
|
+
await artifactsHandler.handle({ imageData, frame, assets, onArtifact });
|
|
63
|
+
}
|
|
64
64
|
return imageData;
|
|
65
65
|
}
|
|
66
66
|
finally {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/web-renderer"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/web-renderer",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.384",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"scripts": {
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"author": "Remotion <jonny@remotion.dev>",
|
|
17
17
|
"license": "UNLICENSED",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"remotion": "4.0.
|
|
20
|
-
"mediabunny": "1.25.
|
|
19
|
+
"remotion": "4.0.384",
|
|
20
|
+
"mediabunny": "1.25.8"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
24
|
-
"@remotion/player": "4.0.
|
|
25
|
-
"@remotion/media": "4.0.
|
|
23
|
+
"@remotion/eslint-config-internal": "4.0.384",
|
|
24
|
+
"@remotion/player": "4.0.384",
|
|
25
|
+
"@remotion/media": "4.0.384",
|
|
26
26
|
"@vitejs/plugin-react": "4.1.0",
|
|
27
27
|
"@vitest/browser-playwright": "4.0.9",
|
|
28
28
|
"playwright": "1.55.1",
|