🎥 Make videos programmatically with React
`@remotion/lambda`: Document single-function rendering
Jonny Burger1a6da27e022a
diff --git a/packages/docs/docs/lambda/cli/render.mdx b/packages/docs/docs/lambda/cli/render.mdxindex d899b97f2d..c7b0ba97fd 100644--- a/packages/docs/docs/lambda/cli/render.mdx+++ b/packages/docs/docs/lambda/cli/render.mdx@@ -128,6 +128,8 @@ Specify the number of Lambda functions to use for rendering. This is an alternatThe concurrency is defined as `frameCount / framesPerLambda`. Remotion will automatically calculate the appropriate `framesPerLambda` value based on your concurrency setting.+From <AvailableFrom v="4.0.517" inline />, setting `--concurrency=1` without specifying `--renderer-function-name` makes the main function render the video directly. No additional renderer function is invoked.+Maximum value: 200Minimum value: Depends on video length (must result in `framesPerLambda >= 4`)diff --git a/packages/docs/docs/lambda/concurrency.mdx b/packages/docs/docs/lambda/concurrency.mdxindex 9a72202f8e..50177e6aa4 100644--- a/packages/docs/docs/lambda/concurrency.mdx+++ b/packages/docs/docs/lambda/concurrency.mdx@@ -5,7 +5,7 @@ title: Concurrencycrumb: 'Lambda'----Remotion Lambda is a highly concurrent distributed video rendering system. That means that the video rendering work is split up across many Lambda functions. How many Lambda functions exactly can be defined by you, or you let Remotions defaults decide.+Remotion Lambda is a distributed video rendering system. The video is split into chunks that can be rendered concurrently. You can define the number of chunks or use the Remotion defaults.## Setting the concurrency@@ -13,6 +13,8 @@ You can set the concurrency via the [`framesPerLambda`](/docs/lambda/rendermediaAlternatively, you can use the [`concurrency`](/docs/lambda/rendermediaonlambda#concurrency) option (or [`--concurrency`](/docs/lambda/cli/render#--concurrency) via CLI) to specify the number of Lambda functions directly without needing to know the video duration.+From <AvailableFrom v="4.0.517" inline />, setting `concurrency` to `1` without specifying a `rendererFunctionName` makes the main function render the video directly. No additional renderer function is invoked.+The concurrency is defined as `frameCount / framesPerLambda`. That means that the higher you set `framesPerLambda`, the lower the concurrency gets.:::notediff --git a/packages/docs/docs/lambda/estimateprice.mdx b/packages/docs/docs/lambda/estimateprice.mdxindex 054bce8f5c..4aac37c7b6 100644--- a/packages/docs/docs/lambda/estimateprice.mdx+++ b/packages/docs/docs/lambda/estimateprice.mdx@@ -10,8 +10,8 @@ Calculates the AWS costs incurred for AWS Lambda given the region, execution durDuring rendering, many Lambda functions are spawned:-- The main function spawns many worker functions, waits for chunks to be rendered, and stitches them together for the full video. This is the longest-running Lambda function.-- Render functions render a short portion of a video and then shut down.+- The main function normally spawns worker functions, waits for chunks to be rendered, and stitches them together for the full video. This is the longest-running Lambda function.+- Renderer functions render a short portion of a video and then shut down. From <AvailableFrom v="4.0.517" inline />, with `concurrency: 1` and no `rendererFunctionName`, the main function renders the video directly and no renderer function is invoked.- Other short-lived, negligible functions get launched for initializing lambdas and fetching progress.The total duration is the sum of execution duration of all of the above Lambda functions.diff --git a/packages/docs/docs/lambda/faq.mdx b/packages/docs/docs/lambda/faq.mdxindex fa3fcbf585..4be82e1485 100644--- a/packages/docs/docs/lambda/faq.mdx+++ b/packages/docs/docs/lambda/faq.mdx@@ -25,8 +25,11 @@ There are three exceptions when it is possible to deploy multiple functions:### How many videos can I render concurrently?It depends on the [concurrency limit](/docs/lambda/limits) of your AWS account.-Every render uses between 3 and 200 concurrent Lambda functions, depending on the [concurrency](/docs/lambda/concurrency) of the render.-If you exceed the concurrency limit, you will get an `TooManyRequestsException` error from AWS Lambda.+Normally, a render uses a launch invocation, renderer invocations, and short progress invocations. The number of renderer invocations depends on the [concurrency](/docs/lambda/concurrency) of the render.++From <AvailableFrom v="4.0.517" inline />, setting `concurrency` to `1` without specifying a `rendererFunctionName` makes the launch invocation render the video directly, so no separate renderer invocation is used. A progress request may briefly use another invocation.++If you exceed the concurrency limit, you will get a `TooManyRequestsException` error from AWS Lambda.### Do I need to create multiple buckets?diff --git a/packages/docs/docs/lambda/how-lambda-works.mdx b/packages/docs/docs/lambda/how-lambda-works.mdxindex 10eff89fe9..fdc0af0561 100644--- a/packages/docs/docs/lambda/how-lambda-works.mdx+++ b/packages/docs/docs/lambda/how-lambda-works.mdx@@ -26,11 +26,10 @@ that was passed and runs the <a href="/docs/props-resolution">as the metadata (such as the duration in frames).<br /><Step>4</Step> Based on the determined duration of the video and the <a href="/docs/lambda/concurrency">concurrency-</a>, several <strong>renderer functions</strong> are spawned, which are tasked to-render a portion of the video.<br />-<Step>5</Step> The renderer functions use <a href="https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/">+</a>, the video is split into chunks. Normally, a <strong>renderer function</strong> is invoked for each chunk. From <AvailableFrom v="4.0.517" inline />, if <code>concurrency</code> is <code>1</code> and no <a href="/docs/lambda/rendermediaonlambda#rendererfunctionname"><code>rendererFunctionName</code></a> is specified, the main function renders the only chunk itself.<br />+<Step>5</Step> Separate renderer functions use <a href="https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/">AWS Lambda Response Streaming-</a> to report progress as well as the binary video chunks. <br />+</a> to report progress and send the binary video chunks to the main function. This streaming step is skipped when the main function renders directly.<br /><Step>6</Step> The main function concatenates the progress reports into aconcise <code>progress.json</code> file and periodically uploads it to S3.<br /><Step>7</Step> The <a href="/docs/lambda/getrenderprogress">diff --git a/packages/docs/docs/lambda/rendermediaonlambda.mdx b/packages/docs/docs/lambda/rendermediaonlambda.mdxindex 208657fa46..804d8b0a6e 100644--- a/packages/docs/docs/lambda/rendermediaonlambda.mdx+++ b/packages/docs/docs/lambda/rendermediaonlambda.mdx@@ -83,6 +83,8 @@ Specify the number of Lambda functions to use for rendering. This is an alternatThe concurrency is defined as `frameCount / framesPerLambda`. Remotion will automatically calculate the appropriate `framesPerLambda` value based on your concurrency setting.+From <AvailableFrom v="4.0.517" inline />, setting `concurrency` to `1` without specifying a [`rendererFunctionName`](#rendererfunctionname) makes the main function render the video directly. No additional renderer function is invoked.+Maximum value: 200Minimum value: Depends on video length (must result in `framesPerLambda >= 4`)@@ -402,7 +404,7 @@ Use [`logLevel`](#loglevel) instead.## Return value-Returns a promise resolving to an object containing four properties. Of these, `renderId`, `bucketName` are useful for passing to `getRenderProgress()`.+Returns a promise resolving to an object. `renderId` and `bucketName` are useful for passing to [`getRenderProgress()`](/docs/lambda/getrenderprogress).### `renderId`@@ -414,9 +416,13 @@ 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.+A link to the CloudWatch logs of the renderer functions, if you have not disabled CloudWatch. With `concurrency: 1` and no `rendererFunctionName`, no separate renderer function is invoked; use `cloudWatchMainLogs` instead.++### `cloudWatchMainLogs`<AvailableFrom v="4.0.174" />++A link to the CloudWatch logs of the main function. This is also where rendering logs are written when `concurrency` is `1` and no `rendererFunctionName` is specified.-### `lambdaInsightsUrl`<AvailableFrom v="4.0.61"/>+### `lambdaInsightsLogs`<AvailableFrom v="4.0.61"/>A link to the [Lambda Insights](/docs/lambda/insights), if you enabled it.@@ -424,6 +430,10 @@ A link to the [Lambda Insights](/docs/lambda/insights), if you enabled it.A link to the folder in the AWS console where each chunk and render is located.+### `progressJsonInConsole`<AvailableFrom v="4.0.182" />++A link to the `progress.json` file in the AWS console.+## See also- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/lambda-client/src/render-media-on-lambda.ts)diff --git a/packages/docs/docs/lambda/troubleshooting/debug.mdx b/packages/docs/docs/lambda/troubleshooting/debug.mdxindex a914ebbea5..bb8738769d 100644--- a/packages/docs/docs/lambda/troubleshooting/debug.mdx+++ b/packages/docs/docs/lambda/troubleshooting/debug.mdx@@ -56,14 +56,16 @@ If your error message reads that the main Lambda function has timed out, it mean<Step>1</Step> Get the Log URL:- If you use the CLI, add `--log=verbose` to the command. This will print a CloudWatch link to the console.-- When using [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda) add `logLevel: "verbose"` as an option. You will get a `cloudWatchLogs` field in the return value.+- When using [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda), add `logLevel: "verbose"`. Use the returned `cloudWatchLogs` URL for renderer functions and `cloudWatchMainLogs` for the main function.++From <AvailableFrom v="4.0.517" inline />, with `concurrency: 1` and no `rendererFunctionName`, the main function renders directly and there are no separate renderer logs. The CLI prints only the main function link; API users should open `cloudWatchMainLogs`.Open this link and log into AWS if needed. A log stream will open.<img src="/img/cloudwatch.png" /> <br /><br />-By default, the filter is set to:+The renderer function link uses this filter:```"method=renderer,renderId=[render-id]"diff --git a/packages/docs/docs/terminology/concurrency.mdx b/packages/docs/docs/terminology/concurrency.mdxindex 6048d13941..4f130add96 100644--- a/packages/docs/docs/terminology/concurrency.mdx+++ b/packages/docs/docs/terminology/concurrency.mdx@@ -9,7 +9,9 @@ Concurrency can mean different things depending on the context.**In local rendering,** concurrency refers to how many browser tabs are opened in parallel during a render.Each Chrome tab renders web content and then screenshots it.-**For rendering on Lambda,** concurrency refers to the amount of Lambda functions that are spawned for a render. You can control the Lambda concurrency using the [`framesPerLambda`](/docs/lambda/rendermediaonlambda#framesperlambda) option.+**For rendering on Lambda,** concurrency refers to the number of chunks that can be rendered in parallel. Normally, each chunk is handled by a separate Lambda function. You can control the Lambda concurrency using the [`framesPerLambda`](/docs/lambda/rendermediaonlambda#framesperlambda) option.++From <AvailableFrom v="4.0.517" inline />, with `concurrency: 1` and no `rendererFunctionName`, the main function renders the only chunk directly instead of invoking a renderer function.Each Lambda function usually opens just a single tab, unless you use the [`concurrencyPerLambda`](/docs/lambda/rendermediaonlambda#concurrencyperlambda) option to increase the amount of tabs per Lambda function.