Skip to main content

优化速度

在本页中,介绍了一些使在 Lambda 上渲染尽可能快的策略。

🌐 On this page, a few strategies are presented for making a render on Lambda as fast as possible.

更高的并发性

🌐 Higher concurrency

通常,framesPerLambda 的较低值会导致更高的并发性,从而有机会在较短的绝对时间内完成渲染。同时,会产生更多的开销,使渲染变得更昂贵。你还会遇到收益递减的情况,添加过多的并发可能会使速度变慢,因为协调多个 Lambda 函数的开销超过了收益。有关更多信息,请参阅 Lambda 并发 页面。

🌐 Generally, a lower value for framesPerLambda will result in higher concurrency and therefore an opportunity to finish the render in less absolute time. At the same time, more overhead will be produced, making the render more expensive. You will also experience diminishing returns, and adding too much concurrency can make the speed slower because the overhead of orchestrating many Lambda functions outweigh the gains. See the Lambda Concurrency page for more information.

更多内存

🌐 More memory

在 Lambda 上增加更多内存也会按比例提高 Lambda 的 CPU 功率,从而使渲染更快。与此同时,成本也会随着你增加的内存线性增加。

🌐 Adding more memory on Lambda will also scale up the CPU power on Lambda proportionally, therefore making the render faster. At the same time, the cost also linearly increases with the memory you add.

concurrencyPerLambda 属性

🌐 concurrencyPerLambda property

renderMediaOnLambda() 中的 concurrencyPerLambda 属性允许你在单个 Lambda 函数中打开多个浏览器标签,从而有机会一次执行更多工作。如果 Lambda 函数过于繁忙,增加并发度也可能适得其反。

🌐 The concurrencyPerLambda property in renderMediaOnLambda() allows you to open multiple browser tabs in a single Lambda function, therefore opening an opportunity to do more work at once. If the Lambda function is too busy, increasing the concurrency might also be counterproductive.

使用 speculateFunctionName()

🌐 Use speculateFunctionName()

你可以不调用 getFunctions(),而是调用 speculateFunctionName() 来计算你即将调用的函数的名称,以节省一次 API 调用并最多节省 1 秒钟。

🌐 Instead of calling getFunctions(), you can call speculateFunctionName() to calculate the name of the function you are about to call to save an API call and save up to 1 second.

桶命名

🌐 Bucket naming

如果你的 Remotion 版本在 2022 年 12 月之前,那么你的存储桶名称可能不包含区域名称。这将导致 Remotion 在启动渲染之前必须列出所有存储桶名称并查询它们的区域。

🌐 If you have a Remotion version before December 2022, then your bucket name might not include the region name in its name. This will result in Remotion having to list all bucket names and query their region before kicking off the render.

查看更多信息请参阅此文章。考虑重新命名你的存储桶或重新设置 Remotion Lambda 以提升速度。如果你在多个区域使用许多 Remotion 存储桶,这一点尤其适用。

使用 MP3 作为音频编解码器v4.0.16

🌐 Use MP3 as an audio codecv4.0.16

默认情况下,视频使用 h264 编解码器,音频使用 aac 编解码器进行渲染。将 audioCodec 设置为 mp3 会使“合并视频”阶段更快,因为 MP3 编解码器的编码速度比 AAC 快得多。然而,音频在 QuickTime 播放器中无法播放,并且文件大小略微增加

🌐 By default, a video renders with the h264 codec and the aac audio codec. Setting the audioCodec to mp3 will make "Combining videos" stage a lot faster, as the MP3 codec is much faster to encode than AAC. However, the audio will not play in QuickTime Player and the file size is minimally higher.

优化渲染性能

🌐 Optimizing render performance

请参阅适用于 Lambda 的一般性能技巧

🌐 See the general performance tips which also apply to Lambda.

另请参阅

🌐 See also