Skip to main content

配置文件

要配置 Remotion,请在你的 Remotion 项目的根目录中创建一个 remotion.config.ts 文件。

🌐 To configure Remotion, create a remotion.config.ts file in the root of your Remotion project.

这些选项将适用于诸如 npx remotion studionpx remotion render 的命令行命令。

🌐 These options will apply to CLI commands such as npx remotion studio and npx remotion render.

warning

使用 SSR API 时,配置文件不起作用。

你可以在这里控制 Remotion 的几种行为。

🌐 You can control several behaviors of Remotion here.

remotion.config.ts
import {Config} from '@remotion/cli/config'; Config.setConcurrency(8); Config.setPixelFormat('yuv444p'); Config.setCodec('h265');

overrideWebpackConfig()v1.1.0

允许你插入自定义的 Webpack 配置。有关自定义 Webpack 配置的更多信息,请参见此页面

🌐 Allows you to insert your custom Webpack config. See the page about custom Webpack configs for more information.

remotion.config.ts
Config.overrideWebpackConfig((currentConfiguration) => { // Return a new Webpack configuration return { ...currentConfiguration, // new configuration }; });

setCachingEnabled()v2.0.0

Enable or disable Webpack caching. This flag is enabled by default, use --bundle-cache=false to disable caching.
remotion.config.ts
Config.setCachingEnabled(false);

命令行标志 --bundle-cache 将优先于此选项。

🌐 The command line flag --bundle-cache will take precedence over this option.

setStudioPort()v4.0.61

为 Studio 设置 HTTP 端口。

🌐 Set the HTTP port for the Studio.

remotion.config.ts
Config.setStudioPort(3003);

命令行标志 --port 将优先于此选项。

🌐 The command line flag --port will take precedence over this option.

setRendererPort()v4.0.61

设置用于宿主 Webpack 包的端口。

🌐 Set the port to be used to host the Webpack bundle.

remotion.config.ts
Config.setRendererPort(3004);

命令行标志 --port 将优先于此选项。

🌐 The command line flag --port will take precedence over this option.

setPublicDir()v3.2.13

Define the location of the public/ directory. If not defined, Remotion will assume the location is the `public` folder in your Remotion root.
remotion.config.ts
Config.setPublicDir('./custom-public-dir');

命令行标志 --public-dir 将优先于此选项。

🌐 The command line flag --public-dir will take precedence over this option.

setBundleOutDir()v4.0.426

Define the location of the resulting bundle. By default it is a folder called build, adjacent to the Remotion Root.
remotion.config.ts
Config.setBundleOutDir('./custom-build-dir');

命令行标志 --out-dir 将优先于此选项。

🌐 The command line flag --out-dir will take precedence over this option.

setBenchmarkRuns()

Specify how many times the video should be rendered during a benchmark. Default 3.
remotion.config.ts
Config.setBenchmarkRuns(5);

命令行标志 --runs 将优先于此选项。

🌐 The command line flag --runs will take precedence over this option.

setBenchmarkConcurrencies()v4.0.430

Specify which concurrency values should be used while benchmarking. Multiple values can be passed separated by comma. Learn more about concurrency.
remotion.config.ts
Config.setBenchmarkConcurrencies('1,4,8');

命令行标志 --concurrencies 将优先于此选项。

🌐 The command line flag --concurrencies will take precedence over this option.

setEntryPoint()v3.2.40

设置 Remotion 入口点,对于 CLI 命令,你不必指定它。

🌐 Sets the Remotion entry point, you don't have to specify it for CLI commands.

remotion.config.ts
Config.setEntryPoint('./src/index.ts');

如果你将入口点作为命令行参数传递,它将优先。

🌐 If you pass an entry point as a CLI argument, it will take precedence.

setLevel()v2.0.1

增加或减少命令行接口中的日志消息数量。 可接受的值:

🌐 Increase or decrease the amount of log messages in the CLI. Acceptable values:

  • error:除错误消息外保持沉默。
  • warn:只显示错误和警告。
  • info (默认): 默认输出 - 除了错误和警告外,还打印进度和输出位置。
  • verbose:以上所有,以及浏览器日志和其他调试信息。
remotion.config.ts
Config.setLevel('verbose');

命令行标志 --log 将优先于此选项。

🌐 The command line flag --log will take precedence over this option.

setMaxTimelineTracks()v2.1.10

设置在工作室时间轴中最多显示多少轨道。这不会影响你的视频,仅影响预览时显示的轨道数量。默认 15

🌐 Set how many tracks are being displayed in the timeline in the Studio at most. This does not affect your video, just the amount of tracks shown when previewing. Default 15.

remotion.config.ts
Config.setMaxTimelineTracks(20);

setKeyboardShortcutsEnabled()v3.2.11

Enable or disable keyboard shortcuts in the Remotion Studio.
remotion.config.ts
Config.setKeyboardShortcutsEnabled(false);

命令行标志 --disable-keyboard-shortcuts 将优先于此选项。

🌐 The command line flag --disable-keyboard-shortcuts will take precedence over this option.

setExperimentalClientSideRenderingEnabled()v4.0.387

Enable WIP client-side rendering in the Remotion Studio. See https://www.remotion.dev/docs/client-side-rendering/ for notes.
remotion.config.ts
Config.setExperimentalClientSideRenderingEnabled(true);

命令行标志 --enable-experimental-client-side-rendering 将优先于此选项。

🌐 The command line flag --enable-experimental-client-side-rendering will take precedence over this option.

setExperimentalRspackEnabled()v4.0.426

在 Studio 中使用 Rspack 替代 Webpack 作为打包工具。默认 false

🌐 Use Rspack instead of Webpack as the bundler for the Studio. Default false.

remotion.config.ts
Config.setExperimentalRspackEnabled(true);

命令行标志 --experimental-rspack 将优先于此选项。

🌐 The command line flag --experimental-rspack will take precedence over this option.

setExperimentalVisualMode()v4.0.428

Nothing here yet, but this is our playground for experiments.
remotion.config.ts
Config.setExperimentalVisualMode(true);

命令行标志 --experimental-visual-mode 将优先于此选项。

🌐 The command line flag --experimental-visual-mode will take precedence over this option.

setWebpackPollingInMilliseconds()v3.3.11

Enables Webpack polling instead of the file system event listeners for hot reloading. This is useful if you are inside a virtual machine or have a remote file system. Pass a value in milliseconds.
remotion.config.ts
Config.setWebpackPollingInMilliseconds(1000);

命令行标志 --webpack-poll 将优先于此选项。

🌐 The command line flag --webpack-poll will take precedence over this option.

setNumberOfSharedAudioTags()v3.3.2

Set number of shared audio tags. See Using the numberOfSharedAudioTags prop for more information.
remotion.config.ts
Config.setNumberOfSharedAudioTags(5);

命令行标志 --number-of-shared-audio-tags 将优先于此选项。

🌐 The command line flag --number-of-shared-audio-tags will take precedence over this option.

setShouldOpenBrowser()v3.3.19

If specified, Remotion will not open a browser window when starting the Studio.
remotion.config.ts
Config.setShouldOpenBrowser(false);

命令行标志 --no-open 将优先于此选项。

🌐 The command line flag --no-open will take precedence over this option.

setBrowserExecutable()v1.5.0

Set a custom Chrome or Chromium executable path. By default Remotion will try to find an existing version of Chrome on your system and if not found, it will download one. This flag is useful if you don't have Chrome installed in a standard location and you want to prevent downloading an additional browser or need support for the H264 codec.
remotion.config.ts
Config.setBrowserExecutable('/usr/bin/google-chrome-stable');

命令行标志 --browser-executable 将优先于此选项。

🌐 The command line flag --browser-executable will take precedence over this option.

setDelayRenderTimeoutInMilliseconds()v2.6.3

之前命名为“setTimeoutInMilliseconds”

🌐 previously named "setTimeoutInMilliseconds"

定义单帧可能花多长时间来解决所有 delayRender() 调用 在超时之前。默认值:30000

🌐 Define how long a single frame may take to resolve all delayRender() calls before it times out. Default: 30000

remotion.config.ts
Config.setDelayRenderTimeoutInMilliseconds(60000);

命令行标志 --timeout 将优先于此选项。

🌐 The command line flag --timeout will take precedence over this option.

setChromiumDisableWebSecurity()v2.6.5

This will most notably disable CORS in Chrome among other security features.
remotion.config.ts
Config.setChromiumDisableWebSecurity(true);

命令行标志 --disable-web-security 将优先于此选项。

🌐 The command line flag --disable-web-security will take precedence over this option.

setChromiumDarkMode()v4.0.381

Whether Chromium should pretend to be in dark mode by emulating the media feature 'prefers-color-scheme: dark'. Default is false.
remotion.config.ts
Config.setChromiumDarkMode(true);

setChromiumIgnoreCertificateErrors()v2.6.5

Results in invalid SSL certificates in Chrome, such as self-signed ones, being ignored.
remotion.config.ts
Config.setChromiumIgnoreCertificateErrors(true);

命令行标志 --ignore-certificate-errors 将优先于此选项。

🌐 The command line flag --ignore-certificate-errors will take precedence over this option.

setChromiumHeadlessMode()v2.6.5

Deprecated - will be removed in 5.0.0. With the migration to Chrome Headless Shell, this option is not functional anymore.

If disabled, the render will open an actual Chrome window where you can see the render happen. The default is headless mode.
remotion.config.ts
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.ts
Config.setChromiumMultiProcessOnLinux(true);

setChromeMode()v4.0.248

One of headless-shell, chrome-for-testing. Default headless-shell. Use chrome-for-testing to take advantage of GPU drivers on Linux.
remotion.config.ts
Config.setChromeMode('chrome-for-testing');

命令行标志 --chrome-mode 将优先于此选项。

🌐 The command line flag --chrome-mode will take precedence over this option.

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 is swangle (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.ts
Config.setChromiumOpenGlRenderer('angle');

命令行标志 --gl 将优先于此选项。

🌐 The command line flag --gl will take precedence over this option.

setConcurrency()

How many CPU threads to use. Minimum 1. The maximum is the amount of threads you have (In Node.JS os.cpus().length). You can also provide a percentage value (e.g. 50%).
remotion.config.ts
Config.setConcurrency(8);

命令行标志 --concurrency 将优先于此选项。

🌐 The command line flag --concurrency will take precedence over this option.

tip

尝试将你的并发设置为 os.cpus().length,以使用 CPU 上的所有线程进行更快的渲染。缺点是系统的其他部分可能会变慢。

setVideoImageFormat()v4.0.0

确定以哪种图片格式渲染帧。可以是以下之一:

🌐 Determines which in which image format to render the frames. Either:

  • jpeg - 最快的选项(默认)
  • png - 较慢,但支持透明度
  • none - 不要渲染图片,只计算音频信息
remotion.config.ts
Config.setVideoImageFormat('png');

setStillImageFormat()v4.0.0

确定以哪种图片格式渲染帧。可以是以下之一:

🌐 Determines which in which image format to render the frames. Either:

  • png(默认)
  • jpeg
  • pdf
  • webp
remotion.config.ts
Config.setStillImageFormat('pdf');

setScale()v2.6.7

按你传入的因子缩放输出帧。 例如,1280x720像素的帧在缩放因子为 1.5 时将变为1920x1080像素。像字体和HTML标记这样的矢量元素将以更多细节呈现。默认值:1

remotion.config.ts
Config.setScale(2);

命令行标志 --scale 将优先于此选项。

🌐 The command line flag --scale will take precedence over this option.

setMuted()v3.2.1

禁用音频输出。默认 false

🌐 Disables audio output. Default false.

remotion.config.ts
Config.setMuted(true);

命令行标志 --muted 将优先于此选项。

🌐 The command line flag --muted will take precedence over this option.

setDisallowParallelEncoding()v4.0.315

不允许渲染器同时进行渲染帧和编码。这使渲染过程更高效地使用内存,但可能会更慢。默认 false

🌐 Disallows the renderer from doing rendering frames and encoding at the same time. This makes the rendering process more memory-efficient, but possibly slower. Default false.

remotion.config.ts
Config.setDisallowParallelEncoding(true);

命令行标志 --disallow-parallel-encoding 将优先于此选项。

🌐 The command line flag --disallow-parallel-encoding will take precedence over this option.

setEnforceAudioTrack()v3.2.1

如果原本没有音频轨道,则渲染一个静音音频轨道。默认 false

🌐 Render a silent audio track if there would be none otherwise. Default false.

remotion.config.ts
Config.setEnforceAudioTrack(true);

命令行标志 --enforce-audio-track 将优先于此选项。

🌐 The command line flag --enforce-audio-track will take precedence over this option.

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.ts
Config.setForSeamlessAacConcatenation(true);

命令行标志 --for-seamless-aac-concatenation 将优先于此选项。

🌐 The command line flag --for-seamless-aac-concatenation will take precedence over this option.

setFrameRange()v2.0.0

Render a subset of a video. Pass a single number to render a still, or a range (e.g. 0-9) to render a subset of frames. Pass 100- to render from frame 100 to the end.
remotion.config.ts
Config.setFrameRange(90); // To render only the 91st frame

or

remotion.config.ts
Config.setFrameRange([0, 20]); // Render a video only containing the first 21 frames

or

remotion.config.ts
Config.setFrameRange([100, null]); // Render from frame 100 to the end of the composition

传递 [number, null] 以从某一帧渲染到合成的结束。v4.0.421

命令行标志 --frames 将优先于此选项。

🌐 The command line flag --frames will take precedence over this option.

setJpegQuality()

每一帧的 JPEG 质量。必须是 0 到 100 之间的数字。如果你渲染的是 PNG 帧,则无效。默认值:80

🌐 The JPEG quality of each frame. Must be a number between 0 and 100. Will not work if you render PNG frames. Default: 80.

remotion.config.ts
Config.setJpegQuality(90);

命令行标志 --jpeg-quality 将优先于此选项。

🌐 The command line flag --jpeg-quality will take precedence over this option.

setDotEnvLocation()

Specify a location for a dotenv file. Default .env.
remotion.config.ts
Config.setDotEnvLocation('.my-env');

命令行标志 --env-file 将优先于此选项。

🌐 The command line flag --env-file will take precedence over this option.

setEveryNthFrame()

This option may only be set when rendering GIFs. It determines how many frames are rendered, while the other ones get skipped in order to lower the FPS of the GIF. For example, if the fps is 30, and everyNthFrame is 2, the FPS of the GIF is 15.
remotion.config.ts
Config.setEveryNthFrame(2);

命令行标志 --every-nth-frame 将优先于此选项。

🌐 The command line flag --every-nth-frame will take precedence over this option.

setNumberOfGifLoops()

Allows you to set the number of loops as follows:
  • null (or omitting in the CLI) plays the GIF indefinitely.
  • 0 disables looping
  • 1 loops the GIF once (plays twice in total)
  • 2 loops the GIF twice (plays three times in total) and so on.
remotion.config.ts
Config.setNumberOfGifLoops(2);

命令行标志 --number-of-gif-loops 将优先于此选项。

🌐 The command line flag --number-of-gif-loops will take precedence over this option.

setOutputLocation()v3.1.6

设置视频或静态图片的输出位置,相对于当前工作目录。默认值是 out/{composition}.{container}。例如,out/HelloWorld.mp4

🌐 Set the output location of the video or still, relative to the current working directory. The default is out/{composition}.{container}. For example, out/HelloWorld.mp4.

remotion.config.ts
Config.setOutputLocation('out/video.mp4');

如果你向 render 命令传递另一个参数,它将优先:npx remotion render src/index.ts HelloWorld out/video.mp4

🌐 If you pass another argument to the render command, it will take precedence: npx remotion render src/index.ts HelloWorld out/video.mp4.

setOverwriteOutput()

将此设置为 false 以防止在 Remotion 输出已存在时被覆盖。

🌐 Set this to false to prevent overwriting Remotion outputs when they already exists.

remotion.config.ts
Config.setOverwriteOutput(false);
info

在 1.x 版本中,默认行为是相反的——Remotion 默认情况下不会覆盖。

setPixelFormat()

Sets the pixel format in FFmpeg. See the FFmpeg docs for an explanation. Acceptable values: "yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le".
remotion.config.ts
Config.setPixelFormat('yuv420p');

命令行标志 --pixel-format 将优先于此选项。

🌐 The command line flag --pixel-format will take precedence over this option.

setCodec()v1.4.0

选择一个支持的编解码器:h264 (默认), h265, vp8, vp9

🌐 Choose one of the supported codecs: h264 (default), 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.ts
Config.setCodec('h265');

命令行标志 --codec 将优先于此选项。

🌐 The command line flag --codec will take precedence over this option.

另请参阅: 编码指南

setAudioCodec()

remotion.config.ts
Config.setAudioCodec('pcm-16');

选择你的音频编码。

🌐 Choose the encoding of your audio.

  • 默认值取决于所选择的 codec
  • 如果你需要未压缩的音频,请选择 pcm-16
  • 并非所有视频容器都支持所有音频编解码器。
  • 如果 codec 选项也指定了音频编解码器,则此选项优先。

命令行标志 --audio-codec 将优先于此选项。

🌐 The command line flag --audio-codec will take precedence over this option.

请参阅 编码指南 以查看默认设置和支持的组合。

🌐 Refer to the Encoding guide to see defaults and supported combinations.

setProResProfile()v2.1.6

Set the ProRes profile. This option is only valid if the codec has been set to prores. Possible values: "4444-xq", "4444", "hq", "standard", "light", "proxy". Default: "hq". See here for an explanation of possible values.
remotion.config.ts
Config.setProResProfile('4444');

命令行标志 --prores-profile 将优先于此选项。

🌐 The command line flag --prores-profile will take precedence over this option.

setX264Preset()v4.2.2

设置预设配置文件。仅当编解码器已设置为 h264 时,此选项才有效。 可能的值:superfastveryfastfasterfastmediumslowslowerveryslowplacebo 默认值:medium

🌐 Set the Preset profile. This option is only valid if the codec has been set to h264. Possible values: superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo, Default: medium

remotion.config.ts
Config.setX264Preset('fast');

命令行标志 --x264-preset 将优先于此选项。

🌐 The command line flag --x264-preset will take precedence over this option.

另见: 编码指南, 透明视频

setImageSequence()v1.4.0

Pass this flag to output an image sequence instead of a video. The default image format is JPEG. See setImageSequence() for more details.
remotion.config.ts
Config.setImageSequence(true);

命令行标志 --sequence 将优先于此选项。

🌐 The command line flag --sequence will take precedence over this option.

overrideHeight()v3.2.40

Overrides the height of the composition.
remotion.config.ts
Config.overrideHeight(600);

命令行标志 --height 将优先于此选项。

🌐 The command line flag --height will take precedence over this option.

overrideWidth()v3.2.40

Overrides the width of the composition.
remotion.config.ts
Config.overrideWidth(900);

命令行标志 --width 将优先于此选项。

🌐 The command line flag --width will take precedence over this option.

overrideFps()v4.0.424

Overrides the frames per second of the composition.
remotion.config.ts
Config.overrideFps(25);

命令行标志 --fps 将优先于此选项。

🌐 The command line flag --fps will take precedence over this option.

overrideDuration()v4.0.424

Overrides the duration in frames of the composition.
remotion.config.ts
Config.overrideDuration(300);

命令行标志 --duration 将优先于此选项。

🌐 The command line flag --duration will take precedence over this option.

setCrf()v1.4.0

输出的“恒定速率因子”(CRF)。使用此设置告诉 FFmpeg 如何在文件大小和质量之间进行权衡。

🌐 The "Constant Rate Factor" (CRF) of the output. Use this setting to tell FFmpeg how to trade off size and quality.

按编解码器划分的 CRF 级别范围:

🌐 Ranges for CRF scale, by codec:

  • h264 的 crf 范围是 1-51,其中 crf 18 是 默认
  • h265 的 crf 范围是 0-51,其中 crf 23 是 默认
  • vp8 的 crf 范围是 4-63,其中 crf 9 是 默认
  • vp9 的 crf 范围是 0-63,其中 crf 28 是 默认

最低值是无损的,最高值是可能的最差质量。更高的值会在牺牲质量的情况下减小文件大小。

🌐 The lowest value is lossless, and the highest value is the worst quality possible. Higher values decrease the filesize at the cost of quality.

范围是指数级的,因此将 CRF 值增加 +6 会导致大约一半的比特率/文件大小,而 -6 则会导致大约两倍的比特率。

🌐 The range is exponential, so increasing the CRF value +6 results in roughly half the bitrate / file size, while -6 leads to roughly twice the bitrate.

选择仍能提供可接受质量的最高 CRF 值。如果输出看起来不错,则尝试更高的值。如果看起来不好,则选择更低的值。

🌐 Choose the highest CRF value that still provides an acceptable quality. If the output looks good, then try a higher value. If it looks bad, choose a lower value.

remotion.config.ts
Config.setCrf(16);

命令行标志 --crf 将优先于此选项。

🌐 The command line flag --crf will take precedence over this option.

note

如果启用硬件加速,则无法设置 crf。请改用setVideoBitrate() 选项。

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.ts
Config.setVideoBitrate('1M');

命令行标志 --video-bitrate 将优先于此选项。

🌐 The command line flag --video-bitrate will take precedence over this option.

setEncodingBufferSize()v4.0.78

The value for the -bufsize flag of FFmpeg. Should be used in conjunction with the encoding max rate flag.

remotion.config.ts
Config.setEncodingBufferSize('10000k');

命令行标志 --buffer-size 将优先于此选项。

🌐 The command line flag --buffer-size will take precedence over this option.

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.ts
Config.setEncodingMaxRate('5000k');

命令行标志 --max-rate 将优先于此选项。

🌐 The command line flag --max-rate will take precedence over this option.

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.ts
Config.setAudioBitrate('128K');

命令行标志 --audio-bitrate 将优先于此选项。

🌐 The command line flag --audio-bitrate will take precedence over this option.

setAudioLatencyHint()v4.0.303

Sets the audio latency hint for the global AudioContext context that Remotion uses to play audio.
Possible values: interactive, balanced, playback

remotion.config.ts
Config.setAudioLatencyHint('interactive');

--audio-latency-hint 命令行标志将优先于此选项。

🌐 The --audio-latency-hint command line flag will take precedence over this option.

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.ts
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.ts
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.ts
Config.setDeleteAfter('3-days');

setBeepOnFinish()v4.0.84

Whether the Remotion Studio tab should beep when the render is finished.

remotion.config.ts
Config.setBeepOnFinish(true);

命令行标志 --beep-on-finish 将优先于此选项。

🌐 The command line flag --beep-on-finish will take precedence over this option.

setEnableCrossSiteIsolation()v4.0.306

Enable Cross-Site Isolation in the Studio (sets Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy HTTP headers, required for @remotion/whisper-web).

remotion.config.ts
Config.setEnableCrossSiteIsolation(true);

命令行标志 --cross-site-isolation 将优先于此选项。

🌐 The command line flag --cross-site-isolation will take precedence over this option.

setAskAIEnabled()v4.0.407

If the Cmd + I shortcut of the Ask AI modal conflicts with your Studio, you can disable it using this.

remotion.config.ts
Config.setAskAIEnabled(false);

命令行标志 --disable-ask-ai 将优先于此选项。

🌐 The command line flag --disable-ask-ai will take precedence over this option.

setForceNewStudioEnabled()v4.0.421

Forces starting a new Studio instance even if one is already running on the same port for the same project.

remotion.config.ts
Config.setForceNewStudioEnabled(true);

命令行标志 --force-new 将优先于此选项。

🌐 The command line flag --force-new will take precedence over this option.

setIPv4()v4.0.125

Forces Remotion to bind to an IPv4 interface for the Studio server.

remotion.config.ts
Config.setIPv4(true);

命令行标志 --ipv4 将优先于此选项。

🌐 The command line flag --ipv4 will take precedence over this option.

setBufferStateDelayInMilliseconds()v4.0.111

设置在播放器进入缓冲状态后,工作室中的播放器显示缓冲界面的毫秒数。默认值为 300

🌐 Set the amount of milliseconds after which the Player in the Studio will display a buffering UI after the Player has entered a buffer state. Default 300.

remotion.config.ts
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.ts
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.ts
Config.setPreferLosslessAudio(true);

setHardwareAcceleration()v4.0.228

One of "disable", "if-possible", or "required" . Default "disable". Encode using a hardware-accelerated encoder if available. If set to "required" and no hardware-accelerated encoder is available, then the render will fail.

remotion.config.ts
Config.setHardwareAcceleration('if-possible');

overrideFfmpegCommand()v3.2.22

修改 Remotion 在底层使用的 FFmpeg 命令。它以 reducer 风格工作,这意味着你传入一个函数,该函数以命令作为参数并返回一个新的命令。

🌐 Modifies the FFmpeg command that Remotion uses under the hood. It works reducer-style, meaning that you pass a function that takes a command as an argument and returns a new command.

remotion.config.ts
Config.overrideFfmpegCommand(({args}) => { // Define the custom FFmpeg options as an array of strings const customFfmpegOptions = ['-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 path args.splice(args.length - 1, 0, ...customFfmpegOptions); return args; });

你传入的函数必须接受一个对象作为它的唯一参数,该对象包含以下属性:

🌐 The function you pass must accept an object as it's only parameter which contains the following properties:

  • type:要么 "stitcher" 要么 "pre-stitcher"。如果有足够的内存和 CPU,可采用两遍处理的视频生成方式。pre-stitcher 是编码阶段,stitcher 是复用阶段。如果覆盖函数只调用一次 stitcher,那么编码和复用将在同一步完成。你可以通过在渲染命令中添加 --log=verbose 来判断是否启用了并行编码。
  • args:作为参数传递给 FFmpeg 命令的字符串数组。

你的函数必须返回一个修改过的字符串数组。

🌐 Your function must return a modified array of strings.

warning

不建议使用此功能。在使用它之前,我们希望让你了解一些注意事项:

  • 渲染命令可能会随任何新的 Remotion 版本而更改,即使是在补丁升级时。这可能会导致你使用此功能时出现问题。
  • 根据所选的编解码器、可用的 CPU 和内存,Remotion 可能会或可能不会使用“并行编码”,这将导致多个 FFmpeg 命令被执行。你的函数必须能够处理被多次调用的情况。
  • Remotion 提供的 FFmpeg 二进制文件只支持 FFmpeg 命令的一个小子集,因此并非所有传递的选项都会被应用。
  • 使用 Remotion Lambda 时此功能不可用。

在使用此技巧之前,请通过 Discord 联系 Remotion 团队,并询问我们是否愿意以干净的方式实现你需要的功能——我们经常根据用户反馈快速实现新功能。

🌐 Before you use this hack, reach out to the Remotion team on Discord and ask us if we are open to implement the feature you need in a clean way - we often do implement new features quickly based on users feedback.

setPublicLicenseKey()v4.0.398

The public license key for your company license, obtained from the "Usage" tab on remotion.pro. If you are eligible for the free license, pass "free-license".

remotion.config.ts
Config.setPublicLicenseKey('your-license-key');

命令行标志 --public-license-key 将优先于此选项。

🌐 The command line flag --public-license-key will take precedence over this option.

setImageSequencePattern()

Pattern for naming image sequence files. Supports [frame] for the zero-padded frame number and [ext] for the file extension.
remotion.config.ts
Config.setImageSequencePattern('frame_[frame]_custom.[ext]');

命令行标志 --image-sequence-pattern 将优先于此选项。

🌐 The command line flag --image-sequence-pattern will take precedence over this option.

setQuality()

v4.0.0 中重命名为 setJpegQuality

🌐 Renamed to setJpegQuality in v4.0.0.

setFfmpegExecutable()

在 v4.0 中移除

🌐 removed in v4.0

允许你使用自定义的 FFmpeg 二进制文件。必须是绝对路径。默认情况下,此项为 null,将使用 PATH 中的 FFmpeg。

🌐 Allows you to use a custom FFmpeg binary. Must be an absolute path. By default, this is null and the FFmpeg in PATH will be used.

remotion.config.ts
import {Config} from '@remotion/cli/config'; // ---cut--- Config.setFfmpegExecutable('/path/to/custom/ffmpeg');

命令行标志 --ffmpeg-executable 将优先于此选项。

🌐 The command line flag --ffmpeg-executable will take precedence over this option.

setFfprobeExecutable()

在 v4.0 中移除

🌐 removed in v4.0

允许你使用自定义的 ffprobe 二进制文件。必须是绝对路径。默认情况下,这为 null,并将使用 PATH 中的 ffprobe

🌐 Allows you to use a custom ffprobe binary. Must be an absolute path. By default, this is null and the ffprobe in PATH will be used.

remotion.config.ts
import {Config} from '@remotion/cli/config'; // ---cut--- Config.setFfprobeExecutable('/path/to/custom/ffprobe');

命令行标志 --ffprobe-executable 将优先于此选项。

🌐 The command line flag --ffprobe-executable will take precedence over this option.

setPort()

_在 v4.0.61 中已弃用 - 请改用 setStudioPort()setRendererPort()

🌐 deprecated in v4.0.61 - use setStudioPort() and setRendererPort() instead.

定义 Remotion 应该在哪个端口启动其 HTTP 服务器。
默认情况下,Remotion 会尝试寻找一个空闲的端口。
如果你指定了一个端口,但它不可用,Remotion 将抛出错误。

🌐 Define on which port Remotion should start it's HTTP servers.
By default, Remotion will try to find a free port.
If you specify a port, but it's not available, Remotion will throw an error.

warning

设置此选项将会破坏 Remotion Studio 中的渲染,因为此选项同时控制两个设置:

单独使用这些选项。

🌐 Use the options individually.

remotion.config.ts
Config.setPort(3003);

命令行标志 --port 将优先于此选项。如果在 npx remotion studio 上设置,它将设置 Studio 端口,否则将设置渲染器端口。

🌐 The command line flag --port will take precedence over this option. If set on npx remotion studio, it will set the Studio port, otherwise the renderer port.

setOutputFormat()

在 v4.0.0 中移除 已弃用。请改用 setCodec()setImageSequence()

🌐 Removed in v4.0.0 Deprecated. Use setCodec() and setImageSequence() instead.

'mp4''png-sequence'

🌐 Either 'mp4' or 'png-sequence'.

remotion.config.ts
import {Config} from '@remotion/cli/config'; // ---cut--- Config.setOutputFormat('mp4');

命令行标志 --sequence--codec 将优先于此选项。

🌐 The command line flags --sequence and --codec will take precedence over this option.

命令行标志 --quality 将优先于此选项。

🌐 The command line flag --quality will take precedence over this option.

setImageFormat()v1.4.0

在 v4.0 中移除

🌐 Removed in v4.0

在 v4.0 中被 setVideoImageFormat()setStillImageFormat() 替换

🌐 Replaced in v4.0 with setVideoImageFormat() and setStillImageFormat()

确定以哪种图片格式渲染帧。可以是以下之一:

🌐 Determines which in which image format to render the frames. Either:

  • jpeg - 最快的选项(v1.1 的默认设置)
  • png - 较慢,但支持透明度
  • none - 不要渲染图片,只计算音频信息(从 v2.0 开始可用)
remotion.config.ts
import {Config} from '@remotion/cli/config'; // ---cut--- Config.setImageFormat('png');

命令行标志 --image-format 将优先于此选项。

🌐 The command line flag --image-format will take precedence over this option.

导入 ES 模块

🌐 Importing ES Modules

配置文件 会在 CommonJS 环境中执行。如果你想导入 ES 模块来覆盖 Webpack 配置,可以将异步函数传递给 Config.overrideWebpackConfig()

🌐 The config file gets executed in a CommonJS environment. If you want to import ES modules to override the Webpack config, you can pass an async function to Config.overrideWebpackConfig():

remotion.config.ts
import {Config} from '@remotion/cli/config'; Config.overrideWebpackConfig(async (currentConfiguration) => { const {enableSass} = await import('./src/enable-sass'); return enableSass(currentConfiguration); });

旧配置文件格式

🌐 Old config file format

在 v3.3.39 中,引入了一种新的配置文件格式,它将选项扁平化,以便可以更容易地使用 TypeScript 自动补齐进行发现。

🌐 In v3.3.39, a new config file format was introduced which flattens the options so they can more easily be discovered using TypeScript autocompletion.

以前,每个配置选项都是两级深:

🌐 Previously, each config option was two levels deep:

remotion.config.ts
Config.Bundling.setCachingEnabled(false);

从 v3.3.39 开始,所有选项都可以直接从 Config 对象访问。

🌐 From v3.3.39 on, all options can be accessed directly from the Config object.

remotion.config.ts
Config.setCachingEnabled(false);

旧的方法已被弃用,但在可预见的未来仍然可用。

🌐 The old way is deprecated, but will work for the foreseeable future.

另请参阅

🌐 See also