@remotion/renderer 4.0.0-alpha4 → 4.0.0-alpha5
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/README.md +5 -43
- package/dist/assets/download-map.d.ts +0 -26
- package/dist/assets/download-map.js +0 -5
- package/dist/assets/get-audio-channels.d.ts +1 -2
- package/dist/assets/get-audio-channels.js +5 -9
- package/dist/audio-codec.d.ts +4 -3
- package/dist/audio-codec.js +3 -9
- package/dist/browser/BrowserFetcher.d.ts +0 -1
- package/dist/browser/BrowserFetcher.js +1 -2
- package/dist/browser/BrowserRunner.js +8 -2
- package/dist/browser/FrameManager.js +2 -3
- package/dist/browser/LaunchOptions.d.ts +1 -0
- package/dist/browser/Launcher.js +2 -1
- package/dist/browser/devtools-commands.d.ts +5 -1
- package/dist/browser/devtools-types.d.ts +78 -0
- package/dist/browser/is-target-closed-err.d.ts +1 -0
- package/dist/browser/is-target-closed-err.js +9 -0
- package/dist/call-ffmpeg.d.ts +14 -0
- package/dist/call-ffmpeg.js +37 -0
- package/dist/check-apple-silicon.js +2 -45
- package/dist/client.d.ts +67 -42
- package/dist/client.js +27 -1
- package/dist/codec-supports-media.d.ts +2 -1
- package/dist/codec-supports-media.js +20 -5
- package/dist/combine-videos.d.ts +0 -3
- package/dist/combine-videos.js +5 -9
- package/dist/compositor/compose.d.ts +3 -1
- package/dist/compositor/compose.js +34 -14
- package/dist/compositor/compositor.d.ts +12 -0
- package/dist/compositor/compositor.js +202 -0
- package/dist/compositor/get-executable-path.d.ts +1 -1
- package/dist/compositor/get-executable-path.js +27 -8
- package/dist/compositor/make-nonce.d.ts +1 -0
- package/dist/compositor/make-nonce.js +8 -0
- package/dist/compositor/payloads.d.ts +34 -7
- package/dist/create-ffmpeg-complex-filter.d.ts +5 -5
- package/dist/create-ffmpeg-complex-filter.js +2 -4
- package/dist/create-ffmpeg-merge-filter.d.ts +2 -5
- package/dist/create-ffmpeg-merge-filter.js +2 -10
- package/dist/create-silent-audio.d.ts +1 -4
- package/dist/create-silent-audio.js +3 -7
- package/dist/crf.js +8 -2
- package/dist/delete-directory.js +16 -16
- package/dist/file-extensions.d.ts +1 -12
- package/dist/file-extensions.js +1 -13
- package/dist/get-compositions.d.ts +3 -5
- package/dist/get-compositions.js +8 -11
- package/dist/get-extension-from-codec.d.ts +2 -2
- package/dist/get-frame-padded-index.d.ts +2 -1
- package/dist/guess-extension-for-media.d.ts +1 -3
- package/dist/guess-extension-for-media.js +4 -8
- package/dist/image-format.d.ts +12 -6
- package/dist/image-format.js +16 -13
- package/dist/index.d.ts +66 -59
- package/dist/index.js +15 -17
- package/dist/jpeg-quality.d.ts +1 -0
- package/dist/jpeg-quality.js +21 -0
- package/dist/merge-audio-track.d.ts +0 -2
- package/dist/merge-audio-track.js +3 -10
- package/dist/offthread-video-server.d.ts +8 -8
- package/dist/offthread-video-server.js +63 -56
- package/dist/open-browser.d.ts +1 -0
- package/dist/open-browser.js +7 -6
- package/dist/options/audio-bitrate.d.ts +2 -0
- package/dist/options/audio-bitrate.js +11 -0
- package/dist/options/crf.d.ts +2 -0
- package/dist/options/crf.js +11 -0
- package/dist/options/enforce-audio.d.ts +2 -0
- package/dist/options/enforce-audio.js +11 -0
- package/dist/options/jpeg-quality.d.ts +2 -0
- package/dist/options/jpeg-quality.js +11 -0
- package/dist/options/mute.d.ts +2 -0
- package/dist/options/mute.js +11 -0
- package/dist/options/option.d.ts +8 -0
- package/dist/options/option.js +2 -0
- package/dist/options/scale.d.ts +2 -0
- package/dist/options/scale.js +11 -0
- package/dist/options/video-bitrate.d.ts +2 -0
- package/dist/options/video-bitrate.js +11 -0
- package/dist/options/video-codec.d.ts +2 -0
- package/dist/options/video-codec.js +11 -0
- package/dist/perf.d.ts +1 -1
- package/dist/perf.js +9 -7
- package/dist/prepare-server.d.ts +3 -4
- package/dist/prepare-server.js +5 -5
- package/dist/preprocess-audio-track.d.ts +0 -4
- package/dist/preprocess-audio-track.js +4 -8
- package/dist/prespawn-ffmpeg.d.ts +6 -9
- package/dist/prespawn-ffmpeg.js +7 -12
- package/dist/prestitcher-memory-usage.d.ts +0 -4
- package/dist/prestitcher-memory-usage.js +2 -3
- package/dist/prores-profile.d.ts +1 -2
- package/dist/prores-profile.js +4 -4
- package/dist/provide-screenshot.d.ts +4 -5
- package/dist/provide-screenshot.js +2 -2
- package/dist/puppeteer-screenshot.d.ts +3 -3
- package/dist/puppeteer-screenshot.js +9 -32
- package/dist/render-frames.d.ts +13 -25
- package/dist/render-frames.js +29 -40
- package/dist/render-media.d.ts +16 -18
- package/dist/render-media.js +33 -43
- package/dist/render-still.d.ts +10 -8
- package/dist/render-still.js +14 -13
- package/dist/screenshot-dom-element.d.ts +4 -5
- package/dist/screenshot-dom-element.js +6 -3
- package/dist/screenshot-task.d.ts +2 -3
- package/dist/screenshot-task.js +38 -23
- package/dist/serve-handler/index.js +6 -4
- package/dist/serve-static.d.ts +2 -3
- package/dist/serve-static.js +24 -20
- package/dist/stitch-frames-to-video.d.ts +2 -12
- package/dist/stitch-frames-to-video.js +24 -33
- package/dist/take-frame-and-compose.d.ts +4 -5
- package/dist/take-frame-and-compose.js +12 -6
- package/dist/tmp-dir.js +1 -2
- package/dist/validate-concurrency.d.ts +2 -0
- package/dist/validate-concurrency.js +11 -5
- package/dist/validate-output-filename.d.ts +1 -1
- package/dist/validate-puppeteer-timeout.js +1 -0
- package/install-toolchain.mjs +36 -0
- package/package.json +11 -10
package/dist/render-media.js
CHANGED
|
@@ -15,14 +15,13 @@ const crf_1 = require("./crf");
|
|
|
15
15
|
const delete_directory_1 = require("./delete-directory");
|
|
16
16
|
const ensure_frames_in_order_1 = require("./ensure-frames-in-order");
|
|
17
17
|
const ensure_output_directory_1 = require("./ensure-output-directory");
|
|
18
|
-
const find_closest_package_json_1 = require("./find-closest-package-json");
|
|
19
18
|
const get_duration_from_frame_range_1 = require("./get-duration-from-frame-range");
|
|
20
19
|
const get_extension_from_codec_1 = require("./get-extension-from-codec");
|
|
21
20
|
const get_extension_of_filename_1 = require("./get-extension-of-filename");
|
|
22
21
|
const get_frame_to_render_1 = require("./get-frame-to-render");
|
|
23
22
|
const image_format_1 = require("./image-format");
|
|
24
23
|
const is_audio_codec_1 = require("./is-audio-codec");
|
|
25
|
-
const
|
|
24
|
+
const jpeg_quality_1 = require("./jpeg-quality");
|
|
26
25
|
const make_cancel_signal_1 = require("./make-cancel-signal");
|
|
27
26
|
const overwrite_1 = require("./overwrite");
|
|
28
27
|
const perf_1 = require("./perf");
|
|
@@ -30,36 +29,27 @@ const pixel_format_1 = require("./pixel-format");
|
|
|
30
29
|
const prespawn_ffmpeg_1 = require("./prespawn-ffmpeg");
|
|
31
30
|
const prestitcher_memory_usage_1 = require("./prestitcher-memory-usage");
|
|
32
31
|
const prores_profile_1 = require("./prores-profile");
|
|
33
|
-
const quality_1 = require("./quality");
|
|
34
32
|
const render_frames_1 = require("./render-frames");
|
|
35
33
|
const stitch_frames_to_video_1 = require("./stitch-frames-to-video");
|
|
36
34
|
const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
|
|
37
35
|
const validate_every_nth_frame_1 = require("./validate-every-nth-frame");
|
|
38
|
-
const validate_ffmpeg_1 = require("./validate-ffmpeg");
|
|
39
36
|
const validate_ffmpeg_override_1 = require("./validate-ffmpeg-override");
|
|
37
|
+
const validate_number_of_gif_loops_1 = require("./validate-number-of-gif-loops");
|
|
40
38
|
const validate_output_filename_1 = require("./validate-output-filename");
|
|
41
39
|
const validate_scale_1 = require("./validate-scale");
|
|
42
40
|
const validate_videobitrate_1 = require("./validate-videobitrate");
|
|
43
41
|
const SLOWEST_FRAME_COUNT = 10;
|
|
44
|
-
const getConcurrency = (others) => {
|
|
45
|
-
if ('concurrency' in others) {
|
|
46
|
-
return others.concurrency;
|
|
47
|
-
}
|
|
48
|
-
if ('parallelism' in others) {
|
|
49
|
-
return others.parallelism;
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
};
|
|
53
42
|
/**
|
|
54
43
|
*
|
|
55
44
|
* @description Render a video from a composition
|
|
56
45
|
* @see [Documentation](https://www.remotion.dev/docs/renderer/render-media)
|
|
57
46
|
*/
|
|
58
|
-
const renderMedia = ({ proResProfile, crf, composition,
|
|
59
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
const renderMedia = ({ proResProfile, crf, composition, inputProps, pixelFormat, codec, envVariables, frameRange, puppeteerInstance, outputLocation, onProgress, overwrite, onDownload, dumpBrowserLogs, onBrowserLog, onStart, timeoutInMilliseconds, chromiumOptions, scale, browserExecutable, port, cancelSignal, muted, enforceAudioTrack, ffmpegOverride, audioBitrate, videoBitrate, audioCodec, ...options }) => {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
49
|
+
if (options.quality) {
|
|
50
|
+
throw new Error(`The "quality" option has been renamed. Please use "jpegQuality" instead.`);
|
|
51
|
+
}
|
|
52
|
+
(0, jpeg_quality_1.validateJpegQuality)(options.jpegQuality);
|
|
63
53
|
(0, crf_1.validateQualitySettings)({ crf, codec, videoBitrate });
|
|
64
54
|
(0, validate_videobitrate_1.validateBitrate)(audioBitrate, 'audioBitrate');
|
|
65
55
|
(0, validate_videobitrate_1.validateBitrate)(videoBitrate, 'videoBitrate');
|
|
@@ -80,12 +70,11 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
80
70
|
? path_1.default.resolve(process.cwd(), outputLocation)
|
|
81
71
|
: null;
|
|
82
72
|
(0, validate_scale_1.validateScale)(scale);
|
|
83
|
-
const concurrency = getConcurrency(options);
|
|
84
73
|
(0, validate_ffmpeg_override_1.validateFfmpegOverride)(ffmpegOverride);
|
|
85
74
|
const everyNthFrame = (_b = options.everyNthFrame) !== null && _b !== void 0 ? _b : 1;
|
|
86
75
|
(0, validate_every_nth_frame_1.validateEveryNthFrame)(everyNthFrame, codec);
|
|
87
76
|
const numberOfGifLoops = (_c = options.numberOfGifLoops) !== null && _c !== void 0 ? _c : null;
|
|
88
|
-
|
|
77
|
+
(0, validate_number_of_gif_loops_1.validateNumberOfGifLoops)(numberOfGifLoops, codec);
|
|
89
78
|
let stitchStage = 'encoding';
|
|
90
79
|
let stitcherFfmpeg;
|
|
91
80
|
let preStitcher = null;
|
|
@@ -104,20 +93,21 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
104
93
|
hasEnoughMemory &&
|
|
105
94
|
(0, can_use_parallel_encoding_1.canUseParallelEncoding)(codec);
|
|
106
95
|
if (options.verbose) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
const log = (_f = options.printLog) !== null && _f !== void 0 ? _f : console.log;
|
|
97
|
+
log('[PRESTITCHER] Free memory:', freeMemory, 'Estimated usage parallel encoding', estimatedUsage);
|
|
98
|
+
log('[PRESTITCHER]: Codec supports parallel rendering:', (0, can_use_parallel_encoding_1.canUseParallelEncoding)(codec));
|
|
99
|
+
log('[PRESTITCHER]: User disallowed parallel encoding:', Boolean(options.disallowParallelEncoding));
|
|
110
100
|
if (parallelEncoding) {
|
|
111
|
-
|
|
101
|
+
log('[PRESTITCHER] Parallel encoding is enabled.');
|
|
112
102
|
}
|
|
113
103
|
else {
|
|
114
|
-
|
|
104
|
+
log('[PRESTITCHER] Parallel encoding is disabled.');
|
|
115
105
|
}
|
|
116
106
|
}
|
|
117
107
|
const imageFormat = (0, is_audio_codec_1.isAudioCodec)(codec)
|
|
118
108
|
? 'none'
|
|
119
|
-
: (
|
|
120
|
-
const
|
|
109
|
+
: (_g = options.imageFormat) !== null && _g !== void 0 ? _g : 'jpeg';
|
|
110
|
+
const jpegQuality = imageFormat === 'jpeg' ? options.jpegQuality : undefined;
|
|
121
111
|
(0, image_format_1.validateSelectedPixelFormatAndImageFormatCombination)(pixelFormat, imageFormat);
|
|
122
112
|
const preEncodedFileLocation = parallelEncoding
|
|
123
113
|
? path_1.default.join(downloadMap.preEncode, 'pre-encode.' + (0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, audioCodec !== null && audioCodec !== void 0 ? audioCodec : null))
|
|
@@ -125,7 +115,7 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
125
115
|
const outputDir = parallelEncoding
|
|
126
116
|
? null
|
|
127
117
|
: fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'react-motion-render'));
|
|
128
|
-
if (((
|
|
118
|
+
if (((_h = options.internal) === null || _h === void 0 ? void 0 : _h.onCtrlCExit) && outputDir) {
|
|
129
119
|
options.internal.onCtrlCExit(() => (0, delete_directory_1.deleteDirectory)(outputDir));
|
|
130
120
|
}
|
|
131
121
|
(0, validate_even_dimensions_with_codec_1.validateEvenDimensionsWithCodec)({
|
|
@@ -156,10 +146,10 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
156
146
|
const { waitForRightTimeOfFrameToBeInserted, setFrameToStitch, waitForFinish } = (0, ensure_frames_in_order_1.ensureFramesInOrder)(realFrameRange);
|
|
157
147
|
const fps = composition.fps / (everyNthFrame !== null && everyNthFrame !== void 0 ? everyNthFrame : 1);
|
|
158
148
|
remotion_1.Internals.validateFps(fps, 'in "renderMedia()"', codec === 'gif');
|
|
159
|
-
const createPrestitcherIfNecessary =
|
|
149
|
+
const createPrestitcherIfNecessary = () => {
|
|
160
150
|
var _a;
|
|
161
151
|
if (preEncodedFileLocation) {
|
|
162
|
-
preStitcher =
|
|
152
|
+
preStitcher = (0, prespawn_ffmpeg_1.prespawnFfmpeg)({
|
|
163
153
|
width: composition.width * (scale !== null && scale !== void 0 ? scale : 1),
|
|
164
154
|
height: composition.height * (scale !== null && scale !== void 0 ? scale : 1),
|
|
165
155
|
fps,
|
|
@@ -173,12 +163,11 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
173
163
|
callUpdate();
|
|
174
164
|
},
|
|
175
165
|
verbose: (_a = options.verbose) !== null && _a !== void 0 ? _a : false,
|
|
176
|
-
ffmpegExecutable,
|
|
177
166
|
imageFormat,
|
|
178
167
|
signal: cancelPrestitcher.cancelSignal,
|
|
179
168
|
ffmpegOverride: ffmpegOverride !== null && ffmpegOverride !== void 0 ? ffmpegOverride : (({ args }) => args),
|
|
180
169
|
videoBitrate: videoBitrate !== null && videoBitrate !== void 0 ? videoBitrate : null,
|
|
181
|
-
}
|
|
170
|
+
});
|
|
182
171
|
stitcherFfmpeg = preStitcher.task;
|
|
183
172
|
}
|
|
184
173
|
};
|
|
@@ -221,16 +210,17 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
221
210
|
}
|
|
222
211
|
minTime = (_b = (_a = slowestFrames[slowestFrames.length - 1]) === null || _a === void 0 ? void 0 : _a.time) !== null && _b !== void 0 ? _b : minTime;
|
|
223
212
|
};
|
|
224
|
-
const happyPath = createPrestitcherIfNecessary()
|
|
213
|
+
const happyPath = Promise.resolve(createPrestitcherIfNecessary())
|
|
225
214
|
.then(() => {
|
|
215
|
+
var _a;
|
|
226
216
|
const renderFramesProc = (0, render_frames_1.renderFrames)({
|
|
227
|
-
|
|
217
|
+
composition,
|
|
228
218
|
onFrameUpdate: (frame, frameIndex, timeToRenderInMilliseconds) => {
|
|
229
219
|
renderedFrames = frame;
|
|
230
220
|
callUpdate();
|
|
231
221
|
recordFrameTime(frameIndex, timeToRenderInMilliseconds);
|
|
232
222
|
},
|
|
233
|
-
concurrency,
|
|
223
|
+
concurrency: options.concurrency,
|
|
234
224
|
outputDir,
|
|
235
225
|
onStart: (data) => {
|
|
236
226
|
renderedFrames = 0;
|
|
@@ -240,7 +230,7 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
240
230
|
inputProps,
|
|
241
231
|
envVariables,
|
|
242
232
|
imageFormat,
|
|
243
|
-
|
|
233
|
+
jpegQuality,
|
|
244
234
|
frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
|
|
245
235
|
puppeteerInstance,
|
|
246
236
|
everyNthFrame,
|
|
@@ -257,20 +247,19 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
257
247
|
setFrameToStitch(Math.min(realFrameRange[1] + 1, frame + everyNthFrame));
|
|
258
248
|
}
|
|
259
249
|
: undefined,
|
|
260
|
-
serveUrl,
|
|
250
|
+
serveUrl: options.serveUrl,
|
|
261
251
|
dumpBrowserLogs,
|
|
262
252
|
onBrowserLog,
|
|
263
253
|
onDownload,
|
|
264
254
|
timeoutInMilliseconds,
|
|
265
255
|
chromiumOptions,
|
|
266
256
|
scale,
|
|
267
|
-
ffmpegExecutable,
|
|
268
|
-
ffprobeExecutable,
|
|
269
257
|
browserExecutable,
|
|
270
258
|
port,
|
|
271
259
|
cancelSignal: cancelRenderFrames.cancelSignal,
|
|
272
260
|
downloadMap,
|
|
273
261
|
muted: disableAudio,
|
|
262
|
+
verbose: (_a = options.verbose) !== null && _a !== void 0 ? _a : false,
|
|
274
263
|
});
|
|
275
264
|
return renderFramesProc;
|
|
276
265
|
})
|
|
@@ -302,8 +291,6 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
302
291
|
proResProfile,
|
|
303
292
|
crf,
|
|
304
293
|
assetsInfo,
|
|
305
|
-
ffmpegExecutable,
|
|
306
|
-
ffprobeExecutable,
|
|
307
294
|
onProgress: (frame) => {
|
|
308
295
|
stitchStage = 'muxing';
|
|
309
296
|
encodedFrames = frame;
|
|
@@ -329,8 +316,11 @@ const renderMedia = ({ proResProfile, crf, composition, ffmpegExecutable, ffprob
|
|
|
329
316
|
encodedDoneIn = Date.now() - stitchStart;
|
|
330
317
|
callUpdate();
|
|
331
318
|
slowestFrames.sort((a, b) => b.time - a.time);
|
|
332
|
-
|
|
333
|
-
|
|
319
|
+
const result = {
|
|
320
|
+
buffer,
|
|
321
|
+
slowestFrames,
|
|
322
|
+
};
|
|
323
|
+
return result;
|
|
334
324
|
})
|
|
335
325
|
.catch((err) => {
|
|
336
326
|
/**
|
package/dist/render-still.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnySmallCompMetadata } from 'remotion';
|
|
3
3
|
import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
|
|
4
4
|
import type { DownloadMap } from './assets/download-map';
|
|
5
5
|
import type { BrowserExecutable } from './browser-executable';
|
|
6
6
|
import type { Browser as PuppeteerBrowser } from './browser/Browser';
|
|
7
|
-
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
8
7
|
import type { StillImageFormat } from './image-format';
|
|
9
|
-
import type { ServeUrlOrWebpackBundle } from './legacy-webpack-config';
|
|
10
8
|
import type { CancelSignal } from './make-cancel-signal';
|
|
11
9
|
import type { ChromiumOptions } from './open-browser';
|
|
12
10
|
declare type InnerStillOptions = {
|
|
13
|
-
composition:
|
|
11
|
+
composition: AnySmallCompMetadata;
|
|
14
12
|
output?: string | null;
|
|
15
13
|
frame?: number;
|
|
16
14
|
inputProps?: unknown;
|
|
17
15
|
imageFormat?: StillImageFormat;
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Renamed to `jpegQuality`
|
|
18
|
+
*/
|
|
19
|
+
quality?: never;
|
|
20
|
+
jpegQuality?: number;
|
|
19
21
|
puppeteerInstance?: PuppeteerBrowser;
|
|
20
22
|
dumpBrowserLogs?: boolean;
|
|
21
23
|
envVariables?: Record<string, string>;
|
|
@@ -26,17 +28,17 @@ declare type InnerStillOptions = {
|
|
|
26
28
|
scale?: number;
|
|
27
29
|
onDownload?: RenderMediaOnDownload;
|
|
28
30
|
cancelSignal?: CancelSignal;
|
|
29
|
-
ffmpegExecutable?: FfmpegExecutable;
|
|
30
|
-
ffprobeExecutable?: FfmpegExecutable;
|
|
31
31
|
/**
|
|
32
32
|
* @deprecated Only for Remotion internal usage
|
|
33
33
|
*/
|
|
34
34
|
downloadMap?: DownloadMap;
|
|
35
|
+
verbose?: boolean;
|
|
35
36
|
};
|
|
36
37
|
declare type RenderStillReturnValue = {
|
|
37
38
|
buffer: Buffer | null;
|
|
38
39
|
};
|
|
39
|
-
export declare type RenderStillOptions = InnerStillOptions &
|
|
40
|
+
export declare type RenderStillOptions = InnerStillOptions & {
|
|
41
|
+
serveUrl: string;
|
|
40
42
|
port?: number | null;
|
|
41
43
|
};
|
|
42
44
|
/**
|
package/dist/render-still.js
CHANGED
|
@@ -37,18 +37,20 @@ const ensure_output_directory_1 = require("./ensure-output-directory");
|
|
|
37
37
|
const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
|
|
38
38
|
const find_closest_package_json_1 = require("./find-closest-package-json");
|
|
39
39
|
const image_format_1 = require("./image-format");
|
|
40
|
-
const
|
|
40
|
+
const jpeg_quality_1 = require("./jpeg-quality");
|
|
41
41
|
const make_cancel_signal_1 = require("./make-cancel-signal");
|
|
42
42
|
const open_browser_1 = require("./open-browser");
|
|
43
43
|
const prepare_server_1 = require("./prepare-server");
|
|
44
44
|
const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
45
|
-
const quality_1 = require("./quality");
|
|
46
45
|
const seek_to_frame_1 = require("./seek-to-frame");
|
|
47
46
|
const set_props_and_env_1 = require("./set-props-and-env");
|
|
48
47
|
const take_frame_and_compose_1 = require("./take-frame-and-compose");
|
|
49
48
|
const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
|
|
50
49
|
const validate_scale_1 = require("./validate-scale");
|
|
51
|
-
const innerRenderStill = async ({ composition, quality, imageFormat =
|
|
50
|
+
const innerRenderStill = async ({ composition, quality, imageFormat = image_format_1.DEFAULT_STILL_IMAGE_FORMAT, serveUrl, puppeteerInstance, dumpBrowserLogs = false, onError, inputProps, envVariables, output, frame = 0, overwrite = true, browserExecutable, timeoutInMilliseconds, chromiumOptions, scale = 1, proxyPort, cancelSignal, downloadMap, jpegQuality, }) => {
|
|
51
|
+
if (quality) {
|
|
52
|
+
throw new Error('quality has been renamed to jpegQuality. Please rename the option.');
|
|
53
|
+
}
|
|
52
54
|
remotion_1.Internals.validateDimension(composition.height, 'height', 'in the `config` object passed to `renderStill()`');
|
|
53
55
|
remotion_1.Internals.validateDimension(composition.width, 'width', 'in the `config` object passed to `renderStill()`');
|
|
54
56
|
remotion_1.Internals.validateFps(composition.fps, 'in the `config` object of `renderStill()`', false);
|
|
@@ -57,7 +59,7 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
57
59
|
component: 'in the `config` object passed to `renderStill()`',
|
|
58
60
|
allowFloats: false,
|
|
59
61
|
});
|
|
60
|
-
(0, image_format_1.
|
|
62
|
+
(0, image_format_1.validateStillImageFormat)(imageFormat);
|
|
61
63
|
remotion_1.Internals.validateFrame({
|
|
62
64
|
frame,
|
|
63
65
|
durationInFrames: composition.durationInFrames,
|
|
@@ -71,10 +73,10 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
71
73
|
(0, validate_scale_1.validateScale)(scale);
|
|
72
74
|
output =
|
|
73
75
|
typeof output === 'string' ? path_1.default.resolve(process.cwd(), output) : null;
|
|
74
|
-
if (
|
|
76
|
+
if (jpegQuality !== undefined && imageFormat !== 'jpeg') {
|
|
75
77
|
throw new Error("You can only pass the `quality` option if `imageFormat` is 'jpeg'.");
|
|
76
78
|
}
|
|
77
|
-
(0,
|
|
79
|
+
(0, jpeg_quality_1.validateJpegQuality)(jpegQuality);
|
|
78
80
|
if (output) {
|
|
79
81
|
if (fs_1.default.existsSync(output)) {
|
|
80
82
|
if (!overwrite) {
|
|
@@ -168,7 +170,7 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
168
170
|
imageFormat,
|
|
169
171
|
scale,
|
|
170
172
|
output,
|
|
171
|
-
|
|
173
|
+
jpegQuality,
|
|
172
174
|
wantsBuffer: !output,
|
|
173
175
|
});
|
|
174
176
|
await cleanup();
|
|
@@ -181,22 +183,21 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
181
183
|
*/
|
|
182
184
|
const renderStill = (options) => {
|
|
183
185
|
var _a, _b;
|
|
184
|
-
const selectedServeUrl = (0, legacy_webpack_config_1.getServeUrlWithFallback)(options);
|
|
185
186
|
const downloadMap = (_a = options.downloadMap) !== null && _a !== void 0 ? _a : (0, download_map_1.makeDownloadMap)();
|
|
186
187
|
const onDownload = (_b = options.onDownload) !== null && _b !== void 0 ? _b : (() => () => undefined);
|
|
187
188
|
const happyPath = new Promise((resolve, reject) => {
|
|
188
|
-
var _a, _b
|
|
189
|
+
var _a, _b;
|
|
189
190
|
const onError = (err) => reject(err);
|
|
190
191
|
let close = null;
|
|
191
192
|
(0, prepare_server_1.prepareServer)({
|
|
192
|
-
webpackConfigOrServeUrl:
|
|
193
|
+
webpackConfigOrServeUrl: options.serveUrl,
|
|
193
194
|
onDownload,
|
|
194
195
|
onError,
|
|
195
|
-
|
|
196
|
-
ffprobeExecutable: (_b = options.ffprobeExecutable) !== null && _b !== void 0 ? _b : null,
|
|
197
|
-
port: (_c = options.port) !== null && _c !== void 0 ? _c : null,
|
|
196
|
+
port: (_a = options.port) !== null && _a !== void 0 ? _a : null,
|
|
198
197
|
downloadMap,
|
|
199
198
|
remotionRoot: (0, find_closest_package_json_1.findRemotionRoot)(),
|
|
199
|
+
concurrency: 1,
|
|
200
|
+
verbose: (_b = options.verbose) !== null && _b !== void 0 ? _b : false,
|
|
200
201
|
})
|
|
201
202
|
.then(({ serveUrl, closeServer, offthreadPort }) => {
|
|
202
203
|
close = closeServer;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { ClipRegion } from 'remotion';
|
|
3
2
|
import type { Page } from './browser/BrowserPage';
|
|
4
|
-
import type {
|
|
5
|
-
export declare const screenshotDOMElement: ({ page, imageFormat,
|
|
3
|
+
import type { StillImageFormat } from './image-format';
|
|
4
|
+
export declare const screenshotDOMElement: ({ page, imageFormat, jpegQuality, opts, height, width, clipRegion, }: {
|
|
6
5
|
page: Page;
|
|
7
|
-
imageFormat:
|
|
8
|
-
|
|
6
|
+
imageFormat: StillImageFormat;
|
|
7
|
+
jpegQuality: number | undefined;
|
|
9
8
|
opts: {
|
|
10
9
|
path: string | null;
|
|
11
10
|
};
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.screenshotDOMElement = void 0;
|
|
4
4
|
const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
5
5
|
const puppeteer_screenshot_1 = require("./puppeteer-screenshot");
|
|
6
|
-
const screenshotDOMElement = async ({ page, imageFormat,
|
|
6
|
+
const screenshotDOMElement = async ({ page, imageFormat, jpegQuality, opts, height, width, clipRegion, }) => {
|
|
7
7
|
const { path } = opts;
|
|
8
|
-
if (imageFormat === 'png'
|
|
8
|
+
if (imageFormat === 'png' ||
|
|
9
|
+
imageFormat === 'pdf' ||
|
|
10
|
+
imageFormat === 'webp') {
|
|
9
11
|
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
10
12
|
pageFunction: () => {
|
|
11
13
|
document.body.style.background = 'transparent';
|
|
@@ -25,6 +27,7 @@ const screenshotDOMElement = async ({ page, imageFormat, quality, opts, height,
|
|
|
25
27
|
page,
|
|
26
28
|
});
|
|
27
29
|
}
|
|
30
|
+
// @ts-expect-error
|
|
28
31
|
if (imageFormat === 'none') {
|
|
29
32
|
throw new TypeError('Tried to make a screenshot with format "none"');
|
|
30
33
|
}
|
|
@@ -33,7 +36,7 @@ const screenshotDOMElement = async ({ page, imageFormat, quality, opts, height,
|
|
|
33
36
|
omitBackground: imageFormat === 'png',
|
|
34
37
|
path: path !== null && path !== void 0 ? path : undefined,
|
|
35
38
|
type: imageFormat,
|
|
36
|
-
|
|
39
|
+
jpegQuality,
|
|
37
40
|
width,
|
|
38
41
|
height,
|
|
39
42
|
clipRegion,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { ClipRegion } from 'remotion';
|
|
3
2
|
import type { Page } from './browser/BrowserPage';
|
|
4
3
|
import type { StillImageFormat } from './image-format';
|
|
5
|
-
export declare const screenshotTask: ({ format, height, omitBackground, page, width, path,
|
|
4
|
+
export declare const screenshotTask: ({ format, height, omitBackground, page, width, path, jpegQuality, clipRegion, }: {
|
|
6
5
|
page: Page;
|
|
7
6
|
format: StillImageFormat;
|
|
8
7
|
path?: string | undefined;
|
|
9
|
-
|
|
8
|
+
jpegQuality?: number | undefined;
|
|
10
9
|
omitBackground: boolean;
|
|
11
10
|
width: number;
|
|
12
11
|
height: number;
|
package/dist/screenshot-task.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.screenshotTask = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const perf_1 = require("./perf");
|
|
9
|
-
const screenshotTask = async ({ format, height, omitBackground, page, width, path,
|
|
9
|
+
const screenshotTask = async ({ format, height, omitBackground, page, width, path, jpegQuality, clipRegion, }) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const client = page._client();
|
|
12
12
|
const target = page.target();
|
|
@@ -15,34 +15,49 @@ const screenshotTask = async ({ format, height, omitBackground, page, width, pat
|
|
|
15
15
|
targetId: target._targetId,
|
|
16
16
|
});
|
|
17
17
|
(0, perf_1.stopPerfMeasure)(perfTarget);
|
|
18
|
-
const shouldSetDefaultBackground = omitBackground
|
|
18
|
+
const shouldSetDefaultBackground = omitBackground;
|
|
19
19
|
if (shouldSetDefaultBackground)
|
|
20
20
|
await client.send('Emulation.setDefaultBackgroundColorOverride', {
|
|
21
21
|
color: { r: 0, g: 0, b: 0, a: 0 },
|
|
22
22
|
});
|
|
23
23
|
const cap = (0, perf_1.startPerfMeasure)('capture');
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
25
|
+
let result;
|
|
26
|
+
if (format === 'pdf') {
|
|
27
|
+
result = await client.send('Page.printToPDF', {
|
|
28
|
+
paperWidth: width / 96,
|
|
29
|
+
paperHeight: height / 96,
|
|
30
|
+
marginTop: 0,
|
|
31
|
+
marginBottom: 0,
|
|
32
|
+
marginLeft: 0,
|
|
33
|
+
marginRight: 0,
|
|
34
|
+
scale: 1,
|
|
35
|
+
printBackground: true,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
result = await client.send('Page.captureScreenshot', {
|
|
40
|
+
format,
|
|
41
|
+
quality: jpegQuality,
|
|
42
|
+
clip: clipRegion !== null && clipRegion !== 'hide'
|
|
43
|
+
? {
|
|
44
|
+
x: clipRegion.x,
|
|
45
|
+
y: clipRegion.y,
|
|
46
|
+
height: clipRegion.height,
|
|
47
|
+
scale: 1,
|
|
48
|
+
width: clipRegion.width,
|
|
49
|
+
}
|
|
50
|
+
: {
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0,
|
|
53
|
+
height,
|
|
54
|
+
scale: 1,
|
|
55
|
+
width,
|
|
56
|
+
},
|
|
57
|
+
captureBeyondViewport: true,
|
|
58
|
+
optimizeForSpeed: true,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
46
61
|
(0, perf_1.stopPerfMeasure)(cap);
|
|
47
62
|
if (shouldSetDefaultBackground)
|
|
48
63
|
await client.send('Emulation.setDefaultBackgroundColorOverride');
|
|
@@ -59,10 +59,11 @@ const findRelated = async (current, relativePath) => {
|
|
|
59
59
|
};
|
|
60
60
|
const sendError = (absolutePath, response, spec) => {
|
|
61
61
|
const { message, statusCode } = spec;
|
|
62
|
-
response.statusCode = statusCode;
|
|
63
62
|
const headers = getHeaders(absolutePath, null);
|
|
64
|
-
response.writeHead(statusCode,
|
|
65
|
-
|
|
63
|
+
response.writeHead(statusCode, {
|
|
64
|
+
...headers,
|
|
65
|
+
'Content-Type': 'application/json',
|
|
66
|
+
});
|
|
66
67
|
response.end(JSON.stringify({ statusCode, message }));
|
|
67
68
|
};
|
|
68
69
|
const internalError = (absolutePath, response) => {
|
|
@@ -123,7 +124,8 @@ const serveHandler = async (request, response, config) => {
|
|
|
123
124
|
try {
|
|
124
125
|
const related = await findRelated(current, relativePath);
|
|
125
126
|
if (related) {
|
|
126
|
-
|
|
127
|
+
stats = related.stats;
|
|
128
|
+
absolutePath = related.absolutePath;
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
catch (err) {
|
package/dist/serve-static.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
|
|
2
2
|
import type { DownloadMap } from './assets/download-map';
|
|
3
|
-
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
4
3
|
export declare const serveStatic: (path: string | null, options: {
|
|
5
4
|
port: number | null;
|
|
6
|
-
ffmpegExecutable: FfmpegExecutable;
|
|
7
|
-
ffprobeExecutable: FfmpegExecutable;
|
|
8
5
|
onDownload: RenderMediaOnDownload;
|
|
9
6
|
onError: (err: Error) => void;
|
|
10
7
|
downloadMap: DownloadMap;
|
|
11
8
|
remotionRoot: string;
|
|
9
|
+
concurrency: number;
|
|
10
|
+
verbose: boolean;
|
|
12
11
|
}) => Promise<{
|
|
13
12
|
port: number;
|
|
14
13
|
close: () => Promise<void>;
|
package/dist/serve-static.js
CHANGED
|
@@ -9,13 +9,12 @@ const get_port_1 = require("./get-port");
|
|
|
9
9
|
const offthread_video_server_1 = require("./offthread-video-server");
|
|
10
10
|
const serve_handler_1 = require("./serve-handler");
|
|
11
11
|
const serveStatic = async (path, options) => {
|
|
12
|
-
const offthreadRequest = (0, offthread_video_server_1.startOffthreadVideoServer)({
|
|
13
|
-
ffmpegExecutable: options.ffmpegExecutable,
|
|
14
|
-
ffprobeExecutable: options.ffprobeExecutable,
|
|
12
|
+
const { listener: offthreadRequest, close: closeCompositor } = (0, offthread_video_server_1.startOffthreadVideoServer)({
|
|
15
13
|
onDownload: options.onDownload,
|
|
16
14
|
onError: options.onError,
|
|
17
15
|
downloadMap: options.downloadMap,
|
|
18
|
-
|
|
16
|
+
concurrency: options.concurrency,
|
|
17
|
+
verbose: options.verbose,
|
|
19
18
|
});
|
|
20
19
|
const connections = {};
|
|
21
20
|
const server = http_1.default.createServer((request, response) => {
|
|
@@ -31,7 +30,9 @@ const serveStatic = async (path, options) => {
|
|
|
31
30
|
(0, serve_handler_1.serveHandler)(request, response, {
|
|
32
31
|
public: path,
|
|
33
32
|
}).catch(() => {
|
|
34
|
-
response.
|
|
33
|
+
if (!response.headersSent) {
|
|
34
|
+
response.writeHead(500);
|
|
35
|
+
}
|
|
35
36
|
response.end('Error serving file');
|
|
36
37
|
});
|
|
37
38
|
});
|
|
@@ -65,22 +66,25 @@ const serveStatic = async (path, options) => {
|
|
|
65
66
|
for (const key in connections)
|
|
66
67
|
connections[key].destroy();
|
|
67
68
|
};
|
|
68
|
-
const close = () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
const close = async () => {
|
|
70
|
+
await Promise.all([
|
|
71
|
+
closeCompositor(),
|
|
72
|
+
new Promise((resolve, reject) => {
|
|
73
|
+
destroyConnections();
|
|
74
|
+
server.close((err) => {
|
|
75
|
+
if (err) {
|
|
76
|
+
if (err.code ===
|
|
77
|
+
'ERR_SERVER_NOT_RUNNING') {
|
|
78
|
+
return resolve();
|
|
79
|
+
}
|
|
80
|
+
reject(err);
|
|
76
81
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
82
|
+
else {
|
|
83
|
+
resolve();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}),
|
|
87
|
+
]);
|
|
84
88
|
};
|
|
85
89
|
return { port: selectedPort, close };
|
|
86
90
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
|
|
3
2
|
import type { RenderAssetInfo } from './assets/download-map';
|
|
4
3
|
import type { AudioCodec } from './audio-codec';
|
|
5
4
|
import type { Codec } from './codec';
|
|
6
|
-
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
7
5
|
import type { FfmpegOverrideFn } from './ffmpeg-override';
|
|
8
|
-
import type {
|
|
6
|
+
import type { VideoImageFormat } from './image-format';
|
|
9
7
|
import type { CancelSignal } from './make-cancel-signal';
|
|
10
8
|
import type { PixelFormat } from './pixel-format';
|
|
11
9
|
import type { ProResProfile } from './prores-profile';
|
|
@@ -27,27 +25,19 @@ export declare type StitcherOptions = {
|
|
|
27
25
|
onDownload?: RenderMediaOnDownload;
|
|
28
26
|
proResProfile?: ProResProfile;
|
|
29
27
|
verbose?: boolean;
|
|
30
|
-
ffmpegExecutable?: FfmpegExecutable;
|
|
31
|
-
ffprobeExecutable?: FfmpegExecutable;
|
|
32
28
|
dir?: string;
|
|
33
29
|
cancelSignal?: CancelSignal;
|
|
34
30
|
internalOptions?: {
|
|
35
31
|
preEncodedFileLocation: string | null;
|
|
36
|
-
imageFormat:
|
|
32
|
+
imageFormat: VideoImageFormat;
|
|
37
33
|
preferLossless: boolean;
|
|
38
34
|
};
|
|
39
35
|
muted?: boolean;
|
|
40
36
|
enforceAudioTrack?: boolean;
|
|
41
37
|
ffmpegOverride?: FfmpegOverrideFn;
|
|
42
38
|
};
|
|
43
|
-
declare type ReturnType = {
|
|
44
|
-
task: Promise<Buffer | null>;
|
|
45
|
-
getLogs: () => string;
|
|
46
|
-
};
|
|
47
|
-
export declare const spawnFfmpeg: (options: StitcherOptions, remotionRoot: string) => Promise<ReturnType>;
|
|
48
39
|
/**
|
|
49
40
|
* @description Takes a series of images and audio information generated by renderFrames() and encodes it to a video.
|
|
50
41
|
* @see [Documentation](https://www.remotion.dev/docs/renderer/stitch-frames-to-video)
|
|
51
42
|
*/
|
|
52
43
|
export declare const stitchFramesToVideo: (options: StitcherOptions) => Promise<Buffer | null>;
|
|
53
|
-
export {};
|