@remotion/renderer 4.0.0-webhook.26 → 4.1.0-alpha1
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/README.md +9 -0
- package/client.d.ts +1 -0
- package/client.js +1 -0
- package/dist/assets/calculate-asset-positions.d.ts +0 -0
- package/dist/assets/calculate-asset-positions.js +1 -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 +0 -0
- package/dist/assets/convert-assets-to-file-urls.js +0 -0
- package/dist/assets/download-and-map-assets-to-file.d.ts +6 -4
- package/dist/assets/download-and-map-assets-to-file.js +49 -19
- package/dist/assets/download-file.d.ts +8 -5
- package/dist/assets/download-file.js +71 -8
- package/dist/assets/download-map.d.ts +8 -29
- package/dist/assets/download-map.js +15 -16
- package/dist/assets/ffmpeg-volume-expression.d.ts +4 -3
- package/dist/assets/ffmpeg-volume-expression.js +5 -3
- 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 -2
- package/dist/assets/get-audio-channels.js +14 -12
- package/dist/assets/read-file.d.ts +1 -1
- package/dist/assets/read-file.js +5 -7
- 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 +2 -2
- 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 +5 -4
- package/dist/assets/types.js +0 -0
- package/dist/audio-codec.d.ts +28 -0
- package/dist/audio-codec.js +83 -0
- package/dist/browser/Browser.d.ts +16 -14
- package/dist/browser/Browser.js +69 -72
- package/dist/browser/BrowserConnector.d.ts +0 -0
- package/dist/browser/BrowserConnector.js +0 -0
- package/dist/browser/BrowserFetcher.d.ts +16 -64
- package/dist/browser/BrowserFetcher.js +147 -235
- package/dist/browser/BrowserPage.d.ts +21 -6
- package/dist/browser/BrowserPage.js +54 -22
- package/dist/browser/BrowserRunner.d.ts +1 -1
- package/dist/browser/BrowserRunner.js +32 -22
- package/dist/browser/Connection.d.ts +0 -0
- package/dist/browser/Connection.js +1 -1
- package/dist/browser/ConsoleMessage.d.ts +1 -1
- package/dist/browser/ConsoleMessage.js +0 -0
- package/dist/browser/DOMWorld.d.ts +5 -4
- package/dist/browser/DOMWorld.js +16 -9
- package/dist/browser/Errors.d.ts +0 -0
- package/dist/browser/Errors.js +0 -0
- package/dist/browser/EvalTypes.d.ts +7 -7
- 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 -2
- package/dist/browser/FrameManager.js +13 -17
- 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 +14 -14
- package/dist/browser/LaunchOptions.d.ts +2 -2
- package/dist/browser/LaunchOptions.js +0 -0
- package/dist/browser/Launcher.d.ts +9 -3
- package/dist/browser/Launcher.js +16 -29
- package/dist/browser/LifecycleWatcher.d.ts +1 -1
- package/dist/browser/LifecycleWatcher.js +0 -0
- package/dist/browser/NetworkEventManager.d.ts +4 -4
- 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 +21 -21
- package/dist/browser/Product.d.ts +1 -1
- package/dist/browser/Product.js +0 -0
- package/dist/browser/PuppeteerNode.d.ts +2 -5
- package/dist/browser/PuppeteerNode.js +2 -11
- package/dist/browser/PuppeteerViewport.d.ts +0 -0
- package/dist/browser/PuppeteerViewport.js +0 -0
- package/dist/browser/ScreenshotOptions.d.ts +0 -14
- package/dist/browser/ScreenshotOptions.js +0 -1
- package/dist/browser/Target.d.ts +4 -3
- package/dist/browser/Target.js +8 -2
- 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 +34 -48
- package/dist/browser/devtools-commands.d.ts +5 -1
- package/dist/browser/devtools-commands.js +0 -0
- package/dist/browser/devtools-types.d.ts +92 -10
- 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 +8 -8
- package/dist/browser/is-target-closed-err.d.ts +1 -0
- package/dist/browser/is-target-closed-err.js +9 -0
- package/dist/browser/mitt/index.d.ts +6 -6
- 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 +1 -1
- package/dist/browser/revisions.js +0 -0
- package/dist/browser/should-log-message.d.ts +24 -0
- package/dist/browser/should-log-message.js +72 -0
- package/dist/browser/util.d.ts +2 -2
- package/dist/browser/util.js +0 -0
- package/dist/browser-executable.d.ts +1 -1
- package/dist/browser-executable.js +0 -0
- package/dist/browser-log.d.ts +1 -1
- package/dist/browser-log.js +0 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +0 -0
- package/dist/calculate-ffmpeg-filters.d.ts +2 -1
- package/dist/calculate-ffmpeg-filters.js +1 -0
- package/dist/call-ffmpeg.d.ts +14 -0
- package/dist/call-ffmpeg.js +42 -0
- package/dist/can-use-parallel-encoding.d.ts +0 -0
- package/dist/can-use-parallel-encoding.js +0 -0
- package/dist/chalk/index.d.ts +54 -0
- package/dist/chalk/index.js +135 -0
- package/dist/chalk/is-color-supported.d.ts +1 -0
- package/dist/chalk/is-color-supported.js +37 -0
- package/dist/check-apple-silicon.d.ts +1 -1
- package/dist/check-apple-silicon.js +8 -47
- package/dist/chunk.d.ts +0 -0
- package/dist/chunk.js +0 -0
- package/dist/client.d.ts +204 -0
- package/dist/client.js +49 -0
- package/dist/codec-supports-media.d.ts +3 -2
- package/dist/codec-supports-media.js +20 -5
- package/dist/codec.d.ts +2 -2
- package/dist/codec.js +0 -0
- package/dist/combine-videos.d.ts +6 -2
- package/dist/combine-videos.js +17 -17
- package/dist/compositor/compose.d.ts +26 -0
- package/dist/compositor/compose.js +82 -0
- package/dist/compositor/compositor.d.ts +11 -0
- package/dist/compositor/compositor.js +219 -0
- package/dist/compositor/get-executable-path.d.ts +1 -0
- package/dist/compositor/get-executable-path.js +57 -0
- package/dist/compositor/make-nonce.d.ts +1 -0
- package/dist/compositor/make-nonce.js +8 -0
- package/dist/compositor/payloads.d.ts +68 -0
- package/dist/{ffmpeg-executable.js → compositor/payloads.js} +0 -0
- 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-positive-frame-index.d.ts +0 -0
- package/dist/convert-to-positive-frame-index.js +0 -0
- package/dist/create-ffmpeg-complex-filter.d.ts +5 -1
- package/dist/create-ffmpeg-complex-filter.js +6 -4
- package/dist/create-ffmpeg-merge-filter.d.ts +5 -1
- package/dist/create-ffmpeg-merge-filter.js +21 -13
- package/dist/create-silent-audio.d.ts +1 -3
- package/dist/create-silent-audio.js +3 -6
- package/dist/crf.d.ts +6 -2
- package/dist/crf.js +41 -8
- package/dist/cycle-browser-tabs.d.ts +2 -5
- package/dist/cycle-browser-tabs.js +5 -5
- 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 +1 -1
- package/dist/delete-directory.js +43 -17
- package/dist/does-have-m2-bug.d.ts +3 -0
- package/dist/does-have-m2-bug.js +12 -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 +5 -5
- package/dist/error-handling/handle-javascript-exception.d.ts +0 -0
- package/dist/error-handling/handle-javascript-exception.js +10 -0
- package/dist/error-handling/symbolicate-error.d.ts +0 -0
- package/dist/error-handling/symbolicate-error.js +6 -3
- package/dist/error-handling/symbolicateable-error.d.ts +0 -0
- package/dist/error-handling/symbolicateable-error.js +0 -0
- package/dist/ffmpeg-filter-file.d.ts +6 -1
- package/dist/ffmpeg-filter-file.js +40 -8
- package/dist/ffmpeg-override.d.ts +1 -1
- package/dist/ffmpeg-override.js +0 -0
- package/dist/file-extensions.d.ts +14 -0
- package/dist/file-extensions.js +76 -0
- package/dist/find-closest-package-json.d.ts +2 -0
- package/dist/find-closest-package-json.js +31 -0
- package/dist/frame-range.d.ts +1 -1
- package/dist/frame-range.js +0 -0
- package/dist/get-browser-instance.d.ts +8 -3
- package/dist/get-browser-instance.js +10 -5
- package/dist/get-codec-name.d.ts +0 -0
- package/dist/get-codec-name.js +0 -0
- package/dist/get-compositions.d.ts +27 -14
- package/dist/get-compositions.js +72 -39
- package/dist/get-concurrency.d.ts +1 -1
- package/dist/get-concurrency.js +11 -4
- 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 +5 -1
- package/dist/get-extension-from-codec.js +56 -32
- package/dist/get-extension-of-filename.d.ts +0 -0
- package/dist/get-extension-of-filename.js +5 -1
- package/dist/get-frame-padded-index.d.ts +3 -2
- package/dist/get-frame-padded-index.js +3 -2
- package/dist/get-frame-to-render.d.ts +0 -0
- package/dist/get-frame-to-render.js +1 -1
- package/dist/get-local-browser-executable.d.ts +0 -0
- package/dist/get-local-browser-executable.js +7 -15
- package/dist/get-port.d.ts +4 -1
- package/dist/get-port.js +8 -8
- package/dist/get-prores-profile-name.d.ts +0 -0
- package/dist/get-prores-profile-name.js +0 -0
- package/dist/get-video-threads-flag.d.ts +0 -0
- package/dist/get-video-threads-flag.js +3 -3
- package/dist/guess-extension-for-media.d.ts +3 -1
- package/dist/guess-extension-for-media.js +4 -7
- package/dist/image-format.d.ts +12 -6
- package/dist/image-format.js +19 -13
- package/dist/index.d.ts +368 -49
- package/dist/index.js +68 -46
- package/dist/is-audio-codec.d.ts +0 -0
- package/dist/is-audio-codec.js +0 -0
- package/dist/is-serve-url.d.ts +0 -0
- package/dist/is-serve-url.js +0 -0
- package/dist/jpeg-quality.d.ts +2 -0
- package/dist/jpeg-quality.js +22 -0
- package/dist/locks.d.ts +7 -0
- package/dist/locks.js +44 -0
- package/dist/log-level.d.ts +1 -1
- package/dist/log-level.js +0 -0
- package/dist/logger.d.ts +24 -0
- package/dist/logger.js +68 -0
- package/dist/make-cancel-signal.d.ts +13 -2
- package/dist/make-cancel-signal.js +24 -1
- package/dist/merge-audio-track.d.ts +4 -4
- package/dist/merge-audio-track.js +38 -33
- package/dist/mime-db.d.ts +0 -0
- package/dist/mime-db.js +0 -0
- package/dist/mime-types.d.ts +0 -0
- package/dist/mime-types.js +3 -3
- package/dist/normalize-serve-url.d.ts +0 -0
- package/dist/normalize-serve-url.js +0 -0
- package/dist/offthread-video-server.d.ts +47 -11
- package/dist/offthread-video-server.js +111 -58
- package/dist/open-browser.d.ts +21 -6
- package/dist/open-browser.js +37 -16
- 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/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 +1 -1
- 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 +2 -2
- package/dist/perf.js +9 -7
- package/dist/pixel-format.d.ts +2 -2
- 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 +25 -10
- package/dist/prepare-server.js +71 -18
- package/dist/preprocess-audio-track.d.ts +7 -5
- package/dist/preprocess-audio-track.js +7 -8
- package/dist/prespawn-ffmpeg.d.ts +20 -10
- package/dist/prespawn-ffmpeg.js +67 -29
- package/dist/prestitcher-memory-usage.d.ts +0 -4
- package/dist/prestitcher-memory-usage.js +4 -5
- package/dist/prores-profile.d.ts +6 -4
- package/dist/prores-profile.js +8 -8
- package/dist/provide-screenshot.d.ts +8 -4
- package/dist/provide-screenshot.js +5 -2
- package/dist/puppeteer-evaluate.d.ts +0 -0
- package/dist/puppeteer-evaluate.js +20 -12
- package/dist/puppeteer-screenshot.d.ts +12 -2
- package/dist/puppeteer-screenshot.js +18 -45
- package/dist/redirect-status-codes.d.ts +1 -0
- package/dist/redirect-status-codes.js +6 -0
- package/dist/render-frames.d.ts +52 -35
- package/dist/render-frames.js +248 -143
- package/dist/render-media.d.ts +76 -29
- package/dist/render-media.js +324 -195
- package/dist/render-still.d.ts +46 -19
- package/dist/render-still.js +128 -69
- package/dist/replace-browser.d.ts +6 -0
- package/dist/replace-browser.js +47 -0
- package/dist/resolve-asset-src.d.ts +0 -0
- package/dist/resolve-asset-src.js +2 -2
- package/dist/sample-rate.d.ts +0 -0
- package/dist/sample-rate.js +0 -0
- package/dist/screenshot-dom-element.d.ts +8 -4
- package/dist/screenshot-dom-element.js +15 -4
- package/dist/screenshot-task.d.ts +11 -2
- package/dist/screenshot-task.js +43 -13
- package/dist/seek-to-frame.d.ts +1 -0
- package/dist/seek-to-frame.js +49 -3
- package/dist/select-composition.d.ts +41 -0
- package/dist/select-composition.js +156 -0
- package/dist/serve-handler/index.d.ts +1 -1
- package/dist/serve-handler/index.js +21 -19
- package/dist/serve-handler/is-path-inside.d.ts +0 -0
- package/dist/serve-handler/is-path-inside.js +3 -3
- 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 +8 -6
- package/dist/serve-static.js +85 -59
- package/dist/set-props-and-env.d.ts +5 -3
- package/dist/set-props-and-env.js +18 -10
- package/dist/stitch-frames-to-video.d.ts +39 -16
- package/dist/stitch-frames-to-video.js +210 -121
- package/dist/stringify-ffmpeg-filter.d.ts +10 -2
- package/dist/stringify-ffmpeg-filter.js +37 -34
- package/dist/symbolicate-stacktrace.d.ts +16 -3
- package/dist/symbolicate-stacktrace.js +49 -24
- package/dist/take-frame-and-compose.d.ts +22 -0
- package/dist/take-frame-and-compose.js +103 -0
- package/dist/tmp-dir.d.ts +0 -0
- package/dist/tmp-dir.js +7 -8
- package/dist/truthy.d.ts +1 -1
- package/dist/truthy.js +0 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.js +0 -0
- package/dist/validate-concurrency.d.ts +2 -0
- package/dist/validate-concurrency.js +21 -10
- 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 +0 -0
- package/dist/validate-ffmpeg-override.js +0 -0
- 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 +2 -3
- package/dist/validate-opengl-renderer.js +9 -4
- package/dist/validate-output-filename.d.ts +7 -2
- package/dist/validate-output-filename.js +20 -51
- package/dist/validate-puppeteer-timeout.d.ts +0 -0
- package/dist/validate-puppeteer-timeout.js +1 -0
- 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 +5 -31
- package/dist/ws/ws-types.d.ts +0 -0
- package/dist/ws/ws-types.js +2 -1
- package/install-toolchain.mjs +36 -0
- package/package.json +70 -60
- package/types/ws/index.d.ts +5 -5
- package/.prettierrc.js +0 -14
- package/dist/assets/dl-browser.d.ts +0 -1
- package/dist/assets/dl-browser.js +0 -38
- package/dist/assets/get-video-stream-duration.d.ts +0 -4
- package/dist/assets/get-video-stream-duration.js +0 -59
- package/dist/calculate-sar-dar-pixels.d.ts +0 -9
- package/dist/calculate-sar-dar-pixels.js +0 -19
- package/dist/convert-to-pcm.d.ts +0 -6
- package/dist/convert-to-pcm.js +0 -20
- package/dist/ensure-presentation-timestamp.d.ts +0 -2
- package/dist/ensure-presentation-timestamp.js +0 -69
- package/dist/extract-frame-from-video.d.ts +0 -16
- package/dist/extract-frame-from-video.js +0 -277
- package/dist/ffmpeg-executable.d.ts +0 -1
- package/dist/ffmpeg-flags.d.ts +0 -12
- package/dist/ffmpeg-flags.js +0 -45
- package/dist/frame-to-ffmpeg-timestamp.d.ts +0 -1
- package/dist/frame-to-ffmpeg-timestamp.js +0 -8
- package/dist/get-audio-codec-name.d.ts +0 -2
- package/dist/get-audio-codec-name.js +0 -28
- package/dist/get-video-info.d.ts +0 -3
- package/dist/get-video-info.js +0 -49
- package/dist/is-beyond-last-frame.d.ts +0 -3
- package/dist/is-beyond-last-frame.js +0 -12
- package/dist/last-frame-from-video-cache.d.ts +0 -17
- package/dist/last-frame-from-video-cache.js +0 -55
- package/dist/legacy-webpack-config.d.ts +0 -9
- package/dist/legacy-webpack-config.js +0 -13
- package/dist/quality.d.ts +0 -1
- package/dist/quality.js +0 -21
- package/dist/validate-ffmpeg.d.ts +0 -2
- package/dist/validate-ffmpeg.js +0 -72
- package/dist/validate-frame.d.ts +0 -1
- package/dist/validate-frame.js +0 -24
- package/tsconfig.json +0 -10
- package/vitest.config.ts +0 -8
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
export declare const BrowserSafeApis: {
|
|
2
|
+
getFileExtensionFromCodec: <T extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">(codec: T, audioCodec: "mp3" | "aac" | "pcm-16" | "opus" | null) => import("./file-extensions").FileExtension;
|
|
3
|
+
validCodecs: readonly ["h264", "h265", "vp8", "vp9", "mp3", "aac", "wav", "prores", "h264-mkv", "gif"];
|
|
4
|
+
validAudioCodecs: readonly ["pcm-16", "aac", "mp3", "opus"];
|
|
5
|
+
getDefaultCrfForCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => number;
|
|
6
|
+
getValidCrfRanges: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => [number, number];
|
|
7
|
+
isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif" | undefined) => boolean;
|
|
8
|
+
proResProfileOptions: readonly ["4444-xq", "4444", "hq", "standard", "light", "proxy"];
|
|
9
|
+
validPixelFormats: readonly ["yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le"];
|
|
10
|
+
DEFAULT_PIXEL_FORMAT: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le";
|
|
11
|
+
supportedAudioCodecs: {
|
|
12
|
+
readonly h264: readonly ["aac", "pcm-16"];
|
|
13
|
+
readonly 'h264-mkv': readonly ["pcm-16"];
|
|
14
|
+
readonly aac: readonly ["aac", "pcm-16"];
|
|
15
|
+
readonly gif: const[];
|
|
16
|
+
readonly h265: readonly ["aac", "pcm-16"];
|
|
17
|
+
readonly mp3: readonly ["mp3", "pcm-16"];
|
|
18
|
+
readonly prores: readonly ["aac", "pcm-16"];
|
|
19
|
+
readonly vp8: readonly ["opus", "pcm-16"];
|
|
20
|
+
readonly vp9: readonly ["opus", "pcm-16"];
|
|
21
|
+
readonly wav: readonly ["pcm-16"];
|
|
22
|
+
};
|
|
23
|
+
defaultFileExtensionMap: {
|
|
24
|
+
h264: {
|
|
25
|
+
default: import("./file-extensions").FileExtension;
|
|
26
|
+
forAudioCodec: {
|
|
27
|
+
aac: {
|
|
28
|
+
possible: import("./file-extensions").FileExtension[];
|
|
29
|
+
default: import("./file-extensions").FileExtension;
|
|
30
|
+
};
|
|
31
|
+
"pcm-16": {
|
|
32
|
+
possible: import("./file-extensions").FileExtension[];
|
|
33
|
+
default: import("./file-extensions").FileExtension;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
h265: {
|
|
38
|
+
default: import("./file-extensions").FileExtension;
|
|
39
|
+
forAudioCodec: {
|
|
40
|
+
aac: {
|
|
41
|
+
possible: import("./file-extensions").FileExtension[];
|
|
42
|
+
default: import("./file-extensions").FileExtension;
|
|
43
|
+
};
|
|
44
|
+
"pcm-16": {
|
|
45
|
+
possible: import("./file-extensions").FileExtension[];
|
|
46
|
+
default: import("./file-extensions").FileExtension;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
vp8: {
|
|
51
|
+
default: import("./file-extensions").FileExtension;
|
|
52
|
+
forAudioCodec: {
|
|
53
|
+
"pcm-16": {
|
|
54
|
+
possible: import("./file-extensions").FileExtension[];
|
|
55
|
+
default: import("./file-extensions").FileExtension;
|
|
56
|
+
};
|
|
57
|
+
opus: {
|
|
58
|
+
possible: import("./file-extensions").FileExtension[];
|
|
59
|
+
default: import("./file-extensions").FileExtension;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
vp9: {
|
|
64
|
+
default: import("./file-extensions").FileExtension;
|
|
65
|
+
forAudioCodec: {
|
|
66
|
+
"pcm-16": {
|
|
67
|
+
possible: import("./file-extensions").FileExtension[];
|
|
68
|
+
default: import("./file-extensions").FileExtension;
|
|
69
|
+
};
|
|
70
|
+
opus: {
|
|
71
|
+
possible: import("./file-extensions").FileExtension[];
|
|
72
|
+
default: import("./file-extensions").FileExtension;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
mp3: {
|
|
77
|
+
default: import("./file-extensions").FileExtension;
|
|
78
|
+
forAudioCodec: {
|
|
79
|
+
mp3: {
|
|
80
|
+
possible: import("./file-extensions").FileExtension[];
|
|
81
|
+
default: import("./file-extensions").FileExtension;
|
|
82
|
+
};
|
|
83
|
+
"pcm-16": {
|
|
84
|
+
possible: import("./file-extensions").FileExtension[];
|
|
85
|
+
default: import("./file-extensions").FileExtension;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
aac: {
|
|
90
|
+
default: import("./file-extensions").FileExtension;
|
|
91
|
+
forAudioCodec: {
|
|
92
|
+
aac: {
|
|
93
|
+
possible: import("./file-extensions").FileExtension[];
|
|
94
|
+
default: import("./file-extensions").FileExtension;
|
|
95
|
+
};
|
|
96
|
+
"pcm-16": {
|
|
97
|
+
possible: import("./file-extensions").FileExtension[];
|
|
98
|
+
default: import("./file-extensions").FileExtension;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
wav: {
|
|
103
|
+
default: import("./file-extensions").FileExtension;
|
|
104
|
+
forAudioCodec: {
|
|
105
|
+
"pcm-16": {
|
|
106
|
+
possible: import("./file-extensions").FileExtension[];
|
|
107
|
+
default: import("./file-extensions").FileExtension;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
prores: {
|
|
112
|
+
default: import("./file-extensions").FileExtension;
|
|
113
|
+
forAudioCodec: {
|
|
114
|
+
aac: {
|
|
115
|
+
possible: import("./file-extensions").FileExtension[];
|
|
116
|
+
default: import("./file-extensions").FileExtension;
|
|
117
|
+
};
|
|
118
|
+
"pcm-16": {
|
|
119
|
+
possible: import("./file-extensions").FileExtension[];
|
|
120
|
+
default: import("./file-extensions").FileExtension;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
"h264-mkv": {
|
|
125
|
+
default: import("./file-extensions").FileExtension;
|
|
126
|
+
forAudioCodec: {
|
|
127
|
+
"pcm-16": {
|
|
128
|
+
possible: import("./file-extensions").FileExtension[];
|
|
129
|
+
default: import("./file-extensions").FileExtension;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
gif: {
|
|
134
|
+
default: import("./file-extensions").FileExtension;
|
|
135
|
+
forAudioCodec: {
|
|
136
|
+
[x: string]: {
|
|
137
|
+
possible: import("./file-extensions").FileExtension[];
|
|
138
|
+
default: import("./file-extensions").FileExtension;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
defaultAudioCodecs: {
|
|
144
|
+
h264: {
|
|
145
|
+
compressed: "aac" | "pcm-16" | null;
|
|
146
|
+
lossless: "aac" | "pcm-16" | null;
|
|
147
|
+
};
|
|
148
|
+
h265: {
|
|
149
|
+
compressed: "aac" | "pcm-16" | null;
|
|
150
|
+
lossless: "aac" | "pcm-16" | null;
|
|
151
|
+
};
|
|
152
|
+
vp8: {
|
|
153
|
+
compressed: "pcm-16" | "opus" | null;
|
|
154
|
+
lossless: "pcm-16" | "opus" | null;
|
|
155
|
+
};
|
|
156
|
+
vp9: {
|
|
157
|
+
compressed: "pcm-16" | "opus" | null;
|
|
158
|
+
lossless: "pcm-16" | "opus" | null;
|
|
159
|
+
};
|
|
160
|
+
mp3: {
|
|
161
|
+
compressed: "mp3" | "pcm-16" | null;
|
|
162
|
+
lossless: "mp3" | "pcm-16" | null;
|
|
163
|
+
};
|
|
164
|
+
aac: {
|
|
165
|
+
compressed: "aac" | "pcm-16" | null;
|
|
166
|
+
lossless: "aac" | "pcm-16" | null;
|
|
167
|
+
};
|
|
168
|
+
wav: {
|
|
169
|
+
compressed: "pcm-16" | null;
|
|
170
|
+
lossless: "pcm-16" | null;
|
|
171
|
+
};
|
|
172
|
+
prores: {
|
|
173
|
+
compressed: "aac" | "pcm-16" | null;
|
|
174
|
+
lossless: "aac" | "pcm-16" | null;
|
|
175
|
+
};
|
|
176
|
+
"h264-mkv": {
|
|
177
|
+
compressed: "pcm-16" | null;
|
|
178
|
+
lossless: "pcm-16" | null;
|
|
179
|
+
};
|
|
180
|
+
gif: {
|
|
181
|
+
compressed: any;
|
|
182
|
+
lossless: any;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
defaultCodecsForFileExtension: Record<import("./file-extensions").FileExtension, "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">;
|
|
186
|
+
validateOutputFilename: <T_1 extends "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif">({ codec, audioCodec, extension, preferLossless, }: {
|
|
187
|
+
codec: T_1;
|
|
188
|
+
audioCodec: "mp3" | "aac" | "pcm-16" | "opus" | null;
|
|
189
|
+
extension: string;
|
|
190
|
+
preferLossless: boolean;
|
|
191
|
+
}) => void;
|
|
192
|
+
options: {
|
|
193
|
+
scaleOption: import(".").RemotionOption;
|
|
194
|
+
crfOption: import(".").RemotionOption;
|
|
195
|
+
jpegQualityOption: import(".").RemotionOption;
|
|
196
|
+
videoBitrate: import(".").RemotionOption;
|
|
197
|
+
audioBitrateOption: import(".").RemotionOption;
|
|
198
|
+
enforceAudioOption: import(".").RemotionOption;
|
|
199
|
+
muteOption: import(".").RemotionOption;
|
|
200
|
+
videoCodecOption: import(".").RemotionOption;
|
|
201
|
+
};
|
|
202
|
+
codecSupportsCrf: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => boolean;
|
|
203
|
+
codecSupportsVideoBitrate: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => boolean;
|
|
204
|
+
};
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserSafeApis = void 0;
|
|
4
|
+
const audio_codec_1 = require("./audio-codec");
|
|
5
|
+
const codec_1 = require("./codec");
|
|
6
|
+
const codec_supports_media_1 = require("./codec-supports-media");
|
|
7
|
+
const crf_1 = require("./crf");
|
|
8
|
+
const file_extensions_1 = require("./file-extensions");
|
|
9
|
+
const get_extension_from_codec_1 = require("./get-extension-from-codec");
|
|
10
|
+
const is_audio_codec_1 = require("./is-audio-codec");
|
|
11
|
+
const audio_bitrate_1 = require("./options/audio-bitrate");
|
|
12
|
+
const crf_2 = require("./options/crf");
|
|
13
|
+
const enforce_audio_1 = require("./options/enforce-audio");
|
|
14
|
+
const jpeg_quality_1 = require("./options/jpeg-quality");
|
|
15
|
+
const mute_1 = require("./options/mute");
|
|
16
|
+
const scale_1 = require("./options/scale");
|
|
17
|
+
const video_bitrate_1 = require("./options/video-bitrate");
|
|
18
|
+
const video_codec_1 = require("./options/video-codec");
|
|
19
|
+
const pixel_format_1 = require("./pixel-format");
|
|
20
|
+
const prores_profile_1 = require("./prores-profile");
|
|
21
|
+
const validate_output_filename_1 = require("./validate-output-filename");
|
|
22
|
+
exports.BrowserSafeApis = {
|
|
23
|
+
getFileExtensionFromCodec: get_extension_from_codec_1.getFileExtensionFromCodec,
|
|
24
|
+
validCodecs: codec_1.validCodecs,
|
|
25
|
+
validAudioCodecs: audio_codec_1.validAudioCodecs,
|
|
26
|
+
getDefaultCrfForCodec: crf_1.getDefaultCrfForCodec,
|
|
27
|
+
getValidCrfRanges: crf_1.getValidCrfRanges,
|
|
28
|
+
isAudioCodec: is_audio_codec_1.isAudioCodec,
|
|
29
|
+
proResProfileOptions: prores_profile_1.proResProfileOptions,
|
|
30
|
+
validPixelFormats: pixel_format_1.validPixelFormats,
|
|
31
|
+
DEFAULT_PIXEL_FORMAT: pixel_format_1.DEFAULT_PIXEL_FORMAT,
|
|
32
|
+
supportedAudioCodecs: audio_codec_1.supportedAudioCodecs,
|
|
33
|
+
defaultFileExtensionMap: file_extensions_1.defaultFileExtensionMap,
|
|
34
|
+
defaultAudioCodecs: audio_codec_1.defaultAudioCodecs,
|
|
35
|
+
defaultCodecsForFileExtension: get_extension_from_codec_1.defaultCodecsForFileExtension,
|
|
36
|
+
validateOutputFilename: validate_output_filename_1.validateOutputFilename,
|
|
37
|
+
options: {
|
|
38
|
+
scaleOption: scale_1.scaleOption,
|
|
39
|
+
crfOption: crf_2.crfOption,
|
|
40
|
+
jpegQualityOption: jpeg_quality_1.jpegQualityOption,
|
|
41
|
+
videoBitrate: video_bitrate_1.videoBitrate,
|
|
42
|
+
audioBitrateOption: audio_bitrate_1.audioBitrateOption,
|
|
43
|
+
enforceAudioOption: enforce_audio_1.enforceAudioOption,
|
|
44
|
+
muteOption: mute_1.muteOption,
|
|
45
|
+
videoCodecOption: video_codec_1.videoCodecOption,
|
|
46
|
+
},
|
|
47
|
+
codecSupportsCrf: codec_supports_media_1.codecSupportsCrf,
|
|
48
|
+
codecSupportsVideoBitrate: codec_supports_media_1.codecSupportsVideoBitrate,
|
|
49
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Codec } from './codec';
|
|
2
|
-
|
|
2
|
+
type MediaSupport = {
|
|
3
3
|
video: boolean;
|
|
4
4
|
audio: boolean;
|
|
5
5
|
};
|
|
6
6
|
export declare const codecSupportsMedia: (codec: Codec) => MediaSupport;
|
|
7
|
-
export declare const codecSupportsCrf: (codec: Codec) => boolean
|
|
7
|
+
export declare const codecSupportsCrf: (codec: Codec) => boolean;
|
|
8
|
+
export declare const codecSupportsVideoBitrate: (codec: Codec) => boolean;
|
|
8
9
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codecSupportsCrf = exports.codecSupportsMedia = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.codecSupportsVideoBitrate = exports.codecSupportsCrf = exports.codecSupportsMedia = void 0;
|
|
4
|
+
const crf_1 = require("./crf");
|
|
5
5
|
const support = {
|
|
6
6
|
'h264-mkv': {
|
|
7
7
|
audio: true,
|
|
@@ -48,9 +48,24 @@ const codecSupportsMedia = (codec) => {
|
|
|
48
48
|
return support[codec];
|
|
49
49
|
};
|
|
50
50
|
exports.codecSupportsMedia = codecSupportsMedia;
|
|
51
|
+
const codecSupportsVideoBitrateMap = {
|
|
52
|
+
'h264-mkv': true,
|
|
53
|
+
aac: false,
|
|
54
|
+
gif: false,
|
|
55
|
+
h264: true,
|
|
56
|
+
h265: true,
|
|
57
|
+
mp3: false,
|
|
58
|
+
prores: false,
|
|
59
|
+
vp8: true,
|
|
60
|
+
vp9: true,
|
|
61
|
+
wav: false,
|
|
62
|
+
};
|
|
51
63
|
const codecSupportsCrf = (codec) => {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
return supportsCrf;
|
|
64
|
+
const range = (0, crf_1.getValidCrfRanges)(codec);
|
|
65
|
+
return range[0] !== range[1];
|
|
55
66
|
};
|
|
56
67
|
exports.codecSupportsCrf = codecSupportsCrf;
|
|
68
|
+
const codecSupportsVideoBitrate = (codec) => {
|
|
69
|
+
return codecSupportsVideoBitrateMap[codec];
|
|
70
|
+
};
|
|
71
|
+
exports.codecSupportsVideoBitrate = codecSupportsVideoBitrate;
|
package/dist/codec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const validCodecs: readonly ["h264", "h265", "vp8", "vp9", "mp3", "aac", "wav", "prores", "h264-mkv", "gif"];
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type Codec = typeof validCodecs[number];
|
|
3
|
+
export type CodecOrUndefined = Codec | undefined;
|
|
4
4
|
export declare const DEFAULT_CODEC: Codec;
|
package/dist/codec.js
CHANGED
|
File without changes
|
package/dist/combine-videos.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { AudioCodec } from './audio-codec';
|
|
1
2
|
import type { Codec } from './codec';
|
|
2
|
-
|
|
3
|
+
type Options = {
|
|
3
4
|
files: string[];
|
|
4
5
|
filelistDir: string;
|
|
5
6
|
output: string;
|
|
@@ -8,4 +9,7 @@ export declare const combineVideos: ({ files, filelistDir, output, onProgress, n
|
|
|
8
9
|
codec: Codec;
|
|
9
10
|
fps: number;
|
|
10
11
|
numberOfGifLoops: number | null;
|
|
11
|
-
|
|
12
|
+
audioCodec: AudioCodec | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const combineVideos: (options: Options) => Promise<void>;
|
|
15
|
+
export {};
|
package/dist/combine-videos.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Combine multiple video chunks, useful for decentralized rendering
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
4
|
exports.combineVideos = void 0;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const audio_codec_1 = require("./audio-codec");
|
|
8
|
+
const call_ffmpeg_1 = require("./call-ffmpeg");
|
|
12
9
|
const is_audio_codec_1 = require("./is-audio-codec");
|
|
13
10
|
const parse_ffmpeg_progress_1 = require("./parse-ffmpeg-progress");
|
|
14
11
|
const truthy_1 = require("./truthy");
|
|
15
|
-
const combineVideos = async (
|
|
12
|
+
const combineVideos = async (options) => {
|
|
16
13
|
var _a;
|
|
14
|
+
const { files, filelistDir, output, onProgress, numberOfFrames, codec, fps, numberOfGifLoops, audioCodec, } = options;
|
|
17
15
|
const fileList = files.map((p) => `file '${p}'`).join('\n');
|
|
18
|
-
const fileListTxt = (0,
|
|
19
|
-
(0,
|
|
16
|
+
const fileListTxt = (0, node_path_1.join)(filelistDir, 'files.txt');
|
|
17
|
+
(0, node_fs_1.writeFileSync)(fileListTxt, fileList);
|
|
18
|
+
const resolvedAudioCodec = audioCodec !== null && audioCodec !== void 0 ? audioCodec : (0, audio_codec_1.getDefaultAudioCodec)({ codec, preferLossless: false });
|
|
20
19
|
try {
|
|
21
|
-
const task = (0,
|
|
20
|
+
const task = (0, call_ffmpeg_1.callFf)('ffmpeg', [
|
|
22
21
|
(0, is_audio_codec_1.isAudioCodec)(codec) ? null : '-r',
|
|
23
22
|
(0, is_audio_codec_1.isAudioCodec)(codec) ? null : String(fps),
|
|
24
23
|
'-f',
|
|
@@ -35,20 +34,21 @@ const combineVideos = async ({ files, filelistDir, output, onProgress, numberOfF
|
|
|
35
34
|
: '-1',
|
|
36
35
|
(0, is_audio_codec_1.isAudioCodec)(codec) ? null : '-c:v',
|
|
37
36
|
(0, is_audio_codec_1.isAudioCodec)(codec) ? null : codec === 'gif' ? 'gif' : 'copy',
|
|
38
|
-
'-c:a',
|
|
39
|
-
|
|
37
|
+
resolvedAudioCodec ? '-c:a' : null,
|
|
38
|
+
resolvedAudioCodec
|
|
39
|
+
? (0, audio_codec_1.mapAudioCodecToFfmpegAudioCodecName)(resolvedAudioCodec)
|
|
40
|
+
: null,
|
|
40
41
|
// Set max bitrate up to 512kbps, will choose lower if that's too much
|
|
41
42
|
'-b:a',
|
|
42
43
|
'512K',
|
|
43
44
|
codec === 'h264' ? '-movflags' : null,
|
|
44
45
|
codec === 'h264' ? 'faststart' : null,
|
|
45
|
-
'-shortest',
|
|
46
46
|
'-y',
|
|
47
47
|
output,
|
|
48
48
|
].filter(truthy_1.truthy));
|
|
49
49
|
(_a = task.stderr) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
50
50
|
if (onProgress) {
|
|
51
|
-
const parsed = (0, parse_ffmpeg_progress_1.parseFfmpegProgress)(data.toString());
|
|
51
|
+
const parsed = (0, parse_ffmpeg_progress_1.parseFfmpegProgress)(data.toString('utf8'));
|
|
52
52
|
if (parsed !== undefined) {
|
|
53
53
|
onProgress(parsed);
|
|
54
54
|
}
|
|
@@ -56,10 +56,10 @@ const combineVideos = async ({ files, filelistDir, output, onProgress, numberOfF
|
|
|
56
56
|
});
|
|
57
57
|
await task;
|
|
58
58
|
onProgress(numberOfFrames);
|
|
59
|
-
(
|
|
59
|
+
(0, node_fs_1.rmSync)(filelistDir, { recursive: true });
|
|
60
60
|
}
|
|
61
61
|
catch (err) {
|
|
62
|
-
(
|
|
62
|
+
(0, node_fs_1.rmSync)(filelistDir, { recursive: true });
|
|
63
63
|
throw err;
|
|
64
64
|
}
|
|
65
65
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DownloadMap } from '../assets/download-map';
|
|
2
|
+
import type { Compositor } from './compositor';
|
|
3
|
+
import type { CompositorCommand, CompositorCommandSerialized, CompositorImageFormat, Layer } from './payloads';
|
|
4
|
+
type CompositorInput = {
|
|
5
|
+
height: number;
|
|
6
|
+
width: number;
|
|
7
|
+
layers: Layer[];
|
|
8
|
+
imageFormat: CompositorImageFormat;
|
|
9
|
+
};
|
|
10
|
+
type ComposeInput = CompositorInput & {
|
|
11
|
+
output: string;
|
|
12
|
+
compositor: Compositor;
|
|
13
|
+
};
|
|
14
|
+
export declare const serializeCommand: <Type extends keyof CompositorCommand>(command: Type, params: CompositorCommand[Type]) => CompositorCommandSerialized<Type>;
|
|
15
|
+
export declare const composeWithoutCache: ({ height, width, layers, output, imageFormat, compositor, }: CompositorInput & {
|
|
16
|
+
output: string;
|
|
17
|
+
compositor: Compositor;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
export declare const compose: ({ height, width, layers, output, downloadMap, imageFormat, compositor, }: CompositorInput & {
|
|
20
|
+
output: string;
|
|
21
|
+
compositor: Compositor;
|
|
22
|
+
} & {
|
|
23
|
+
downloadMap: DownloadMap;
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
export declare const callCompositor: (payload: string) => Promise<void>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.callCompositor = exports.compose = exports.composeWithoutCache = exports.serializeCommand = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const promises_1 = require("node:fs/promises");
|
|
8
|
+
const call_ffmpeg_1 = require("../call-ffmpeg");
|
|
9
|
+
const get_executable_path_1 = require("./get-executable-path");
|
|
10
|
+
const make_nonce_1 = require("./make-nonce");
|
|
11
|
+
const getCompositorHash = ({ ...input }) => {
|
|
12
|
+
return (0, node_crypto_1.createHash)('sha256').update(JSON.stringify(input)).digest('base64');
|
|
13
|
+
};
|
|
14
|
+
const serializeCommand = (command, params) => {
|
|
15
|
+
return {
|
|
16
|
+
nonce: (0, make_nonce_1.makeNonce)(),
|
|
17
|
+
payload: {
|
|
18
|
+
type: command,
|
|
19
|
+
params,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.serializeCommand = serializeCommand;
|
|
24
|
+
const composeWithoutCache = async ({ height, width, layers, output, imageFormat, compositor, }) => {
|
|
25
|
+
await compositor.executeCommand('Compose', {
|
|
26
|
+
height,
|
|
27
|
+
width,
|
|
28
|
+
layers,
|
|
29
|
+
output,
|
|
30
|
+
output_format: imageFormat,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.composeWithoutCache = composeWithoutCache;
|
|
34
|
+
const compose = async ({ height, width, layers, output, downloadMap, imageFormat, compositor, }) => {
|
|
35
|
+
const hash = getCompositorHash({ height, width, layers, imageFormat });
|
|
36
|
+
if (downloadMap.compositorCache[hash]) {
|
|
37
|
+
await (0, promises_1.copyFile)(downloadMap.compositorCache[hash], output);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
await (0, exports.composeWithoutCache)({
|
|
41
|
+
compositor,
|
|
42
|
+
height,
|
|
43
|
+
imageFormat,
|
|
44
|
+
layers,
|
|
45
|
+
output,
|
|
46
|
+
width,
|
|
47
|
+
});
|
|
48
|
+
downloadMap.compositorCache[hash] = output;
|
|
49
|
+
};
|
|
50
|
+
exports.compose = compose;
|
|
51
|
+
const callCompositor = (payload) => {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const execPath = (0, get_executable_path_1.getExecutablePath)('compositor');
|
|
54
|
+
if (!process.env.READ_ONLY_FS) {
|
|
55
|
+
(0, node_fs_1.chmodSync)(execPath, 0o755);
|
|
56
|
+
}
|
|
57
|
+
const child = (0, node_child_process_1.spawn)(execPath, [payload], (0, call_ffmpeg_1.dynamicLibraryPathOptions)());
|
|
58
|
+
const stderrChunks = [];
|
|
59
|
+
child.stderr.on('data', (d) => stderrChunks.push(d));
|
|
60
|
+
child.on('close', (code) => {
|
|
61
|
+
if (code === 0) {
|
|
62
|
+
resolve();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const message = Buffer.concat(stderrChunks).toString('utf-8');
|
|
66
|
+
try {
|
|
67
|
+
// Try to see if the error is a JSON
|
|
68
|
+
const parsed = JSON.parse(message);
|
|
69
|
+
const msg = `Compositor error: ${parsed.error}`;
|
|
70
|
+
const err = new Error(`${msg}\n${parsed.backtrace}`);
|
|
71
|
+
reject(err);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
reject(new Error(`Compositor panicked: ${message}`));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
child.stdin.write(payload);
|
|
79
|
+
child.stdin.end();
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
exports.callCompositor = callCompositor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { CompositorCommand } from './payloads';
|
|
3
|
+
export type Compositor = {
|
|
4
|
+
finishCommands: () => void;
|
|
5
|
+
executeCommand: <T extends keyof CompositorCommand>(type: T, payload: CompositorCommand[T]) => Promise<Buffer>;
|
|
6
|
+
waitForDone: () => Promise<void>;
|
|
7
|
+
pid: number | null;
|
|
8
|
+
};
|
|
9
|
+
export declare const getIdealMaximumFrameCacheItems: () => number;
|
|
10
|
+
export declare const startLongRunningCompositor: (maximumFrameCacheItems: number, verbose: boolean, indent: boolean) => Compositor;
|
|
11
|
+
export declare const startCompositor: <T extends keyof CompositorCommand>(type: T, payload: CompositorCommand[T], indent: boolean) => Compositor;
|