@remotion/renderer 4.0.0-reorg.8 → 4.0.0-retry.8
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/LICENSE.md +8 -8
- package/dist/assets/calculate-asset-positions.d.ts +0 -0
- package/dist/assets/calculate-asset-positions.js +0 -0
- package/dist/assets/calculate-atempo.d.ts +0 -0
- package/dist/assets/calculate-atempo.js +0 -0
- package/dist/assets/convert-assets-to-file-urls.d.ts +3 -2
- package/dist/assets/convert-assets-to-file-urls.js +2 -2
- package/dist/assets/download-and-map-assets-to-file.d.ts +8 -6
- package/dist/assets/download-and-map-assets-to-file.js +91 -50
- package/dist/assets/download-file.d.ts +1 -1
- package/dist/assets/download-file.js +4 -2
- 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 +0 -0
- package/dist/assets/ffmpeg-volume-expression.js +0 -0
- package/dist/assets/flatten-volume-array.d.ts +0 -0
- package/dist/assets/flatten-volume-array.js +0 -0
- package/dist/assets/get-audio-channels.d.ts +2 -6
- package/dist/assets/get-audio-channels.js +6 -7
- package/dist/assets/get-video-stream-duration.d.ts +3 -5
- package/dist/assets/get-video-stream-duration.js +39 -14
- package/dist/assets/read-file.d.ts +0 -0
- package/dist/assets/read-file.js +0 -0
- package/dist/assets/round-volume-to-avoid-stack-overflow.d.ts +0 -0
- package/dist/assets/round-volume-to-avoid-stack-overflow.js +0 -0
- package/dist/assets/sanitize-filename.d.ts +0 -0
- package/dist/assets/sanitize-filename.js +0 -0
- package/dist/assets/sanitize-filepath.d.ts +0 -0
- package/dist/assets/sanitize-filepath.js +0 -0
- package/dist/assets/truncate-utf8-bytes.d.ts +0 -0
- package/dist/assets/truncate-utf8-bytes.js +0 -0
- package/dist/assets/types.d.ts +0 -0
- package/dist/assets/types.js +0 -0
- package/dist/browser/Browser.d.ts +1 -0
- package/dist/browser/Browser.js +9 -10
- package/dist/browser/BrowserConnector.d.ts +0 -0
- package/dist/browser/BrowserConnector.js +0 -0
- package/dist/browser/BrowserFetcher.d.ts +0 -0
- package/dist/browser/BrowserFetcher.js +12 -10
- package/dist/browser/BrowserPage.d.ts +0 -0
- package/dist/browser/BrowserPage.js +0 -0
- package/dist/browser/BrowserRunner.d.ts +1 -4
- package/dist/browser/BrowserRunner.js +28 -71
- package/dist/browser/Connection.d.ts +0 -0
- package/dist/browser/Connection.js +1 -1
- package/dist/browser/ConsoleMessage.d.ts +0 -0
- package/dist/browser/ConsoleMessage.js +0 -0
- package/dist/browser/DOMWorld.d.ts +0 -0
- package/dist/browser/DOMWorld.js +0 -0
- package/dist/browser/Errors.d.ts +0 -0
- package/dist/browser/Errors.js +0 -0
- package/dist/browser/EvalTypes.d.ts +0 -0
- package/dist/browser/EvalTypes.js +0 -0
- package/dist/browser/EventEmitter.d.ts +0 -0
- package/dist/browser/EventEmitter.js +0 -0
- package/dist/browser/ExecutionContext.d.ts +0 -0
- package/dist/browser/ExecutionContext.js +0 -0
- package/dist/browser/FrameManager.d.ts +0 -0
- package/dist/browser/FrameManager.js +0 -0
- package/dist/browser/HTTPRequest.d.ts +0 -0
- package/dist/browser/HTTPRequest.js +0 -0
- package/dist/browser/HTTPResponse.d.ts +0 -0
- package/dist/browser/HTTPResponse.js +0 -0
- package/dist/browser/JSHandle.d.ts +0 -0
- package/dist/browser/JSHandle.js +0 -0
- package/dist/browser/LaunchOptions.d.ts +0 -4
- package/dist/browser/LaunchOptions.js +0 -0
- package/dist/browser/Launcher.d.ts +1 -1
- package/dist/browser/Launcher.js +5 -363
- package/dist/browser/LifecycleWatcher.d.ts +0 -0
- package/dist/browser/LifecycleWatcher.js +0 -0
- package/dist/browser/NetworkEventManager.d.ts +0 -0
- package/dist/browser/NetworkEventManager.js +0 -0
- package/dist/browser/NetworkManager.d.ts +0 -0
- package/dist/browser/NetworkManager.js +0 -0
- package/dist/browser/NodeWebSocketTransport.d.ts +0 -0
- package/dist/browser/NodeWebSocketTransport.js +1 -1
- package/dist/browser/Product.d.ts +0 -0
- package/dist/browser/Product.js +0 -0
- package/dist/browser/PuppeteerNode.d.ts +0 -0
- package/dist/browser/PuppeteerNode.js +1 -4
- package/dist/browser/PuppeteerViewport.d.ts +0 -0
- package/dist/browser/PuppeteerViewport.js +0 -0
- package/dist/browser/ScreenshotOptions.d.ts +0 -0
- package/dist/browser/ScreenshotOptions.js +0 -0
- package/dist/browser/Target.d.ts +0 -0
- package/dist/browser/Target.js +0 -0
- package/dist/browser/TaskQueue.d.ts +0 -0
- package/dist/browser/TaskQueue.js +0 -0
- package/dist/browser/TimeoutSettings.d.ts +0 -0
- package/dist/browser/TimeoutSettings.js +0 -0
- package/dist/browser/assert.d.ts +0 -0
- package/dist/browser/assert.js +0 -0
- package/dist/browser/create-browser-fetcher.d.ts +0 -0
- package/dist/browser/create-browser-fetcher.js +2 -44
- package/dist/browser/devtools-commands.d.ts +0 -0
- package/dist/browser/devtools-commands.js +0 -0
- package/dist/browser/devtools-types.d.ts +0 -0
- package/dist/browser/devtools-types.js +0 -0
- package/dist/browser/get-download-destination.d.ts +0 -0
- package/dist/browser/get-download-destination.js +0 -0
- package/dist/browser/mitt/index.d.ts +0 -0
- package/dist/browser/mitt/index.js +0 -0
- package/dist/browser/node.d.ts +0 -0
- package/dist/browser/node.js +0 -0
- package/dist/browser/revisions.d.ts +0 -1
- package/dist/browser/revisions.js +0 -1
- package/dist/browser/util.d.ts +0 -0
- package/dist/browser/util.js +0 -0
- package/dist/browser-executable.d.ts +0 -0
- package/dist/browser-executable.js +0 -0
- package/dist/browser-log.d.ts +0 -0
- package/dist/browser-log.js +0 -0
- package/dist/browser.d.ts +0 -0
- package/dist/browser.js +0 -0
- package/dist/calculate-ffmpeg-filters.d.ts +0 -0
- package/dist/calculate-ffmpeg-filters.js +0 -0
- package/dist/calculate-sar-dar-pixels.d.ts +0 -0
- package/dist/calculate-sar-dar-pixels.js +0 -0
- package/dist/can-use-parallel-encoding.d.ts +0 -0
- package/dist/can-use-parallel-encoding.js +0 -0
- package/dist/check-apple-silicon.d.ts +1 -0
- package/dist/check-apple-silicon.js +55 -0
- package/dist/chunk.d.ts +0 -0
- package/dist/chunk.js +0 -0
- package/dist/codec-supports-media.d.ts +1 -0
- package/dist/codec-supports-media.js +8 -1
- package/dist/codec.d.ts +0 -0
- package/dist/codec.js +0 -0
- package/dist/combine-videos.d.ts +0 -0
- package/dist/combine-videos.js +1 -1
- package/dist/compress-assets.d.ts +0 -0
- package/dist/compress-assets.js +0 -0
- package/dist/convert-number-of-gif-loops-to-ffmpeg.d.ts +0 -0
- package/dist/convert-number-of-gif-loops-to-ffmpeg.js +0 -0
- package/dist/convert-to-pcm.d.ts +0 -0
- package/dist/convert-to-pcm.js +0 -0
- package/dist/convert-to-positive-frame-index.d.ts +4 -0
- package/dist/convert-to-positive-frame-index.js +8 -0
- package/dist/create-ffmpeg-complex-filter.d.ts +2 -1
- package/dist/create-ffmpeg-complex-filter.js +2 -11
- package/dist/create-ffmpeg-merge-filter.d.ts +0 -0
- package/dist/create-ffmpeg-merge-filter.js +0 -0
- package/dist/create-silent-audio.d.ts +0 -0
- package/dist/create-silent-audio.js +0 -0
- package/dist/crf.d.ts +5 -1
- package/dist/crf.js +33 -6
- package/dist/cycle-browser-tabs.d.ts +0 -0
- package/dist/cycle-browser-tabs.js +0 -0
- package/dist/delay-render-embedded-stack.d.ts +0 -0
- package/dist/delay-render-embedded-stack.js +0 -0
- package/dist/delete-directory.d.ts +0 -0
- package/dist/delete-directory.js +0 -0
- package/dist/ensure-frames-in-order.d.ts +0 -0
- package/dist/ensure-frames-in-order.js +0 -0
- package/dist/ensure-output-directory.d.ts +0 -0
- package/dist/ensure-output-directory.js +0 -0
- package/dist/ensure-presentation-timestamp.d.ts +2 -1
- package/dist/ensure-presentation-timestamp.js +7 -5
- package/dist/error-handling/handle-javascript-exception.d.ts +0 -0
- package/dist/error-handling/handle-javascript-exception.js +0 -0
- package/dist/error-handling/symbolicate-error.d.ts +0 -0
- package/dist/error-handling/symbolicate-error.js +0 -0
- package/dist/error-handling/symbolicateable-error.d.ts +0 -0
- package/dist/error-handling/symbolicateable-error.js +0 -0
- package/dist/extract-frame-from-video.d.ts +2 -0
- package/dist/extract-frame-from-video.js +42 -15
- package/dist/ffmpeg-executable.d.ts +0 -0
- package/dist/ffmpeg-executable.js +0 -0
- package/dist/ffmpeg-filter-file.d.ts +2 -1
- package/dist/ffmpeg-filter-file.js +4 -6
- package/dist/ffmpeg-flags.d.ts +5 -2
- package/dist/ffmpeg-flags.js +37 -7
- package/dist/ffmpeg-override.d.ts +4 -0
- package/dist/ffmpeg-override.js +2 -0
- package/dist/frame-range.d.ts +0 -0
- package/dist/frame-range.js +0 -0
- package/dist/frame-to-ffmpeg-timestamp.d.ts +0 -0
- package/dist/frame-to-ffmpeg-timestamp.js +0 -0
- package/dist/get-audio-codec-name.d.ts +0 -0
- package/dist/get-audio-codec-name.js +0 -0
- package/dist/get-browser-instance.d.ts +0 -0
- package/dist/get-browser-instance.js +0 -0
- package/dist/get-codec-name.d.ts +0 -0
- package/dist/get-codec-name.js +0 -0
- package/dist/get-compositions.d.ts +5 -0
- package/dist/get-compositions.js +14 -6
- package/dist/get-concurrency.d.ts +0 -0
- package/dist/get-concurrency.js +0 -0
- package/dist/get-duration-from-frame-range.d.ts +0 -0
- package/dist/get-duration-from-frame-range.js +0 -0
- package/dist/get-extension-from-codec.d.ts +1 -1
- package/dist/get-extension-from-codec.js +0 -0
- package/dist/get-extension-of-filename.d.ts +0 -0
- package/dist/get-extension-of-filename.js +0 -0
- package/dist/get-frame-padded-index.d.ts +0 -0
- package/dist/get-frame-padded-index.js +0 -0
- package/dist/get-frame-to-render.d.ts +0 -0
- package/dist/get-frame-to-render.js +0 -0
- package/dist/get-local-browser-executable.d.ts +0 -0
- package/dist/get-local-browser-executable.js +1 -3
- package/dist/get-port.d.ts +0 -0
- package/dist/get-port.js +0 -0
- package/dist/get-prores-profile-name.d.ts +0 -0
- package/dist/get-prores-profile-name.js +0 -0
- package/dist/get-video-info.d.ts +2 -7
- package/dist/get-video-info.js +7 -8
- 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 -1
- package/dist/guess-extension-for-media.js +1 -1
- package/dist/image-format.d.ts +1 -1
- package/dist/image-format.js +3 -0
- package/dist/index.d.ts +19 -28
- package/dist/index.js +16 -24
- package/dist/is-audio-codec.d.ts +0 -0
- package/dist/is-audio-codec.js +0 -0
- package/dist/is-beyond-last-frame.d.ts +3 -2
- package/dist/is-beyond-last-frame.js +5 -5
- package/dist/is-serve-url.d.ts +0 -0
- package/dist/is-serve-url.js +0 -0
- package/dist/last-frame-from-video-cache.d.ts +3 -2
- package/dist/last-frame-from-video-cache.js +17 -17
- package/dist/legacy-webpack-config.d.ts +0 -0
- package/dist/legacy-webpack-config.js +0 -0
- package/dist/log-level.d.ts +0 -0
- package/dist/log-level.js +0 -0
- package/dist/make-cancel-signal.d.ts +0 -0
- package/dist/make-cancel-signal.js +0 -0
- package/dist/merge-audio-track.d.ts +2 -0
- package/dist/merge-audio-track.js +6 -3
- package/dist/mime-db.d.ts +0 -0
- package/dist/mime-db.js +0 -0
- package/dist/mime-types.d.ts +1 -0
- package/dist/mime-types.js +6 -1
- package/dist/normalize-serve-url.d.ts +0 -0
- package/dist/normalize-serve-url.js +0 -0
- package/dist/offthread-video-server.d.ts +3 -2
- package/dist/offthread-video-server.js +14 -2
- package/dist/open-browser.d.ts +0 -0
- package/dist/open-browser.js +3 -12
- package/dist/overwrite.d.ts +0 -0
- package/dist/overwrite.js +0 -0
- package/dist/p-limit.d.ts +0 -0
- package/dist/p-limit.js +0 -0
- package/dist/parse-browser-error-stack.d.ts +0 -0
- package/dist/parse-browser-error-stack.js +0 -0
- package/dist/parse-ffmpeg-progress.d.ts +0 -0
- package/dist/parse-ffmpeg-progress.js +0 -0
- package/dist/perf.d.ts +0 -0
- package/dist/perf.js +0 -0
- package/dist/pixel-format.d.ts +1 -1
- package/dist/pixel-format.js +3 -0
- package/dist/pool.d.ts +0 -0
- package/dist/pool.js +0 -0
- package/dist/prepare-server.d.ts +3 -2
- package/dist/prepare-server.js +3 -3
- package/dist/preprocess-audio-track.d.ts +2 -0
- package/dist/preprocess-audio-track.js +3 -3
- package/dist/prespawn-ffmpeg.d.ts +3 -0
- package/dist/prespawn-ffmpeg.js +15 -11
- package/dist/prestitcher-memory-usage.d.ts +12 -0
- package/dist/prestitcher-memory-usage.js +30 -0
- package/dist/prores-profile.d.ts +4 -1
- package/dist/prores-profile.js +6 -6
- package/dist/provide-screenshot.d.ts +0 -0
- package/dist/provide-screenshot.js +0 -0
- package/dist/puppeteer-evaluate.d.ts +0 -0
- package/dist/puppeteer-evaluate.js +0 -0
- package/dist/puppeteer-screenshot.d.ts +0 -0
- package/dist/puppeteer-screenshot.js +0 -0
- package/dist/quality.d.ts +0 -0
- package/dist/quality.js +0 -0
- package/dist/render-frames.d.ts +16 -3
- package/dist/render-frames.js +98 -30
- package/dist/render-media.d.ts +30 -4
- package/dist/render-media.js +123 -20
- package/dist/render-still.d.ts +6 -1
- package/dist/render-still.js +37 -11
- package/dist/resolve-asset-src.d.ts +0 -0
- package/dist/resolve-asset-src.js +0 -0
- package/dist/sample-rate.d.ts +0 -0
- package/dist/sample-rate.js +0 -0
- package/dist/screenshot-dom-element.d.ts +0 -0
- package/dist/screenshot-dom-element.js +0 -0
- package/dist/screenshot-task.d.ts +0 -0
- package/dist/screenshot-task.js +30 -15
- package/dist/seek-to-frame.d.ts +0 -0
- package/dist/seek-to-frame.js +0 -0
- package/dist/serve-handler/index.d.ts +0 -0
- package/dist/serve-handler/index.js +0 -0
- package/dist/serve-handler/is-path-inside.d.ts +0 -0
- package/dist/serve-handler/is-path-inside.js +0 -0
- package/dist/serve-handler/range-parser.d.ts +0 -0
- package/dist/serve-handler/range-parser.js +0 -0
- package/dist/serve-static.d.ts +2 -1
- package/dist/serve-static.js +14 -1
- package/dist/set-props-and-env.d.ts +3 -1
- package/dist/set-props-and-env.js +34 -8
- package/dist/stitch-frames-to-video.d.ts +7 -7
- package/dist/stitch-frames-to-video.js +68 -57
- package/dist/stringify-ffmpeg-filter.d.ts +0 -0
- package/dist/stringify-ffmpeg-filter.js +0 -0
- package/dist/symbolicate-stacktrace.d.ts +0 -0
- package/dist/symbolicate-stacktrace.js +0 -0
- package/dist/tmp-dir.d.ts +0 -0
- package/dist/tmp-dir.js +0 -0
- package/dist/truthy.d.ts +0 -0
- package/dist/truthy.js +0 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +0 -0
- package/dist/validate-concurrency.d.ts +0 -0
- package/dist/validate-concurrency.js +0 -0
- package/dist/validate-even-dimensions-with-codec.d.ts +0 -0
- package/dist/validate-even-dimensions-with-codec.js +0 -0
- package/dist/validate-every-nth-frame.d.ts +2 -1
- package/dist/validate-every-nth-frame.js +8 -1
- package/dist/validate-ffmpeg-override.d.ts +2 -0
- package/dist/validate-ffmpeg-override.js +12 -0
- package/dist/validate-ffmpeg.d.ts +4 -1
- package/dist/validate-ffmpeg.js +23 -7
- package/dist/validate-frame.d.ts +0 -0
- package/dist/validate-frame.js +3 -3
- package/dist/validate-number-of-gif-loops.d.ts +2 -0
- package/dist/validate-number-of-gif-loops.js +24 -0
- package/dist/validate-opengl-renderer.d.ts +0 -0
- package/dist/validate-opengl-renderer.js +0 -0
- package/dist/validate-output-filename.d.ts +0 -0
- package/dist/validate-output-filename.js +0 -0
- package/dist/validate-puppeteer-timeout.d.ts +0 -0
- package/dist/validate-puppeteer-timeout.js +1 -1
- package/dist/validate-scale.d.ts +0 -0
- package/dist/validate-scale.js +0 -0
- package/dist/validate-videobitrate.d.ts +1 -0
- package/dist/validate-videobitrate.js +20 -0
- package/dist/wait-for-symbolication-error-to-be-done.d.ts +0 -0
- package/dist/wait-for-symbolication-error-to-be-done.js +0 -0
- package/dist/warn-about-ffmpeg-version.d.ts +5 -0
- package/dist/warn-about-ffmpeg-version.js +37 -0
- package/dist/ws/ws-types.d.ts +0 -0
- package/dist/ws/ws-types.js +0 -0
- package/package.json +7 -7
- package/dist/make-assets-download-dir.d.ts +0 -1
- package/dist/make-assets-download-dir.js +0 -13
- package/vitest.config.ts +0 -8
package/dist/render-frames.js
CHANGED
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.renderFrames = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
9
10
|
const remotion_1 = require("remotion");
|
|
10
11
|
const download_and_map_assets_to_file_1 = require("./assets/download-and-map-assets-to-file");
|
|
12
|
+
const download_map_1 = require("./assets/download-map");
|
|
11
13
|
const browser_1 = require("./browser");
|
|
12
14
|
const compress_assets_1 = require("./compress-assets");
|
|
13
15
|
const cycle_browser_tabs_1 = require("./cycle-browser-tabs");
|
|
@@ -18,7 +20,6 @@ const get_frame_padded_index_1 = require("./get-frame-padded-index");
|
|
|
18
20
|
const get_frame_to_render_1 = require("./get-frame-to-render");
|
|
19
21
|
const image_format_1 = require("./image-format");
|
|
20
22
|
const legacy_webpack_config_1 = require("./legacy-webpack-config");
|
|
21
|
-
const make_assets_download_dir_1 = require("./make-assets-download-dir");
|
|
22
23
|
const open_browser_1 = require("./open-browser");
|
|
23
24
|
const perf_1 = require("./perf");
|
|
24
25
|
const pool_1 = require("./pool");
|
|
@@ -30,6 +31,7 @@ const seek_to_frame_1 = require("./seek-to-frame");
|
|
|
30
31
|
const set_props_and_env_1 = require("./set-props-and-env");
|
|
31
32
|
const truthy_1 = require("./truthy");
|
|
32
33
|
const validate_scale_1 = require("./validate-scale");
|
|
34
|
+
const MAX_RETRIES_PER_FRAME = 1;
|
|
33
35
|
const getComposition = (others) => {
|
|
34
36
|
if ('composition' in others) {
|
|
35
37
|
return others.composition;
|
|
@@ -39,12 +41,21 @@ const getComposition = (others) => {
|
|
|
39
41
|
}
|
|
40
42
|
return undefined;
|
|
41
43
|
};
|
|
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 undefined;
|
|
52
|
+
};
|
|
42
53
|
const getPool = async (pages) => {
|
|
43
54
|
const puppeteerPages = await Promise.all(pages);
|
|
44
55
|
const pool = new pool_1.Pool(puppeteerPages);
|
|
45
56
|
return pool;
|
|
46
57
|
};
|
|
47
|
-
const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, quality, imageFormat = image_format_1.DEFAULT_IMAGE_FORMAT, frameRange, puppeteerInstance, onError, envVariables, onBrowserLog, onFrameBuffer, onDownload, pagesArray, serveUrl, composition, timeoutInMilliseconds, scale,
|
|
58
|
+
const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, quality, imageFormat = image_format_1.DEFAULT_IMAGE_FORMAT, frameRange, puppeteerInstance, onError, envVariables, onBrowserLog, onFrameBuffer, onDownload, pagesArray, serveUrl, composition, timeoutInMilliseconds, scale, actualConcurrency, everyNthFrame = 1, proxyPort, cancelSignal, downloadMap, muted, makeBrowser, }) => {
|
|
48
59
|
if (!puppeteerInstance) {
|
|
49
60
|
throw new Error('no puppeteer instance passed to innerRenderFrames - internal error');
|
|
50
61
|
}
|
|
@@ -59,8 +70,8 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, qual
|
|
|
59
70
|
const realFrameRange = (0, get_frame_to_render_1.getRealFrameRange)(composition.durationInFrames, frameRange !== null && frameRange !== void 0 ? frameRange : null);
|
|
60
71
|
const framesToRender = (0, get_duration_from_frame_range_1.getFramesToRender)(realFrameRange, everyNthFrame);
|
|
61
72
|
const lastFrame = framesToRender[framesToRender.length - 1];
|
|
62
|
-
const
|
|
63
|
-
const page = await
|
|
73
|
+
const makePage = async (instance) => {
|
|
74
|
+
const page = await instance.newPage();
|
|
64
75
|
pagesArray.push(page);
|
|
65
76
|
await page.setViewport({
|
|
66
77
|
width: composition.width,
|
|
@@ -87,21 +98,37 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, qual
|
|
|
87
98
|
timeoutInMilliseconds,
|
|
88
99
|
proxyPort,
|
|
89
100
|
retriesRemaining: 2,
|
|
101
|
+
audioEnabled: !muted,
|
|
102
|
+
videoEnabled: imageFormat !== 'none',
|
|
90
103
|
});
|
|
91
104
|
await (0, puppeteer_evaluate_1.puppeteerEvaluateWithCatch)({
|
|
92
|
-
|
|
105
|
+
// eslint-disable-next-line max-params
|
|
106
|
+
pageFunction: (id, defaultProps, durationInFrames, fps, height, width) => {
|
|
93
107
|
window.setBundleMode({
|
|
94
108
|
type: 'composition',
|
|
95
109
|
compositionName: id,
|
|
110
|
+
compositionDefaultProps: defaultProps,
|
|
111
|
+
compositionDurationInFrames: durationInFrames,
|
|
112
|
+
compositionFps: fps,
|
|
113
|
+
compositionHeight: height,
|
|
114
|
+
compositionWidth: width,
|
|
96
115
|
});
|
|
97
116
|
},
|
|
98
|
-
args: [
|
|
117
|
+
args: [
|
|
118
|
+
composition.id,
|
|
119
|
+
composition.defaultProps,
|
|
120
|
+
composition.durationInFrames,
|
|
121
|
+
composition.fps,
|
|
122
|
+
composition.height,
|
|
123
|
+
composition.width,
|
|
124
|
+
],
|
|
99
125
|
frame: null,
|
|
100
126
|
page,
|
|
101
127
|
});
|
|
102
128
|
page.off('console', logCallback);
|
|
103
129
|
return page;
|
|
104
|
-
}
|
|
130
|
+
};
|
|
131
|
+
const pages = new Array(actualConcurrency).fill(true).map(makePage);
|
|
105
132
|
// If rendering a GIF and skipping frames, we must ensure it starts from 0
|
|
106
133
|
// and then is consecutive so FFMPEG recognizes the sequence
|
|
107
134
|
const countType = everyNthFrame === 1 ? 'actual-frames' : 'from-zero';
|
|
@@ -120,14 +147,15 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, qual
|
|
|
120
147
|
cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
|
|
121
148
|
stopped = true;
|
|
122
149
|
});
|
|
123
|
-
const
|
|
150
|
+
const renderFrameWithOptionToReject = async (frame, index, reject) => {
|
|
124
151
|
const pool = await poolPromise;
|
|
125
152
|
const freePage = await pool.acquire();
|
|
126
153
|
if (stopped) {
|
|
127
|
-
|
|
154
|
+
return reject(new Error('Render was stopped'));
|
|
128
155
|
}
|
|
156
|
+
const startTime = perf_hooks_1.performance.now();
|
|
129
157
|
const errorCallbackOnFrame = (err) => {
|
|
130
|
-
|
|
158
|
+
reject(err);
|
|
131
159
|
};
|
|
132
160
|
const cleanupPageError = (0, handle_javascript_exception_1.handleJavascriptException)({
|
|
133
161
|
page: freePage,
|
|
@@ -187,26 +215,59 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, qual
|
|
|
187
215
|
compressedAssets.forEach((asset) => {
|
|
188
216
|
(0, download_and_map_assets_to_file_1.downloadAndMapAssetsToFileUrl)({
|
|
189
217
|
asset,
|
|
190
|
-
downloadDir,
|
|
191
218
|
onDownload,
|
|
219
|
+
downloadMap,
|
|
192
220
|
}).catch((err) => {
|
|
193
221
|
onError(new Error(`Error while downloading asset: ${err.stack}`));
|
|
194
222
|
});
|
|
195
223
|
});
|
|
196
|
-
pool.release(freePage);
|
|
197
224
|
framesRendered++;
|
|
198
|
-
onFrameUpdate(framesRendered, frame);
|
|
225
|
+
onFrameUpdate(framesRendered, frame, perf_hooks_1.performance.now() - startTime);
|
|
199
226
|
cleanupPageError();
|
|
200
227
|
freePage.off('error', errorCallbackOnFrame);
|
|
201
|
-
|
|
202
|
-
}
|
|
228
|
+
pool.release(freePage);
|
|
229
|
+
};
|
|
230
|
+
const renderFrame = (frame, index) => {
|
|
231
|
+
return new Promise((resolve, reject) => {
|
|
232
|
+
renderFrameWithOptionToReject(frame, index, reject)
|
|
233
|
+
.then(() => {
|
|
234
|
+
resolve();
|
|
235
|
+
})
|
|
236
|
+
.catch((err) => {
|
|
237
|
+
reject(err);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
const renderFrameAndRetryTargetClose = async (frame, index, retriesLeft, attempt) => {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
try {
|
|
244
|
+
await renderFrame(frame, index);
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
if (!((_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.includes('Target closed')) &&
|
|
248
|
+
!((_b = err === null || err === void 0 ? void 0 : err.message) === null || _b === void 0 ? void 0 : _b.includes('Session closed'))) {
|
|
249
|
+
throw err;
|
|
250
|
+
}
|
|
251
|
+
if (retriesLeft === 0) {
|
|
252
|
+
console.warn(err, `The browser crashed ${attempt} times while rendering frame ${frame}. Not retrying anymore. Learn more about this error under https://www.remotion.dev/docs/target-closed`);
|
|
253
|
+
throw err;
|
|
254
|
+
}
|
|
255
|
+
console.warn(`The browser crashed while rendering frame ${frame}, retrying ${retriesLeft} more times. Learn more about this error under https://www.remotion.dev/docs/target-closed`);
|
|
256
|
+
const pool = await poolPromise;
|
|
257
|
+
const page = await makePage(await makeBrowser());
|
|
258
|
+
pool.release(page);
|
|
259
|
+
await renderFrameAndRetryTargetClose(frame, index, retriesLeft - 1, attempt + 1);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
const progress = Promise.all(framesToRender.map((frame, index) => renderFrameAndRetryTargetClose(frame, index, MAX_RETRIES_PER_FRAME, 1)));
|
|
203
263
|
const happyPath = progress.then(() => {
|
|
264
|
+
const firstFrameIndex = countType === 'from-zero' ? 0 : framesToRender[0];
|
|
204
265
|
const returnValue = {
|
|
205
266
|
assetsInfo: {
|
|
206
267
|
assets,
|
|
207
|
-
downloadDir,
|
|
208
268
|
imageSequenceName: `element-%0${filePadLength}d.${imageFormat}`,
|
|
209
|
-
firstFrameIndex
|
|
269
|
+
firstFrameIndex,
|
|
270
|
+
downloadMap,
|
|
210
271
|
},
|
|
211
272
|
frameCount: framesToRender.length,
|
|
212
273
|
};
|
|
@@ -219,8 +280,9 @@ const innerRenderFrames = ({ onFrameUpdate, outputDir, onStart, inputProps, qual
|
|
|
219
280
|
.then(() => happyPath);
|
|
220
281
|
};
|
|
221
282
|
const renderFrames = (options) => {
|
|
222
|
-
var _a, _b, _c
|
|
283
|
+
var _a, _b, _c;
|
|
223
284
|
const composition = getComposition(options);
|
|
285
|
+
const concurrency = getConcurrency(options);
|
|
224
286
|
if (!composition) {
|
|
225
287
|
throw new Error('No `composition` option has been specified for renderFrames()');
|
|
226
288
|
}
|
|
@@ -234,15 +296,19 @@ const renderFrames = (options) => {
|
|
|
234
296
|
const selectedServeUrl = (0, legacy_webpack_config_1.getServeUrlWithFallback)(options);
|
|
235
297
|
(0, quality_1.validateQuality)(options.quality);
|
|
236
298
|
(0, validate_scale_1.validateScale)(options.scale);
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
299
|
+
const makeBrowser = () => {
|
|
300
|
+
var _a;
|
|
301
|
+
return (0, open_browser_1.openBrowser)(browser_1.DEFAULT_BROWSER, {
|
|
302
|
+
shouldDumpIo: options.dumpBrowserLogs,
|
|
303
|
+
browserExecutable: options.browserExecutable,
|
|
304
|
+
chromiumOptions: options.chromiumOptions,
|
|
305
|
+
forceDeviceScaleFactor: (_a = options.scale) !== null && _a !== void 0 ? _a : 1,
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
const browserInstance = (_a = options.puppeteerInstance) !== null && _a !== void 0 ? _a : makeBrowser();
|
|
309
|
+
const downloadMap = (_b = options.downloadMap) !== null && _b !== void 0 ? _b : (0, download_map_1.makeDownloadMap)();
|
|
244
310
|
const onDownload = (_c = options.onDownload) !== null && _c !== void 0 ? _c : (() => () => undefined);
|
|
245
|
-
const
|
|
311
|
+
const actualConcurrency = (0, get_concurrency_1.getActualConcurrency)(concurrency !== null && concurrency !== void 0 ? concurrency : null);
|
|
246
312
|
const openedPages = [];
|
|
247
313
|
return new Promise((resolve, reject) => {
|
|
248
314
|
var _a, _b, _c;
|
|
@@ -260,16 +326,16 @@ const renderFrames = (options) => {
|
|
|
260
326
|
Promise.all([
|
|
261
327
|
(0, prepare_server_1.prepareServer)({
|
|
262
328
|
webpackConfigOrServeUrl: selectedServeUrl,
|
|
263
|
-
downloadDir,
|
|
264
329
|
onDownload,
|
|
265
330
|
onError,
|
|
266
331
|
ffmpegExecutable: (_a = options.ffmpegExecutable) !== null && _a !== void 0 ? _a : null,
|
|
267
332
|
ffprobeExecutable: (_b = options.ffprobeExecutable) !== null && _b !== void 0 ? _b : null,
|
|
268
333
|
port: (_c = options.port) !== null && _c !== void 0 ? _c : null,
|
|
334
|
+
downloadMap,
|
|
269
335
|
}),
|
|
270
336
|
browserInstance,
|
|
271
337
|
]).then(([{ serveUrl, closeServer, offthreadPort }, puppeteerInstance]) => {
|
|
272
|
-
const { stopCycling } = (0, cycle_browser_tabs_1.cycleBrowserTabs)(puppeteerInstance,
|
|
338
|
+
const { stopCycling } = (0, cycle_browser_tabs_1.cycleBrowserTabs)(puppeteerInstance, actualConcurrency);
|
|
273
339
|
cleanup.push(stopCycling);
|
|
274
340
|
cleanup.push(closeServer);
|
|
275
341
|
return innerRenderFrames({
|
|
@@ -279,10 +345,11 @@ const renderFrames = (options) => {
|
|
|
279
345
|
pagesArray: openedPages,
|
|
280
346
|
serveUrl,
|
|
281
347
|
composition,
|
|
282
|
-
|
|
348
|
+
actualConcurrency,
|
|
283
349
|
onDownload,
|
|
284
|
-
downloadDir,
|
|
285
350
|
proxyPort: offthreadPort,
|
|
351
|
+
downloadMap,
|
|
352
|
+
makeBrowser,
|
|
286
353
|
});
|
|
287
354
|
}),
|
|
288
355
|
])
|
|
@@ -311,6 +378,7 @@ const renderFrames = (options) => {
|
|
|
311
378
|
cleanup.forEach((c) => {
|
|
312
379
|
c();
|
|
313
380
|
});
|
|
381
|
+
// Don't clear download dir because it might be used by stitchFramesToVideo
|
|
314
382
|
});
|
|
315
383
|
});
|
|
316
384
|
};
|
package/dist/render-media.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { SmallTCompMetadata } from 'remotion';
|
|
3
2
|
import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
|
|
3
|
+
import type { DownloadMap } from './assets/download-map';
|
|
4
4
|
import type { BrowserExecutable } from './browser-executable';
|
|
5
5
|
import type { BrowserLog } from './browser-log';
|
|
6
6
|
import type { Browser as PuppeteerBrowser } from './browser/Browser';
|
|
7
7
|
import type { Codec } from './codec';
|
|
8
8
|
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
9
|
+
import type { FfmpegOverrideFn } from './ffmpeg-override';
|
|
9
10
|
import type { FrameRange } from './frame-range';
|
|
10
11
|
import type { ServeUrlOrWebpackBundle } from './legacy-webpack-config';
|
|
11
12
|
import type { CancelSignal } from './make-cancel-signal';
|
|
@@ -14,11 +15,17 @@ import type { PixelFormat } from './pixel-format';
|
|
|
14
15
|
import type { ProResProfile } from './prores-profile';
|
|
15
16
|
import type { OnStartData } from './types';
|
|
16
17
|
export declare type StitchingState = 'encoding' | 'muxing';
|
|
18
|
+
export declare type SlowFrame = {
|
|
19
|
+
frame: number;
|
|
20
|
+
time: number;
|
|
21
|
+
};
|
|
22
|
+
export declare type OnSlowestFrames = (frames: SlowFrame[]) => void;
|
|
17
23
|
export declare type RenderMediaOnProgress = (progress: {
|
|
18
24
|
renderedFrames: number;
|
|
19
25
|
encodedFrames: number;
|
|
20
26
|
encodedDoneIn: number | null;
|
|
21
27
|
renderedDoneIn: number | null;
|
|
28
|
+
progress: number;
|
|
22
29
|
stitchStage: StitchingState;
|
|
23
30
|
}) => void;
|
|
24
31
|
export declare type RenderMediaOptions = {
|
|
@@ -26,7 +33,6 @@ export declare type RenderMediaOptions = {
|
|
|
26
33
|
codec: Codec;
|
|
27
34
|
composition: SmallTCompMetadata;
|
|
28
35
|
inputProps?: unknown;
|
|
29
|
-
parallelism?: number | null;
|
|
30
36
|
crf?: number | null;
|
|
31
37
|
imageFormat?: 'png' | 'jpeg' | 'none';
|
|
32
38
|
ffmpegExecutable?: FfmpegExecutable;
|
|
@@ -52,10 +58,30 @@ export declare type RenderMediaOptions = {
|
|
|
52
58
|
cancelSignal?: CancelSignal;
|
|
53
59
|
browserExecutable?: BrowserExecutable;
|
|
54
60
|
verbose?: boolean;
|
|
55
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Only for Remotion internal usage
|
|
63
|
+
*/
|
|
64
|
+
downloadMap?: DownloadMap;
|
|
65
|
+
muted?: boolean;
|
|
66
|
+
enforceAudioTrack?: boolean;
|
|
67
|
+
ffmpegOverride?: FfmpegOverrideFn;
|
|
68
|
+
audioBitrate?: string | null;
|
|
69
|
+
videoBitrate?: string | null;
|
|
70
|
+
onSlowestFrames?: OnSlowestFrames;
|
|
71
|
+
disallowParallelEncoding?: boolean;
|
|
72
|
+
} & ServeUrlOrWebpackBundle & ConcurrencyOrParallelism;
|
|
73
|
+
declare type ConcurrencyOrParallelism = {
|
|
74
|
+
concurrency?: number | null;
|
|
75
|
+
} | {
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated This field has been renamed to `concurrency`
|
|
78
|
+
*/
|
|
79
|
+
parallelism?: number | null;
|
|
80
|
+
};
|
|
56
81
|
/**
|
|
57
82
|
*
|
|
58
83
|
* @description Render a video from a composition
|
|
59
84
|
* @link https://www.remotion.dev/docs/renderer/render-media
|
|
60
85
|
*/
|
|
61
|
-
export declare const renderMedia: ({
|
|
86
|
+
export declare const renderMedia: ({ 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, ffmpegOverride, audioBitrate, videoBitrate, onSlowestFrames, ...options }: RenderMediaOptions) => Promise<Buffer | null>;
|
|
87
|
+
export {};
|
package/dist/render-media.js
CHANGED
|
@@ -8,42 +8,75 @@ 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");
|
|
12
14
|
const crf_1 = require("./crf");
|
|
15
|
+
const delete_directory_1 = require("./delete-directory");
|
|
13
16
|
const ensure_frames_in_order_1 = require("./ensure-frames-in-order");
|
|
14
17
|
const ensure_output_directory_1 = require("./ensure-output-directory");
|
|
15
18
|
const get_duration_from_frame_range_1 = require("./get-duration-from-frame-range");
|
|
16
19
|
const get_extension_from_codec_1 = require("./get-extension-from-codec");
|
|
17
20
|
const get_extension_of_filename_1 = require("./get-extension-of-filename");
|
|
18
21
|
const get_frame_to_render_1 = require("./get-frame-to-render");
|
|
22
|
+
const image_format_1 = require("./image-format");
|
|
23
|
+
const is_audio_codec_1 = require("./is-audio-codec");
|
|
19
24
|
const legacy_webpack_config_1 = require("./legacy-webpack-config");
|
|
20
25
|
const make_cancel_signal_1 = require("./make-cancel-signal");
|
|
21
26
|
const overwrite_1 = require("./overwrite");
|
|
22
27
|
const perf_1 = require("./perf");
|
|
28
|
+
const pixel_format_1 = require("./pixel-format");
|
|
23
29
|
const prespawn_ffmpeg_1 = require("./prespawn-ffmpeg");
|
|
30
|
+
const prestitcher_memory_usage_1 = require("./prestitcher-memory-usage");
|
|
31
|
+
const prores_profile_1 = require("./prores-profile");
|
|
24
32
|
const quality_1 = require("./quality");
|
|
25
33
|
const render_frames_1 = require("./render-frames");
|
|
26
34
|
const stitch_frames_to_video_1 = require("./stitch-frames-to-video");
|
|
27
|
-
const tmp_dir_1 = require("./tmp-dir");
|
|
28
35
|
const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
|
|
36
|
+
const validate_every_nth_frame_1 = require("./validate-every-nth-frame");
|
|
37
|
+
const validate_ffmpeg_1 = require("./validate-ffmpeg");
|
|
38
|
+
const validate_ffmpeg_override_1 = require("./validate-ffmpeg-override");
|
|
29
39
|
const validate_output_filename_1 = require("./validate-output-filename");
|
|
30
40
|
const validate_scale_1 = require("./validate-scale");
|
|
41
|
+
const validate_videobitrate_1 = require("./validate-videobitrate");
|
|
42
|
+
const SLOWEST_FRAME_COUNT = 10;
|
|
43
|
+
const getConcurrency = (others) => {
|
|
44
|
+
if ('concurrency' in others) {
|
|
45
|
+
return others.concurrency;
|
|
46
|
+
}
|
|
47
|
+
if ('parallelism' in others) {
|
|
48
|
+
return others.parallelism;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
31
52
|
/**
|
|
32
53
|
*
|
|
33
54
|
* @description Render a video from a composition
|
|
34
55
|
* @link https://www.remotion.dev/docs/renderer/render-media
|
|
35
56
|
*/
|
|
36
|
-
const renderMedia = ({
|
|
37
|
-
var _a, _b;
|
|
38
|
-
(0,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
const renderMedia = ({ 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, ffmpegOverride, audioBitrate, videoBitrate, onSlowestFrames, ...options }) => {
|
|
58
|
+
var _a, _b, _c, _d;
|
|
59
|
+
(0, validate_ffmpeg_1.validateFfmpeg)(ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : null);
|
|
60
|
+
(0, quality_1.validateQuality)(options.quality);
|
|
61
|
+
(0, crf_1.validateQualitySettings)({ crf, codec, videoBitrate });
|
|
62
|
+
(0, validate_videobitrate_1.validateBitrate)(audioBitrate, 'audioBitrate');
|
|
63
|
+
(0, validate_videobitrate_1.validateBitrate)(videoBitrate, 'videoBitrate');
|
|
64
|
+
(0, prores_profile_1.validateSelectedCodecAndProResCombination)({
|
|
65
|
+
codec,
|
|
66
|
+
proResProfile,
|
|
67
|
+
});
|
|
68
|
+
(0, pixel_format_1.validateSelectedPixelFormatAndCodecCombination)(pixelFormat, codec);
|
|
42
69
|
if (outputLocation) {
|
|
43
70
|
(0, validate_output_filename_1.validateOutputFilename)(codec, (0, get_extension_of_filename_1.getExtensionOfFilename)(outputLocation));
|
|
44
71
|
}
|
|
72
|
+
const absoluteOutputLocation = outputLocation
|
|
73
|
+
? path_1.default.resolve(process.cwd(), outputLocation)
|
|
74
|
+
: null;
|
|
45
75
|
(0, validate_scale_1.validateScale)(scale);
|
|
76
|
+
const concurrency = getConcurrency(options);
|
|
77
|
+
(0, validate_ffmpeg_override_1.validateFfmpegOverride)(ffmpegOverride);
|
|
46
78
|
const everyNthFrame = (_a = options.everyNthFrame) !== null && _a !== void 0 ? _a : 1;
|
|
79
|
+
(0, validate_every_nth_frame_1.validateEveryNthFrame)(everyNthFrame, codec);
|
|
47
80
|
const numberOfGifLoops = (_b = options.numberOfGifLoops) !== null && _b !== void 0 ? _b : null;
|
|
48
81
|
const serveUrl = (0, legacy_webpack_config_1.getServeUrlWithFallback)(options);
|
|
49
82
|
let stitchStage = 'encoding';
|
|
@@ -55,11 +88,32 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
55
88
|
let encodedDoneIn = null;
|
|
56
89
|
let cancelled = false;
|
|
57
90
|
const renderStart = Date.now();
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
91
|
+
const downloadMap = (_c = options.downloadMap) !== null && _c !== void 0 ? _c : (0, download_map_1.makeDownloadMap)();
|
|
92
|
+
const { estimatedUsage, freeMemory, hasEnoughMemory } = (0, prestitcher_memory_usage_1.shouldUseParallelEncoding)({
|
|
93
|
+
height: composition.height,
|
|
94
|
+
width: composition.width,
|
|
95
|
+
});
|
|
96
|
+
const parallelEncoding = !options.disallowParallelEncoding &&
|
|
97
|
+
hasEnoughMemory &&
|
|
98
|
+
(0, can_use_parallel_encoding_1.canUseParallelEncoding)(codec);
|
|
99
|
+
if (options.verbose) {
|
|
100
|
+
console.log('[PRESTITCHER] Free memory:', freeMemory, 'Estimated usage parallel encoding', estimatedUsage);
|
|
101
|
+
console.log('[PRESTITCHER]: Codec supports parallel rendering:', (0, can_use_parallel_encoding_1.canUseParallelEncoding)(codec));
|
|
102
|
+
console.log('[PRESTITCHER]: User disallowed parallel encoding:', Boolean(options.disallowParallelEncoding));
|
|
103
|
+
if (parallelEncoding) {
|
|
104
|
+
console.log('[PRESTITCHER] Parallel encoding is enabled.');
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
console.log('[PRESTITCHER] Parallel encoding is disabled.');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const imageFormat = (0, is_audio_codec_1.isAudioCodec)(codec)
|
|
111
|
+
? 'none'
|
|
112
|
+
: (_d = options.imageFormat) !== null && _d !== void 0 ? _d : 'jpeg';
|
|
113
|
+
const quality = imageFormat === 'jpeg' ? options.quality : undefined;
|
|
114
|
+
(0, image_format_1.validateSelectedPixelFormatAndImageFormatCombination)(pixelFormat, imageFormat);
|
|
61
115
|
const preEncodedFileLocation = parallelEncoding
|
|
62
|
-
? path_1.default.join(
|
|
116
|
+
? path_1.default.join(downloadMap.preEncode, 'pre-encode.' + (0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, 'chunk'))
|
|
63
117
|
: null;
|
|
64
118
|
const outputDir = parallelEncoding
|
|
65
119
|
? null
|
|
@@ -77,6 +131,9 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
77
131
|
renderedDoneIn,
|
|
78
132
|
renderedFrames,
|
|
79
133
|
stitchStage,
|
|
134
|
+
progress: Math.round(((0.7 * renderedFrames + 0.3 * encodedFrames) /
|
|
135
|
+
composition.durationInFrames) *
|
|
136
|
+
100) / 100,
|
|
80
137
|
});
|
|
81
138
|
};
|
|
82
139
|
const realFrameRange = (0, get_frame_to_render_1.getRealFrameRange)(composition.durationInFrames, frameRange !== null && frameRange !== void 0 ? frameRange : null);
|
|
@@ -107,8 +164,10 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
107
164
|
},
|
|
108
165
|
verbose: (_a = options.verbose) !== null && _a !== void 0 ? _a : false,
|
|
109
166
|
ffmpegExecutable,
|
|
110
|
-
imageFormat
|
|
167
|
+
imageFormat,
|
|
111
168
|
signal: cancelPrestitcher.cancelSignal,
|
|
169
|
+
ffmpegOverride: ffmpegOverride !== null && ffmpegOverride !== void 0 ? ffmpegOverride : (({ args }) => args),
|
|
170
|
+
videoBitrate: videoBitrate !== null && videoBitrate !== void 0 ? videoBitrate : null,
|
|
112
171
|
});
|
|
113
172
|
stitcherFfmpeg = preStitcher.task;
|
|
114
173
|
}
|
|
@@ -126,15 +185,42 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
126
185
|
}
|
|
127
186
|
}
|
|
128
187
|
};
|
|
188
|
+
const mediaSupport = (0, codec_supports_media_1.codecSupportsMedia)(codec);
|
|
189
|
+
const disableAudio = !mediaSupport.audio || muted;
|
|
190
|
+
const slowestFrames = [];
|
|
191
|
+
let maxTime = 0;
|
|
192
|
+
let minTime = 0;
|
|
193
|
+
const recordFrameTime = (frameIndex, time) => {
|
|
194
|
+
var _a, _b;
|
|
195
|
+
const frameTime = { frame: frameIndex, time };
|
|
196
|
+
if (time < minTime && slowestFrames.length === SLOWEST_FRAME_COUNT) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (time > maxTime) {
|
|
200
|
+
// add at starting;
|
|
201
|
+
slowestFrames.unshift(frameTime);
|
|
202
|
+
maxTime = time;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
// add frame at appropriate position
|
|
206
|
+
const index = slowestFrames.findIndex(({ time: indexTime }) => indexTime < time);
|
|
207
|
+
slowestFrames.splice(index, 0, frameTime);
|
|
208
|
+
}
|
|
209
|
+
if (slowestFrames.length > SLOWEST_FRAME_COUNT) {
|
|
210
|
+
slowestFrames.pop();
|
|
211
|
+
}
|
|
212
|
+
minTime = (_b = (_a = slowestFrames[slowestFrames.length - 1]) === null || _a === void 0 ? void 0 : _a.time) !== null && _b !== void 0 ? _b : minTime;
|
|
213
|
+
};
|
|
129
214
|
const happyPath = createPrestitcherIfNecessary()
|
|
130
215
|
.then(() => {
|
|
131
216
|
const renderFramesProc = (0, render_frames_1.renderFrames)({
|
|
132
217
|
config: composition,
|
|
133
|
-
onFrameUpdate: (frame) => {
|
|
218
|
+
onFrameUpdate: (frame, frameIndex, timeToRenderInMilliseconds) => {
|
|
134
219
|
renderedFrames = frame;
|
|
135
220
|
callUpdate();
|
|
221
|
+
recordFrameTime(frameIndex, timeToRenderInMilliseconds);
|
|
136
222
|
},
|
|
137
|
-
|
|
223
|
+
concurrency,
|
|
138
224
|
outputDir,
|
|
139
225
|
onStart: (data) => {
|
|
140
226
|
renderedFrames = 0;
|
|
@@ -143,7 +229,7 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
143
229
|
},
|
|
144
230
|
inputProps,
|
|
145
231
|
envVariables,
|
|
146
|
-
imageFormat
|
|
232
|
+
imageFormat,
|
|
147
233
|
quality,
|
|
148
234
|
frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
|
|
149
235
|
puppeteerInstance,
|
|
@@ -173,6 +259,8 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
173
259
|
browserExecutable,
|
|
174
260
|
port,
|
|
175
261
|
cancelSignal: cancelRenderFrames.cancelSignal,
|
|
262
|
+
downloadMap,
|
|
263
|
+
muted: disableAudio,
|
|
176
264
|
});
|
|
177
265
|
return renderFramesProc;
|
|
178
266
|
})
|
|
@@ -182,8 +270,8 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
182
270
|
.then(([{ assetsInfo }]) => {
|
|
183
271
|
renderedDoneIn = Date.now() - renderStart;
|
|
184
272
|
callUpdate();
|
|
185
|
-
if (
|
|
186
|
-
(0, ensure_output_directory_1.ensureOutputDirectory)(
|
|
273
|
+
if (absoluteOutputLocation) {
|
|
274
|
+
(0, ensure_output_directory_1.ensureOutputDirectory)(absoluteOutputLocation);
|
|
187
275
|
}
|
|
188
276
|
const stitchStart = Date.now();
|
|
189
277
|
return Promise.all([
|
|
@@ -191,10 +279,10 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
191
279
|
width: composition.width * (scale !== null && scale !== void 0 ? scale : 1),
|
|
192
280
|
height: composition.height * (scale !== null && scale !== void 0 ? scale : 1),
|
|
193
281
|
fps,
|
|
194
|
-
outputLocation,
|
|
282
|
+
outputLocation: absoluteOutputLocation,
|
|
195
283
|
internalOptions: {
|
|
196
284
|
preEncodedFileLocation,
|
|
197
|
-
imageFormat
|
|
285
|
+
imageFormat,
|
|
198
286
|
},
|
|
199
287
|
force: overwrite !== null && overwrite !== void 0 ? overwrite : overwrite_1.DEFAULT_OVERWRITE,
|
|
200
288
|
pixelFormat,
|
|
@@ -214,6 +302,11 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
214
302
|
verbose: options.verbose,
|
|
215
303
|
dir: outputDir !== null && outputDir !== void 0 ? outputDir : undefined,
|
|
216
304
|
cancelSignal: cancelStitcher.cancelSignal,
|
|
305
|
+
muted: disableAudio,
|
|
306
|
+
enforceAudioTrack,
|
|
307
|
+
ffmpegOverride,
|
|
308
|
+
audioBitrate,
|
|
309
|
+
videoBitrate,
|
|
217
310
|
}),
|
|
218
311
|
stitchStart,
|
|
219
312
|
]);
|
|
@@ -222,6 +315,8 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
222
315
|
encodedFrames = (0, get_duration_from_frame_range_1.getFramesToRender)(realFrameRange, everyNthFrame).length;
|
|
223
316
|
encodedDoneIn = Date.now() - stitchStart;
|
|
224
317
|
callUpdate();
|
|
318
|
+
slowestFrames.sort((a, b) => b.time - a.time);
|
|
319
|
+
onSlowestFrames === null || onSlowestFrames === void 0 ? void 0 : onSlowestFrames(slowestFrames);
|
|
225
320
|
return buffer;
|
|
226
321
|
})
|
|
227
322
|
.catch((err) => {
|
|
@@ -250,7 +345,15 @@ const renderMedia = ({ parallelism, proResProfile, crf, composition, imageFormat
|
|
|
250
345
|
.finally(() => {
|
|
251
346
|
if (preEncodedFileLocation !== null &&
|
|
252
347
|
fs_1.default.existsSync(preEncodedFileLocation)) {
|
|
253
|
-
|
|
348
|
+
(0, delete_directory_1.deleteDirectory)(path_1.default.dirname(preEncodedFileLocation));
|
|
349
|
+
}
|
|
350
|
+
// Clean download map if it was not passed in
|
|
351
|
+
if (!(options === null || options === void 0 ? void 0 : options.downloadMap)) {
|
|
352
|
+
(0, download_map_1.cleanDownloadMap)(downloadMap);
|
|
353
|
+
}
|
|
354
|
+
// Clean temporary image frames when rendering ends or fails
|
|
355
|
+
if (outputDir && fs_1.default.existsSync(outputDir)) {
|
|
356
|
+
(0, delete_directory_1.deleteDirectory)(outputDir);
|
|
254
357
|
}
|
|
255
358
|
});
|
|
256
359
|
return Promise.race([
|
package/dist/render-still.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SmallTCompMetadata } from 'remotion';
|
|
2
2
|
import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
|
|
3
|
+
import type { DownloadMap } from './assets/download-map';
|
|
3
4
|
import type { BrowserExecutable } from './browser-executable';
|
|
4
5
|
import type { Browser as PuppeteerBrowser } from './browser/Browser';
|
|
5
6
|
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
@@ -26,8 +27,12 @@ declare type InnerStillOptions = {
|
|
|
26
27
|
cancelSignal?: CancelSignal;
|
|
27
28
|
ffmpegExecutable?: FfmpegExecutable;
|
|
28
29
|
ffprobeExecutable?: FfmpegExecutable;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Only for Remotion internal usage
|
|
32
|
+
*/
|
|
33
|
+
downloadMap?: DownloadMap;
|
|
29
34
|
};
|
|
30
|
-
declare type RenderStillOptions = InnerStillOptions & ServeUrlOrWebpackBundle & {
|
|
35
|
+
export declare type RenderStillOptions = InnerStillOptions & ServeUrlOrWebpackBundle & {
|
|
31
36
|
port?: number | null;
|
|
32
37
|
};
|
|
33
38
|
/**
|