Skip to main content

npx remotion lambda render

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

命令的结构如下:

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

参数:

  • 使用 sites create 命令或调用 deploySite() 获取 Serve URL
  • Composition ID。如果未指定,将获取组合列表,您可以选择一个组合。
  • output-location 参数是可选的。如果不指定,视频将存储在您的 S3 存储桶中。如果指定位置,它将在额外步骤中下载到您的设备中。

示例命令

渲染视频:

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

渲染视频并将其保存到 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
npx remotion lambda render https://remotionlambda-abcdef.s3.eu-central-1.amazonaws.com/sites/testbed/index.html my-comp out/video.mp4

使用简写 Serve URL:

npx remotion lambda render testbed my-comp
npx remotion lambda render testbed my-comp
info

如果使用简写 Serve URL,则必须传递组合 ID。仅当传递完整 Serve URL 时,才能获取可用组合。

传入输入属性:

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

打印包括 CloudWatch 链接在内的调试信息:

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

保持输出视频私有:

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

仅渲染音频:

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

标志

--region

AWS区域。项目和函数都应该在此区域中。

--props

传递给视频所选组合的输入属性。
必须是一个序列化的 JSON 字符串 (--props='{"hello": "world"}') 或一个指向 JSON 文件的路径 (./path/to/props.json)。
从根组件中,可以使用 getInputProps() 读取属性。
您可以使用 calculateMetadata() 转换输入属性。

note

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

--log

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

--privacy

其中之一:

  • "public"默认):渲染的媒体可以在 S3 URL 下公开访问。
  • "private":渲染的媒体不是公开可用的,但可以使用 presignUrl() 创建签名链接。
  • "no-acl"从 v.3.1.7 开始可用):不设置 ACL 选项,如果您要写入不支持 ACL 的另一个存储桶,可以使用此选项,使用 outName

--max-retries

如果渲染失败,单个块重试的次数。默认为 1

--frames-per-lambda

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

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

note

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

--concurrency-per-lambdav3.0.30

--jpeg-quality

0 到 100 之间的值,用于 JPEG 渲染质量。在渲染 PNG 帧时不起作用。

--quality

v4.0.0 中更名为 jpegQuality

--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

设置 ProRes 档案。此选项仅在 codec 设置为 prores 时有效。可能的值:4444-xq4444hqstandardlightproxy。查看此处以了解可能的值。默认值:hq

--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

设置输出的 Constant Rate Factor (CRF)。最小为 0。如果希望保持最佳质量并对文件大小不太关心,请使用此速率控制模式。

--pixel-format

设置自定义像素格式。查看此处以获取可用值。

--image-format

jpegpng - JPEG 速度更快,但不支持透明度。 默认图像格式为 jpeg

--scale

通过传入的因子缩放输出帧。 例如,一个 1280x720px 的帧将以 1.5 的比例因子变为 1920x1080px 的帧。像字体和 HTML 标记等矢量元素将以更多细节呈现。

--env-file

指定 dotenv 文件的位置 - 默认为 .env了解有关环境变量在 Remotion 中的工作方式。

--frames

渲染视频的子集。例如:--frames=0-9 选择前10帧。要渲染静态图,请使用 still 命令。

--every-nth-framev3.1.0

仅渲染每第n帧。 此选项仅在渲染 GIF 时可设置。这允许您降低 GIF 的帧速率。

例如,仅每隔一帧,每隔三帧等。仅适用于渲染 GIF。点击此处了解更多详情。

--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

--out-name

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

--overwritev3.2.25

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

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

--webhookv3.2.30

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

--webhook-secretv3.2.30

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

--heightv3.2.40

覆盖合成高度。

--widthv3.2.40

覆盖组合宽度。

--function-namev3.3.38

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

--renderer-function-namev3.3.38

如果指定了此函数,将用于渲染各个块。如果要使用具有更高或更低功率的函数来渲染块,则此选项很有用。

如果要使用此选项,函数必须位于相同的区域、相同的帐户,并且与主函数具有相同的版本。

--force-bucket-namev3.3.42

指定要使用的特定存储桶名称。不建议这样做,而是让 Remotion 自动发现正确的存储桶。

--ignore-certificate-errors

导致 Chrome 忽略无效的 SSL 证书,例如自签名证书。

--disable-web-security

这将主要禁用 Chrome 中的 CORS,以及其他安全功能。

--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 浏览器所假定的自定义用户代理。

--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

--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), "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.

--force-path-stylev4.0.202

forcePathStyle 传递给 AWS S3 客户端。如果您不知道这是什么,您可能不需要它。