Skip to content

🎥 Make videos programmatically with React

renderer function

Jonny Burger5246cd0ee574
diff --git a/packages/docs/docs/lambda/cli/render.md b/packages/docs/docs/lambda/cli/render.md
index 95aa7f2414..82cb4ecc5c 100644
--- a/packages/docs/docs/lambda/cli/render.md
+++ b/packages/docs/docs/lambda/cli/render.md
@@ -218,6 +218,12 @@ _available from v3.2.40_
[Overrides composition width.](/docs/config#overridewidth)
+### `--function-name`
+
+_available from v3.3.38_
+
+Specify the name of the function which should be used to invoke and orchestrate the render. You only need to pass it if there are multiple functions with different configurations.
+
### `--renderer-function-name`
_available from v3.3.38_
diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.ts
index 2197094a27..8d961e41f1 100644
--- a/packages/lambda/src/api/render-media-on-lambda.ts
+++ b/packages/lambda/src/api/render-media-on-lambda.ts
@@ -182,6 +182,7 @@ export const renderMediaOnLambda = async ({
method: LambdaRoutines.renderer,
region,
renderId: res.renderId,
+ rendererFunctionName: rendererFunctionName ?? null,
}),
folderInS3Console: getS3RenderUrl({
bucketName: res.bucketName,
diff --git a/packages/lambda/src/cli/args.ts b/packages/lambda/src/cli/args.ts
index d4f511ae47..cb7170d52b 100644
--- a/packages/lambda/src/cli/args.ts
+++ b/packages/lambda/src/cli/args.ts
@@ -31,6 +31,7 @@ type LambdaCommandLineOptions = {
webhook: string | undefined;
['webhook-secret']: string | undefined;
['renderer-function-name']: string | undefined;
+ ['function-name']: string | undefined;
};
export const parsedLambdaCli = CliInternals.minimist<LambdaCommandLineOptions>(
diff --git a/packages/lambda/src/cli/helpers/find-function-name.ts b/packages/lambda/src/cli/helpers/find-function-name.ts
index 627ea39502..1d4afce0f5 100644
--- a/packages/lambda/src/cli/helpers/find-function-name.ts
+++ b/packages/lambda/src/cli/helpers/find-function-name.ts
@@ -1,6 +1,7 @@
import {VERSION} from 'remotion/version';
import {getFunctions} from '../../api/get-functions';
import {BINARY_NAME} from '../../shared/constants';
+import {parsedLambdaCli} from '../args';
import {FUNCTIONS_COMMAND} from '../commands/functions';
import {FUNCTIONS_DEPLOY_SUBCOMMAND} from '../commands/functions/deploy';
import {FUNCTIONS_LS_SUBCOMMAND} from '../commands/functions/ls';
@@ -14,7 +15,7 @@ export const findFunctionName = async () => {
region: getAwsRegion(),
compatibleOnly: false,
});
- const lambdasWithMatchingVersion = remotionLambdas.filter(
+ let lambdasWithMatchingVersion = remotionLambdas.filter(
(l) => l.version === VERSION
);
@@ -37,15 +38,61 @@ export const findFunctionName = async () => {
}
if (lambdasWithMatchingVersion.length > 1) {
- Log.error(
- 'More than 1 lambda function found in your account. This is an error.'
- );
- Log.info(`Delete extraneous lambda functions in your AWS console or run`);
- Log.info(
- ` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_RM_SUBCOMMAND} $(npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_LS_SUBCOMMAND} -q) -y`
- );
- Log.info('to delete all lambda functions.');
- quit(1);
+ if (parsedLambdaCli['function-name']) {
+ const prevFunctions = [...lambdasWithMatchingVersion];
+ lambdasWithMatchingVersion = lambdasWithMatchingVersion.filter(
+ (l) => l.functionName === parsedLambdaCli['function-name']
+ );
+ if (lambdasWithMatchingVersion.length === 0) {
+ Log.error(
+ `No lambda function with name "${parsedLambdaCli['function-name']}" and version ${VERSION} found in your account.`
+ );
+ Log.info();
+
+ if (prevFunctions.length === 0) {
+ Log.info(
+ `No functions for version ${VERSION} were found, deploy one using:`
+ );
+ Log.info(
+ ` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_DEPLOY_SUBCOMMAND}`
+ );
+ quit(1);
+ }
+
+ Log.info('The following functions were found:');
+ for (const l of prevFunctions) {
+ Log.info(`- ${l.functionName} (v${l.version})`);
+ }
+
+ Log.info('Remove the `--function-name` parameter use one of them.');
+
+ quit(1);
+ }
+ } else {
+ Log.error(
+ 'More than 1 lambda function found in your account. Unsure which one to use.'
+ );
+ Log.info();
+ Log.info('Possible solutions:');
+ Log.info(
+ '- Define using `--function-name` which function you want to use.'
+ );
+ Log.info(
+ `- Delete extraneous lambda functions in your AWS console or using:`
+ );
+ Log.info(
+ ` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_RM_SUBCOMMAND} $(npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_LS_SUBCOMMAND} -q) -y`
+ );
+ Log.info();
+ Log.info(
+ `The following functions were found (only showing v${VERSION}):`
+ );
+ for (const l of lambdasWithMatchingVersion) {
+ Log.info(`- ${l.functionName}`);
+ }
+
+ quit(1);
+ }
}
const {functionName} = lambdasWithMatchingVersion[0];
diff --git a/packages/lambda/src/shared/get-aws-urls.ts b/packages/lambda/src/shared/get-aws-urls.ts
index c0b7581cc4..396f54dbc8 100644
--- a/packages/lambda/src/shared/get-aws-urls.ts
+++ b/packages/lambda/src/shared/get-aws-urls.ts
@@ -6,13 +6,16 @@ export const getCloudwatchStreamUrl = ({
functionName,
method,
renderId,
+ rendererFunctionName,
}: {
region: AwsRegion;
functionName: string;
+ rendererFunctionName: string | null;
method: LambdaRoutines;
renderId: string;
}) => {
- return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:log-groups/log-group/$252Faws$252Flambda$252F${functionName}/log-events$3FfilterPattern$3D$2522method$253D${method}$252CrenderId$253D${renderId}$2522`;
+ const functionNameToUse = rendererFunctionName ?? functionName;
+ return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:log-groups/log-group/$252Faws$252Flambda$252F${functionNameToUse}/log-events$3FfilterPattern$3D$2522method$253D${method}$252CrenderId$253D${renderId}$2522`;
};
export const getS3RenderUrl = ({