Skip to main content

renderMediaOnLambdaAndStream()v4.0.542

Starts a media render on AWS Lambda, streams progress, and waits for the render to finish. Requires a deployed function and site or Serve URL using the same Remotion version as the client.

render.ts
import {renderMediaOnLambdaAndStream} from '@remotion/lambda-client'; const result = await renderMediaOnLambdaAndStream({ region: 'eu-central-1', functionName: 'remotion-render-4-0-542-mem2048mb-disk2048mb-120sec', serveUrl: 'https://example.com/remotion/index.html', composition: 'MyComposition', codec: 'h264', onInit: ({renderId, bucketName}) => { console.log({renderId, bucketName}); }, onProgress: ({overallProgress}) => { console.log(`${Math.round(overallProgress * 100)}%`); }, }); console.log(result.outputFile);

Also exported from @remotion/lambda. To start a render without waiting, use renderMediaOnLambda(). For image sequences, use renderFramesOnLambdaAndStream().

Arguments​

Accepts the same render options as renderMediaOnLambda(), plus the callbacks below.

onInit?​

Called once with the startup metadata, including renderId, bucketName, and diagnostic links. Defaults to no callback. Save this identity to observe the render later with getRenderProgress().

onProgress?​

Called with the same progress object as getRenderProgress(). Defaults to no callback. Updates are coalesced; the callback does not run for every frame.

Both callbacks may return a promise and are awaited in order. Throwing or rejecting stops observation and rejects renderMediaOnLambdaAndStream(). It does not cancel the render.

Return value​

Resolves with the final progress object. done is true, and outputFile, outBucket, and outKey identify the finished media. The result also includes costs, artifacts, and separate audio output when requested.

The promise rejects if the render fails to start, or on a fatal render error, timeout, callback failure, or observation failure. A RenderMediaOnLambdaAndStreamError retains these diagnostic properties:

renderId​

The render ID, or null if startup metadata was not received.

bucketName​

The render bucket, or null if startup metadata was not received.

render​

The startup metadata, or null before initialization.

progress​

The last observed progress object, or null before progress was received. Its errors array includes render diagnostics.

cause​

The original observation or callback error, or the remote error stack when available.

Streaming and recovery​

Progress streams directly in standard AWS regions. In cn-north-1 and cn-northwest-1, the API starts asynchronously and polls for progress. If a stream breaks, stalls for 30 seconds, or ends before the render finishes, observation falls back to polling the same render. An ended stream alone does not indicate success.

If the connection closes before a render ID is received, the promise rejects. The render may still be running. The API never retries the start request automatically.

Progress continues to be saved in S3 during rendering, so getRenderProgress() remains available to independent observers. This API streams progress; it does not stream video bytes. Use downloadMedia() to download the output.

Disconnection and cancellation​

Closing the client or stopping observation leaves the render running. To cancel it, start with enableCancellation: true and call cancelRenderOnLambda().

The Lambda render CLI uses this lifecycle for media and image sequence renders. Ctrl+C stops waiting by default. With --enable-cancellation, Ctrl+C explicitly cancels the render.

Compatibility​

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also​