Skip to main content

Remotion Lambda 是如何工作的

本文档描述了在触发 Remotion Lambda 视频渲染时执行的过程。

🌐 This document describes the procedure that gets executed when a Remotion Lambda video render is triggered.

note

本文档解释了从版本 4.0.165 起的 Lambda 架构。
以前,Lambda 函数不使用响应流,而是将数据块保存到 S3。

A single Lambda function is invoked using renderMediaOnLambda() - either directly or via the CLI which also calls this API. This invocation is called the main function.
2
The main function visits the Serve URL that it is being passed in a headless browser.
3
The main function finds the composition based on the composition ID that was passed and runs the props resolution algorithm to determine the props that should be passed to the video as well as the metadata (such as the duration in frames).
4
Based on the determined duration of the video and the concurrency , several renderer functions are spawned, which are tasked to render a portion of the video.
5
The renderer functions use AWS Lambda Response Streaming to report progress as well as the binary video chunks.
6
The main function concatenates the progress reports into a concise progress.json file and periodically uploads it to S3.
7
The getRenderProgress() API queries the S3 bucket for the progress.json file and returns the progress of the render.
8
As soon as all chunks have arrived in the main function, they get seamlessly concatenated. The concatenation algorithm is not a public API at the moment.
9
The main function uploads the final video to S3 and shuts down.

常见问题

🌐 FAQ

我可以自己开发一个分布式渲染器吗?

🌐 Can I roll my own distributed renderer?

目前,块的无缝连接不是公开的 API。
你可以使用 frameRangeaudioCodec: "pcm-16" 渲染块,然后使用 FFmpeg 将它们连接起来。

🌐 The seamless concatenation of chunks is not a public API at the moment.
You may render chunks using frameRange and audioCodec: "pcm-16" which you can concatenate using FFmpeg.

构建分布式渲染器很困难,并且不推荐大多数人使用。

🌐 Building a distributed renderer is hard, and not recommended for most.

每个块都会下载所有资源吗?

🌐 Will each chunk download all assets?

每个块将下载在此块中引用的所有资源。 这可能导致资源被多次同时下载,从而可能使服务器不堪重负或触发速率限制。此外,即使资源在 S3 上,你也需要为带宽付费。

在设计你的解决方案时请记住这一点,并考虑使用CDN来提供资源。

🌐 Keep this in mind when designing your solution and consider using a CDN to serve assets.


1) 一个用于避免 S3 带宽费用的 API 被 计划了。