Skip to content

🎥 Make videos programmatically with React

allow to pick composition in lambda

Jonny Burger1aa7e224bb8f
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsx
index b7f9c2c817..05dc11c147 100644
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@ -26,6 +26,7 @@ import {previewCommand} from './preview';
import {printHelp} from './print-help';
import {createOverwriteableCliOutput} from './progress-bar';
import {render} from './render';
+import {selectComposition} from './select-composition';
import {still} from './still';
import {upgrade} from './upgrade';
import {
@@ -114,4 +115,5 @@ export const CliInternals = {
getFinalCodec,
determineFinalImageFormat,
minimist,
+ selectComposition,
};
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index e9e5ae2d92..b14367a009 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -1,5 +1,5 @@
import {CliInternals} from '@remotion/cli';
-import {RenderInternals} from '@remotion/renderer';
+import {getCompositions, RenderInternals} from '@remotion/renderer';
import {downloadMedia} from '../../../api/download-media';
import {getRenderProgress} from '../../../api/get-render-progress';
import {renderMediaOnLambda} from '../../../api/render-media-on-lambda';
@@ -8,11 +8,13 @@ import {
DEFAULT_MAX_RETRIES,
DEFAULT_OUTPUT_PRIVACY,
} from '../../../shared/constants';
+import {convertToServeUrl} from '../../../shared/convert-to-serve-url';
import {sleep} from '../../../shared/sleep';
import {validateFramesPerLambda} from '../../../shared/validate-frames-per-lambda';
import type {LambdaCodec} from '../../../shared/validate-lambda-codec';
import {validatePrivacy} from '../../../shared/validate-privacy';
import {validateMaxRetries} from '../../../shared/validate-retries';
+import {validateServeUrl} from '../../../shared/validate-serveurl';
import {parsedLambdaCli} from '../../args';
import {getAwsRegion} from '../../get-aws-region';
import {findFunctionName} from '../../helpers/find-function-name';
@@ -36,15 +38,17 @@ export const renderCommand = async (args: string[]) => {
quit(1);
}
- const composition = args[1];
+ const region = getAwsRegion();
+
+ let composition: string = args[1];
if (!composition) {
- Log.error('No composition ID passed.');
- Log.info('Pass an additional argument specifying the composition ID.');
- Log.info();
- Log.info(
- `${BINARY_NAME} ${RENDER_COMMAND} <serve-url> <composition-id> [output-location]`
- );
- quit(1);
+ Log.info('No compositions passed. Fetching compositions...');
+
+ validateServeUrl(serveUrl);
+ const realServeUrl = await convertToServeUrl(serveUrl, region);
+ const comps = await getCompositions(realServeUrl);
+ const {compositionId} = await CliInternals.selectComposition(comps);
+ composition = compositionId;
}
const outName = parsedLambdaCli['out-name'];
@@ -82,8 +86,6 @@ export const renderCommand = async (args: string[]) => {
const functionName = await findFunctionName();
- const region = getAwsRegion();
-
const maxRetries = parsedLambdaCli['max-retries'] ?? DEFAULT_MAX_RETRIES;
validateMaxRetries(maxRetries);
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index 838679c862..5afcfa3097 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -1,5 +1,5 @@
import {CliInternals, ConfigInternals} from '@remotion/cli';
-import {RenderInternals} from '@remotion/renderer';
+import {getCompositions, RenderInternals} from '@remotion/renderer';
import {downloadMedia} from '../../api/download-media';
import {renderStillOnLambda} from '../../api/render-still-on-lambda';
import {
@@ -7,8 +7,10 @@ import {
DEFAULT_MAX_RETRIES,
DEFAULT_OUTPUT_PRIVACY,
} from '../../shared/constants';
+import {convertToServeUrl} from '../../shared/convert-to-serve-url';
import {validatePrivacy} from '../../shared/validate-privacy';
import {validateMaxRetries} from '../../shared/validate-retries';
+import {validateServeUrl} from '../../shared/validate-serveurl';
import {parsedLambdaCli} from '../args';
import {getAwsRegion} from '../get-aws-region';
import {findFunctionName} from '../helpers/find-function-name';
@@ -32,15 +34,18 @@ export const stillCommand = async (args: string[]) => {
quit(1);
}
- const composition = args[1];
+ const region = getAwsRegion();
+ let composition = args[1];
if (!composition) {
- Log.error('No composition ID passed.');
- Log.info('Pass an additional argument specifying the composition ID.');
- Log.info();
- Log.info(
- `${BINARY_NAME} ${STILL_COMMAND} <serve-url> <composition-id> [output-location]`
- );
- quit(1);
+ if (!composition) {
+ Log.info('No compositions passed. Fetching compositions...');
+
+ validateServeUrl(serveUrl);
+ const realServeUrl = await convertToServeUrl(serveUrl, region);
+ const comps = await getCompositions(realServeUrl);
+ const {compositionId} = await CliInternals.selectComposition(comps);
+ composition = compositionId;
+ }
}
const downloadName = args[2] ?? null;
@@ -92,7 +97,7 @@ export const stillCommand = async (args: string[]) => {
imageFormat,
composition,
privacy,
- region: getAwsRegion(),
+ region,
maxRetries,
envVariables,
frame: stillFrame,
@@ -115,7 +120,7 @@ export const stillCommand = async (args: string[]) => {
const {outputPath, sizeInBytes} = await downloadMedia({
bucketName: res.bucketName,
outPath: downloadName,
- region: getAwsRegion(),
+ region,
renderId: res.renderId,
});
Log.info('Done!', outputPath, CliInternals.formatBytes(sizeInBytes));