Skip to main content

常见问题

关于 Remotion Lambda 的一些常见问题。

🌐 Some commonly asked questions about Remotion Lambda.

Lambda 是自托管的吗?

🌐 Is Lambda self-hosted?

是的,你需要在自己的 AWS 账户中托管 Remotion Lambda。Remotion 目前不提供托管渲染解决方案。

🌐 Yes, you host Remotion Lambda in your own AWS account. Remotion does not offer a hosted rendering solution at this time.

我需要为每次渲染部署一个函数吗?

🌐 Do I need to deploy a function for each render?

不,一般来说,你只需要部署一个函数,它就能够渲染多个视频,甚至可以跨不同的项目。

🌐 No, in general you only need to deploy one function and it will be capable of rendering multiple videos, even across different projects.

有三种例外情况可以部署多个功能:

🌐 There are three exceptions when it is possible to deploy multiple functions:

  • 如果你使用多个区域,则需要为每个区域部署一个函数。
  • 如果你正在升级到更新版本的 Remotion Lambda,则需要部署一个新函数。然后,你可以同时运行新旧函数。@remotion/lambda CLI 将始终选择你 AWS 账户中与客户端包版本相同的函数。如果你使用 getFunctions() Node.JS API,请将 compatibleOnly 标志设置为 true,以筛选发布本与 @remotion/lambda 包不匹配的函数。
  • 如果你正在部署具有不同内存大小、磁盘大小或超时设置的函数,则可以创建一个新函数。但是,目前如果有多个合适的函数可用,Remotion 将会随机选择其中一个。因此,你应该仅使用此策略来更改函数的参数,而不会导致停机。

我可以同时渲染多少个视频?

🌐 How many videos can I render concurrently?

这取决于你 AWS 账户的并发限制。 每次渲染会使用 3 到 200 个并发 Lambda 函数,具体取决于渲染的并发。 如果你超过并发限制,将会收到来自 AWS Lambda 的 TooManyRequestsException 错误。

🌐 It depends on the concurrency limit of your AWS account.
Every render uses between 3 and 200 concurrent Lambda functions, depending on the concurrency of the render.
If you exceed the concurrency limit, you will get an TooManyRequestsException error from AWS Lambda.

我需要创建多个存储桶吗?

🌐 Do I need to create multiple buckets?

仅推荐每个区域使用一个桶

🌐 Only one bucket per region is recommended.

我需要部署多个站点吗?

🌐 Do I need to deploy multiple sites?

你可以部署一个网站,并将其用于所需的任意数量渲染。如果你有多个网站,你可以部署它们所有网站,并重用相同的 Lambda 函数。

🌐 You can deploy one site and use it for as many renders as you need. If you have multiple sites, you can deploy all of them and reuse the same Lambda function.

如果我想渲染更长的视频怎么办?

🌐 What if I want to render longer videos?

你不需要担心 Lambda 函数的超时,因为 Remotion 会将视频分成许多部分并并行渲染它们。然而,你需要注意可能不能超过的存储限制。参见:磁盘大小

🌐 You don't need to worry about the timeout of a Lambda function because Remotion splits the video in many parts and renders them in parallel. However, you need to be aware of the storage limits that may not be exceeded. See: Disk size

你为什么不使用 Amazon EFS?

🌐 Why are you not using Amazon EFS?

我们评估了亚马逊弹性文件系统(EFS),发现EFS的速度优势不足以证明其增加的复杂性是合理的——为了集成EFS,需要创建VPC和安全组,这将禁用公共互联网访问。为了恢复公共互联网访问,需要创建一个持久的EC2实例来代理流量,这抵消了Lambda的许多优势。

🌐 We have evaluated Amazon Elastic File System (EFS) and we found the speed benefits of EFS are not substantial enough to warrant the increased complexity - for EFS to be integrated, VPC and security groups need to be created which will disable public internet access. To restore public internet access, a persistent EC2 instance needs to be created for proxying the traffic, negating many benefits of Lambda.

Remotion Lambda 多少钱?

🌐 How much does Remotion Lambda cost?

有两个成本组成部分:Remotion 许可证费(请参见 定价,仅适用于公司)和 AWS 成本。AWS 成本取决于你为 Lambda 函数分配的内存量。我们会为你估算 Lambda 成本,并在 API 响应中报告。

🌐 There are two cost components: The Remotion licensing fee (see pricing, only applies if you are a company) and the AWS costs. AWS cost is dependant on the amount of memory that you assign to your lambda function. We estimate the Lambda costs for you and report it in the API response.

我如何升级/重新部署 Lambda 函数?

🌐 How can I upgrade/redeploy a Lambda function?

Remotion 将寻找与 Node.JS 库 / CLI 匹配的 lambda 函数版本。

🌐 Remotion will look for a version of the lambda function that matches the Node.JS library / CLI.

如果你不再依赖旧功能,你可以先删除所有现有功能:

🌐 If you don't rely on the old function anymore, you can first delete all existing functions:

npx remotion lambda functions rmall

你可以使用以下方式部署新功能:

🌐 You can deploy a new function using:

npx remotion lambda functions deploy

如果你正在使用 Node.JS API,以下 API 很有用:getFunctions()deployFunction()deleteFunction()

🌐 If you are using the Node.JS APIs, the following APIs are useful: getFunctions(), deployFunction() and deleteFunction().

我可以修改在 Lambda 内运行的代码吗?

🌐 Can I modify the code that is run inside the Lambda?

在 Lambda 内运行的代码是由 Remotion 提供的执行器二进制文件。你不能编写代码来运行在 Remotion 为你部署的函数内部,但你可以使用许多配置选项,并且可以通过诸如 renderMediaOnLambda 这样的 API 从另一个 Lambda 函数调用 Remotion Lambda 函数。

🌐 The code that is run inside the Lambda is an executor binary that is provided by Remotion. You cannot write code to run inside the function that Remotion deploys for you, but you can make use of many configuration options and call a Remotion Lambda function from another Lambda function using APIs like renderMediaOnLambda.

在 Remotion Lambda 函数中运行的源代码可以在这里找到,并在必要时进行分叉。我们建议首先联系 Remotion 团队,并确认是否真的有必要分叉。

🌐 The source code of what is run inside a Remotion Lambda function can be found here and forked if necessary. We recommend to reach out to the Remotion team first and check if a fork is really necessary.

我可以让网站变为私密吗?

🌐 Can I make a site private?

当你在 Lambda 上渲染视频时,你需要指定一个指向 Remotion 代码的 Webpack 包的 Serve URL。 这是一个 URL,如果被知道,任何人都可以公开访问。

🌐 When you render a video on Lambda, you specify a Serve URL pointing to a Webpack bundle of Remotion code.
This is a URL that, if known, can be publicly accessed by anyone.

Lambda 函数需要启动一个无头浏览器并访问这个 URL,以便渲染视频。 桶中的项目不能设为私有,因为它们需要通过无头浏览器的 URL 进行访问。

🌐 The Lambda function needs to spawn a headless browser and visit this URL in order to render the video.
The items in the bucket cannot be made private because they need to be accessible via URL in the headless browser.

确保不要在代码中硬编码敏感数据,例如 API 密钥或用户数据。 相反,使用 renderMediaOnLambda()inputPropsenvVariables 选项在渲染期间传递数据。 这些值永远不会被公开访问。

🌐 Make sure to not hardcode sensitive data in your code, such as API keys, or user data.
Instead, use the inputProps and envVariables options of renderMediaOnLambda() to pass data during the render.
Those values will never be publicly accessible.

通过使你的网站通过 Serve URL 可用,你可能会暴露你的压缩 React 代码。
这通常不是问题,因为任何网站都会暴露它们的压缩前端代码。

🌐 By making your site available under a Serve URL, you may expose your minified React code.
This is normally not a problem, because any website will expose their minified frontend code.

如果你想让你的网站更私密,你可以:

🌐 If you would like to make your site more private, you can:

  • 使用更长、难以猜到的站点名称
  • 在你的存储桶根目录放置一个 robots.txt,并设置一个 Disallow: / 规则,以防止爬虫访问你的网站以及你的网站出现在搜索结果中。

只有你可以触发你账户上的渲染

🌐 Only you can trigger renders on your account

通过 Serve URL 让网站可访问,并不会允许任何人在你的账户上触发 Lambda 渲染。
该 URL 仅提供 HTML、JavaScript 和资源,但确实公开了访问你 AWS 账户上任何计算的权限。

🌐 Making the site accessible via a Serve URL will not allow anyone to trigger a Lambda render on your account.
The URL only serves HTML, JavaScript and assets, but does expose access to invoking any computation on your AWS account.

我是否每次渲染都必须部署一个新站点?

🌐 Do I have to deploy a new site for every render?

不,你不应该每次渲染都部署一个新的包。相反,你应该只部署一次你的网站,并将视频的所有内容参数化:

🌐 No, you shouldn’t have to deploy a new bundle for every render. Instead, deploy your site once and parametrize everything about the video:

  • 使用 inputProps 来参数化视频的内容。例如,你可以传递一个应该出现在视频中的元素数组。
  • 使用 calculateMetadata() 来参数化视频的时长、尺寸和帧率。
  • 如果你有多个不同的模板,它们不共享数据结构,请部署一个包含多个 <Composition> 的包。

另见:“Passing props”

🌐 See also: Passing props