deployFunction()
在你的 AWS 账户中创建一个 AWS Lambda 函数,该函数将能够在云端渲染视频。
🌐 Creates an AWS Lambda function in your AWS account that will be able to render a video in the cloud.
如果具有相同版本、内存大小和超时设置的函数已经存在,将返回该函数,而不会创建新的函数。这意味着该函数可以被视为幂等的。
🌐 If a function with the same version, memory size and timeout already existed, it will be returned instead without a new one being created. This means this function can be treated as idempotent.
示例
🌐 Example
import {deployFunction } from '@remotion/lambda';
const {functionName } = await deployFunction ({
region : 'us-east-1',
timeoutInSeconds : 120,
memorySizeInMb : 2048,
createCloudWatchLogGroup : true,
diskSizeInMb : 2048,
});
console .log (functionName );参数
🌐 Arguments
一个具有以下属性的对象:
🌐 An object with the following properties:
region
你希望将 Lambda 函数部署到的 AWS 区域。它必须与你的 Lambda 层所在的区域相同。
🌐 The AWS region which you want to deploy the Lambda function too. It must be the same region that your Lambda Layer resides in.
timeoutInSeconds
Lambda 函数在被终止之前可以运行的最长时间。必须低于 900 秒。 我们建议超时时间为 120 秒或更短——请记住,如果你使用高并发进行渲染,Remotion Lambda 是最快的。如果你的视频渲染时间较长,应增加并发性而不是延长超时时间。
🌐 How long the Lambda function may run before it gets killed. Must be below 900 seconds. We recommend a timeout of 120 seconds or lower - remember, Remotion Lambda is the fastest if you render with a high concurrency. If your video takes longer to render, the concurrency should be increased rather than the timeout.
memorySizeInMb
Lambda 函数应拥有多少兆字节的内存。默认情况下,我们建议使用 2048MB。你可以根据视频的内存消耗情况增减此值。允许的最小值为 512,允许的最大值为 10240。由于 Remotion Lambda 的费用与内存量直接相关,我们建议尽量保持此值尽可能低。
🌐 How many megabytes of RAM the Lambda function should have. By default we recommend a value of 2048MB. You may increase or decrease it depending on how memory-consuming your video is. The minimum allowed number is 512, the maximum allowed number is 10240. Since the costs of Remotion Lambda is directly proportional to the amount of RAM, we recommend to keep this amount as low as possible.
createCloudWatchLogGroup?
是否应该将日志保存到 CloudWatch。我们建议启用此选项。
🌐 Whether logs should be saved into CloudWatch. We recommend enabling this option.
cloudWatchLogRetentionPeriodInDays?
CloudWatch 日志的保留期限。默认值:14 天。
🌐 Retention period for the CloudWatch Logs. Default: 14 days.
diskSizeInMb?
设置 Lambda 函数可用的磁盘存储量。必须在 512MB 到 10240MB(10GB)之间。如果你想渲染更长的视频,请将其设置得更高。参见: 磁盘大小
🌐 Sets the amount of disk storage that is available in the Lambda function. Must be between 512MB and 10240MB (10GB). Set this higher if you want to render longer videos. See also: Disk size
| Remotion 版本 | 默认 |
|---|---|
| <5.0.0 | 2048MB |
| >=5.0.0 | 10240MB |
customRoleArn?
使用自定义角色来执行该功能,而不是默认角色(arn:aws:iam::[aws-account-id]:role/remotion-lambda-role)
🌐 Use a custom role for the function instead of the default (arn:aws:iam::[aws-account-id]:role/remotion-lambda-role)
enableLambdaInsights?v4.0.61
Enable Lambda Insights in AWS CloudWatch. For this to work, you may have to update your role permission.
runtimePreference?v4.0.205
其中之一:
🌐 One of:
default:当前解析为cjkapple-emojis:使用苹果表情符号而不是谷歌表情符号。CJK 字符将被移除。cjk:包含中日韓(CJK)字符和谷歌表情符号。苹果表情符号将被移除。
苹果表情符号是苹果公司的知识产权。
你对在项目中使用苹果表情符号负责。
返回值
🌐 Return value
一个具有以下值的对象:
🌐 An object with the following values:
functionName(字符串): 刚创建的函数的名称。alreadyExisted:(boolean): 创建是否被跳过,因为该函数已存在。
另请参阅
🌐 See also