Skip to content

🎥 Make videos programmatically with React

lambda

Jonny Burger316c7e2a32d2
diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.ts
index cb360a6d9a..3aba192f20 100644
--- a/packages/lambda/src/api/render-media-on-lambda.ts
+++ b/packages/lambda/src/api/render-media-on-lambda.ts
@@ -10,6 +10,7 @@ import type {
X264Preset,
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
+import {wrapWithErrorHandling} from '@remotion/renderer/src/wrap-with-error-handling';
import type {AwsRegion} from '../pricing/aws-regions';
import {callLambda} from '../shared/call-lambda';
import type {OutNameInput, Privacy} from '../shared/constants';
@@ -76,28 +77,8 @@ export type RenderMediaOnLambdaOutput = {
folderInS3Console: string;
};
-/**
- * @description Triggers a render on a lambda given a composition and a lambda function.
- * @see [Documentation](https://remotion.dev/docs/lambda/rendermediaonlambda)
- * @param params.functionName The name of the Lambda function that should be used
- * @param params.serveUrl The URL of the deployed project
- * @param params.composition The ID of the composition which should be rendered.
- * @param params.inputProps The input props that should be passed to the composition.
- * @param params.codec The media codec which should be used for encoding.
- * @param params.imageFormat In which image format the frames should be rendered. Default "jpeg"
- * @param params.crf The constant rate factor to be used during encoding.
- * @param params.envVariables Object containing environment variables to be inserted into the video environment
- * @param params.proResProfile The ProRes profile if rendering a ProRes video
- * @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
- * @param params.region The AWS region in which the media should be rendered.
- * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"
- * @param params.logLevel Level of logging that Lambda function should perform. Default "info".
- * @param params.webhook Configuration for webhook called upon completion or timeout of the render.
- * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
- */
-
-export const renderMediaOnLambda = async (
- input: RenderMediaOnLambdaInput,
+const renderMediaOnLambdaRaw = async (
+ input: RenderMediaOnLambdaInput
): Promise<RenderMediaOnLambdaOutput> => {
const {functionName, region, rendererFunctionName} = input;
@@ -130,7 +111,7 @@ export const renderMediaOnLambda = async (
} catch (err) {
if ((err as Error).stack?.includes('UnrecognizedClientException')) {
throw new Error(
- 'UnrecognizedClientException: The AWS credentials provided were probably mixed up. Learn how to fix this issue here: https://remotion.dev/docs/lambda/troubleshooting/unrecognizedclientexception',
+ 'UnrecognizedClientException: The AWS credentials provided were probably mixed up. Learn how to fix this issue here: https://remotion.dev/docs/lambda/troubleshooting/unrecognizedclientexception'
);
}
@@ -138,6 +119,29 @@ export const renderMediaOnLambda = async (
}
};
+/**
+ * @description Triggers a render on a lambda given a composition and a lambda function.
+ * @see [Documentation](https://remotion.dev/docs/lambda/rendermediaonlambda)
+ * @param params.functionName The name of the Lambda function that should be used
+ * @param params.serveUrl The URL of the deployed project
+ * @param params.composition The ID of the composition which should be rendered.
+ * @param params.inputProps The input props that should be passed to the composition.
+ * @param params.codec The media codec which should be used for encoding.
+ * @param params.imageFormat In which image format the frames should be rendered. Default "jpeg"
+ * @param params.crf The constant rate factor to be used during encoding.
+ * @param params.envVariables Object containing environment variables to be inserted into the video environment
+ * @param params.proResProfile The ProRes profile if rendering a ProRes video
+ * @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
+ * @param params.region The AWS region in which the media should be rendered.
+ * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"
+ * @param params.logLevel Level of logging that Lambda function should perform. Default "info".
+ * @param params.webhook Configuration for webhook called upon completion or timeout of the render.
+ * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
+ */
+export const renderMediaOnLambda = wrapWithErrorHandling(
+ renderMediaOnLambdaRaw
+) as typeof renderMediaOnLambdaRaw;
+
/**
* @deprecated Renamed to renderMediaOnLambda()
*/
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index 5b674b1cd8..748d0ad469 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -5,6 +5,7 @@ import type {
ToOptions,
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
+import {wrapWithErrorHandling} from '@remotion/renderer/src/wrap-with-error-handling';
import {VERSION} from 'remotion/version';
import type {AwsRegion} from '../pricing/aws-regions';
import {callLambda} from '../shared/call-lambda';
@@ -59,24 +60,7 @@ export type RenderStillOnLambdaOutput = {
cloudWatchLogs: string;
};
-/**
- * @description Renders a still frame on Lambda
- * @link https://remotion.dev/docs/lambda/renderstillonlambda
- * @param params.functionName The name of the Lambda function that should be used
- * @param params.serveUrl The URL of the deployed project
- * @param params.composition The ID of the composition which should be rendered.
- * @param params.inputProps The input props that should be passed to the composition.
- * @param params.imageFormat In which image format the frames should be rendered.
- * @param params.envVariables Object containing environment variables to be inserted into the video environment
- * @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
- * @param params.region The AWS region in which the video should be rendered.
- * @param params.maxRetries How often rendering a chunk may fail before the video render gets aborted.
- * @param params.frame Which frame should be used for the still image. Default 0.
- * @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
- * @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
- */
-
-export const renderStillOnLambda = async ({
+const renderStillOnLambdaRaw = async ({
functionName,
serveUrl,
inputProps,
@@ -104,7 +88,7 @@ export const renderStillOnLambda = async ({
}: RenderStillOnLambdaInput): Promise<RenderStillOnLambdaOutput> => {
if (quality) {
throw new Error(
- 'The `quality` option is deprecated. Use `jpegQuality` instead.',
+ 'The `quality` option is deprecated. Use `jpegQuality` instead.'
);
}
@@ -181,10 +165,30 @@ export const renderStillOnLambda = async ({
} catch (err) {
if ((err as Error).stack?.includes('UnrecognizedClientException')) {
throw new Error(
- 'UnrecognizedClientException: The AWS credentials provided were probably mixed up. Learn how to fix this issue here: https://remotion.dev/docs/lambda/troubleshooting/unrecognizedclientexception',
+ 'UnrecognizedClientException: The AWS credentials provided were probably mixed up. Learn how to fix this issue here: https://remotion.dev/docs/lambda/troubleshooting/unrecognizedclientexception'
);
}
throw err;
}
};
+
+/**
+ * @description Renders a still frame on Lambda
+ * @link https://remotion.dev/docs/lambda/renderstillonlambda
+ * @param params.functionName The name of the Lambda function that should be used
+ * @param params.serveUrl The URL of the deployed project
+ * @param params.composition The ID of the composition which should be rendered.
+ * @param params.inputProps The input props that should be passed to the composition.
+ * @param params.imageFormat In which image format the frames should be rendered.
+ * @param params.envVariables Object containing environment variables to be inserted into the video environment
+ * @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
+ * @param params.region The AWS region in which the video should be rendered.
+ * @param params.maxRetries How often rendering a chunk may fail before the video render gets aborted.
+ * @param params.frame Which frame should be used for the still image. Default 0.
+ * @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
+ * @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
+ */
+export const renderStillOnLambda = wrapWithErrorHandling(
+ renderStillOnLambdaRaw
+) as typeof renderStillOnLambdaRaw;