Skip to main content

renderMediaOnLambda()

Triggers a render on a lambda given a composition and a lambda function.

Example

tsx
const { bucketName, renderId } = await renderMediaOnLambda({
region: "us-east-1",
functionName: "remotion-render-bds9aab",
composition: "MyVideo",
serveUrl:
"https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",
codec: "h264",
});
tsx
const { bucketName, renderId } = await renderMediaOnLambda({
region: "us-east-1",
functionName: "remotion-render-bds9aab",
composition: "MyVideo",
serveUrl:
"https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw",
codec: "h264",
});

Arguments

An object with the following properties:

region

In which region your Lambda function is deployed. It's highly recommended that your Remotion site is also in the same region.

privacy

optional since v3.2.27

One of:

  • "public" (default): The rendered media is publicly accessible under the S3 URL.
  • "private": The rendered media is not publicly available, but signed links can be created using presignUrl().
  • "no-acl" (available from v.3.1.7): The ACL option is not being set at all, this option is useful if you are writing to another bucket that does not support ACL using outName.

functionName

The name of the deployed Lambda function. Use deployFunction() to create a new function and getFunctions() to obtain currently deployed Lambdas.

framesPerLambda

optional

The video rendering process gets distributed across multiple Lambda functions. This setting controls how many frames are rendered per Lambda invocation. The lower the number you pass, the more Lambdas get spawned.

Default value: Dependant on video length
Minimum value: 4

note

The framesPerLambda parameter cannot result in more than 200 functions being spawned. See: Concurrency

serveUrl

A URL pointing to a Remotion project. Use deploySite() to deploy a Remotion project.

composition

The id of the composition you want to render.

inputProps

optional since v3.2.27

React props that are passed to your composition. You define the shape of the props that the component accepts.

codec

Which codec should be used to encode the video.

Video codecs h264 and vp8 are supported, prores is supported since v3.2.0.

Audio codecs mp3, aac and wav are also supported.

See also renderMedia() -> codec.

forceHeight

available from v3.2.40

Overrides default composition height.

forceWidth

available from v3.2.40

Overrides default composition width.

muted

Disables audio output. See also renderMedia() -> muted.

imageFormat

optional since v3.2.27

See renderMedia() -> imageFormat.

crf

See renderMedia() -> crf.

envVariables

See renderMedia() -> envVariables.

pixelFormat

See renderMedia() -> pixelFormat.

proResProfile

See renderMedia() -> proResProfile.

quality

See renderMedia() -> quality.

audioBitrate

See renderMedia() -> audioBitrate.

videoBitrate

See renderMedia() -> videoBitrate.

maxRetries

optional since v3.2.27, default 1

How often a chunk may be retried to render in case the render fails. If a rendering of a chunk is failed, the error will be reported in the getRenderProgress() object and retried up to as many times as you specify using this option.

scale

optional

Scales the output dimensions by a factor. See Scaling to learn more about this feature.

outName

optional

The file name of the media output.

It can either be:

  • undefined - it will default to out plus the appropriate file extension, for example: renders/${renderId}/out.mp4.
  • A string - it will get saved to the same S3 bucket as your site under the key renders/{renderId}/{outName}.
  • An object if you want to render to a different bucket or cloud provider - see here for detailed instructions

timeoutInMilliseconds?

optional

A number describing how long the render may take to resolve all delayRender() calls before it times out. Default: 30000

chromiumOptions?

optional, available from v2.6.5

Allows you to set certain Chromium / Google Chrome flags. See: Chromium flags.

concurrencyPerLambda?

optional, available from v3.0.30

By default, each Lambda function renders with concurrency 1 (one open browser tab). You may use the option to customize this value.

everyNthFrame?

optional, available from v3.1

Renders only every nth frame. For example only every second frame, every third frame and so on. Only works for rendering GIFs. See here for more details.

numberOfGifLoops?

optional, available since v3.1

Set the looping behavior. This option may only be set when rendering GIFs. See here for more details.

downloadBehavior?

optional, available since v3.1.5

How the output file should behave when accessed through the S3 output link in the browser.
Either:

  • {"type": "play-in-browser"} - the default. The video will play in the browser.
  • {"type": "download", fileName: null} or {"type": "download", fileName: "download.mp4"} - a Content-Disposition header will be added which makes the browser download the file. You can optionally override the filename.

disableWebSecurity

boolean - default false

This will most notably disable CORS among other security features.

ignoreCertificateErrors

boolean - default false

Results in invalid SSL certificates, such as self-signed ones, being ignored.

gl

string

Select the OpenGL renderer backend for Chromium. Accepted values:

  • "angle",
  • "egl",
  • "swiftshader"
  • "swangle"
  • null - Chromiums default
note

The default for Lambda is swangle, but null elsewhere.

overwrite

available from v3.2.25

If a custom out name is specified and a file already exists at this key in the S3 bucket, decide whether that file will be deleted before the render begins. Default false.

An existing file at the output S3 key will conflict with the render and must be deleted beforehand. If this setting is false and a conflict occurs, an error will be thrown.

webhook

optional, available from v3.2.30

If specified, Remotion will send a POST request to the provided endpoint to notify your application when the Lambda rendering process finishes, errors out or times out.

tsx
import { RenderMediaOnLambdaInput } from "@remotion/lambda";
 
const webhook: RenderMediaOnLambdaInput["webhook"] = {
url: "https://mapsnap.app/api/webhook",
secret: process.env.WEBHOOK_SECRET as string,
};
tsx
import { RenderMediaOnLambdaInput } from "@remotion/lambda";
 
const webhook: RenderMediaOnLambdaInput["webhook"] = {
url: "https://mapsnap.app/api/webhook",
secret: process.env.WEBHOOK_SECRET as string,
};

If you don't want to set up validation, you can set secret to null:

tsx
import { RenderMediaOnLambdaInput } from "@remotion/lambda";
 
const webhook: RenderMediaOnLambdaInput["webhook"] = {
url: "https://mapsnap.app/api/webhook",
secret: null,
};
tsx
import { RenderMediaOnLambdaInput } from "@remotion/lambda";
 
const webhook: RenderMediaOnLambdaInput["webhook"] = {
url: "https://mapsnap.app/api/webhook",
secret: null,
};

See here for detailed instructions on how to set up your webhook.

Return value

Returns a promise resolving to an object containing two properties: renderId, bucketName, cloudWatchLogs. Those are useful for passing to getRenderProgress()

renderId

A unique alphanumeric identifier for this render. Useful for obtaining status and finding the relevant files in the S3 bucket.

bucketName

The S3 bucket name in which all files are being saved.

cloudWatchLogs

available from v3.2.10

A link to CloudWatch (if you haven't disabled it) that you can visit to see the logs for the render.

See also