Skip to main content

npx remotion cloudrun render

EXPERIMENTAL

Cloud Run 处于 Alpha 阶段,这意味着 API 可能会在任何版本中更改,文档尚未完成。请查看 更改日志以了解最新的重大更改

使用 npx remotion cloudrun render 命令,您可以在 GCP 上渲染视频。

命令的结构如下:

npx remotion cloudrun render <serve-url> [<composition-id>] [<output-location>]
npx remotion cloudrun render <serve-url> [<composition-id>] [<output-location>]
  • 通过使用 sites create 命令部署 Remotion 项目到 GCP 存储桶,或调用 deployService() 来获取服务 URL。
  • 组合 ID。如果未指定,将获取组合列表,您可以选择一个组合。
  • output-location 参数是可选的。如果不指定,视频将存储在您的 Cloud 存储桶中。如果指定位置,它将在额外步骤中下载到您的设备。

示例命令

渲染视频,传递服务名称:

npx remotion cloudrun render https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh/index.html tiles --service-name=remotion--3-3-82--mem512mi--cpu1-0--t-800
npx remotion cloudrun render https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh/index.html tiles --service-name=remotion--3-3-82--mem512mi--cpu1-0--t-800

使用站点名称而不是完整的服务 URL:

npx remotion cloudrun render test-site tiles --service-name=remotion--3-3-82--mem512mi--cpu1-0--t-800
npx remotion cloudrun render test-site tiles --service-name=remotion--3-3-82--mem512mi--cpu1-0--t-800

传入输入属性:

npx remotion cloudrun render test-site tiles --service-name=remotion--3-3-82--mem512mi--cpu1-0--t-800 --props='{"hi": "there"}'
npx remotion cloudrun render test-site tiles --service-name=remotion--3-3-82--mem512mi--cpu1-0--t-800 --props='{"hi": "there"}'

标志

--region

选择的 GCP 区域。为了获得最低延迟,服务、站点和输出存储桶应位于同一区域。

--props

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

note

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

--privacy

其中之一:

  • "public"默认):渲染的媒体可以通过 Cloud 存储 URL 公开访问。
  • "private":渲染的媒体不是公开的,但对具有正确权限的 GCP 项目内的用户可用。

--force-bucket-name

指定用于输出的特定存储桶名称。生成的 Google Cloud 存储 URL 将采用 gs://{bucket-name}/renders/{render-id}/{file-name} 的格式。如果未设置,Remotion 将根据区域选择正确的存储桶。

--concurrency

一个数字或描述应打开多少个浏览器选项卡的字符串。默认为 "50%"。

note

在 v4.0.76 之前,默认值为 "100%"。现在已与其他服务器端渲染 API 对齐。

--jpeg-quality

JPEG 渲染质量介于 0 和 100 之间。当渲染 PNG 帧时不起作用。

--image-format

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

--scale

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

--env-file

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

--out-name

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

--cloud-run-url

指定应用于执行渲染的服务的 URL。您必须设置 cloud-run-url 或者 service-name,但不能同时设置两者。

--service-name

指定应用于执行渲染的服务的名称。这与区域一起用于确定服务端点,因为相同的服务名称可以存在于多个区域。您必须设置 cloud-run-url 或者 service-name,但不能同时设置两者。

--codec

h264h265pngvp8mp3aacwavprores。如果不提供 --codec,将使用 h264

--audio-codec

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

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

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

设置自定义像素格式。请参见此处以获取可用值。

--every-nth-frame

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

例如,仅每隔一帧、每隔三帧等。仅适用于渲染 GIF。请参见此处获取更多详细信息。

--number-of-gif-loops

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.

--frames

渲染视频的子集。示例:--frames=0-9 选择前10帧。

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

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