@remotion/renderer 4.0.0-oops.3 → 4.0.0-prefetch.7
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/assets/calculate-asset-positions.d.ts +2 -2
- package/dist/assets/convert-assets-to-file-urls.d.ts +5 -4
- package/dist/assets/convert-assets-to-file-urls.js +2 -2
- package/dist/assets/download-and-map-assets-to-file.d.ts +16 -6
- package/dist/assets/download-and-map-assets-to-file.js +152 -45
- package/dist/assets/download-file.d.ts +10 -5
- package/dist/assets/download-file.js +20 -5
- package/dist/assets/download-map.d.ts +64 -0
- package/dist/assets/download-map.js +73 -0
- package/dist/assets/ffmpeg-volume-expression.d.ts +3 -3
- package/dist/assets/ffmpeg-volume-expression.js +16 -14
- package/dist/assets/flatten-volume-array.d.ts +1 -1
- package/dist/assets/get-audio-channels.d.ts +3 -4
- package/dist/assets/get-audio-channels.js +14 -4
- package/dist/assets/get-video-stream-duration.d.ts +4 -0
- package/dist/assets/get-video-stream-duration.js +59 -0
- package/dist/assets/read-file.js +4 -1
- package/dist/assets/types.d.ts +1 -1
- package/dist/browser/Browser.d.ts +60 -0
- package/dist/browser/Browser.js +218 -0
- package/dist/browser/BrowserConnector.d.ts +19 -0
- package/dist/browser/BrowserConnector.js +17 -0
- package/dist/browser/BrowserFetcher.d.ts +89 -0
- package/dist/browser/BrowserFetcher.js +510 -0
- package/dist/browser/BrowserPage.d.ts +74 -0
- package/dist/browser/BrowserPage.js +283 -0
- package/dist/browser/BrowserRunner.d.ts +39 -0
- package/dist/browser/BrowserRunner.js +308 -0
- package/dist/browser/Connection.d.ts +42 -0
- package/dist/browser/Connection.js +242 -0
- package/dist/browser/ConsoleMessage.d.ts +31 -0
- package/dist/browser/ConsoleMessage.js +48 -0
- package/dist/browser/DOMWorld.d.ts +52 -0
- package/dist/browser/DOMWorld.js +272 -0
- package/dist/browser/Errors.d.ts +25 -0
- package/dist/browser/Errors.js +35 -0
- package/dist/browser/EvalTypes.d.ts +27 -0
- package/dist/browser/EvalTypes.js +17 -0
- package/dist/browser/EventEmitter.d.ts +23 -0
- package/dist/browser/EventEmitter.js +53 -0
- package/dist/browser/ExecutionContext.d.ts +34 -0
- package/dist/browser/ExecutionContext.js +174 -0
- package/dist/browser/FrameManager.d.ts +93 -0
- package/dist/browser/FrameManager.js +496 -0
- package/dist/browser/HTTPRequest.d.ts +28 -0
- package/dist/browser/HTTPRequest.js +37 -0
- package/dist/browser/HTTPResponse.d.ts +21 -0
- package/dist/browser/HTTPResponse.js +41 -0
- package/dist/browser/JSHandle.d.ts +35 -0
- package/dist/browser/JSHandle.js +90 -0
- package/dist/browser/LaunchOptions.d.ts +37 -0
- package/dist/browser/LaunchOptions.js +17 -0
- package/dist/browser/Launcher.d.ts +9 -0
- package/dist/browser/Launcher.js +504 -0
- package/dist/browser/LifecycleWatcher.d.ts +29 -0
- package/dist/browser/LifecycleWatcher.js +180 -0
- package/dist/browser/NetworkEventManager.d.ts +33 -0
- package/dist/browser/NetworkEventManager.js +81 -0
- package/dist/browser/NetworkManager.d.ts +34 -0
- package/dist/browser/NetworkManager.js +231 -0
- package/dist/browser/NodeWebSocketTransport.d.ts +17 -0
- package/dist/browser/NodeWebSocketTransport.js +87 -0
- package/dist/browser/Product.d.ts +16 -0
- package/dist/browser/Product.js +17 -0
- package/dist/browser/PuppeteerNode.d.ts +40 -0
- package/dist/browser/PuppeteerNode.js +81 -0
- package/dist/browser/PuppeteerViewport.d.ts +5 -0
- package/dist/browser/PuppeteerViewport.js +2 -0
- package/dist/browser/ScreenshotOptions.d.ts +14 -0
- package/dist/browser/ScreenshotOptions.js +2 -0
- package/dist/browser/Target.d.ts +61 -0
- package/dist/browser/Target.js +146 -0
- package/dist/browser/TaskQueue.d.ts +20 -0
- package/dist/browser/TaskQueue.js +47 -0
- package/dist/browser/TimeoutSettings.d.ts +24 -0
- package/dist/browser/TimeoutSettings.js +62 -0
- package/dist/browser/assert.d.ts +1 -0
- package/dist/browser/assert.js +9 -0
- package/dist/browser/create-browser-fetcher.d.ts +17 -0
- package/dist/browser/create-browser-fetcher.js +119 -0
- package/dist/browser/devtools-commands.d.ts +270 -0
- package/dist/browser/devtools-commands.js +2 -0
- package/dist/browser/devtools-types.d.ts +1122 -0
- package/dist/browser/devtools-types.js +2 -0
- package/dist/browser/get-download-destination.d.ts +1 -0
- package/dist/browser/get-download-destination.js +38 -0
- package/dist/browser/mitt/index.d.ts +22 -0
- package/dist/browser/mitt/index.js +49 -0
- package/dist/browser/node.d.ts +2 -0
- package/dist/browser/node.js +9 -0
- package/dist/browser/revisions.d.ts +21 -0
- package/dist/browser/revisions.js +22 -0
- package/dist/browser/util.d.ts +47 -0
- package/dist/browser/util.js +169 -0
- package/dist/browser-executable.d.ts +1 -0
- package/dist/browser-executable.js +2 -0
- package/dist/browser-log.d.ts +1 -1
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +4 -0
- package/dist/calculate-ffmpeg-filters.d.ts +1 -1
- package/dist/calculate-ffmpeg-filters.js +2 -2
- package/dist/calculate-sar-dar-pixels.d.ts +9 -0
- package/dist/calculate-sar-dar-pixels.js +19 -0
- package/dist/can-use-parallel-encoding.d.ts +1 -1
- package/dist/can-use-parallel-encoding.js +2 -2
- package/dist/codec-supports-media.d.ts +8 -0
- package/dist/codec-supports-media.js +56 -0
- package/dist/codec.d.ts +4 -0
- package/dist/codec.js +16 -0
- package/dist/combine-videos.d.ts +4 -2
- package/dist/combine-videos.js +19 -5
- package/dist/compress-assets.d.ts +7 -0
- package/dist/compress-assets.js +25 -0
- package/dist/convert-number-of-gif-loops-to-ffmpeg.d.ts +1 -0
- package/dist/convert-number-of-gif-loops-to-ffmpeg.js +17 -0
- package/dist/convert-to-pcm.d.ts +1 -1
- package/dist/create-ffmpeg-complex-filter.d.ts +6 -2
- package/dist/create-ffmpeg-complex-filter.js +2 -11
- package/dist/create-ffmpeg-merge-filter.js +3 -3
- package/dist/create-silent-audio.d.ts +1 -1
- package/dist/crf.d.ts +5 -0
- package/dist/crf.js +64 -0
- package/dist/cycle-browser-tabs.d.ts +3 -2
- package/dist/cycle-browser-tabs.js +14 -2
- package/dist/delay-render-embedded-stack.d.ts +1 -1
- package/dist/ensure-frames-in-order.d.ts +1 -1
- package/dist/ensure-frames-in-order.js +3 -2
- package/dist/ensure-presentation-timestamp.d.ts +2 -0
- package/dist/ensure-presentation-timestamp.js +69 -0
- package/dist/error-handling/handle-javascript-exception.d.ts +2 -2
- package/dist/error-handling/handle-javascript-exception.js +3 -4
- package/dist/error-handling/symbolicate-error.d.ts +1 -1
- package/dist/error-handling/symbolicateable-error.d.ts +1 -1
- package/dist/extract-frame-from-video.d.ts +15 -0
- package/dist/extract-frame-from-video.js +277 -0
- package/dist/ffmpeg-executable.d.ts +1 -0
- package/dist/ffmpeg-executable.js +2 -0
- package/dist/ffmpeg-filter-file.d.ts +2 -1
- package/dist/ffmpeg-filter-file.js +4 -6
- package/dist/frame-range.d.ts +2 -0
- package/dist/frame-range.js +49 -0
- package/dist/frame-to-ffmpeg-timestamp.d.ts +1 -0
- package/dist/frame-to-ffmpeg-timestamp.js +8 -0
- package/dist/get-audio-codec-name.d.ts +1 -1
- package/dist/get-audio-codec-name.js +2 -2
- package/dist/get-browser-instance.d.ts +4 -3
- package/dist/get-browser-instance.js +2 -2
- package/dist/get-codec-name.d.ts +1 -1
- package/dist/get-codec-name.js +5 -2
- package/dist/get-compositions.d.ts +15 -5
- package/dist/get-compositions.js +35 -11
- package/dist/get-duration-from-frame-range.d.ts +1 -2
- package/dist/get-duration-from-frame-range.js +13 -9
- package/dist/get-extension-from-codec.d.ts +2 -2
- package/dist/get-extension-from-codec.js +5 -0
- package/dist/get-extension-of-filename.d.ts +1 -1
- package/dist/get-extension-of-filename.js +3 -0
- package/dist/get-frame-padded-index.d.ts +14 -0
- package/dist/get-frame-padded-index.js +33 -0
- package/dist/get-frame-to-render.d.ts +1 -1
- package/dist/get-local-browser-executable.d.ts +2 -1
- package/dist/get-local-browser-executable.js +7 -5
- package/dist/get-port.js +30 -37
- package/dist/get-prores-profile-name.d.ts +2 -1
- package/dist/get-video-info.d.ts +3 -0
- package/dist/get-video-info.js +49 -0
- package/dist/get-video-threads-flag.d.ts +1 -0
- package/dist/get-video-threads-flag.js +18 -0
- package/dist/guess-extension-for-media.d.ts +1 -0
- package/dist/guess-extension-for-media.js +27 -0
- package/dist/image-format.d.ts +6 -1
- package/dist/image-format.js +25 -1
- package/dist/index.d.ts +94 -20
- package/dist/index.js +93 -6
- package/dist/is-audio-codec.d.ts +2 -0
- package/dist/is-audio-codec.js +7 -0
- package/dist/is-beyond-last-frame.d.ts +3 -0
- package/dist/is-beyond-last-frame.js +12 -0
- package/dist/last-frame-from-video-cache.d.ts +16 -0
- package/dist/last-frame-from-video-cache.js +55 -0
- package/dist/log-level.d.ts +4 -0
- package/dist/log-level.js +15 -0
- package/dist/make-cancel-signal.d.ts +7 -0
- package/dist/make-cancel-signal.js +25 -0
- package/dist/merge-audio-track.d.ts +3 -1
- package/dist/merge-audio-track.js +14 -8
- package/dist/mime-db.d.ts +6 -0
- package/dist/mime-db.js +8636 -0
- package/dist/mime-types.d.ts +3 -0
- package/dist/mime-types.js +94 -0
- package/dist/offthread-video-server.d.ts +17 -0
- package/dist/offthread-video-server.js +86 -0
- package/dist/open-browser.d.ts +10 -7
- package/dist/open-browser.js +63 -20
- package/dist/overwrite.d.ts +1 -0
- package/dist/overwrite.js +4 -0
- package/dist/perf.d.ts +5 -0
- package/dist/perf.js +35 -0
- package/dist/pixel-format.d.ts +5 -0
- package/dist/pixel-format.js +26 -0
- package/dist/prepare-server.d.ts +14 -2
- package/dist/prepare-server.js +38 -5
- package/dist/preprocess-audio-track.d.ts +5 -2
- package/dist/preprocess-audio-track.js +3 -3
- package/dist/prespawn-ffmpeg.d.ts +7 -1
- package/dist/prespawn-ffmpeg.js +20 -16
- package/dist/prestitcher-memory-usage.d.ts +12 -0
- package/dist/prestitcher-memory-usage.js +30 -0
- package/dist/prores-profile.d.ts +5 -0
- package/dist/prores-profile.js +23 -0
- package/dist/provide-screenshot.d.ts +4 -5
- package/dist/provide-screenshot.js +1 -2
- package/dist/puppeteer-evaluate.d.ts +1 -1
- package/dist/puppeteer-evaluate.js +3 -4
- package/dist/puppeteer-screenshot.d.ts +3 -3
- package/dist/puppeteer-screenshot.js +7 -5
- package/dist/quality.d.ts +1 -0
- package/dist/quality.js +21 -0
- package/dist/render-frames.d.ts +24 -8
- package/dist/render-frames.js +153 -65
- package/dist/render-media.d.ts +35 -9
- package/dist/render-media.js +194 -70
- package/dist/render-still.d.ts +25 -7
- package/dist/render-still.js +91 -26
- package/dist/screenshot-dom-element.d.ts +6 -8
- package/dist/screenshot-dom-element.js +3 -6
- package/dist/screenshot-task.d.ts +3 -3
- package/dist/screenshot-task.js +36 -23
- package/dist/seek-to-frame.d.ts +2 -2
- package/dist/seek-to-frame.js +2 -2
- package/dist/serve-handler/index.d.ts +4 -0
- package/dist/serve-handler/index.js +204 -0
- package/dist/serve-handler/is-path-inside.d.ts +1 -0
- package/dist/serve-handler/is-path-inside.js +27 -0
- package/dist/serve-handler/range-parser.d.ts +13 -0
- package/dist/serve-handler/range-parser.js +57 -0
- package/dist/serve-static.d.ts +11 -3
- package/dist/serve-static.js +37 -7
- package/dist/set-props-and-env.d.ts +6 -2
- package/dist/set-props-and-env.js +65 -12
- package/dist/stitch-frames-to-video.d.ts +17 -5
- package/dist/stitch-frames-to-video.js +130 -46
- package/dist/stringify-ffmpeg-filter.d.ts +2 -2
- package/dist/stringify-ffmpeg-filter.js +12 -7
- package/dist/symbolicate-stacktrace.d.ts +1 -1
- package/dist/symbolicate-stacktrace.js +3 -3
- package/dist/tmp-dir.js +5 -1
- package/dist/truthy.d.ts +3 -0
- package/dist/truthy.js +7 -0
- package/dist/types.d.ts +1 -1
- package/dist/validate-concurrency.d.ts +1 -0
- package/dist/validate-concurrency.js +24 -0
- package/dist/validate-even-dimensions-with-codec.d.ts +1 -1
- package/dist/validate-even-dimensions-with-codec.js +2 -2
- package/dist/validate-every-nth-frame.d.ts +1 -0
- package/dist/validate-every-nth-frame.js +21 -0
- package/dist/validate-ffmpeg.js +2 -3
- package/dist/validate-frame.d.ts +1 -0
- package/dist/validate-frame.js +24 -0
- package/dist/validate-opengl-renderer.d.ts +5 -0
- package/dist/validate-opengl-renderer.js +15 -0
- package/dist/validate-output-filename.d.ts +1 -1
- package/dist/validate-output-filename.js +5 -0
- package/dist/wait-for-symbolication-error-to-be-done.d.ts +3 -0
- package/dist/wait-for-symbolication-error-to-be-done.js +34 -0
- package/dist/ws/ws-types.d.ts +14 -0
- package/dist/ws/ws-types.js +10 -0
- package/package.json +13 -16
- package/tsconfig.json +2 -2
- package/types/ws/index.d.ts +509 -0
- package/vitest.config.ts +8 -0
- package/dist/make-assets-download-dir.d.ts +0 -1
- package/dist/make-assets-download-dir.js +0 -8
package/dist/render-media.js
CHANGED
|
@@ -8,29 +8,50 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const remotion_1 = require("remotion");
|
|
11
|
+
const download_map_1 = require("./assets/download-map");
|
|
11
12
|
const can_use_parallel_encoding_1 = require("./can-use-parallel-encoding");
|
|
13
|
+
const codec_supports_media_1 = require("./codec-supports-media");
|
|
14
|
+
const crf_1 = require("./crf");
|
|
15
|
+
const delete_directory_1 = require("./delete-directory");
|
|
12
16
|
const ensure_frames_in_order_1 = require("./ensure-frames-in-order");
|
|
13
17
|
const ensure_output_directory_1 = require("./ensure-output-directory");
|
|
14
18
|
const get_duration_from_frame_range_1 = require("./get-duration-from-frame-range");
|
|
15
19
|
const get_extension_from_codec_1 = require("./get-extension-from-codec");
|
|
16
20
|
const get_extension_of_filename_1 = require("./get-extension-of-filename");
|
|
17
21
|
const get_frame_to_render_1 = require("./get-frame-to-render");
|
|
22
|
+
const is_audio_codec_1 = require("./is-audio-codec");
|
|
18
23
|
const legacy_webpack_config_1 = require("./legacy-webpack-config");
|
|
24
|
+
const make_cancel_signal_1 = require("./make-cancel-signal");
|
|
25
|
+
const overwrite_1 = require("./overwrite");
|
|
26
|
+
const perf_1 = require("./perf");
|
|
19
27
|
const prespawn_ffmpeg_1 = require("./prespawn-ffmpeg");
|
|
28
|
+
const prestitcher_memory_usage_1 = require("./prestitcher-memory-usage");
|
|
29
|
+
const quality_1 = require("./quality");
|
|
20
30
|
const render_frames_1 = require("./render-frames");
|
|
21
31
|
const stitch_frames_to_video_1 = require("./stitch-frames-to-video");
|
|
22
|
-
const tmp_dir_1 = require("./tmp-dir");
|
|
23
32
|
const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
|
|
24
33
|
const validate_output_filename_1 = require("./validate-output-filename");
|
|
25
34
|
const validate_scale_1 = require("./validate-scale");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @description Render a video from a composition
|
|
38
|
+
* @link https://www.remotion.dev/docs/renderer/render-media
|
|
39
|
+
*/
|
|
40
|
+
const renderMedia = ({ parallelism, proResProfile, crf, composition, ffmpegExecutable, ffprobeExecutable, inputProps, pixelFormat, codec, envVariables, frameRange, puppeteerInstance, outputLocation, onProgress, overwrite, onDownload, dumpBrowserLogs, onBrowserLog, onStart, timeoutInMilliseconds, chromiumOptions, scale, browserExecutable, port, cancelSignal, muted, enforceAudioTrack, ...options }) => {
|
|
41
|
+
var _a, _b, _c, _d;
|
|
42
|
+
(0, quality_1.validateQuality)(options.quality);
|
|
29
43
|
if (typeof crf !== 'undefined' && crf !== null) {
|
|
30
|
-
|
|
44
|
+
(0, crf_1.validateSelectedCrfAndCodecCombination)(crf, codec);
|
|
31
45
|
}
|
|
32
|
-
|
|
46
|
+
if (outputLocation) {
|
|
47
|
+
(0, validate_output_filename_1.validateOutputFilename)(codec, (0, get_extension_of_filename_1.getExtensionOfFilename)(outputLocation));
|
|
48
|
+
}
|
|
49
|
+
const absoluteOutputLocation = outputLocation
|
|
50
|
+
? path_1.default.resolve(process.cwd(), outputLocation)
|
|
51
|
+
: null;
|
|
33
52
|
(0, validate_scale_1.validateScale)(scale);
|
|
53
|
+
const everyNthFrame = (_a = options.everyNthFrame) !== null && _a !== void 0 ? _a : 1;
|
|
54
|
+
const numberOfGifLoops = (_b = options.numberOfGifLoops) !== null && _b !== void 0 ? _b : null;
|
|
34
55
|
const serveUrl = (0, legacy_webpack_config_1.getServeUrlWithFallback)(options);
|
|
35
56
|
let stitchStage = 'encoding';
|
|
36
57
|
let stitcherFfmpeg;
|
|
@@ -39,37 +60,66 @@ const renderMedia = async ({ parallelism, proResProfile, crf, composition, image
|
|
|
39
60
|
let renderedFrames = 0;
|
|
40
61
|
let renderedDoneIn = null;
|
|
41
62
|
let encodedDoneIn = null;
|
|
63
|
+
let cancelled = false;
|
|
42
64
|
const renderStart = Date.now();
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
65
|
+
const downloadMap = (_c = options.downloadMap) !== null && _c !== void 0 ? _c : (0, download_map_1.makeDownloadMap)();
|
|
66
|
+
const { estimatedUsage, freeMemory, hasEnoughMemory } = (0, prestitcher_memory_usage_1.shouldUseParallelEncoding)({
|
|
67
|
+
height: composition.height,
|
|
68
|
+
width: composition.width,
|
|
69
|
+
});
|
|
70
|
+
const parallelEncoding = hasEnoughMemory && (0, can_use_parallel_encoding_1.canUseParallelEncoding)(codec);
|
|
71
|
+
if (options.verbose) {
|
|
72
|
+
console.log('[PRESTITCHER] Free memory:', freeMemory, 'Estimated usage parallel encoding', estimatedUsage);
|
|
73
|
+
console.log('[PRESTICHER]: Codec supports parallel rendering:', (0, can_use_parallel_encoding_1.canUseParallelEncoding)(codec));
|
|
74
|
+
if (parallelEncoding) {
|
|
75
|
+
console.log('[PRESTICHER] Parallel encoding is enabled.');
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log('[PRESTITCHER] Parallel encoding is disabled.');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const imageFormat = (0, is_audio_codec_1.isAudioCodec)(codec)
|
|
82
|
+
? 'none'
|
|
83
|
+
: (_d = options.imageFormat) !== null && _d !== void 0 ? _d : 'jpeg';
|
|
84
|
+
const quality = imageFormat === 'jpeg' ? options.quality : undefined;
|
|
46
85
|
const preEncodedFileLocation = parallelEncoding
|
|
47
|
-
? path_1.default.join(
|
|
86
|
+
? path_1.default.join(downloadMap.preEncode, 'pre-encode.' + (0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, 'chunk'))
|
|
48
87
|
: null;
|
|
49
88
|
const outputDir = parallelEncoding
|
|
50
89
|
? null
|
|
51
|
-
:
|
|
90
|
+
: fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'react-motion-render'));
|
|
52
91
|
(0, validate_even_dimensions_with_codec_1.validateEvenDimensionsWithCodec)({
|
|
53
92
|
codec,
|
|
54
93
|
height: composition.height,
|
|
55
94
|
scale: scale !== null && scale !== void 0 ? scale : 1,
|
|
56
95
|
width: composition.width,
|
|
57
96
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
97
|
+
const callUpdate = () => {
|
|
98
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
99
|
+
encodedDoneIn,
|
|
100
|
+
encodedFrames,
|
|
101
|
+
renderedDoneIn,
|
|
102
|
+
renderedFrames,
|
|
103
|
+
stitchStage,
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const realFrameRange = (0, get_frame_to_render_1.getRealFrameRange)(composition.durationInFrames, frameRange !== null && frameRange !== void 0 ? frameRange : null);
|
|
107
|
+
const cancelRenderFrames = (0, make_cancel_signal_1.makeCancelSignal)();
|
|
108
|
+
const cancelPrestitcher = (0, make_cancel_signal_1.makeCancelSignal)();
|
|
109
|
+
const cancelStitcher = (0, make_cancel_signal_1.makeCancelSignal)();
|
|
110
|
+
cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
|
|
111
|
+
cancelRenderFrames.cancel();
|
|
112
|
+
});
|
|
113
|
+
const { waitForRightTimeOfFrameToBeInserted, setFrameToStitch, waitForFinish } = (0, ensure_frames_in_order_1.ensureFramesInOrder)(realFrameRange);
|
|
114
|
+
const fps = composition.fps / (everyNthFrame !== null && everyNthFrame !== void 0 ? everyNthFrame : 1);
|
|
115
|
+
remotion_1.Internals.validateFps(fps, 'in "renderMedia()"', codec === 'gif');
|
|
116
|
+
const createPrestitcherIfNecessary = async () => {
|
|
117
|
+
var _a;
|
|
68
118
|
if (preEncodedFileLocation) {
|
|
69
119
|
preStitcher = await (0, prespawn_ffmpeg_1.prespawnFfmpeg)({
|
|
70
120
|
width: composition.width * (scale !== null && scale !== void 0 ? scale : 1),
|
|
71
121
|
height: composition.height * (scale !== null && scale !== void 0 ? scale : 1),
|
|
72
|
-
fps
|
|
122
|
+
fps,
|
|
73
123
|
outputLocation: preEncodedFileLocation,
|
|
74
124
|
pixelFormat,
|
|
75
125
|
codec,
|
|
@@ -79,15 +129,32 @@ const renderMedia = async ({ parallelism, proResProfile, crf, composition, image
|
|
|
79
129
|
encodedFrames = frame;
|
|
80
130
|
callUpdate();
|
|
81
131
|
},
|
|
82
|
-
verbose:
|
|
132
|
+
verbose: (_a = options.verbose) !== null && _a !== void 0 ? _a : false,
|
|
83
133
|
ffmpegExecutable,
|
|
84
|
-
imageFormat
|
|
134
|
+
imageFormat,
|
|
135
|
+
signal: cancelPrestitcher.cancelSignal,
|
|
85
136
|
});
|
|
86
137
|
stitcherFfmpeg = preStitcher.task;
|
|
87
138
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
139
|
+
};
|
|
140
|
+
const waitForPrestitcherIfNecessary = async () => {
|
|
141
|
+
var _a;
|
|
142
|
+
if (stitcherFfmpeg) {
|
|
143
|
+
await waitForFinish();
|
|
144
|
+
(_a = stitcherFfmpeg === null || stitcherFfmpeg === void 0 ? void 0 : stitcherFfmpeg.stdin) === null || _a === void 0 ? void 0 : _a.end();
|
|
145
|
+
try {
|
|
146
|
+
await stitcherFfmpeg;
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
throw new Error(preStitcher === null || preStitcher === void 0 ? void 0 : preStitcher.getLogs());
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const mediaSupport = (0, codec_supports_media_1.codecSupportsMedia)(codec);
|
|
154
|
+
const disableAudio = !mediaSupport.audio || muted;
|
|
155
|
+
const happyPath = createPrestitcherIfNecessary()
|
|
156
|
+
.then(() => {
|
|
157
|
+
const renderFramesProc = (0, render_frames_1.renderFrames)({
|
|
91
158
|
config: composition,
|
|
92
159
|
onFrameUpdate: (frame) => {
|
|
93
160
|
renderedFrames = frame;
|
|
@@ -102,16 +169,22 @@ const renderMedia = async ({ parallelism, proResProfile, crf, composition, image
|
|
|
102
169
|
},
|
|
103
170
|
inputProps,
|
|
104
171
|
envVariables,
|
|
105
|
-
imageFormat
|
|
172
|
+
imageFormat,
|
|
106
173
|
quality,
|
|
107
174
|
frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
|
|
108
175
|
puppeteerInstance,
|
|
176
|
+
everyNthFrame,
|
|
109
177
|
onFrameBuffer: parallelEncoding
|
|
110
178
|
? async (buffer, frame) => {
|
|
111
179
|
var _a;
|
|
112
180
|
await waitForRightTimeOfFrameToBeInserted(frame);
|
|
181
|
+
if (cancelled) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const id = (0, perf_1.startPerfMeasure)('piping');
|
|
113
185
|
(_a = stitcherFfmpeg === null || stitcherFfmpeg === void 0 ? void 0 : stitcherFfmpeg.stdin) === null || _a === void 0 ? void 0 : _a.write(buffer);
|
|
114
|
-
|
|
186
|
+
(0, perf_1.stopPerfMeasure)(id);
|
|
187
|
+
setFrameToStitch(Math.min(realFrameRange[1] + 1, frame + everyNthFrame));
|
|
115
188
|
}
|
|
116
189
|
: undefined,
|
|
117
190
|
serveUrl,
|
|
@@ -121,55 +194,106 @@ const renderMedia = async ({ parallelism, proResProfile, crf, composition, image
|
|
|
121
194
|
timeoutInMilliseconds,
|
|
122
195
|
chromiumOptions,
|
|
123
196
|
scale,
|
|
197
|
+
ffmpegExecutable,
|
|
198
|
+
ffprobeExecutable,
|
|
199
|
+
browserExecutable,
|
|
200
|
+
port,
|
|
201
|
+
cancelSignal: cancelRenderFrames.cancelSignal,
|
|
202
|
+
downloadMap,
|
|
203
|
+
muted: disableAudio,
|
|
124
204
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
catch (err) {
|
|
132
|
-
throw new Error(preStitcher === null || preStitcher === void 0 ? void 0 : preStitcher.getLogs());
|
|
133
|
-
}
|
|
134
|
-
}
|
|
205
|
+
return renderFramesProc;
|
|
206
|
+
})
|
|
207
|
+
.then((renderFramesReturn) => {
|
|
208
|
+
return Promise.all([renderFramesReturn, waitForPrestitcherIfNecessary()]);
|
|
209
|
+
})
|
|
210
|
+
.then(([{ assetsInfo }]) => {
|
|
135
211
|
renderedDoneIn = Date.now() - renderStart;
|
|
136
212
|
callUpdate();
|
|
137
|
-
|
|
213
|
+
if (absoluteOutputLocation) {
|
|
214
|
+
(0, ensure_output_directory_1.ensureOutputDirectory)(absoluteOutputLocation);
|
|
215
|
+
}
|
|
138
216
|
const stitchStart = Date.now();
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
217
|
+
return Promise.all([
|
|
218
|
+
(0, stitch_frames_to_video_1.stitchFramesToVideo)({
|
|
219
|
+
width: composition.width * (scale !== null && scale !== void 0 ? scale : 1),
|
|
220
|
+
height: composition.height * (scale !== null && scale !== void 0 ? scale : 1),
|
|
221
|
+
fps,
|
|
222
|
+
outputLocation: absoluteOutputLocation,
|
|
223
|
+
internalOptions: {
|
|
224
|
+
preEncodedFileLocation,
|
|
225
|
+
imageFormat,
|
|
226
|
+
},
|
|
227
|
+
force: overwrite !== null && overwrite !== void 0 ? overwrite : overwrite_1.DEFAULT_OVERWRITE,
|
|
228
|
+
pixelFormat,
|
|
229
|
+
codec,
|
|
230
|
+
proResProfile,
|
|
231
|
+
crf,
|
|
232
|
+
assetsInfo,
|
|
233
|
+
ffmpegExecutable,
|
|
234
|
+
ffprobeExecutable,
|
|
235
|
+
onProgress: (frame) => {
|
|
236
|
+
stitchStage = 'muxing';
|
|
237
|
+
encodedFrames = frame;
|
|
238
|
+
callUpdate();
|
|
239
|
+
},
|
|
240
|
+
onDownload,
|
|
241
|
+
numberOfGifLoops,
|
|
242
|
+
verbose: options.verbose,
|
|
243
|
+
dir: outputDir !== null && outputDir !== void 0 ? outputDir : undefined,
|
|
244
|
+
cancelSignal: cancelStitcher.cancelSignal,
|
|
245
|
+
muted: disableAudio,
|
|
246
|
+
enforceAudioTrack,
|
|
247
|
+
}),
|
|
248
|
+
stitchStart,
|
|
249
|
+
]);
|
|
250
|
+
})
|
|
251
|
+
.then(([buffer, stitchStart]) => {
|
|
252
|
+
encodedFrames = (0, get_duration_from_frame_range_1.getFramesToRender)(realFrameRange, everyNthFrame).length;
|
|
165
253
|
encodedDoneIn = Date.now() - stitchStart;
|
|
166
254
|
callUpdate();
|
|
167
|
-
|
|
168
|
-
|
|
255
|
+
return buffer;
|
|
256
|
+
})
|
|
257
|
+
.catch((err) => {
|
|
258
|
+
/**
|
|
259
|
+
* When an error is thrown in renderFrames(...) (e.g., when delayRender() is used incorrectly), fs.unlinkSync(...) throws an error that the file is locked because ffmpeg is still running, and renderMedia returns it.
|
|
260
|
+
* Therefore we first kill the FFMPEG process before deleting the file
|
|
261
|
+
*/
|
|
262
|
+
cancelled = true;
|
|
263
|
+
cancelRenderFrames.cancel();
|
|
264
|
+
cancelStitcher.cancel();
|
|
265
|
+
cancelPrestitcher.cancel();
|
|
266
|
+
if (stitcherFfmpeg !== undefined && stitcherFfmpeg.exitCode === null) {
|
|
267
|
+
const promise = new Promise((resolve) => {
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
resolve();
|
|
270
|
+
}, 2000);
|
|
271
|
+
stitcherFfmpeg.on('close', resolve);
|
|
272
|
+
});
|
|
273
|
+
stitcherFfmpeg.kill();
|
|
274
|
+
return promise.then(() => {
|
|
275
|
+
throw err;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
throw err;
|
|
279
|
+
})
|
|
280
|
+
.finally(() => {
|
|
169
281
|
if (preEncodedFileLocation !== null &&
|
|
170
282
|
fs_1.default.existsSync(preEncodedFileLocation)) {
|
|
171
|
-
|
|
283
|
+
(0, delete_directory_1.deleteDirectory)(path_1.default.dirname(preEncodedFileLocation));
|
|
172
284
|
}
|
|
173
|
-
|
|
285
|
+
// Clean download map if it was not passed in
|
|
286
|
+
if (!(options === null || options === void 0 ? void 0 : options.downloadMap)) {
|
|
287
|
+
(0, download_map_1.cleanDownloadMap)(downloadMap);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
return Promise.race([
|
|
291
|
+
happyPath,
|
|
292
|
+
new Promise((_resolve, reject) => {
|
|
293
|
+
cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
|
|
294
|
+
reject(new Error('renderMedia() got cancelled'));
|
|
295
|
+
});
|
|
296
|
+
}),
|
|
297
|
+
]);
|
|
174
298
|
};
|
|
175
299
|
exports.renderMedia = renderMedia;
|
package/dist/render-still.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { SmallTCompMetadata } from 'remotion';
|
|
2
|
+
import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
|
|
3
|
+
import type { DownloadMap } from './assets/download-map';
|
|
4
|
+
import type { BrowserExecutable } from './browser-executable';
|
|
5
|
+
import type { Browser as PuppeteerBrowser } from './browser/Browser';
|
|
6
|
+
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
7
|
+
import type { StillImageFormat } from './image-format';
|
|
8
|
+
import type { ServeUrlOrWebpackBundle } from './legacy-webpack-config';
|
|
9
|
+
import type { CancelSignal } from './make-cancel-signal';
|
|
10
|
+
import type { ChromiumOptions } from './open-browser';
|
|
5
11
|
declare type InnerStillOptions = {
|
|
6
|
-
composition:
|
|
12
|
+
composition: SmallTCompMetadata;
|
|
7
13
|
output: string;
|
|
8
14
|
frame?: number;
|
|
9
15
|
inputProps?: unknown;
|
|
@@ -17,10 +23,22 @@ declare type InnerStillOptions = {
|
|
|
17
23
|
timeoutInMilliseconds?: number;
|
|
18
24
|
chromiumOptions?: ChromiumOptions;
|
|
19
25
|
scale?: number;
|
|
26
|
+
onDownload?: RenderMediaOnDownload;
|
|
27
|
+
cancelSignal?: CancelSignal;
|
|
28
|
+
ffmpegExecutable?: FfmpegExecutable;
|
|
29
|
+
ffprobeExecutable?: FfmpegExecutable;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Only for Remotion internal usage
|
|
32
|
+
*/
|
|
33
|
+
downloadMap?: DownloadMap;
|
|
34
|
+
};
|
|
35
|
+
declare type RenderStillOptions = InnerStillOptions & ServeUrlOrWebpackBundle & {
|
|
36
|
+
port?: number | null;
|
|
20
37
|
};
|
|
21
|
-
declare type RenderStillOptions = InnerStillOptions & ServeUrlOrWebpackBundle;
|
|
22
38
|
/**
|
|
23
|
-
*
|
|
39
|
+
*
|
|
40
|
+
* @description Render a still frame from a composition
|
|
41
|
+
* @link https://www.remotion.dev/docs/renderer/render-still
|
|
24
42
|
*/
|
|
25
43
|
export declare const renderStill: (options: RenderStillOptions) => Promise<void>;
|
|
26
44
|
export {};
|
package/dist/render-still.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -26,24 +30,29 @@ exports.renderStill = void 0;
|
|
|
26
30
|
const fs_1 = __importStar(require("fs"));
|
|
27
31
|
const path_1 = __importDefault(require("path"));
|
|
28
32
|
const remotion_1 = require("remotion");
|
|
33
|
+
const download_map_1 = require("./assets/download-map");
|
|
34
|
+
const browser_1 = require("./browser");
|
|
29
35
|
const ensure_output_directory_1 = require("./ensure-output-directory");
|
|
30
36
|
const handle_javascript_exception_1 = require("./error-handling/handle-javascript-exception");
|
|
37
|
+
const image_format_1 = require("./image-format");
|
|
31
38
|
const legacy_webpack_config_1 = require("./legacy-webpack-config");
|
|
32
39
|
const open_browser_1 = require("./open-browser");
|
|
33
40
|
const prepare_server_1 = require("./prepare-server");
|
|
34
41
|
const provide_screenshot_1 = require("./provide-screenshot");
|
|
35
42
|
const puppeteer_evaluate_1 = require("./puppeteer-evaluate");
|
|
43
|
+
const quality_1 = require("./quality");
|
|
36
44
|
const seek_to_frame_1 = require("./seek-to-frame");
|
|
37
45
|
const set_props_and_env_1 = require("./set-props-and-env");
|
|
46
|
+
const validate_frame_1 = require("./validate-frame");
|
|
38
47
|
const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
|
|
39
48
|
const validate_scale_1 = require("./validate-scale");
|
|
40
|
-
const innerRenderStill = async ({ composition, quality, imageFormat = 'png', serveUrl, puppeteerInstance, dumpBrowserLogs = false, onError, inputProps, envVariables, output, frame = 0, overwrite = true, browserExecutable, timeoutInMilliseconds, chromiumOptions, scale, }) => {
|
|
49
|
+
const innerRenderStill = async ({ composition, quality, imageFormat = 'png', serveUrl, puppeteerInstance, dumpBrowserLogs = false, onError, inputProps, envVariables, output, frame = 0, overwrite = true, browserExecutable, timeoutInMilliseconds, chromiumOptions, scale, proxyPort, cancelSignal, }) => {
|
|
41
50
|
remotion_1.Internals.validateDimension(composition.height, 'height', 'in the `config` object passed to `renderStill()`');
|
|
42
51
|
remotion_1.Internals.validateDimension(composition.width, 'width', 'in the `config` object passed to `renderStill()`');
|
|
43
|
-
remotion_1.Internals.validateFps(composition.fps, 'in the `config` object of `renderStill()`');
|
|
52
|
+
remotion_1.Internals.validateFps(composition.fps, 'in the `config` object of `renderStill()`', false);
|
|
44
53
|
remotion_1.Internals.validateDurationInFrames(composition.durationInFrames, 'in the `config` object passed to `renderStill()`');
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
(0, image_format_1.validateNonNullImageFormat)(imageFormat);
|
|
55
|
+
(0, validate_frame_1.validateFrame)(frame, composition.durationInFrames);
|
|
47
56
|
(0, validate_puppeteer_timeout_1.validatePuppeteerTimeout)(timeoutInMilliseconds);
|
|
48
57
|
(0, validate_scale_1.validateScale)(scale);
|
|
49
58
|
if (typeof output !== 'string') {
|
|
@@ -53,7 +62,7 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
53
62
|
if (quality !== undefined && imageFormat !== 'jpeg') {
|
|
54
63
|
throw new Error("You can only pass the `quality` option if `imageFormat` is 'jpeg'.");
|
|
55
64
|
}
|
|
56
|
-
|
|
65
|
+
(0, quality_1.validateQuality)(quality);
|
|
57
66
|
if (fs_1.default.existsSync(output)) {
|
|
58
67
|
if (!overwrite) {
|
|
59
68
|
throw new Error(`Cannot render still - "overwrite" option was set to false, but the output destination ${output} already exists.`);
|
|
@@ -64,17 +73,27 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
64
73
|
}
|
|
65
74
|
}
|
|
66
75
|
(0, ensure_output_directory_1.ensureOutputDirectory)(output);
|
|
67
|
-
const browserInstance = puppeteerInstance !== null && puppeteerInstance !== void 0 ? puppeteerInstance : (await (0, open_browser_1.openBrowser)(
|
|
76
|
+
const browserInstance = puppeteerInstance !== null && puppeteerInstance !== void 0 ? puppeteerInstance : (await (0, open_browser_1.openBrowser)(browser_1.DEFAULT_BROWSER, {
|
|
68
77
|
browserExecutable,
|
|
69
78
|
shouldDumpIo: dumpBrowserLogs,
|
|
70
79
|
chromiumOptions,
|
|
80
|
+
forceDeviceScaleFactor: scale !== null && scale !== void 0 ? scale : 1,
|
|
71
81
|
}));
|
|
72
82
|
const page = await browserInstance.newPage();
|
|
73
|
-
page.setViewport({
|
|
83
|
+
await page.setViewport({
|
|
74
84
|
width: composition.width,
|
|
75
85
|
height: composition.height,
|
|
76
86
|
deviceScaleFactor: scale !== null && scale !== void 0 ? scale : 1,
|
|
77
87
|
});
|
|
88
|
+
const errorCallback = (err) => {
|
|
89
|
+
onError(err);
|
|
90
|
+
cleanup();
|
|
91
|
+
};
|
|
92
|
+
const cleanUpJSException = (0, handle_javascript_exception_1.handleJavascriptException)({
|
|
93
|
+
page,
|
|
94
|
+
onError: errorCallback,
|
|
95
|
+
frame: null,
|
|
96
|
+
});
|
|
78
97
|
const cleanup = async () => {
|
|
79
98
|
cleanUpJSException();
|
|
80
99
|
if (puppeteerInstance) {
|
|
@@ -86,14 +105,8 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
86
105
|
});
|
|
87
106
|
}
|
|
88
107
|
};
|
|
89
|
-
|
|
90
|
-
onError(err);
|
|
108
|
+
cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
|
|
91
109
|
cleanup();
|
|
92
|
-
};
|
|
93
|
-
const cleanUpJSException = (0, handle_javascript_exception_1.handleJavascriptException)({
|
|
94
|
-
page,
|
|
95
|
-
onError: errorCallback,
|
|
96
|
-
frame: null,
|
|
97
110
|
});
|
|
98
111
|
await (0, set_props_and_env_1.setPropsAndEnv)({
|
|
99
112
|
inputProps,
|
|
@@ -102,15 +115,32 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
102
115
|
serveUrl,
|
|
103
116
|
initialFrame: frame,
|
|
104
117
|
timeoutInMilliseconds,
|
|
118
|
+
proxyPort,
|
|
119
|
+
retriesRemaining: 2,
|
|
120
|
+
audioEnabled: false,
|
|
121
|
+
videoEnabled: true,
|
|
105
122
|
});
|
|
106
123
|
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
107
|
-
|
|
124
|
+
// eslint-disable-next-line max-params
|
|
125
|
+
pageFunction: (id, defaultProps, durationInFrames, fps, height, width) => {
|
|
108
126
|
window.setBundleMode({
|
|
109
127
|
type: 'composition',
|
|
110
128
|
compositionName: id,
|
|
129
|
+
compositionDefaultProps: defaultProps,
|
|
130
|
+
compositionDurationInFrames: durationInFrames,
|
|
131
|
+
compositionFps: fps,
|
|
132
|
+
compositionHeight: height,
|
|
133
|
+
compositionWidth: width,
|
|
111
134
|
});
|
|
112
135
|
},
|
|
113
|
-
args: [
|
|
136
|
+
args: [
|
|
137
|
+
composition.id,
|
|
138
|
+
composition.defaultProps,
|
|
139
|
+
composition.durationInFrames,
|
|
140
|
+
composition.fps,
|
|
141
|
+
composition.height,
|
|
142
|
+
composition.width,
|
|
143
|
+
],
|
|
114
144
|
frame: null,
|
|
115
145
|
page,
|
|
116
146
|
});
|
|
@@ -127,20 +157,55 @@ const innerRenderStill = async ({ composition, quality, imageFormat = 'png', ser
|
|
|
127
157
|
await cleanup();
|
|
128
158
|
};
|
|
129
159
|
/**
|
|
130
|
-
*
|
|
160
|
+
*
|
|
161
|
+
* @description Render a still frame from a composition
|
|
162
|
+
* @link https://www.remotion.dev/docs/renderer/render-still
|
|
131
163
|
*/
|
|
132
|
-
const renderStill =
|
|
164
|
+
const renderStill = (options) => {
|
|
165
|
+
var _a, _b;
|
|
133
166
|
const selectedServeUrl = (0, legacy_webpack_config_1.getServeUrlWithFallback)(options);
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
167
|
+
const downloadMap = (_a = options.downloadMap) !== null && _a !== void 0 ? _a : (0, download_map_1.makeDownloadMap)();
|
|
168
|
+
const onDownload = (_b = options.onDownload) !== null && _b !== void 0 ? _b : (() => () => undefined);
|
|
169
|
+
const happyPath = new Promise((resolve, reject) => {
|
|
170
|
+
var _a, _b, _c;
|
|
171
|
+
const onError = (err) => reject(err);
|
|
172
|
+
let close = null;
|
|
173
|
+
(0, prepare_server_1.prepareServer)({
|
|
174
|
+
webpackConfigOrServeUrl: selectedServeUrl,
|
|
175
|
+
onDownload,
|
|
176
|
+
onError,
|
|
177
|
+
ffmpegExecutable: (_a = options.ffmpegExecutable) !== null && _a !== void 0 ? _a : null,
|
|
178
|
+
ffprobeExecutable: (_b = options.ffprobeExecutable) !== null && _b !== void 0 ? _b : null,
|
|
179
|
+
port: (_c = options.port) !== null && _c !== void 0 ? _c : null,
|
|
180
|
+
downloadMap,
|
|
181
|
+
})
|
|
182
|
+
.then(({ serveUrl, closeServer, offthreadPort }) => {
|
|
183
|
+
close = closeServer;
|
|
184
|
+
return innerRenderStill({
|
|
185
|
+
...options,
|
|
186
|
+
serveUrl,
|
|
187
|
+
onError: (err) => reject(err),
|
|
188
|
+
proxyPort: offthreadPort,
|
|
189
|
+
});
|
|
140
190
|
})
|
|
141
191
|
.then((res) => resolve(res))
|
|
142
192
|
.catch((err) => reject(err))
|
|
143
|
-
.finally(() =>
|
|
193
|
+
.finally(() => {
|
|
194
|
+
// Clean download map if it was not passed in
|
|
195
|
+
if (!(options === null || options === void 0 ? void 0 : options.downloadMap)) {
|
|
196
|
+
(0, download_map_1.cleanDownloadMap)(downloadMap);
|
|
197
|
+
}
|
|
198
|
+
return close === null || close === void 0 ? void 0 : close();
|
|
199
|
+
});
|
|
144
200
|
});
|
|
201
|
+
return Promise.race([
|
|
202
|
+
happyPath,
|
|
203
|
+
new Promise((_resolve, reject) => {
|
|
204
|
+
var _a;
|
|
205
|
+
(_a = options.cancelSignal) === null || _a === void 0 ? void 0 : _a.call(options, () => {
|
|
206
|
+
reject(new Error('renderStill() got cancelled'));
|
|
207
|
+
});
|
|
208
|
+
}),
|
|
209
|
+
]);
|
|
145
210
|
};
|
|
146
211
|
exports.renderStill = renderStill;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { ImageFormat } from 'remotion';
|
|
1
|
+
import type { Page } from './browser/BrowserPage';
|
|
2
|
+
import type { ImageFormat } from './image-format';
|
|
4
3
|
export declare const screenshotDOMElement: ({ page, imageFormat, quality, opts, }: {
|
|
5
|
-
page:
|
|
4
|
+
page: Page;
|
|
6
5
|
imageFormat: ImageFormat;
|
|
7
6
|
quality: number | undefined;
|
|
8
|
-
opts
|
|
9
|
-
path
|
|
10
|
-
|
|
11
|
-
} | undefined;
|
|
7
|
+
opts: {
|
|
8
|
+
path: string | null;
|
|
9
|
+
};
|
|
12
10
|
}) => Promise<Buffer>;
|
|
@@ -3,11 +3,8 @@ 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, quality, opts
|
|
7
|
-
const
|
|
8
|
-
const { selector } = opts;
|
|
9
|
-
if (!selector)
|
|
10
|
-
throw Error('Please provide a selector.');
|
|
6
|
+
const screenshotDOMElement = async ({ page, imageFormat, quality, opts, }) => {
|
|
7
|
+
const { path } = opts;
|
|
11
8
|
if (imageFormat === 'png') {
|
|
12
9
|
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
13
10
|
pageFunction: () => {
|
|
@@ -33,7 +30,7 @@ const screenshotDOMElement = async ({ page, imageFormat, quality, opts = {}, })
|
|
|
33
30
|
}
|
|
34
31
|
return (0, puppeteer_screenshot_1.screenshot)(page, {
|
|
35
32
|
omitBackground: imageFormat === 'png',
|
|
36
|
-
path,
|
|
33
|
+
path: path !== null && path !== void 0 ? path : undefined,
|
|
37
34
|
type: imageFormat,
|
|
38
35
|
quality,
|
|
39
36
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { StillImageFormat } from '
|
|
1
|
+
import type { Page } from './browser/BrowserPage';
|
|
2
|
+
import type { ScreenshotOptions } from './browser/ScreenshotOptions';
|
|
3
|
+
import type { StillImageFormat } from './image-format';
|
|
4
4
|
export declare const _screenshotTask: (page: Page, format: StillImageFormat, options: ScreenshotOptions) => Promise<Buffer | string>;
|