Skip to content

🎥 Make videos programmatically with React

client implementation

Jonny Burger2aec8194a22c
diff --git a/packages/lambda/src/api/get-compositions-on-lambda.ts b/packages/lambda/src/api/get-compositions-on-lambda.ts
new file mode 100644
index 0000000000..b67163814d
--- /dev/null
+++ b/packages/lambda/src/api/get-compositions-on-lambda.ts
@@ -0,0 +1,67 @@
+import type {ChromiumOptions, LogLevel} from '@remotion/renderer';
+import {VERSION} from 'remotion/version';
+import type {AwsRegion} from '../client';
+import {LambdaRoutines} from '../defaults';
+import {callLambda} from '../shared/call-lambda';
+import {convertToServeUrl} from '../shared/convert-to-serve-url';
+import {serializeInputProps} from '../shared/serialize-input-props';
+
+export type GetCompositionsOnLambdaInput = {
+ chromiumOptions?: ChromiumOptions;
+ region: AwsRegion;
+ inputProps: unknown;
+ functionName: string;
+ serveUrl: string;
+ envVariables?: Record<string, string>;
+ logLevel?: LogLevel;
+ timeoutInMilliseconds?: number;
+};
+
+export type GetCompositionsOnLambdaOutput = {};
+
+export const getCompositionsOnLambda = async ({
+ chromiumOptions,
+ serveUrl,
+ region,
+ inputProps,
+ functionName,
+ envVariables,
+ logLevel,
+ timeoutInMilliseconds,
+}: GetCompositionsOnLambdaInput) => {
+ const realServeUrl = await convertToServeUrl(serveUrl, region);
+
+ const serializedInputProps = await serializeInputProps({
+ inputProps,
+ region,
+ type: 'still',
+ });
+
+ try {
+ const res = await callLambda({
+ functionName,
+ type: LambdaRoutines.compositions,
+ payload: {
+ chromiumOptions: chromiumOptions ?? {},
+ serveUrl: realServeUrl,
+ envVariables,
+ inputProps: serializedInputProps,
+ logLevel: logLevel ?? 'info',
+ timeoutInMilliseconds: timeoutInMilliseconds ?? 30000,
+ version: VERSION,
+ },
+ region,
+ });
+ return {
+ compositions: res.compositions,
+ };
+ } 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'
+ );
+ }
+
+ throw err;
+ }
+};