Skip to main content

npx remotion lambda render

使用 npx remotion lambda render 命令,你可以在云端渲染视频。

🌐 Using the npx remotion lambda render command, you can render a video in the cloud.

一个命令的结构如下:

🌐 The structure of a command is as follows:

npx remotion lambda render <serve-url> [<composition-id>] [<output-location>]

参数:

🌐 Arguments:

  • 使用 sites create 命令或通过调用 deploySite() 获取 Serve URL
  • 【作品 ID】(/docs/terminology/composition#composition-id)。如果未指定,将会获取作品列表,你可以选择一个作品。
  • output-location 参数是可选的。如果你不指定它,视频将存储在你的 S3 存储桶中。如果你指定了位置,它将在另一步中下载到你的设备上。

示例命令

🌐 Example commands

渲染视频:

🌐 Rendering a video:

npx remotion lambda render https://remotionlambda-abcdef.s3.eu-central-1.amazonaws.com/sites/testbed/index.html my-comp

渲染视频并将其保存到 out/video.mp4

🌐 Rendering a video and saving it to out/video.mp4:

npx remotion lambda render https://remotionlambda-abcdef.s3.eu-central-1.amazonaws.com/sites/testbed/index.html my-comp out/video.mp4

使用简写的 serve URL:

🌐 Using the shorthand serve URL:

npx remotion lambda render testbed my-comp
info

如果你使用简化的 serve URL,你必须传递一个 composition ID。只有在传递完整的 serve URL 时,才能获取可用的 compositions。

传入输入属性:

🌐 Passing in input props:

npx remotion lambda render --props='{"hi": "there"}' testbed my-comp

打印调试信息,包括 CloudWatch 链接:

🌐 Printing debug information including a CloudWatch link:

npx remotion lambda render --log=verbose testbed my-comp

保持输出视频私密:

🌐 Keeping the output video private:

npx remotion lambda render --privacy=private testbed my-comp

仅渲染音频:

🌐 Rendering only the audio:

npx remotion lambda render --codec=mp3 testbed my-comp

标志

🌐 Flags

--region

要选择的 AWS 区域。项目和函数都应在此区域内。

🌐 The AWS region to select. Both project and function should be in this region.

--props

Input Props to pass to the selected composition of your video. Must be a serialized JSON string (--props='{"hello": "world"}') or a path to a JSON file (./path/to/props.json).
note

Windows 终端不支持内联 JSON 字符串,因为它会移除 " 字符,请改用文件名。

--log

在 Lambda 函数内部使用的日志级别。此外,如果你将其设置为 verbose,将会打印一个指向 CloudWatch 的链接,你可以在其中查看日志。

🌐 Log level to be used inside the Lambda function. Also, if you set it to verbose, a link to CloudWatch will be printed where you can inspect logs.

--privacy

其中之一:

🌐 One of:

  • "public" (默认): 渲染的媒体可以通过 S3 URL 公共访问。
  • "private":渲染的媒体不可公开访问,但可以使用 presignUrl() 创建签名链接。
  • "no-acl"从 v.3.1.7 开始可用):ACL 选项根本没有被设置,如果你使用 outName 写入另一个不支持 ACL 的存储桶时,此选项很有用。

--max-retries

如果单个块渲染失败,将重试多少次。默认 1

🌐 How many times a single chunk is being retried if it fails to render. Default 1.

--frames-per-lambda

在单个 Lambda 函数中应该渲染多少帧。增加它可以减少渲染视频所需的 Lambda 函数数量,减少它可以加快渲染速度。

🌐 How many frames should be rendered in a single Lambda function. Increase it to require less Lambda functions to render the video, decrease it to make the render faster.

默认值:取决于视频长度
最小值: 4

note

framesPerLambda 参数不能导致生成超过 200 个函数。请参见:并发

--concurrencyv4.0.322

指定用于渲染的 Lambda 函数数量。这是 --frames-per-lambda 的一种替代方法,允许你直接设置并发量,而无需知道视频时长。

🌐 Specify the number of Lambda functions to use for rendering. This is an alternative to --frames-per-lambda that allows you to set the concurrency directly without needing to know the video duration.

并发性被定义为 frameCount / framesPerLambda。Remotion 会根据你的并发设置自动计算适当的 framesPerLambda 值。

🌐 The concurrency is defined as frameCount / framesPerLambda. Remotion will automatically calculate the appropriate framesPerLambda value based on your concurrency setting.

最大值:200
最小值:取决于视频长度(必须结果为 framesPerLambda >= 4

🌐 Maximum value: 200
Minimum value: Depends on video length (must result in framesPerLambda >= 4)

note

不能与 --frames-per-lambda 一起使用。只能使用其中之一。

--concurrency-per-lambdav3.0.30

默认情况下,每个 Lambda 函数的并发为 1(一个打开的浏览器标签)。你可以使用此选项自定义此值。

🌐 By default, each Lambda function renders with concurrency 1 (one open browser tab). You may use the option to customize this value.

--jpeg-quality

用于 JPEG 渲染质量的 0 到 100 之间的值 (/docs/config#setjpegquality)。在渲染 PNG 帧时不起作用。

--quality

v4.0.0 中重命名为 jpegQuality

🌐 Renamed to jpegQuality in v4.0.0.

--mutedv3.2.1

禁用音频输出。 此选项仅可在渲染视频时使用。

--codec

h264h265(自 v4.0.32 起支持)或 pngvp8mp3aacwavprores。如果你不提供 --codec,它将使用 h264

--audio-codecv3.3.42

Set the format of the audio that is embedded in the video. Not all codec and audio codec combinations are supported and certain combinations require a certain file extension and container format. See the table in the docs to see possible combinations.

--audio-bitratev3.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

--video-bitratev3.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.

--prores-profile

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.

--x264-preset

Sets a x264 preset profile. Only applies to videos rendered with h264 codec.
Possible values: superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo.
Default: medium

--crf

设置输出的恒定码率因子 (CRF)。最小值为 0。如果你想保持最佳质量而不太关心文件大小,请使用此码率控制模式。

--pixel-format

Sets the pixel format in FFmpeg. See the FFmpeg docs for an explanation. Acceptable values: "yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le".

--image-format

The image format to use when rendering frames for a video. Must be one of "png", "jpeg", "none". Default: "jpeg". JPEG is faster, but does not support transparency.

--scale

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

--env-file

Specify a location for a dotenv file. Default .env.

--frames

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.

--every-nth-framev3.1.0

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.

例如,仅每隔第二帧、每隔第三帧,依此类推。仅适用于渲染 GIF。在这里查看更多详情。

🌐 For example only every second frame, every third frame and so on. Only works for rendering GIFs. See here for more details.

--number-of-gif-loopsv3.1.0

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.

--timeout

一个数字,描述渲染可能花多长时间来解决所有 delayRender() 调用 在超时之前。默认值:30000

🌐 A number describing how long the render may take to resolve all delayRender() calls before it times out. Default: 30000

--out-name

存储在 S3 桶中的媒体输出文件名。默认情况下,它是 out 加上相应的文件扩展名,例如:out.mp4。必须与 /([0-9a-zA-Z-!_.*'()/]+)/g 匹配。

🌐 The file name of the media output as stored in the S3 bucket. By default, it is out plus the appropriate file extension, for example: out.mp4. Must match /([0-9a-zA-Z-!_.*'()/]+)/g.

--overwritev3.2.25

如果指定了自定义输出名称,并且在 S3 存储桶中该键已有文件,则决定在渲染开始前该文件是否会被删除。默认 false

🌐 If a custom out name is specified and a file already exists at this key in the S3 bucket, decide whether that file will be deleted before the render begins. Default false.

输出 S3 键处已存在的文件将与渲染发生冲突,必须预先删除。如果此设置为 false 并且发生冲突,将会抛出错误。

🌐 An existing file at the output S3 key will conflict with the render and must be deleted beforehand. If this setting is false and a conflict occurs, an error will be thrown.

--webhookv3.2.30

设置一个 webhook,当渲染完成或失败时调用。renderMediaOnLambda() -> webhook.url。与 --webhook-secret 一起使用。

🌐 Sets a webhook to be called when the render finishes or fails. renderMediaOnLambda() -> webhook.url. To be used together with --webhook-secret.

--webhook-secretv3.2.30

为 webhook 设置一个 webhook 密钥(见上文)。renderMediaOnLambda() -> webhook.secret。需与 --webhook 一起使用。

🌐 Sets a webhook secret for the webhook (see above). renderMediaOnLambda() -> webhook.secret. To be used together with --webhook.

--heightv3.2.40

Overrides the height of the composition.

--widthv3.2.40

Overrides the width of the composition.

--fpsv4.0.424

Overrides the frames per second of the composition.

--durationv4.0.424

Overrides the duration in frames of the composition.

--function-namev3.3.38

指定应当用于调用和协调渲染的函数名称。只有在存在多个具有不同配置的函数时,才需要传递它。

🌐 Specify the name of the function which should be used to invoke and orchestrate the render. You only need to pass it if there are multiple functions with different configurations.

--renderer-function-namev3.3.38

如果指定,将使用此函数来渲染各个块。如果你希望用于渲染块的函数比主协调函数的性能更高或更低,这非常有用。

🌐 If specified, this function will be used for rendering the individual chunks. This is useful if you want to use a function with higher or lower power for rendering the chunks than the main orchestration function.

如果你想使用此选项,该功能必须与主功能位于同一地区、同一账户并且具有相同版本。

🌐 If you want to use this option, the function must be in the same region, the same account and have the same version as the main function.

--force-bucket-namev3.3.42

指定要使用的特定存储桶名称。这不推荐,最好让 Remotion 自动发现正确的存储桶。

🌐 Specify a specific bucket name to be used. This is not recommended, instead let Remotion discover the right bucket automatically.

--ignore-certificate-errors

导致 Chrome 中的无效 SSL 证书(例如自签名证书)被忽略。

🌐 Results in invalid SSL certificates in Chrome, such as self-signed ones, being ignored.

--disable-web-security

这将最显著地禁用 Chrome 中的 CORS 以及其他安全功能。

🌐 This will most notably disable CORS in Chrome among other security features.

--dark-modev4.0.381

Whether Chromium should pretend to be in dark mode by emulating the media feature 'prefers-color-scheme: dark'. Default is false.

--gl

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"

--user-agentv3.3.83

允许你设置 headless Chrome 浏览器使用的自定义用户代理。

🌐 Lets you set a custom user agent that the headless Chrome browser assumes.

--media-cache-size-in-bytesv4.0.352

Specify the maximum size of the cache that <Video> and <Audio> from @remotion/media may use combined, in bytes.
The default is half of the available system memory when the render starts.

--offthreadvideo-cache-size-in-bytesv4.0.23

From v4.0, Remotion has a cache for <OffthreadVideo> frames. The default is null, corresponding to half of the system memory available when the render starts.
This option allows to override the size of the cache. The higher it is, the faster the render will be, but the more memory will be used.
The used value will be printed when running in verbose mode.
Default: null

--offthreadvideo-video-threadsv4.0.261

The number of threads that<OffthreadVideo> can start to extract frames. The default is 2. Increase carefully, as too many threads may cause instability.

--delete-afterv4.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.

--webhook-custom-datav4.0.25

Pass up to 1,024 bytes of a JSON-serializable object to the webhook. This data will be included in the webhook payload. Alternatively, pass a file path pointing to a JSON file

--color-spacev4.0.28

Color space to use for the video. Acceptable values: "default"(default since 5.0), "bt601" (same as "default", since v4.0.424), "bt709" (since v4.0.28), "bt2020-ncl" (since v4.0.88), "bt2020-cl" (since v4.0.88), .
For best color accuracy, it is recommended to also use "png" as the image format to have accurate color transformations throughout.
Only since v4.0.83, colorspace conversion is actually performed, previously it would only tag the metadata of the video.

--prefer-losslessv4.0.110

Uses a lossless audio codec, if one is available for the codec. If you setaudioCodec, it takes priority over preferLossless.

--metadatav4.0.216

Metadata to be embedded in the video. See here for which metadata is accepted.
The parameter must be in the format of --metadata key=value and can be passed multiple times.

--force-path-stylev4.0.202

forcePathStyle 传递给 AWS S3 客户端。如果你不知道这是什么,你很可能用不到它。

🌐 Passes forcePathStyle to the AWS S3 client. If you don't know what this is, you probably don't need it.

--storage-classv4.0.305

用于渲染媒体的 S3 存储类的 标识符。默认值:undefined(即 STANDARD)。

🌐 An identifier for the S3 storage class of the rendered media. Default: undefined (which is STANDARD).

--license-keyv4.0.409

License key for sending a usage event using @remotion/licensing.

--api-keyv4.0.253

在 v4.0.409 中已弃用

🌐 deprecated in v4.0.409

API key for sending a usage event using @remotion/licensing.