packages/docs/docs/lambda/data-transfer-cost.mdx
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.
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.
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 does not charge for data transfer, so this is a great way to reduce the cost.
If you serve videos or audio files from R2, also make sure that Cloudflare Cache is enabled for the bucket.
Cold reads from R2 can be slower than cached reads, especially when @remotion/media fetches a video through byte range requests.
Use a custom domain for the R2 bucket and configure a Cloudflare Cache Rule for the asset URLs. The r2.dev development URL does not support caching.
After enabling the rule, inspect the response headers for your media URL:
CF-Cache-Status: HIT or MISS means the request went through Cloudflare Cache.CF-Cache-Status: DYNAMIC means the request was not served from cache.See Cloudflare's cache response documentation for the possible values.
Make sure to disable the Bot fight mode for R2:
This ensures no traffic gets blocked when the Lambda function uses a headless browser to load the assets.
@remotion/media tagsThe <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.
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.
You can with some configuration set up a VPC for the Lambda function.
Refer to these notes for how to enable VPC endpoints for Remotion Lambda.