配置文件
要配置 Remotion,请在 Remotion 项目的根目录中创建一个 remotion.config.ts
文件。
这些选项将应用于 CLI 命令,如 npx remotion studio
和 npx remotion render
。
在使用 SSR API 时,配置文件不起作用。
您可以在这里控制 Remotion 的几种行为。
remotion.config.tsts
import {Config } from '@remotion/cli/config';Config .setConcurrency (8);Config .setPixelFormat ('yuv444p');Config .setCodec ('h265');
remotion.config.tsts
import {Config } from '@remotion/cli/config';Config .setConcurrency (8);Config .setPixelFormat ('yuv444p');Config .setCodec ('h265');
overrideWebpackConfig()v1.1.0
允许您插入自定义的 Webpack 配置。查看有关自定义 Webpack 配置的页面 以获取更多信息。
remotion.config.tsts
Config .overrideWebpackConfig ((currentConfiguration ) => {// Return a new Webpack configurationreturn {...currentConfiguration ,// new configuration};});
remotion.config.tsts
Config .overrideWebpackConfig ((currentConfiguration ) => {// Return a new Webpack configurationreturn {...currentConfiguration ,// new configuration};});
setCachingEnabled()v2.0.0
启用或禁用 Webpack 缓存。默认值为 true
,这将使第一次运行的 Webpack 步骤稍慢,但会极大地加快后续运行的速度。
remotion.config.tsts
Config .setCachingEnabled (false);
remotion.config.tsts
Config .setCachingEnabled (false);
命令行标志 --bundle-cache
将覆盖此选项。
setStudioPort()v4.0.61
设置 Studio 的 HTTP 端口。
remotion.config.tsts
Config .setStudioPort (3003);
remotion.config.tsts
Config .setStudioPort (3003);
命令行标志 --port
将覆盖此选项。
setRendererPort()v4.0.61
设置用于托管 Webpack bundle 的端口。
remotion.config.tsts
Config .setStudioPort (3004);
remotion.config.tsts
Config .setStudioPort (3004);
命令行标志 --port
将覆盖此选项。
setPublicDir()v3.2.13
Define the location of thepublic/ directory
. If not defined, Remotion will assume the location is the `public` folder in your Remotion root.
remotion.config.tsts
Config .setPublicDir ('./custom-public-dir');
remotion.config.tsts
Config .setPublicDir ('./custom-public-dir');
- 命令行标志
--public-dir
将优先于此选项。
setEntryPoint()v3.2.40
设置 Remotion 入口点,您不必为 CLI 命令指定它。
remotion.config.tsts
Config .setEntryPoint ('./src/index.ts');
remotion.config.tsts
Config .setEntryPoint ('./src/index.ts');
如果您将入口点作为 CLI 参数传递,它将优先。
setLevel()v2.0.1
增加或减少 CLI 中的日志消息数量。 可接受的值:
error
: 除错误消息外静默。warn
: 仅显示错误和警告。info
(默认): 默认输出 - 除了错误和警告外,还会打印进度和输出位置。verbose
: 以上所有内容,加上浏览器日志和其他调试信息。
remotion.config.tsts
Config .setLevel ('verbose');
remotion.config.tsts
Config .setLevel ('verbose');
- 命令行标志
--log
将优先于此选项。
setMaxTimelineTracks()v2.1.10
设置 Studio 中时间轴中最多显示的轨道数。这不会影响您的视频,只会影响预览时显示的轨道数量。默认 15
。
remotion.config.tsts
Config .setMaxTimelineTracks (20);
remotion.config.tsts
Config .setMaxTimelineTracks (20);
setKeyboardShortcutsEnabled()v3.2.11
Studio 是否应对键盘快捷键做出反应。默认 true
。
remotion.config.tsts
Config .setKeyboardShortcutsEnabled (false);
remotion.config.tsts
Config .setKeyboardShortcutsEnabled (false);
- 命令行标志
--disable-keyboard-shortcuts
将优先于此选项。
setWebpackPollingInMilliseconds()v3.3.11
启用 Webpack 轮询,而不是文件系统事件监听器进行热重载。 如果您在虚拟机内部或拥有远程文件系统,则这很有用。
remotion.config.tsts
Config .setWebpackPollingInMilliseconds (1000);
remotion.config.tsts
Config .setWebpackPollingInMilliseconds (1000);
命令行标志 --webpack-poll
将优先于此选项。
setNumberOfSharedAudioTags()v3.3.2
Studio 中应该挂载多少个共享音频标签。共享音频标签可以帮助防止由于浏览器的音频自动播放策略而导致的播放问题。查看此文章,该文章涵盖了相同的选项,但针对播放器。默认值为 0
,表示不绕过任何自动播放策略。
remotion.config.tsts
Config .setNumberOfSharedAudioTags (5);
remotion.config.tsts
Config .setNumberOfSharedAudioTags (5);
setShouldOpenBrowser()v3.3.19
Remotion 是否应在启动 Studio 时打开浏览器。默认值为 true
。
remotion.config.tsts
Config .setShouldOpenBrowser (false);
remotion.config.tsts
Config .setShouldOpenBrowser (false);
setBrowserExecutable()v1.5.0
设置自定义 Chrome 或 Chromium 可执行文件路径。默认情况下,Remotion 将尝试在系统上找到现有版本的 Chrome,如果找不到,它将下载一个。如果您没有在标准位置安装 Chrome,并且希望防止下载额外的浏览器或需要支持 H264 编解码器,则此标志很有用。
remotion.config.tsts
Config .setBrowserExecutable ('/usr/bin/google-chrome-stable');
remotion.config.tsts
Config .setBrowserExecutable ('/usr/bin/google-chrome-stable');
命令行标志 --browser-executable
将优先于此选项。
setDelayRenderTimeoutInMilliseconds()v2.6.3
先前命名为 "setTimeoutInMilliseconds"
定义单个帧在解决所有 delayRender()
调用之前可能需要多长时间超时。默认值:30000
remotion.config.tsts
Config .setDelayRenderTimeoutInMilliseconds (60000);
remotion.config.tsts
Config .setDelayRenderTimeoutInMilliseconds (60000);
命令行标志 --timeout
将优先于此选项。
setChromiumDisableWebSecurity()v2.6.5
这将主要禁用渲染期间的 CORS 和其他安全功能。
remotion.config.tstsx
Config .setChromiumDisableWebSecurity (true);
remotion.config.tstsx
Config .setChromiumDisableWebSecurity (true);
命令行标志 --disable-web-security
将优先于此选项。
setChromiumIgnoreCertificateErrors()v2.6.5
导致无效的 SSL 证书(如自签名证书)在渲染期间被忽略。
remotion.config.tstsx
Config .setChromiumIgnoreCertificateErrors (true);
remotion.config.tstsx
Config .setChromiumIgnoreCertificateErrors (true);
命令行标志 --ignore-certificate-errors
将优先于此选项。
setChromiumHeadlessMode()v2.6.5
If disabled, the render will open an actual Chrome window where you can see the render happen. The default is headless mode.remotion.config.tstsx
Config .setChromiumHeadlessMode (false);
remotion.config.tstsx
Config .setChromiumHeadlessMode (false);
setChromiumMultiProcessOnLinux()v4.0.42
Removes the--single-process
flag that gets passed to Chromium on Linux by default. This will make the render faster because multiple processes can be used, but may cause issues with some Linux distributions or if window server libraries are missing.Default:
false
until v4.0.136, then true
from v4.0.137 on because newer Chrome versions don't allow rendering with the --single-process
flag. This flag will be removed in Remotion v5.0.
remotion.config.tstsx
Config .setChromiumMultiProcessOnLinux (true);
remotion.config.tstsx
Config .setChromiumMultiProcessOnLinux (true);
命令行标志 --enable-multiprocess-on-linux
将优先于此选项。
setChromiumOpenGlRenderer
Changelog
- From Remotion v2.6.7 until v3.0.7, the default for Remotion Lambda was
swiftshader
, but from v3.0.8 the default isswangle
(Swiftshader on Angle) since Chrome 101 added support for it. - From Remotion v2.4.3 until v2.6.6, the default was
angle
, however it turns out to have a small memory leak that could crash long Remotion renders.
Select the OpenGL renderer backend for Chromium.
Accepted values:
"angle"
"egl"
"swiftshader"
"swangle"
"vulkan"
(from Remotion v4.0.41)"angle-egl"
(from Remotion v4.0.51)
The default is null
, letting Chrome decide, except on Lambda where the default is "swangle"
remotion.config.tstsx
Config .setChromiumOpenGlRenderer ('angle');
remotion.config.tstsx
Config .setChromiumOpenGlRenderer ('angle');
命令行标志 --gl
将优先于此选项。
setConcurrency()
设置有多少 Puppeteer 实例将并行工作以渲染您的视频。
默认值:null
,表示您 CPU 上可用的一半线程。
remotion.config.tsts
Config .setConcurrency (8);
remotion.config.tsts
Config .setConcurrency (8);
命令行标志 --concurrency
将优先于此选项。
尝试将并发设置为 os.cpus().length
,以利用 CPU 上所有可用的线程进行更快的渲染。缺点是您系统的其他部分可能会变慢。
setVideoImageFormat()v4.0.0
确定以哪种图像格式呈现帧。可以是:
jpeg
- 最快的选项(默认)png
- 较慢,但支持透明度none
- 不呈现图像,只计算音频信息
remotion.config.tsts
Config .setVideoImageFormat ('png');
remotion.config.tsts
Config .setVideoImageFormat ('png');
setStillImageFormat()v4.0.0
确定以哪种图像格式呈现帧。可以是:
png
(默认)jpeg
pdf
webp
remotion.config.tsts
Config .setStillImageFormat ('pdf');
remotion.config.tsts
Config .setStillImageFormat ('pdf');
setImageFormat()v1.4.0
在 v4.0 中移除
在 v4.0 中被 setVideoImageFormat()
和 setStillImageFormat()
替换
确定以哪种图像格式呈现帧。可以是:
jpeg
- 最快的选项(从 v1.1 开始默认)png
- 较慢,但支持透明度none
- 不呈现图像,只计算音频信息(从 v2.0 开始可用)
remotion.config.tsts
import {Config} from '@remotion/cli/config';// ---cut---Config.setImageFormat('png');
remotion.config.tsts
import {Config} from '@remotion/cli/config';// ---cut---Config.setImageFormat('png');
命令行标志 --image-format
将覆盖此选项。
setScale()v2.6.7
按您传入的因子缩放输出帧。 例如,一个 1280x720px 的帧将以 1.5
的缩放因子变为 1920x1080px 的帧。像字体和 HTML 标记这样的矢量元素将以更多细节呈现。默认值:1
。
remotion.config.tsts
Config .setScale (2);
remotion.config.tsts
Config .setScale (2);
命令行标志 --scale
将覆盖此选项。
setMuted()v3.2.1
禁用音频输出。默认为 false
。
remotion.config.tsts
Config .setMuted (true);
remotion.config.tsts
Config .setMuted (true);
--muted
命令行标志将优先于此选项。
setEnforceAudioTrack()v3.2.1
如果没有其他音轨,则渲染一个静音音轨。默认为false
。
remotion.config.tsts
Config .setEnforceAudioTrack (true);
remotion.config.tsts
Config .setEnforceAudioTrack (true);
--enforce-audio-track
命令行标志将优先于此选项。
setForSeamlessAacConcatenation()v4.0.123
If enabled, the audio is trimmed to the nearest AAC frame, which is required for seamless concatenation of AAC files. This is a requirement if you later want to combine multiple video snippets seamlessly.This option is used internally. There is currently no documentation yet for to concatenate the audio chunks.
remotion.config.tsts
Config .setForSeamlessAacConcatenation (true);
remotion.config.tsts
Config .setForSeamlessAacConcatenation (true);
--for-seamless-aac-concatenation
命令行标志将优先于此选项。
setFrameRange()v2.0.0
传递一个数字以渲染静止帧,或传递一个元组以渲染视频的子集。帧序列从零开始。
remotion.config.tsts
Config .setFrameRange (90); // 仅渲染第91帧
remotion.config.tsts
Config .setFrameRange (90); // 仅渲染第91帧
或者
remotion.config.tsts
Config .setFrameRange ([0, 20]); // 仅渲染包含前21帧的视频
remotion.config.tsts
Config .setFrameRange ([0, 20]); // 仅渲染包含前21帧的视频
setJpegQuality()
每帧的JPEG质量。必须是介于0和100之间的数字。如果渲染PNG帧,则不起作用。默认值:80。
remotion.config.tsts
Config .setJpegQuality (90);
remotion.config.tsts
Config .setJpegQuality (90);
--jpeg-quality
命令行标志将优先于此选项。
setQuality()
在 v4.0.0
中更名为 setJpegQuality
。
setDotEnvLocation()
设置一个自定义位置用于 .env
文件。您可以指定一个绝对路径或一个相对路径,在这种情况下,它将根据当前工作目录进行解析。
remotion.config.tsts
Config .setDotEnvLocation ('.my-env');
remotion.config.tsts
Config .setDotEnvLocation ('.my-env');
命令行标志 --env-file
将优先于此选项。
setEveryNthFrame()
此选项仅在渲染 GIF 时才能设置。它确定渲染多少帧,而其他帧则被跳过以降低 GIF 的帧速。
例如,如果 fps
为 30,而 everyNthFrame
为 2,则 GIF 的帧速为 15
。
remotion.config.tsts
Config .setEveryNthFrame (2);
remotion.config.tsts
Config .setEveryNthFrame (2);
命令行标志 --every-nth-frame
将优先于此选项。
setNumberOfGifLoops()
Allows you to set the number of loops as follows:null
(or omitting in the CLI) plays the GIF indefinitely.0
disables looping1
loops the GIF once (plays twice in total)2
loops the GIF twice (plays three times in total) and so on.
remotion.config.tsts
Config .setNumberOfGifLoops (2);
remotion.config.tsts
Config .setNumberOfGifLoops (2);
命令行标志 --number-of-gif-loops
将优先于此选项。
setOutputLocation()v3.1.6
设置视频或静态文件的输出位置,相对于当前工作目录。默认为 out/{composition}.{container}
。例如,out/HelloWorld.mp4
。
remotion.config.tsts
Config .setOutputLocation ('out/video.mp4');
remotion.config.tsts
Config .setOutputLocation ('out/video.mp4');
如果您向渲染命令传递另一个参数,它将优先:npx remotion render src/index.ts HelloWorld out/video.mp4
。
setOverwriteOutput()
将此设置为 false
可防止在 Remotion 输出已存在时覆盖它们。
remotion.config.tsts
Config .setOverwriteOutput (false);
remotion.config.tsts
Config .setOverwriteOutput (false);
html
:::info在1.x版本中,默认行为是相反的 - Remotion 默认情况下不会覆盖。:::
html
:::info在1.x版本中,默认行为是相反的 - Remotion 默认情况下不会覆盖。:::
setPixelFormat()
控制FFmpeg中的像素格式。在此处阅读更多信息。 可接受的值:yuv420p
、yuv422p
、yuv444p
、yuv420p10le
、yuv422p10le
、yuv444p10le
。自v1.4起,还支持yuva420p
用于透明的WebM视频。自v2.1.7起,还支持yuva444p10le
用于透明的ProRes视频。
默认值:yuv420p
remotion.config.tsts
Config .setPixelFormat ('yuv420p');
remotion.config.tsts
Config .setPixelFormat ('yuv420p');
命令行标志 --pixel-format
将优先于此选项。
setCodec()v1.4.0
选择支持的编解码器之一:h264
(默认), h265
, vp8
, vp9
。
h264
是您熟知的经典MP4文件。h265
是H264的继任者,文件大小更小。也称为HEVC。浏览器兼容性较差。vp8
是WebM的编解码器。vp9
是WebM的下一代编解码器。文件大小更小,压缩时间更长。prores
是一种常见的编解码器,如果您想将输出导入另一个视频编辑程序 (从v2.1.6起可用)mp3
将仅导出音频为MP3文件 (从v2.0起可用)wav
将仅导出音频为WAV文件 (从v2.0起可用)aac
将仅导出音频为AAC文件 (从v2.0起可用)
remotion.config.tsts
Config .setCodec ('h265');
remotion.config.tsts
Config .setCodec ('h265');
命令行标志 --codec
将优先于此选项。
另请参阅:编码指南
setAudioCodec()
remotion.config.tsts
Config .setAudioCodec ('pcm-16');
remotion.config.tsts
Config .setAudioCodec ('pcm-16');
选择音频的编码方式。
- 默认取决于所选的
codec
。 - 如果需要未压缩的音频,请选择
pcm-16
。 - 并非所有视频容器都支持所有音频编解码器。
- 如果
codec
选项还指定了音频编解码器,则此选项优先。
[命令行标志](/docs/cli/render#--audio-codec) `--audio-codec` 将优先于此选项。请参阅[编码指南](/docs/encoding)以查看默认值和支持的组合。## setProResProfile()<AvailableFrom v="2.1.6" />设置 ProRes 档案。仅当编解码器设置为 `prores` 时,此选项才有效。可能的值:`4444-xq`、`4444`、`hq`、`standard`、`light`、`proxy`。请参阅[此处](https://video.stackexchange.com/a/14715)以了解可能的值。默认值:`hq````ts twoslash title="remotion.config.ts"import {Config} from '@remotion/cli/config';// ---cut---Config.setProResProfile('4444');
[命令行标志](/docs/cli/render#--audio-codec) `--audio-codec` 将优先于此选项。请参阅[编码指南](/docs/encoding)以查看默认值和支持的组合。## setProResProfile()<AvailableFrom v="2.1.6" />设置 ProRes 档案。仅当编解码器设置为 `prores` 时,此选项才有效。可能的值:`4444-xq`、`4444`、`hq`、`standard`、`light`、`proxy`。请参阅[此处](https://video.stackexchange.com/a/14715)以了解可能的值。默认值:`hq````ts twoslash title="remotion.config.ts"import {Config} from '@remotion/cli/config';// ---cut---Config.setProResProfile('4444');
命令行标志 --prores-profile
将优先于此选项。
setX264Preset()v4.2.2
设置预设档案。仅当编解码器设置为 h264
时,此选项才有效。
可能的值:superfast
、veryfast
、faster
、fast
、medium
、slow
、slower
、veryslow
、placebo
。
默认值:medium
remotion.config.tsts
Config .setX264Preset ('fast');
remotion.config.tsts
Config .setX264Preset ('fast');
命令行标志 --prores-profile
将优先于此选项。
setImageSequence()v1.4.0
如果要输出图像序列而不是视频,请将其设置为 true。
remotion.config.tsts
Config .setImageSequence (true);
remotion.config.tsts
Config .setImageSequence (true);
命令行标志 --sequence
将优先于此选项。
overrideHeight()v3.2.40
覆盖渲染视频的高度。
remotion.config.tsts
Config .overrideHeight (600);
remotion.config.tsts
Config .overrideHeight (600);
命令行标志 --height
将优先于此选项。
(查看 h264 验证?)
overrideWidth()v3.2.40
覆盖渲染视频的宽度。
remotion.config.tsts
Config .overrideWidth (900);
remotion.config.tsts
Config .overrideWidth (900);
命令行标志 --width
将优先于此选项
setOutputFormat()
在 v4.0.0 中移除
已弃用。请改用 setCodec()
和 setImageSequence()
。
要么 'mp4'
要么 'png-sequence'
。
remotion.config.tsts
import {Config} from '@remotion/cli/config';// ---cut---Config.setOutputFormat('mp4');
remotion.config.tsts
import {Config} from '@remotion/cli/config';// ---cut---Config.setOutputFormat('mp4');
命令行标志 --sequence
和 --codec
将优先于此选项。
命令行标志 --quality
将优先于此选项。
setCrf()v1.4.0
输出的“恒定速率因子”(CRF)。使用此设置告诉 FFmpeg 如何在大小和质量之间进行权衡。
CRF 范围,按编解码器:
h264
crf 范围为 1-51,其中 crf 18 为 默认。h265
crf 范围为 0-51,其中 crf 23 为 默认。vp8
crf 范围为 4-63,其中 crf 9 为 默认。vp9
crf 范围为 0-63,其中 crf 28 为 默认。
最低值是无损的,最高值是可能的最差质量。较高的值会降低文件大小,但会牺牲质量。
范围是指数级的,因此将 CRF 值增加 +6 大约会使比特率 / 文件大小减少一半,而 -6 则会使比特率大约增加一倍。
选择提供可接受质量的最高 CRF 值。如果输出看起来不错,则尝试更高的值。如果看起来不好,请选择较低的值。
remotion.config.tsts
Config .setCrf (16);
remotion.config.tsts
Config .setCrf (16);
命令行标志 --crf
将优先于此选项。
setVideoBitrate()
v3.2.32
Specify the target bitrate for the generated video. The syntax for FFmpeg's-b:v
parameter should be used. FFmpeg may encode the video in a way that will not result in the exact video bitrate specified. Example values: 512K
for 512 kbps, 1M
for 1 Mbps.
remotion.config.tsts
Config .setVideoBitrate ('1M');
remotion.config.tsts
Config .setVideoBitrate ('1M');
markdown
[命令行标志](/docs/cli/render#--video-bitrate) `--video-bitrate` 将优先于此选项。## `setEncodingBufferSize()`<AvailableFrom v="4.0.78" /><Options id="buffer-size" />```ts twoslash title="remotion.config.ts"import {Config} from '@remotion/cli/config';// ---cut---Config.setEncodingBufferSize('10000k');
markdown
[命令行标志](/docs/cli/render#--video-bitrate) `--video-bitrate` 将优先于此选项。## `setEncodingBufferSize()`<AvailableFrom v="4.0.78" /><Options id="buffer-size" />```ts twoslash title="remotion.config.ts"import {Config} from '@remotion/cli/config';// ---cut---Config.setEncodingBufferSize('10000k');
命令行标志 --buffer-size
将优先于此选项。
setEncodingMaxRate()
v4.0.78
The value for the -maxrate
flag of FFmpeg. Should be used in conjunction with the encoding buffer size flag.
remotion.config.tsts
Config .setEncodingMaxRate ('5000k');
remotion.config.tsts
Config .setEncodingMaxRate ('5000k');
命令行标志 --max-rate
将优先于此选项。
setAudioBitrate()
v3.2.32
Specify the target bitrate for the generated video. The syntax for FFmpeg's -b:a
parameter should be used. FFmpeg may encode the video in a way that will not result in the exact audio bitrate specified. Example values: 512K
for 512 kbps, 1M
for 1 Mbps. Default: 320k
remotion.config.tsts
Config .setAudioBitrate ('128K');
remotion.config.tsts
Config .setAudioBitrate ('128K');
命令行标志 --audio-bitrate
将优先于此选项。
setEnableFolderExpiry()
v4.0.32
When deploying sites, enable or disable S3 Lifecycle policies which allow for renders to auto-delete after a certain time. Default is null
, which does not change any lifecycle policies of the S3 bucket. See: Lambda autodelete.
remotion.config.tsts
Config .setEnableFolderExpiry (true);
remotion.config.tsts
Config .setEnableFolderExpiry (true);
setLambdaInsights()
v4.0.115
Enable Lambda Insights in AWS CloudWatch. For this to work, you may have to update your role permission.
remotion.config.tsts
Config .setLambdaInsights (true);
remotion.config.tsts
Config .setLambdaInsights (true);
setDeleteAfter()
v4.0.32
Automatically delete the render after a certain period. Accepted values are 1-day
, 3-days
, 7-days
and 30-days
.For this to work, your bucket needs to have lifecycles enabled.
remotion.config.tsts
Config .setDeleteAfter ('3-days');
remotion.config.tsts
Config .setDeleteAfter ('3-days');
setBeepOnFinish()
v4.0.84
Whether the Remotion Studio tab should beep when the render is finished.
remotion.config.tsts
Config .setBeepOnFinish (true);
remotion.config.tsts
Config .setBeepOnFinish (true);
[命令行标志](/docs/cli/studio#--beep-on-finish) `--beep-on-finish` 将优先于此选项。## `setBufferStateDelayInMilliseconds()`<AvailableFrom v="4.0.111" />设置播放器进入缓冲状态后多少毫秒后,工作室中的播放器将显示缓冲UI。默认值 `300`。```ts twoslash title="remotion.config.ts"import {Config} from '@remotion/cli/config';// ---cut---Config.setBufferStateDelayInMilliseconds(0);
[命令行标志](/docs/cli/studio#--beep-on-finish) `--beep-on-finish` 将优先于此选项。## `setBufferStateDelayInMilliseconds()`<AvailableFrom v="4.0.111" />设置播放器进入缓冲状态后多少毫秒后,工作室中的播放器将显示缓冲UI。默认值 `300`。```ts twoslash title="remotion.config.ts"import {Config} from '@remotion/cli/config';// ---cut---Config.setBufferStateDelayInMilliseconds(0);
setBinariesDirectory?
v4.0.120
The directory where the platform-specific binaries and libraries that Remotion needs are located. Those include an ffmpeg
and ffprobe
binary, a Rust binary for various tasks, and various shared libraries. If the value is set to null
, which is the default, then the path of a platform-specific package located at node_modules/@remotion/compositor-*
is selected.This option is useful in environments where Remotion is not officially supported to run like bundled serverless functions or Electron.
remotion.config.tsts
Config .setBinariesDirectory ('/path/to/custom/directory');
remotion.config.tsts
Config .setBinariesDirectory ('/path/to/custom/directory');
setPreferLosslessAudio?
v4.0.123
Uses a lossless audio codec, if one is available for the codec. If you setaudioCodec
, it takes priority over preferLossless
.
remotion.config.tsts
Config .setPreferLosslessAudio (true);
remotion.config.tsts
Config .setPreferLosslessAudio (true);
overrideFfmpegCommand()v3.2.22
修改 Remotion 在后台使用的 FFmpeg 命令。它以 reducer 风格工作,这意味着您传递一个函数,该函数以命令作为参数并返回一个新命令。
remotion.config.tstsx
Config .overrideFfmpegCommand (({args }) => {// Define the custom FFmpeg options as an array of stringsconstcustomFfmpegOptions = ['-profile:v','main','-video_track_timescale','90000','-color_primaries','bt709','-color_trc','bt709','-strict','experimental',];// The customFfmpegOptions are inserted before the last element to ensure// they appear before the ffmpeg's output pathargs .splice (args .length - 1, 0, ...customFfmpegOptions );returnargs ;});
remotion.config.tstsx
Config .overrideFfmpegCommand (({args }) => {// Define the custom FFmpeg options as an array of stringsconstcustomFfmpegOptions = ['-profile:v','main','-video_track_timescale','90000','-color_primaries','bt709','-color_trc','bt709','-strict','experimental',];// The customFfmpegOptions are inserted before the last element to ensure// they appear before the ffmpeg's output pathargs .splice (args .length - 1, 0, ...customFfmpegOptions );returnargs ;});
您传递的函数必须接受一个对象作为唯一参数,该对象包含以下属性:
type
:为"stitcher"
或"pre-stitcher"
。如果有足够的内存和 CPU 可用,Remotion 可能会使用并行渲染和编码,这意味着在渲染所有帧之前会生成一个预缝合器进程。您可以通过在渲染命令中添加--log=verbose
来确定是否启用了并行编码。args
:作为 FFmpeg 命令参数传递的字符串数组。
您的函数必须返回修改后的字符串数组。
不建议使用此功能。在使用之前,我们希望让您了解一些注意事项:
- 渲染命令可能会随着任何新的 Remotion 版本更改,即使是补丁升级也可能会破坏您对此功能的使用。
- 根据所选的编解码器、可用的 CPU 和 RAM,Remotion 可能会或可能不会使用 "并行编码",这将导致执行多个 FFmpeg 命令。您的函数必须能够处理多次调用。
- Remotion 提供的 FFmpeg 二进制文件仅支持 FFmpeg 命令的一小部分子集,因此不会应用每个传递的选项。
- 使用 Remotion Lambda 时不支持此功能。
在使用此方法之前,请在 [Discord](https://remotion.dev/discord) 上联系 Remotion 团队,询问我们是否愿意以一种干净的方式实现您需要的功能 - 我们经常根据用户的反馈快速实现新功能。## ~~setFfmpegExecutable()~~_在 v4.0 中移除_允许您使用自定义的 FFmpeg 二进制文件。必须是绝对路径。默认情况下,此值为 null,将使用 `PATH` 中的 FFmpeg。```ts title="remotion.config.ts"import {Config} from '@remotion/cli/config';// ---cut---Config.setFfmpegExecutable('/path/to/custom/ffmpeg');
在使用此方法之前,请在 [Discord](https://remotion.dev/discord) 上联系 Remotion 团队,询问我们是否愿意以一种干净的方式实现您需要的功能 - 我们经常根据用户的反馈快速实现新功能。## ~~setFfmpegExecutable()~~_在 v4.0 中移除_允许您使用自定义的 FFmpeg 二进制文件。必须是绝对路径。默认情况下,此值为 null,将使用 `PATH` 中的 FFmpeg。```ts title="remotion.config.ts"import {Config} from '@remotion/cli/config';// ---cut---Config.setFfmpegExecutable('/path/to/custom/ffmpeg');
命令行标志 --ffmpeg-executable
将覆盖此选项。
setFfprobeExecutable()
在 v4.0 中移除
允许您使用自定义的 ffprobe
二进制文件。必须是绝对路径。默认情况下,此值为 null,将使用 PATH
中的 ffprobe
。
remotion.config.tsts
import {Config} from '@remotion/cli/config';// ---cut---Config.setFfprobeExecutable('/path/to/custom/ffprobe');
remotion.config.tsts
import {Config} from '@remotion/cli/config';// ---cut---Config.setFfprobeExecutable('/path/to/custom/ffprobe');
命令行标志 --ffprobe-executable
将覆盖此选项。
setPort()
在 v4.0.61 中弃用 - 使用 setStudioPort()
和 setRendererPort()
代替。
定义 Remotion 应该在哪个端口启动其 HTTP 服务器。
默认情况下,Remotion 将尝试找到一个空闲端口。
如果您指定了一个端口,但该端口不可用,Remotion 将抛出错误。
设置此选项将破坏 Remotion Studio 中的渲染,因为此选项同时控制两个设置:
- 启动 Remotion Studio 时,将启动一个服务器来托管它 (
setStudioPort()
)。 - 在渲染期间,还会在后台启动一个 HTTP 服务器来提供 Webpack bundle (
setRendererPort()
)。
请分别使用这些选项。
remotion.config.tsts
Config .setPort (3003);
remotion.config.tsts
Config .setPort (3003);
命令行标志 --port
将优先于此选项。如果在 npx remotion studio
上设置,它将设置 Studio 端口,否则将设置渲染器端口。
导入 ES 模块
配置文件 在 CommonJS 环境中执行。如果要导入 ES 模块以覆盖 Webpack 配置,可以将异步函数传递给 Config.overrideWebpackConfig()
:
remotion.config.tsts
import {Config } from '@remotion/cli/config';Config .overrideWebpackConfig (async (currentConfiguration ) => {const {enableSass } = await import('./src/enable-sass');returnenableSass (currentConfiguration );});
remotion.config.tsts
import {Config } from '@remotion/cli/config';Config .overrideWebpackConfig (async (currentConfiguration ) => {const {enableSass } = await import('./src/enable-sass');returnenableSass (currentConfiguration );});
旧配置文件格式
在 v3.3.39 中,引入了一种新的配置文件格式,将选项展平,以便可以更轻松地使用 TypeScript 自动完成发现。
以前,每个配置选项都是两级深度:
remotion.config.tsts
Config.Bundling.setCachingEnabled(false);
remotion.config.tsts
Config.Bundling.setCachingEnabled(false);
从 v3.3.39 开始,所有选项都可以直接从 Config
对象中访问。
remotion.config.tsts
Config .setCachingEnabled (false);
remotion.config.tsts
Config .setCachingEnabled (false);
旧方式已被弃用,但在可预见的未来仍将有效。