renderStillOnLambda()
在 lambda 函数内呈现静态图像,并将其写入指定的输出位置。
如果要呈现视频或音频,请改用 renderMediaOnLambda()
。
如果要在本地呈现静态图像,请改用 renderStill()
。
示例
tsx
import {renderStillOnLambda } from "@remotion/lambda/client";const {estimatedPrice ,url ,sizeInBytes } = awaitrenderStillOnLambda ({region : "us-east-1",functionName : "remotion-render-bds9aab",serveUrl :"https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",composition : "MyVideo",inputProps : {},imageFormat : "png",maxRetries : 1,privacy : "public",envVariables : {},frame : 10,});
tsx
import {renderStillOnLambda } from "@remotion/lambda/client";const {estimatedPrice ,url ,sizeInBytes } = awaitrenderStillOnLambda ({region : "us-east-1",functionName : "remotion-render-bds9aab",serveUrl :"https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",composition : "MyVideo",inputProps : {},imageFormat : "png",maxRetries : 1,privacy : "public",envVariables : {},frame : 10,});
最好从 @remotion/lambda/client
导入此函数,以避免 在无服务器函数内 出现问题。
参数
具有以下属性的对象:
region
Lambda 函数部署的区域。强烈建议您的 Remotion 站点也位于同一区域。
functionName
部署的 Lambda 函数的名称。
使用 deployFunction()
创建新函数,并使用 getFunctions()
获取当前部署的 Lambdas。
serveUrl
指向 Remotion 项目的 URL。使用 deploySite()
部署 Remotion 项目。
composition
要呈现的 composition 的 id
。
inputProps
传递给视频所选 composition 的输入属性。。
必须是 JSON 对象。
从根组件可以使用 getInputProps()
读取属性。
您可以使用 calculateMetadata()
转换输入属性。
privacy
其中之一:
"public"
(默认):呈现的静态图像在 S3 URL 下是公开可访问的。"private"
:呈现的静态图像不是公开可用的,但可以使用 presignUrl() 创建签名链接。"no-acl"
(从 v.3.1.7 开始提供):ACL 选项根本不设置,如果您要写入不 支持 ACL 的另一个存储桶,则此选项很有用,使用outName
。
frame?
可选 - 默认 0
应该呈现哪个合成的帧。帧是从零开始索引的。
从 v3.2.27 开始,允许负值,-1 表示最后一帧。
imageFormat?
可选 - 默认 "png"
请参阅 renderStill() -> imageFormat
。
onInit?
v4.0.6
在渲染开始时调用的回调函数,有助于在渲染失败时获取日志链接。
它接收一个具有以下属性的对象:
renderId
:渲染的 ID。cloudWatchLogs
:Lambda 函数的 CloudWatch 日志链接,如果您没有禁用它。lambdaInsightsUrl
v4.0.61:Lambda 洞察的链接,如果您启用了它。
示例用法:
tsx
import {renderStillOnLambda ,RenderStillOnLambdaInput ,} from "@remotion/lambda/client";constotherParameters :RenderStillOnLambdaInput = {region : "us-east-1",functionName : "remotion-render-bds9aab",serveUrl :"https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",composition : "MyVideo",inputProps : {},imageFormat : "png",maxRetries : 1,privacy : "public",envVariables : {},frame : 10,};awaitrenderStillOnLambda ({...otherParameters ,onInit : ({cloudWatchLogs ,renderId ,lambdaInsightsUrl }) => {console .log (console .log (`Render invoked with ID = ${renderId }`));console .log (`CloudWatch logs (if enabled): ${cloudWatchLogs }`);console .log (`Lambda Insights (if enabled): ${lambdaInsightsUrl }`);},});
tsx
import {renderStillOnLambda ,RenderStillOnLambdaInput ,} from "@remotion/lambda/client";constotherParameters :RenderStillOnLambdaInput = {region : "us-east-1",functionName : "remotion-render-bds9aab",serveUrl :"https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",composition : "MyVideo",inputProps : {},imageFormat : "png",maxRetries : 1,privacy : "public",envVariables : {},frame : 10,};awaitrenderStillOnLambda ({...otherParameters ,onInit : ({cloudWatchLogs ,renderId ,lambdaInsightsUrl }) => {console .log (console .log (`Render invoked with ID = ${renderId }`));console .log (`CloudWatch logs (if enabled): ${cloudWatchLogs }`);console .log (`Lambda Insights (if enabled): ${lambdaInsightsUrl }`);},});
jpegQuality?
可选
设置生成的 JPEG 图像的质量。必须是介于 0 和 100 之间的整数。默认情况下由浏览器决定,当前默认值为 80。
仅当 imageFormat
为 "jpeg"
时才适用,否则此选项无效。
quality?
quality?
在 v4.0.0
中更名为 jpegQuality
。
maxRetries?
可选 - 默认 1
帧渲染可以重试多少次,直到失败。
仅当错误在 不稳定错误列表 中时才执行重试。
envVariables?
可选 - 默认 {}
请参阅 renderStill() -> envVariables
。
forceHeight?
可选,从 v3.2.40 开始可用
覆盖默认合成高度。
forceWidth?
可选,从 v3.2.40 开始可用
覆盖默认合成宽度。
scale?
可选
通过因子缩放输出尺寸。请参阅 Scaling 了解更多关于此功能的信息。
outName?
可选
可以是以下之一:
undefined
- 默认为out
加上适当的文件扩展名,例如:renders/${renderId}/out.mp4
。- 一个
string
- 将保存到与您的站点相同的 S3 存储桶中,键为renders/{renderId}/{outName}
。请确保在字符串末尾包含文件扩展名。 - 如果要渲染到不同的存储桶或云提供商,则为一个对象 - 请参见此处以获取详细说明。
timeoutInMilliseconds?
可选
描述渲染可能需要多长时间来解析所有 delayRender()
调用 在超时之前。默认值:30000
downloadBehavior?
可选,自 v3.1.5 起可用
在通过浏览器中的 S3 输出链接访问输出文件时应如何行为。
要么:
{"type": "play-in-browser"}
- 默认值。视频将在浏览器中播放。{"type": "download", fileName: null}
或{"type": "download", fileName: "download.mp4"}
- 将添加一个Content-Disposition
头,使浏览器下载文件。您可以选择性地覆盖文件名。
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
deleteAfter?
v4.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.
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 isswangle
(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"
userAgent
v3.3.83
允许您设置 headless Chrome 浏览器所假定的自定义用户代理。
forceBucketName?
可选
指定要使用的特定存储桶名称。不建议这样做,而是让 Remotion 自动发现正确的存储桶。
logLevel?
可选
One ofverbose
, 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 读取日志。
forcePathStyle?
v4.0.202
将 forcePathStyle
传递给 AWS S3 客户端。如果您不知道这是什么,您可能不需要它。
dumpBrowserLogs?
dumpBrowserLogs?
可选 - 默认为 false
,在 v4.0 中已弃用
已弃用,建议使用 logLevel
。
返回值
返回一个解析为具有以下属性的对象的 Promise:
bucketName
视频保存在其中的 S3 存储桶。
url
可用的 AWS S3 URL,输出可在其中找到。
outKey
v4.0.141
输出保存的 S3 键。
estimatedPrice
包含关于此操作费用的粗略估算信息的对象。
sizeInBytes
输出图像的大小(以字节为单位)。
renderId
此渲染的唯一字母数字标识符。用于获取状态并在 S3 存储桶中找到相关文件。
cloudWatchLogs
从 v3.2.10 开始可用
CloudWatch 的链接(如果您未禁用它),您可以访问以查看渲染的日志。
artifacts
v4.0.176
在渲染过程中迄今创建的工件。请参阅此处以查看处理字段的示例。