Remotion Tutorials

Deploy Serverless Video Rendering

Your complete guide to deploying Remotion Lambda on AWS for scalable, on-demand video generation. Learn AWS setup, function deployment, API integration, cost optimization, and monitoring strategies.

AWS Lambda Serverless Scaling API
01

AWS Setup and Prerequisites

Configure your AWS environment with the proper permissions and credentials to deploy Remotion Lambda functions.

Rule

Required AWS Permissions

Remotion Lambda requires specific IAM permissions for Lambda, S3, and CloudWatch. Use the built-in policy generator to create the exact permissions needed.

Remotion Lambda Documentation
Tip

Install Lambda Package

Add the Lambda package to your project with npm install @remotion/lambda. This provides both CLI commands and the Node.js API for programmatic rendering.

This project

Generate IAM Policy

Run npx remotion lambda policies user to output the required IAM policy JSON. Create a dedicated IAM user and attach this policy for secure, scoped access.

Tip

Configure Credentials

Set your AWS credentials via environment variables: REMOTION_AWS_ACCESS_KEY_ID, REMOTION_AWS_SECRET_ACCESS_KEY, and REMOTION_AWS_REGION.

Rule

Region Selection

Choose an AWS region close to your users for faster video delivery. Lambda is available in most regions, but us-east-1 offers the most capacity.

AWS Lambda Best Practices
Tip

Prerequisites Checklist

Before deploying, ensure you have all requirements in place for a smooth setup process.

  • AWS account with billing enabled
  • Node.js 18+ installed locally
  • AWS CLI configured (optional)
  • Remotion project ready to deploy
02

Deploying the Lambda Function

Deploy your Remotion rendering function and upload your project to S3 for serverless video generation.

Rule

Deploy the Function

Run npx remotion lambda functions deploy to create the Lambda function with the Remotion runtime. Note the function name returned—you'll need it for rendering.

Remotion Lambda CLI Reference
Tip

Function Configuration

Customize your function with deployment flags: --memory=2048 for RAM allocation, --timeout=240 for max duration, and --disk=2048 for temp storage.

This project

Deploy Your Site

Upload your Remotion project to S3 with npx remotion lambda sites create src/index.ts --site-name=my-video-site. This bundles and hosts your compositions for Lambda access.

Rule

Site Versioning

Use meaningful site names for version control. Deploy staging and production sites separately to safely test changes before going live.

Remotion Deployment Best Practices
Tip

Verify Deployment

List your deployed functions with npx remotion lambda functions ls. Confirm the function name, memory allocation, and timeout match your requirements.

This project

Update Deployments

When updating your project, redeploy the site with the same name. For Remotion version upgrades, also redeploy the function with npx remotion lambda functions deploy.

03

Triggering Renders via API

Integrate Lambda rendering into your applications using the Node.js API for programmatic video generation.

Rule

renderMediaOnLambda API

Use renderMediaOnLambda() from @remotion/lambda/client to start renders programmatically. Pass your function name, serve URL, composition ID, and input props.

Remotion Lambda API Reference
Tip

Essential Parameters

Every render requires these core parameters for successful execution.

  • region: AWS region (e.g., 'us-east-1')
  • functionName: Your deployed function name
  • serveUrl: S3 URL from site deployment
  • composition: Composition ID to render
  • inputProps: Dynamic data for the video
This project

Start a Render

Call renderMediaOnLambda() with your configuration. It returns a renderId and bucketName for tracking progress and retrieving the output.

Rule

Track Render Progress

Poll getRenderProgress() with the render ID to check status. The response includes overallProgress (0-1), done flag, and outputFile URL when complete.

Remotion Lambda API Reference
Tip

Output Configuration

Customize your render output with codec, quality, and privacy settings: codec: 'h264', jpegQuality: 80, privacy: 'public'.

This project

Complete Render Flow

Implement a polling loop that starts the render, checks progress every second, and returns the output URL when done. Handle fatalErrorEncountered for error cases.

04

Cost Optimization Strategies

Minimize AWS costs while maintaining render performance with these optimization techniques.

Rule

Right-Size Memory

Lambda pricing scales with memory allocation. Start with 1024MB and increase only if renders are slow. More memory also means more CPU, so find the sweet spot.

AWS Lambda Pricing
Tip

Memory Recommendations

Choose memory based on your composition complexity.

ComplexityMemoryUse Case
Simple1024MBText animations, basic graphics
Medium2048MBImages, moderate effects
Complex3008MBVideo overlays, heavy processing
This project

Use JPEG Frames

Set imageFormat: 'jpeg' instead of PNG when transparency isn't needed. JPEG frames are smaller and faster to process, reducing both time and cost.

Tip

Optimize Compositions

Reduce render costs by optimizing your Remotion compositions.

  • Minimize external asset fetching
  • Use lower resolution for previews
  • Avoid unnecessary re-renders
  • Cache frequently used assets
Rule

Clean Up Old Renders

S3 storage costs accumulate over time. Use npx remotion lambda renders rm <render-id> to delete old renders, or set up S3 lifecycle policies for automatic cleanup.

AWS S3 Pricing
Tip

Batch Similar Renders

Group renders with similar configurations to maximize Lambda warm starts. Warm functions start faster and cost less than cold starts.

05

Monitoring and Debugging

Monitor your Lambda renders, debug issues, and implement production-ready error handling.

Rule

CloudWatch Logs

Lambda automatically logs to CloudWatch. View logs in the AWS Console or use npx remotion lambda functions ls to see function status and recent activity.

AWS CloudWatch Documentation
Tip

List Recent Renders

Run npx remotion lambda renders ls to view recent render jobs. This shows render IDs, status, duration, and output locations for troubleshooting.

This project

Error Handling

Check progress.fatalErrorEncountered in your polling loop. When true, progress.errors contains error details. Implement retry logic with maxRetries parameter.

Rule

Set Up Alarms

Create CloudWatch alarms for Lambda errors and duration. Get notified when renders fail or take longer than expected, enabling quick response to issues.

AWS CloudWatch Alarms
Tip

Production Best Practices

Follow these practices for reliable production deployments.

  • Use environment variables for configuration
  • Implement exponential backoff for retries
  • Separate staging and production sites
  • Version deployments with meaningful names
  • Monitor costs with AWS Budgets
This project

Debug Failed Renders

When a render fails, check the error message in progress.errors. Common issues include missing assets, invalid props, or timeout exceeded. CloudWatch logs provide detailed stack traces.

Keep Learning

Related tips

Continue exploring with these related guides and tutorials.

Ready to scale your video rendering?

Now that you understand Lambda deployment, explore our template library to find compositions ready for serverless rendering at scale.