---
image: /generated/articles-docs-lambda-rendermediaonlambda.png
id: rendermediaonlambda
title: renderMediaOnLambda()
crumb: 'Lambda API'
---

import {MinimumFramesPerLambda} from '../../components/lambda/default-frames-per-lambda';

Kicks off a render process on Remotion Lambda. The progress can be tracked using [getRenderProgress()](/docs/lambda/getrenderprogress).

Requires a [function](/docs/lambda/deployfunction) to already be deployed to execute the render.  
A [site](/docs/lambda/deploysite) or a [Serve URL](/docs/terminology/serve-url) needs to be specified to determine what will be rendered.

## Example

```tsx twoslash
// ---cut---
import {renderMediaOnLambda} from '@remotion/lambda/client';

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',
});
```

:::note
Preferrably import this function from `@remotion/lambda/client` to avoid problems [inside serverless functions](/docs/lambda/light-client).
:::

## 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 <AvailableFrom v="3.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()](/docs/lambda/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`](#outname).

### `functionName`

The name of the deployed Lambda function.
Use [`deployFunction()`](/docs/lambda/deployfunction) to create a new function and [`getFunctions()`](/docs/lambda/getfunctions) to obtain currently deployed Lambdas.

### `framesPerLambda?`

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](/docs/lambda/concurrency)  
Minimum value: <MinimumFramesPerLambda />

:::note
The `framesPerLambda` parameter cannot result in more than 200 functions being spawned. See: [Concurrency](/docs/lambda/concurrency)
:::

:::note
When rendering transparent WebM videos, chunk boundaries can be visible in the alpha channel. See [Known problem: Rendering transparent WebM on Lambda](/docs/transparent-videos#known-problem-rendering-transparent-webm-on-lambda). Increase `framesPerLambda` to reduce boundaries, or render WebM in one pass if the artifact appears.
:::

### `concurrency?`<AvailableFrom v="4.0.322" />

Specify the number of Lambda functions to use for rendering. This is an alternative to `framesPerLambda` that allows you to set the concurrency directly without needing to know the video duration.

The concurrency is defined as `frameCount / framesPerLambda`. Remotion will automatically calculate the appropriate `framesPerLambda` value based on your concurrency setting.

Maximum value: 200  
Minimum value: Depends on video length (must result in `framesPerLambda >= 4`)

:::note
Cannot be used together with `framesPerLambda`. Use only one of them.
:::

### `frameRange?`

Specify a single frame (passing a `number`) or a range of frames (passing a tuple `[number, number]`) to render a subset of a video. Example: `[0, 9]` to select the first 10 frames. By passing `null` (default) all frames of a composition get rendered. Pass `[number, null]` to render from a frame to the end of the composition.<AvailableFrom v="4.0.421" inline /> To render a still, use [`renderStillOnLambda()`](/docs/lambda/renderstillonlambda).

### `serveUrl`

A URL pointing to a Remotion project. Use [`deploySite()`](/docs/lambda/deploysite) to deploy a Remotion project.

### `composition`

The `id` of the [composition](/docs/composition) you want to render.

### `metadata?`<AvailableFrom v="4.0.216" />

<Options id="metadata" />

### `inputProps?`

Optional since <AvailableFrom v="3.2.27" />.

[Input Props to pass to the selected composition of your video.](/docs/passing-props#passing-input-props-in-the-cli).  
Must be a JSON object.  
From the root component the props can be read using [`getInputProps()`](/docs/get-input-props).  
You may transform input props using [`calculateMetadata()`](/docs/calculate-metadata).

### `codec`

Which codec should be used to encode the video.

Video codecs `h264`, `h265`, `vp8`, `vp9`, `gif` and `prores` are supported.

Audio codecs `mp3`, `aac` and `wav` are also supported.

`av1` is not available on Lambda due to function size constraints.

The option `h264-mkv` has been renamed to just `h264` since `v3.3.34`. Use `h264` to get the same behavior.

See also [`renderMedia() -> codec`](/docs/renderer/render-media#codec).

### `audioCodec?`<AvailableFrom v="3.3.41" />

Choose the encoding of your audio.

- Each Lambda chunk might actually choose an uncompressed codec and convert it in the final encoding stage to prevent audio artifacts.
- The default is dependent on the chosen `codec`.
- Choose `pcm-16` if you need uncompressed audio.
- Not all video containers support all audio codecs.
- This option takes precedence if the `codec` option also specifies an audio codec.

Refer to the [Encoding guide](/docs/encoding/#audio-codec) to see defaults and supported combinations.

### `forceHeight?`<AvailableFrom v="3.2.40" />

Overrides default composition height.

### `forceWidth?`<AvailableFrom v="3.2.40" />

Overrides default composition width.

### `forceFps?`<AvailableFrom v="4.0.424" />

Overrides the default composition FPS.

### `forceDurationInFrames?`<AvailableFrom v="4.0.424" />

Overrides the default composition duration in frames.

### `muted?`

Disables audio output. See also [`renderMedia() -> muted`](/docs/renderer/render-media#muted).

### `sampleRate?`<AvailableFrom v="4.0.448" />

<Options id="sample-rate" />

### `imageFormat?`

Optional since <AvailableFrom v="3.2.27" />.

See [`renderMedia() -> imageFormat`](/docs/renderer/render-media#imageformat).

### `crf?`

See [`renderMedia() -> crf`](/docs/renderer/render-media#crf).

### `envVariables?`

See [`renderMedia() -> envVariables`](/docs/renderer/render-media#envvariables).

### `pixelFormat?`

See [`renderMedia() -> pixelFormat`](/docs/renderer/render-media#pixelformat).

### `proResProfile?`

See [`renderMedia() -> proResProfile`](/docs/renderer/render-media#proresprofile).

### `x264Preset?`

<Options id="x264-preset" />

### `gopSize?`<AvailableFrom v="4.0.466" />

<Options id="gop" />

On Lambda, this sets the maximum GOP size per chunk. Additional keyframes will appear at chunk boundaries, every `framesPerLambda` frames.

### `jpegQuality?`

See [`renderMedia() -> jpegQuality`](/docs/renderer/render-media#jpegquality).

### ~~`quality`~~

Renamed to `jpegQuality` in v4.0.0.

### `audioBitrate?`

<Options id="audio-bitrate" />

### `videoBitrate?`

<Options id="video-bitrate" />

### `bufferSize?`<AvailableFrom v="4.0.78" />

<Options id="buffer-size" />

### `maxRate?`<AvailableFrom v="4.0.78" />

<Options id="max-rate" />

### `maxRetries?`

Optional since <AvailableFrom v="3.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()`](/docs/lambda/getrenderprogress) object and retried up to as many times as you specify using this option.

:::note
A retry only gets executed if a the error is in the [list of flaky errors](https://github.com/remotion-dev/remotion/blob/main/packages/lambda-client/src/is-flaky-error.ts).
:::

### `scale?`

<Options id="scale" />

### `outName?`

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}`. Make sure to include the file extension at the end of the string.
- An object if you want to render to a different bucket or cloud provider - [see here for detailed instructions](/docs/lambda/custom-destination).

### `timeoutInMilliseconds?`

A number describing how long the render may take to resolve all [`delayRender()`](/docs/delay-render) calls [before it times out](/docs/timeout). Default: `30000`

### `concurrencyPerLambda?`<AvailableFrom v="3.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?`<AvailableFrom v="3.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.](/docs/render-as-gif)

### `numberOfGifLoops?`<AvailableFrom v="3.1" />

<Options id="number-of-gif-loops" />

### `downloadBehavior?`<AvailableFrom v="3.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.

### `chromiumOptions?`

Allows you to set certain Chromium / Google Chrome flags. See: [Chromium flags](/docs/chromium-flags).

#### `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`

<Options id="gl" />

### `overwrite?`<AvailableFrom v="3.2.25" />

If a custom out name is specified and a file already exists at this key in the S3 bucket, decide whether the file should be overwritten. Default `false`.  
If the file exists and `overwrite` is `false`, an error will be thrown.

### `rendererFunctionName?`<AvailableFrom v="3.3.38" />

If specified, this function will be used for rendering the individual chunks. This is useful if you want to use a function with higher or lower power for rendering the chunks than the main orchestration function.

If you want to use this option, the function must be in the same region, the same account and have the same version as the main function.

### `webhook?`<AvailableFrom v="3.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 twoslash
import {RenderMediaOnLambdaInput} from '@remotion/lambda';

const webhook: RenderMediaOnLambdaInput['webhook'] = {
  url: 'https://mapsnap.app/api/webhook',
  secret: process.env.WEBHOOK_SECRET as string,
  // Optionally pass up to 1024 bytes of custom data
  customData: {
    id: 42,
  },
};
```

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

```tsx twoslash
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](/docs/lambda/webhooks).

### `forceBucketName?`<AvailableFrom v="3.3.42" />

Specify a specific bucket name to be used. [This is not recommended](/docs/lambda/multiple-buckets), instead let Remotion discover the right bucket automatically.

### `logLevel?`

<Options id="log" />

If the `logLevel` is set to `verbose`, the Lambda function will not clean up artifacts, to aid debugging. Do not use it unless you are debugging a problem.

### `mediaCacheSizeInBytes?`<AvailableFrom v="4.0.352"/>

<Options id="media-cache-size-in-bytes" />

### `offthreadVideoCacheSizeInBytes?`<AvailableFrom v="4.0.23"/>

<Options id="offthreadvideo-cache-size-in-bytes" />

### `offthreadVideoThreads?`<AvailableFrom v="4.0.261"/>

<Options id="offthreadvideo-video-threads" />

### `colorSpace?`<AvailableFrom v="4.0.28"/>

<Options id="color-space" />

### `deleteAfter?`<AvailableFrom v="4.0.32"/>

<Options id="delete-after" />

### `preferLossless?`<AvailableFrom v="4.0.123"/>

<Options id="prefer-lossless" />

### `forcePathStyle?`<AvailableFrom v="4.0.202" />

Passes `forcePathStyle` to the AWS S3 client. If you don't know what this is, you probably don't need it.

### `storageClass?`<AvailableFrom v="4.0.305"/>

An [identifier](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html#sc-compare) for the S3 storage class of the rendered media. Default: `undefined` (which is `STANDARD`).

### `licenseKey?`<AvailableFrom v="4.0.409"/>

<Options id="license-key" />

### `isProduction?`<AvailableFrom v="4.0.409"/>

_default `true`_

<Options id="is-production" />

### ~~`apiKey?`<AvailableFrom v="4.0.253"/>~~

_deprecated in v4.0.409_

<Options id="api-key" />

### ~~`dumpBrowserLogs?`~~

Deprecated in v4.0 in favor of [`logLevel`](#loglevel).

## Return value

Returns a promise resolving to an object containing four properties. Of these, `renderId`, `bucketName` 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`<AvailableFrom v="3.2.10"/>

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

### `lambdaInsightsUrl`<AvailableFrom v="4.0.61"/>

A link to the [Lambda Insights](/docs/lambda/insights), if you enabled it.

### `folderInS3Console`<AvailableFrom v="3.2.43"/>

A link to the folder in the AWS console where each chunk and render is located.

## See also

- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/lambda-client/src/render-media-on-lambda.ts)
- [getRenderProgress()](/docs/lambda/getrenderprogress)
