Skip to main content

getCompositionsOnLambda()

从 v3.3.2 开始可用

获取 Lambda 函数内的组合。

请注意,您还可以使用 getCompositions() 获取托管在 Lambda 上的站点的组合。反之亦然,您还可以使用 getCompositionsOnLambda() 从未托管在 AWS Lambda 上的服务 URL 获取组合。

如果机器无法运行 Chrome,则应使用 getCompositionsOnLambda(),而无法使用 getCompositions()

示例

tsx
import { getCompositionsOnLambda } from "@remotion/lambda/client";
 
const compositions = await getCompositionsOnLambda({
region: "us-east-1",
functionName: "remotion-render-bds9aab",
serveUrl:
"https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",
inputProps: {},
});
 
console.log(compositions); // See below for an example value
tsx
import { getCompositionsOnLambda } from "@remotion/lambda/client";
 
const compositions = await getCompositionsOnLambda({
region: "us-east-1",
functionName: "remotion-render-bds9aab",
serveUrl:
"https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",
inputProps: {},
});
 
console.log(compositions); // See below for an example value
note

最好从 @remotion/lambda/client 导入此函数,以避免在无服务器函数中出现问题。

参数

具有以下属性的对象:

functionName

应用于获取组合列表的部署 Lambda 函数的名称。 使用 deployFunction() 创建新函数,并使用 getFunctions() 获取当前部署的 Lambdas。

region

Lambda 函数部署的区域。

serveUrl

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

inputProps

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

envVariables?

可选 - 默认值 {}

参见 renderMedia() -> envVariables

timeoutInMilliseconds?

描述函数在多少毫秒内评估组合列表超时之前的数字。默认值:30000

chromiumOptions?

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

disableWebSecurity

boolean - 默认 false

这将主要禁用 CORS 和其他安全功能。

ignoreCertificateErrors

boolean - 默认 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"

userAgentv3.3.83

允许您设置头less Chrome 浏览器所假定的自定义用户代理。

forceBucketName?

从 v3.3.42 开始可用

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

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.

可以通过此函数返回的 CloudWatch URL 读取日志。

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

dumpBrowserLogs?

可选 - 默认 false,在 v4.0 中已弃用

已弃用,推荐使用 logLevel

返回值

返回一个解析为可用组合数组的 Promise。示例值:

ts
[
{
id: "HelloWorld",
width: 1920,
height: 1080,
fps: 30,
durationInFrames: 120,
defaultProps: {
title: "Hello World",
},
},
{
id: "Title",
width: 1080,
height: 1080,
fps: 30,
durationInFrames: 90,
defaultProps: undefined,
},
];
ts
[
{
id: "HelloWorld",
width: 1920,
height: 1080,
fps: 30,
durationInFrames: 120,
defaultProps: {
title: "Hello World",
},
},
{
id: "Title",
width: 1080,
height: 1080,
fps: 30,
durationInFrames: 90,
defaultProps: undefined,
},
];