Skip to main content

数据传输成本

在 Remotion Lambda 上渲染时,会打开一个无头浏览器,该浏览器通过 Serve URL 打开你的 bundle。 你的网站和资源是通过 HTTP 加载的,这意味着你将需要为数据传输向 AWS 支付费用。

🌐 When rendering on Remotion Lambda, a headless browser is opened, which opens your bundle via the Serve URL.
Your site and assets are being loaded via HTTP, meaning that you will be charged by AWS for the data transfer.

如果你有大量资源,这些费用可能会累积。 这个网站解释了如果你有大量资源,降低费用的三种选择。

🌐 If you have big assets, these charges may add up.
This site explains three options for reducing the cost if you have big assets.

如果资源在同一区域,数据传输不是免费的么?

🌐 Isn't data transfer free if the assets are in the same region?

不,使用默认设置,由于传输通过 HTTP 进行,即使资源在同一个 S3 区域,AWS 也将此计为出站流量。

🌐 No, with the default settings, since the transfer happens over HTTP, AWS counts this as egress, even if the assets are in the same S3 region.

选项 1:使用备用 CDN 存储资源

🌐 Option 1: Use an alternate CDN for storing assets

许多 Remotion 用户改为使用 Cloudflare R2 来存储他们的大型资源。
这很容易实现——只需将资源放入 Cloudflare R2 存储桶中,并使用你获得的 HTTP URL 来引用它们。

🌐 Many Remotion users use Cloudflare R2 to store their big assets instead.
This is easy to achieve - simply put the assets in a Cloudflare R2 bucket and reference them using the HTTP URL that you get.

Cloudflare 不收取数据传输费用,所以这是降低成本的好方法。

🌐 Cloudflare does not charge for data transfer, so this is a great way to reduce the cost.

确保为 R2 禁用机器人战斗模式:

🌐 Make sure to disable the Bot fight mode for R2:

  • 进入你的域的安全性 -> 设置 -> 禁用“机器人防护模式”
  • 确保在存储桶上使用你自己的域名

这确保了当 Lambda 函数使用无头浏览器加载资源时,不会阻塞任何流量。

🌐 This ensures no traffic gets blocked when the Lambda function uses a headless browser to load the assets.

选项 2:使用 @remotion/media 标签

🌐 Option 2: Use @remotion/media tags

<Video /><Audio /> 组件来自 @remotion/media,支持媒体文件的 部分下载。 与 <OffthreadVideo /> 不同,后者需要在提取帧之前下载整个文件,@remotion/media 标签使用字节范围请求只获取所需的文件部分。

🌐 The <Video /> and <Audio /> components from @remotion/media support partial downloads of media files. Unlike <OffthreadVideo />, which needs to download the entire file before extracting a frame, the @remotion/media tags use byte range requests to only fetch the parts of the file that are needed.

这意味着如果你的作品仅使用了大型视频的一部分,Lambda 函数将不会下载整个文件——从而显著减少数据传输。

🌐 This means that if your composition only uses a portion of a large video, the Lambda function will not download the full file — significantly reducing data transfer.

查看视频标签比较以获取完整的功能对比。

🌐 See the comparison of video tags for a full feature comparison.

选项 3:启用 VPC 端点

🌐 Option 3: Enable VPC endpoints

通过一些配置,你可以为 Lambda 函数设置一个 VPC。

🌐 You can with some configuration set up a VPC for the Lambda function.

请参阅这些 注意 了解如何为 Remotion Lambda 启用 VPC 端点。

🌐 Refer to these notes for how to enable VPC endpoints for Remotion Lambda.

警告

🌐 Caveats

  • 如果 Lambda 函数已经存在,这将不会更新设置。请删除 Remotion Lambda 函数并重新部署一个新的。
  • 你仍然需要为每个请求支付固定费用。
  • 设置 VPC 终端节点可能会限制其他网络流量。
  • 我们尚未有关于如何配置 VPC 端点的建议。

另请参阅

🌐 See also