Skip to content

🎥 Make videos programmatically with React

documetn

Jonny Burger482ea25749ad
diff --git a/packages/docs/docs/getrenderprogress.md b/packages/docs/docs/getrenderprogress.md
index 327456f010..69867030bb 100644
--- a/packages/docs/docs/getrenderprogress.md
+++ b/packages/docs/docs/getrenderprogress.md
@@ -3,3 +3,114 @@ id: getrenderprogress
title: getRenderProgress()
slug: /lambda/getrenderprogress
---
+
+Gets the current status of a render originally triggered via [`renderVideoOnLambda()`](/docs/lambda/rendervideoonlambda).
+
+## Example
+
+```tsx twoslash
+// @module: esnext
+// @target: es2017
+import {getRenderProgress} from '@remotion/lambda';
+
+// ---cut---
+
+const progress = await getRenderProgress({
+ renderId: 'd7nlc2y',
+ bucketName: 'remotionlambda-d9mafgx',
+ functionName: 'remotion-render-la8ffw',
+ region: 'us-east-1'
+})
+```
+
+## API
+
+Call the function by passing an object with the following properties:
+
+### `renderId`
+
+The unique identifier for the render that you want to get the progress for. You can get the renderId from the return value of [`renderVideoOnLambda()`](/docs/lambda/rendervideoonlambda).
+
+### `bucketName`
+
+The bucket in which information about the render is saved. You can get the bucket name from the return value of [`renderVideoOnLambda()`](/docs/lambda/rendervideoonlambda).
+
+### `region`
+
+The region in which the lambda function is located in.
+
+### `functionName`
+
+The name of the function that triggered the render.
+
+## Response
+
+Returns a promise resolving to an object with the following properties:
+
+### `chunks`
+
+How many chunks have been fully rendered so far.
+
+### `done`
+
+`true` if video has been successfully rendered and all processes are done. `false` otherwise.
+
+### `encodingStatus`
+
+Either `null` if not all chunks have been rendered yet or an object with the signature `{framesEncoded: number}` that tells how many frames have been stitched together so far in the concatenation process.
+
+### `costs`
+
+Non-binding information about how much the render is costing. At the moment the calculation is still very inaccurate (on the conservative size, probably shows higher cost than real).
+
+### `renderId`
+
+Mirrors the `renderId` that has been passed as an input
+
+### `renderMetadata`
+
+Contains the following information about the render:
+
+- `totalFrames`: The duration of the video
+- `startedDate`: Timestamp of when the rendering process started.
+- `totalChunks`: Into how many pieces the rendering is divided.
+- `estimatedLambdaInvokations`: The estimated amount of many Lambda functions get called in total, excluding calls to `getRenderProgress()`.
+- `compositionId`: The ID of the composition that is being rendered.
+- `codec`: The selected codec into which the video gets encoded.
+- `usesOptimizationProfile`: If chunk optimization was applied to the render.
+
+### `bucket`
+
+Which bucket the render and other artifacts get saved.
+
+### `outputFile`
+
+`null` if the video is not yet rendered, a `string` containing a URL pointing to the final artifact if the video finished rendering.
+
+### `timeToFinish`
+
+`null` is the video is not yet rendered, a `number` describing how long the render took to finish in miliseconds.
+
+### `errors`
+
+An array which contains errors that occured.
+
+### `fatalErrorEncountered`
+
+`true` if an error occured and the video cannot be rendered. You should stop polling for progress and check the `errors` array.
+
+### `currentTime`
+
+The current time at which the Lambda function responded to the progress request.
+
+### `bucketSize`
+
+How many bytes have been saved to the S3 bucket as a result of this render.
+
+### `lambdasInvoked`
+
+How many lambdas that render a chunk have been invoked yet and have started rendering. Note that `lambdasInvoked` and `renderMetadata.estimatedLambdaInvokations` don't match up currently, this is expected.
+
+## See also
+
+- [renderVideoOnLambda()](/docs/lambda/rendervideoonlambda)
diff --git a/packages/docs/docs/rendervideoonlambda.md b/packages/docs/docs/rendervideoonlambda.md
index 50f8f45920..6f57b5ce51 100644
--- a/packages/docs/docs/rendervideoonlambda.md
+++ b/packages/docs/docs/rendervideoonlambda.md
@@ -3,3 +3,103 @@ id: rendervideoonlambda
title: renderVideoOnLambda()
slug: /lambda/rendervideoonlambda
---
+
+Triggers a render on a lambda given a composition and a lambda function.
+
+## Example
+
+```tsx twoslash
+// @module: esnext
+// @target: es2017
+import {renderVideoOnLambda} from '@remotion/lambda';
+// ---cut---
+
+const {bucketName, renderId} = await renderVideoOnLambda({
+ region: 'us-east-1',
+ functionName: 'remotion-render-bds9aab',
+ composition: 'MyVideo',
+ serveUrl: 'https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw',
+ inputProps: {},
+ codec: 'h264-mkv',
+ imageFormat: 'jpeg',
+ maxRetries: 3,
+})
+```
+
+## 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.
+
+### `functionName`
+
+The name of the deployed Lambda function.
+Use [`deployFunction()`](/docs/lambda/deployfunction) to create a new function and [`getDeployedLambdas()`](/docs/lambda/getdeployedlambdas) to obtain currently deployed Lambdas.
+
+### `serveUrl`
+
+A URL pointing to a Remotion project. Use [`deployProject()`](/docs/lambda/deployproject) to deploy a Remotion project.
+
+### `composition`
+
+The name of the [composition](/docs/composition) you want to render..
+
+### `inputProps`
+
+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. At the moment the only supported video codec is `h264-mkv`, which will return a MP4 encoded using H.264, but where the chunks are encoded in the Matruska container. The reason Lambda has a special value is to allow audio to be stitched together seamlessly.
+
+Audio codecs `mp3`, `aac` and `wav` are also supported.
+
+See also [`stitchFramesToVideo() -> codec`](/docs/stitch-frames-to-video#codec).
+
+### `imageFormat`
+
+See [`renderFrames() -> imageFormat`](/docs/render-frames#imageformat).
+
+### `crf`
+
+See [`stitchFramesToVideo() -> crf`](/docs/stitch-frames-to-video#crf).
+
+### `envVariables`
+
+See [`renderFrames() -> envVariables`](/docs/render-frames#envvariables).
+
+### `pixelFormat`
+
+See [`stitchFramesToVideo() -> pixelFormat`](/docs/stitch-frames-to-video#pixelformat).
+
+### `proResProfile`
+
+See [`stitchFramesToVideo() -> proResProfile`](/docs/stitch-frames-to-video#proresprofile).
+
+### `quality`
+
+See [`renderFrames() -> quality`](/docs/render-frames#quality).
+
+### `maxRetries`
+
+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/get-render-progress) object and retried up to as many times as you specify using this option.
+
+## Return value
+
+Returns a promise resolving to an object containing two properties: `renderId` and `bucketName`. 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.
+
+## See also
+
+- [getRenderProgress()](/docs/lambda/get-render-progress)
diff --git a/packages/docs/docs/stitch-frames-to-video.md b/packages/docs/docs/stitch-frames-to-video.md
index 5f8798b13c..8b1e85d473 100644
--- a/packages/docs/docs/stitch-frames-to-video.md
+++ b/packages/docs/docs/stitch-frames-to-video.md
@@ -86,6 +86,12 @@ _optional_
The constant rate factor of the output, a parameter which controls quality. See [here](/docs/config#setcrf) for more information about this parameter. Default is depending on the codec.
+### `proResProfile?`
+
+_optional_
+
+Sets a ProRes profile. Only applies to videos rendered with `prores` codec. See [Encoding guide](/docs/encoding/#controlling-quality-using-prores-profile) for possible options.
+
### `onProgress?`
_optional_
diff --git a/packages/docs/package.json b/packages/docs/package.json
index 07b0bb4afb..0c28a9d231 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -20,6 +20,7 @@
"@remotion/bundler": "^2.1.12",
"@remotion/gif": "^2.1.12",
"@remotion/media-utils": "^2.1.12",
+ "@remotion/lambda": "^2.1.12",
"@remotion/player": "^2.1.12",
"@remotion/renderer": "^2.1.12",
"@remotion/three": "^2.1.12",
diff --git a/packages/lambda/package.json b/packages/lambda/package.json
index 6e41ddae85..b2d78233ab 100644
--- a/packages/lambda/package.json
+++ b/packages/lambda/package.json
@@ -1,6 +1,6 @@
{
"name": "@remotion/lambda",
- "version": "2.1.7",
+ "version": "2.1.12",
"description": "Utility functions for audio and video",
"main": "dist/index.js",
"sideEffects": false,
diff --git a/packages/lambda/src/api/get-deployed-lambdas.ts b/packages/lambda/src/api/get-deployed-lambdas.ts
index 2b15daa878..2e5dbbe15d 100644
--- a/packages/lambda/src/api/get-deployed-lambdas.ts
+++ b/packages/lambda/src/api/get-deployed-lambdas.ts
@@ -4,6 +4,7 @@ import {getLambdaClient} from '../shared/aws-clients';
import {RENDER_FN_PREFIX} from '../shared/constants';
import {getFunctionVersion} from './get-function-version';
+// TODO: Rename to getDeployedFunctions
export const getDeployedLambdas = async (options: {region: AwsRegion}) => {
const lambdas = await getLambdaClient(options.region).send(
new ListFunctionsCommand({})
diff --git a/packages/lambda/src/api/render-video-on-lambda.ts b/packages/lambda/src/api/render-video-on-lambda.ts
index 5c62ce4d40..8a219884a9 100644
--- a/packages/lambda/src/api/render-video-on-lambda.ts
+++ b/packages/lambda/src/api/render-video-on-lambda.ts
@@ -1,4 +1,4 @@
-import {Codec, ImageFormat, PixelFormat, ProResProfile} from 'remotion';
+import {ImageFormat, PixelFormat, ProResProfile} from 'remotion';
import {AwsRegion} from '../pricing/aws-regions';
import {callLambda} from '../shared/call-lambda';
import {LambdaRoutines} from '../shared/constants';
@@ -21,8 +21,9 @@ export const renderVideoOnLambda = async ({
region: AwsRegion;
functionName: string;
serveUrl: string;
+ composition: string;
inputProps: unknown;
- codec: Codec;
+ codec: 'h264-mkv' | 'mp3' | 'aac' | 'wav';
imageFormat: ImageFormat;
crf?: number | undefined;
envVariables?: Record<string, string>;
@@ -30,7 +31,6 @@ export const renderVideoOnLambda = async ({
proResProfile?: ProResProfile;
quality?: number;
maxRetries: number;
- composition: string;
}) => {
const res = await callLambda({
functionName,