Skip to main content

renderStillOnCloudrun()

EXPERIMENTAL

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

在 Remotion Cloud Run 上启动静态渲染过程。

需要已部署 服务 才能执行渲染。
需要指定一个 站点Serve URL 来确定将要渲染的内容。

示例

tsx
import { renderStillOnCloudrun } from "@remotion/cloudrun/client";
 
const result = await renderStillOnCloudrun({
region: "us-east1",
serviceName: "remotion-render-bds9aab",
composition: "MyStill",
imageFormat: "png",
serveUrl:
"https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh",
});
 
if (result.type === "success") {
console.log(result.bucketName);
console.log(result.renderId);
}
tsx
import { renderStillOnCloudrun } from "@remotion/cloudrun/client";
 
const result = await renderStillOnCloudrun({
region: "us-east1",
serviceName: "remotion-render-bds9aab",
composition: "MyStill",
imageFormat: "png",
serveUrl:
"https://storage.googleapis.com/remotioncloudrun-123asd321/sites/abcdefgh",
});
 
if (result.type === "success") {
console.log(result.bucketName);
console.log(result.renderId);
}
note

@remotion/cloudrun/client 导入,以避免加载整个渲染器,因为它无法捆绑。

参数

一个具有以下属性的对象:

cloudRunUrl?

可选。如果未提供 serviceName,则必填

应用于执行渲染的 Cloud Run 服务的 URL。您必须设置 cloudRunUrl 或 serviceName,但不能同时设置两者。

serviceName?

可选。如果未提供 cloudRunUrl,则必填

应用于执行渲染的 Cloud Run 服务的名称。这与区域一起使用,以确定服务端点,因为相同的服务名称可以存在于多个区域。

region

您的 Cloud Run 服务部署在哪个 GCP 区域。强烈建议您的 Remotion 站点也位于同一区域。

serveUrl

指向 Remotion 项目的 URL。使用 deploySite() 部署 Remotion 项目。

composition

您要渲染的 compositionid

inputProps?

可选

传递给视频所选 composition 的输入属性。
必须是一个 JSON 对象。
从根组件可以使用 getInputProps() 读取属性。
您可以使用 calculateMetadata() 转换输入属性。

隐私?

可选

其中之一:

  • "public"默认):渲染的静态图在 Cloud Storage URL 下是公开可访问的。
  • "private":渲染的静态图不是公开可用的,但对具有正确权限的 GCP 项目内的用户可用。

downloadBehavior?v4.0.176

在浏览器通过 Cloud Storage 输出链接访问输出文件时的行为。

  • {"type": "play-in-browser"} - 默认行为。视频将在浏览器中播放。
  • {"type": "download", fileName: null}{"type": "download", fileName: "download.mp4"} - 将添加一个 Content-Disposition 头,使浏览器下载文件。您可以选择性地覆盖文件名。

forceBucketName?

可选

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

jpegQuality?

可选

请参阅 renderStill() -> jpegQuality

imageFormat?

可选

请参阅 renderStill() -> imageFormat

scale?

可选

通过因子缩放输出尺寸。请参阅缩放以了解更多关于此功能的信息。

envVariables?

可选

请参阅 renderStill() -> envVariables

frame?

可选

应该渲染哪一帧合成。帧是从零开始索引的,允许负值,-1 表示最后一帧。

chromiumOptions?

可选

允许您设置某些 Chromium / Google Chrome 标志。请参阅:Chromium 标志

disableWebSecurity

布尔值 - 默认 false

这将主要禁用 CORS 等安全功能。

ignoreCertificateErrors

布尔值 - 默认 false

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

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"

forceWidth?

可选

覆盖默认合成宽度。

forceHeight?

可选

覆盖默认合成高度。

logLevel?

One of verbose, info, warn, error.
Determines how much is being logged to the console.
verbose will also log console.log's from the browser.
Default info.

outName?

可选

静态输出文件的文件名。

可以是:

  • undefined - 默认为 out 加上适当的文件扩展名,例如:renders/${renderId}/out.mp4
  • 一个 string - 将保存到与您的站点相同的云存储桶中,键为 renders/{renderId}/{outName}。请确保在字符串末尾包含文件扩展名。

delayRenderTimeoutInMilliseconds?

可选

描述渲染可能需要多长时间来解析所有 delayRender() 调用在超时之前。默认值:30000

offthreadVideoCacheSizeInBytes?v4.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

返回值

返回一个解析为包含以下内容的对象的 Promise:

renderId

此渲染的唯一字母数字标识符。用于获取状态并在云存储桶中找到相关文件。

bucketName

正在保存所有文件的云存储桶名称。

privacy

输出文件的隐私性,可以是:

  • "public-read" - 在 Cloud 存储 URL 下公开访问。
  • "project-private" - 不公开,但对具有正确权限的 GCP 项目内的用户可用。

publicUrl

如果隐私设置为公开,则这将是渲染文件的公开访问 URL。如果隐私性不是公开的,则为 null。

cloudStorageUri

Google 存储路径,以 gs://{bucket-name} 开头。可与 gsutil CLI 工具一起使用。

size

以 KB 为单位的渲染静态文件大小。

另请参阅