renderStillOnLambda()
在 lambda 函数中渲染静止图片并将其写入指定的输出位置。
🌐 Renders a still image inside a lambda function and writes it to the specified output location.
如果你想渲染视频或音频,请改用 renderMediaOnLambda()。
🌐 If you want to render a video or audio instead, use renderMediaOnLambda() instead.
如果你想改为在本地呈现静帧,请改用 renderStill()。
🌐 If you want to render a still locally instead, use renderStill() instead.
示例
🌐 Example
import {renderStillOnLambda } from '@remotion/lambda/client';
const {estimatedPrice , url , sizeInBytes } = await renderStillOnLambda ({
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 导入这个函数,以避免 在无服务器函数中 出现问题。
参数
🌐 Arguments
一个具有以下属性的对象:
🌐 An object with the following properties:
region
你的 Lambda 函数部署在哪个区域。强烈建议你的 Remotion 网站也部署在同一个区域。
🌐 In which region your Lambda function is deployed. It's highly recommended that your Remotion site is also in the same region.
functionName
已部署的 Lambda 函数的名称。使用 deployFunction() 创建新函数,使用 getFunctions() 获取当前已部署的 Lambda。
🌐 The name of the deployed Lambda function.
Use deployFunction() to create a new function and getFunctions() to obtain currently deployed Lambdas.
serveUrl
指向 Remotion 项目的 URL。使用 deploySite() 来部署 Remotion 项目。
🌐 A URL pointing to a Remotion project. Use deploySite() to deploy a Remotion project.
composition
你想要呈现的作品的id..
🌐 The id of the composition you want to render..
inputProps
传递给所选视频组合的输入属性。。
必须是一个 JSON 对象。
可以从根组件使用 getInputProps() 读取属性。
你可以使用 calculateMetadata() 转换输入属性。
privacy
其中之一:
🌐 One of:
"public"(默认): 渲染的静态图片可以通过 S3 URL 公开访问。"private":渲染的静态图片尚未公开,但可以使用 presignUrl() 创建带签名的链接。"no-acl"(从 v.3.1.7 开始可用):ACL 选项根本没有被设置,如果你使用outName写入另一个不支持 ACL 的存储桶时,此选项很有用。
frame?
应该渲染作品的哪一帧。默认值:0。帧从零开始计数。
🌐 Which frame of the composition should be rendered. Default: 0. Frames are zero-indexed.
从 v3.2.27 起,允许负值,其中 -1 是最后一帧。
🌐 From v3.2.27, negative values are allowed, with -1 being the last frame.
imageFormat?
见 renderStill() -> imageFormat。默认值:"png"。
🌐 See renderStill() -> imageFormat. Default: "png".
onInit?v4.0.6
当渲染开始时调用的回调函数,即使渲染失败,也可用于获取日志的链接。
🌐 A callback function that gets called when the render starts, useful to obtain the link to the logs even if the render fails.
它接收一个具有以下属性的对象:
🌐 It receives an object with the following properties:
renderId:渲染的ID。cloudWatchLogs:Lambda 函数的 CloudWatch 日志链接,如果你没有禁用它的话。lambdaInsightsUrlv4.0.61:一个指向 Lambda insights 的链接,如果你已启用它。
示例用法:
🌐 Example usage:
import {renderStillOnLambda , RenderStillOnLambdaInput } from '@remotion/lambda/client';
const otherParameters : 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,
};
await renderStillOnLambda ({
...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。
🌐 Sets the quality of the generated JPEG images. Must be an integer between 0 and 100. Default is to leave it up to the browser, current default is 80.
仅在 imageFormat 为 "jpeg" 时适用,否则此选项无效。
🌐 Only applies if imageFormat is "jpeg", otherwise this option is invalid.
quality?
quality?在 v4.0.0 中重命名为 jpegQuality。
🌐 Renamed to jpegQuality in v4.0.0.
maxRetries?
一帧渲染在失败前可以重试的次数。默认值:1。
🌐 How often a frame render may be retried until it fails. Default: 1.
只有当错误在 不稳定错误列表 中时,才会执行重试。
envVariables?
见 renderStill() -> envVariables。默认值:{}。
🌐 See renderStill() -> envVariables. Default: {}.
forceHeight?v3.2.40
覆盖默认的合成高度。
🌐 Overrides the default composition height.
forceWidth?v3.2.40
覆盖默认的合成宽度。
🌐 Overrides the default composition width.
forceFps?v4.0.424
覆盖默认的合成帧率。
🌐 Overrides the default composition FPS.
forceDurationInFrames?v4.0.424
覆盖默认的合成帧数持续时间。
🌐 Overrides the default composition duration in frames.
scale?
Scales the output dimensions by a factor. For example, a 1280x720px frame will become a 1920x1080px frame with a scale factor of 1.5. See Scaling for more details.
outName?
它可以是:
🌐 It can either be:
undefined- 它将默认为out加上适当的文件扩展名,例如:renders/${renderId}/out.mp4。- 一个
string- 它将被保存到与你的网站相同的 S3 存储桶下,键为renders/{renderId}/{outName}。确保在字符串末尾包含文件扩展名。 - 如果你想将对象渲染到不同的存储桶或云提供商,请参见此处的详细说明(/docs/lambda/custom-destination)。
timeoutInMilliseconds?
一个数字,描述渲染可能花多长时间来解决所有 delayRender() 调用 在超时之前。默认值:30000
🌐 A number describing how long the render may take to resolve all delayRender() calls before it times out. Default: 30000
downloadBehavior?v3.1.5
当通过浏览器中的 S3 输出链接访问输出文件时,输出文件应如何表现。
可以是:
🌐 How the output file should behave when accessed through the S3 output link in the browser.
Either:
{"type": "play-in-browser"}- 默认设置。视频将在浏览器中播放。{"type": "download", fileName: null}或{"type": "download", fileName: "download.mp4"}- 将添加一个Content-Disposition头,使浏览器下载文件。你可以选择覆盖文件名。
mediaCacheSizeInBytes?v4.0.352
Specify the maximum size of the cache that <Video> and <Audio> from @remotion/media may use combined, in bytes. The default is half of the available system memory when the render starts.
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
offthreadVideoThreads?v4.0.261
The number of threads that<OffthreadVideo> can start to extract frames. The default is 2. Increase carefully, as too many threads may cause instability.
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 标志。
🌐 Allows you to set certain Chromium / Google Chrome flags. See: Chromium flags.
disableWebSecurity
boolean - 默认 false
🌐 boolean - default false
这将尤其会禁用 CORS 以及其他安全功能。
🌐 This will most notably disable CORS among other security features.
ignoreCertificateErrors
boolean - 默认 false
🌐 boolean - default false
导致无效的 SSL 证书(例如自签名证书)被忽略。
🌐 Results in invalid SSL certificates, such as self-signed ones, being ignored.
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"
userAgentv3.3.83
允许你设置 headless Chrome 浏览器使用的自定义用户代理。
🌐 Lets you set a custom user agent that the headless Chrome browser assumes.
darkMode?v4.0.381
Whether Chromium should pretend to be in dark mode by emulating the media feature 'prefers-color-scheme: dark'. Default is false.
forceBucketName?
指定要使用的特定存储桶名称。这不推荐,最好让 Remotion 自动发现正确的存储桶。
🌐 Specify a specific bucket name to be used. This is not recommended, instead let Remotion discover the right bucket automatically.
logLevel?
One of trace, verbose, info, warn, error.Determines how much info is being logged to the console.
Default
info.
可以通过此函数返回的 CloudWatch URL 查看日志。
🌐 Logs can be read through the CloudWatch URL that this function returns.
forcePathStyle?v4.0.202
将 forcePathStyle 传递给 AWS S3 客户端。如果你不知道这是什么,你很可能用不到它。
🌐 Passes forcePathStyle to the AWS S3 client. If you don't know what this is, you probably don't need it.
storageClass?v4.0.305
用于渲染媒体的 S3 存储类的 标识符。默认值:undefined(即 STANDARD)。
🌐 An identifier for the S3 storage class of the rendered media. Default: undefined (which is STANDARD).
licenseKey?v4.0.409
License key for sending a usage event using @remotion/licensing.
isProduction?v4.0.409
默认 true
🌐 default true
false if this a development render to not count it as a billable render on remotion.pro. Only can be used in conjuction with licenseKey.
dumpBrowserLogs?
dumpBrowserLogs?在 v4.0 中被弃用,取而代之的是 logLevel。
🌐 Deprecated in v4.0 in favor of logLevel.
返回值
🌐 Return value
返回一个解析为具有以下属性的对象的 Promise:
🌐 Returns a promise resolving to an object with the following properties:
bucketName
视频保存的 S3 存储桶。
🌐 The S3 bucket in which the video was saved.
url
输出可用的 AWS S3 URL。
🌐 An AWS S3 URL where the output is available.
outKeyv4.0.141
输出保存的 S3 密钥。
🌐 The S3 key where the output is saved.
estimatedPrice
包含有关此操作大致费用估计信息的对象。
🌐 Object containing roughly estimated information about how expensive this operation was.
sizeInBytes
输出图片的字节大小。
🌐 The size of the output image in bytes.
renderId
此渲染的唯一字母数字标识符。用于获取状态和在 S3 存储桶中查找相关文件。
🌐 A unique alphanumeric identifier for this render. Useful for obtaining status and finding the relevant files in the S3 bucket.
cloudWatchLogsv3.2.10
一个指向 CloudWatch 的链接(如果你没有禁用它),你可以访问该链接查看渲染的日志。
🌐 A link to CloudWatch (if you haven't disabled it) that you can visit to see the logs for the render.
artifactsv4.0.176
在渲染期间迄今为止创建的工件。在这里查看处理字段的示例。
🌐 Artifacts that were created so far during the render. See here for an example of dealing with field.
另请参阅
🌐 See also