Skip to content

🎥 Make videos programmatically with React

various stuff

Jonny Burgerd5f5616e8e20
diff --git a/packages/lambda/src/api/render-video-on-lambda.ts b/packages/lambda/src/api/render-video-on-lambda.ts
index 72c3e63a2a..5c62ce4d40 100644
--- a/packages/lambda/src/api/render-video-on-lambda.ts
+++ b/packages/lambda/src/api/render-video-on-lambda.ts
@@ -1,5 +1,4 @@
import {Codec, ImageFormat, PixelFormat, ProResProfile} from 'remotion';
-import {parsedLambdaCli} from '../cli/args';
import {AwsRegion} from '../pricing/aws-regions';
import {callLambda} from '../shared/call-lambda';
import {LambdaRoutines} from '../shared/constants';
@@ -17,6 +16,7 @@ export const renderVideoOnLambda = async ({
quality,
region,
maxRetries,
+ composition,
}: {
region: AwsRegion;
functionName: string;
@@ -30,6 +30,7 @@ export const renderVideoOnLambda = async ({
proResProfile?: ProResProfile;
quality?: number;
maxRetries: number;
+ composition: string;
}) => {
const res = await callLambda({
functionName,
@@ -37,7 +38,7 @@ export const renderVideoOnLambda = async ({
payload: {
// TODO: Allow to parametrize
chunkSize: 20,
- composition: parsedLambdaCli._[2],
+ composition,
serveUrl,
inputProps,
codec,
diff --git a/packages/lambda/src/cli/commands/functions/deploy.ts b/packages/lambda/src/cli/commands/functions/deploy.ts
index 069377bdf4..65ddae6a2f 100644
--- a/packages/lambda/src/cli/commands/functions/deploy.ts
+++ b/packages/lambda/src/cli/commands/functions/deploy.ts
@@ -15,6 +15,7 @@ import {getAwsRegion} from '../../get-aws-region';
export const FUNCTIONS_DEPLOY_SUBCOMMAND = 'deploy';
export const functionsDeploySubcommand = async () => {
+ // TODO: Should only allow one lambda to be deployed
const region = getAwsRegion();
const timeoutInSeconds = parsedLambdaCli.timeout ?? DEFAULT_TIMEOUT;
const memorySize = parsedLambdaCli.memory ?? DEFAULT_MEMORY_SIZE;
diff --git a/packages/lambda/src/cli/commands/functions/rm.ts b/packages/lambda/src/cli/commands/functions/rm.ts
index 74135afa69..2b02af2ca6 100644
--- a/packages/lambda/src/cli/commands/functions/rm.ts
+++ b/packages/lambda/src/cli/commands/functions/rm.ts
@@ -11,6 +11,7 @@ import {FUNCTIONS_LS_SUBCOMMAND} from './ls';
export const FUNCTIONS_RM_SUBCOMMAND = 'rm';
const LEFT_COL = 16;
+// TODO: Should allow to remove multiple at once
export const functionsRmCommand = async (args: string[]) => {
const region = getAwsRegion();
const functionName = args[0];
diff --git a/packages/lambda/src/cli/commands/sites/index.ts b/packages/lambda/src/cli/commands/sites/index.ts
index 2fcf5ab615..7796df78ba 100644
--- a/packages/lambda/src/cli/commands/sites/index.ts
+++ b/packages/lambda/src/cli/commands/sites/index.ts
@@ -3,6 +3,7 @@ import {Log} from '@remotion/cli/dist/log';
import {BINARY_NAME} from '../../../shared/constants';
import {sitesLsSubcommand, SITES_LS_SUBCOMMAND} from './ls';
import {sitesRmSubcommand, SITES_RM_COMMAND} from './rm';
+import {sitesUploadSubcommand, SITES_UPLOAD_SUBCOMMAND} from './upload';
export const SITES_COMMAND = 'sites';
@@ -11,11 +12,18 @@ export const printSitesHelp = () => {
Log.info();
Log.info('Available subcommands:');
Log.info();
+ Log.info(
+ `${BINARY_NAME} ${SITES_COMMAND} ${SITES_UPLOAD_SUBCOMMAND} <entry-point>`
+ );
+ Log.info(
+ CliInternals.chalk.gray('Creates a new site based on a Remotion project')
+ );
+ Log.info();
Log.info(`${BINARY_NAME} ${SITES_COMMAND} ${SITES_LS_SUBCOMMAND}`);
Log.info(CliInternals.chalk.gray('Lists the sites currently deployed'));
Log.info();
Log.info(`${BINARY_NAME} ${SITES_COMMAND} ${SITES_RM_COMMAND} <site-id>`);
- Log.info(CliInternals.chalk.gray('Remove a site'));
+ Log.info(CliInternals.chalk.gray('Remove a site from the S3 bucket.'));
};
export const sitesCommand = (args: string[]) => {
@@ -27,6 +35,10 @@ export const sitesCommand = (args: string[]) => {
return sitesRmSubcommand(args.slice(1));
}
+ if (args[0] === SITES_UPLOAD_SUBCOMMAND) {
+ return sitesUploadSubcommand(args.slice(1));
+ }
+
if (args[0]) {
Log.error(`Subcommand ${args[0]} not found.`);
printSitesHelp();
diff --git a/packages/lambda/src/cli/upload.ts b/packages/lambda/src/cli/commands/sites/upload.ts
similarity index 86%
rename from packages/lambda/src/cli/upload.ts
rename to packages/lambda/src/cli/commands/sites/upload.ts
index cb0fa382c2..fc3097120b 100644
--- a/packages/lambda/src/cli/upload.ts
+++ b/packages/lambda/src/cli/commands/sites/upload.ts
@@ -1,11 +1,10 @@
import {CliInternals} from '@remotion/cli';
import {existsSync, lstatSync} from 'fs';
import path from 'path';
-import {deployProject} from '../api/deploy-project';
-import {getOrCreateBucket} from '../api/get-or-create-bucket';
-import {BINARY_NAME} from '../shared/constants';
-import {parsedLambdaCli} from './args';
-import {getAwsRegion} from './get-aws-region';
+import {deployProject} from '../../../api/deploy-project';
+import {getOrCreateBucket} from '../../../api/get-or-create-bucket';
+import {BINARY_NAME} from '../../../shared/constants';
+import {getAwsRegion} from '../../get-aws-region';
import {
BucketCreationProgress,
BundleProgress,
@@ -13,13 +12,13 @@ import {
makeBucketProgress,
makeBundleProgress,
makeDeployProgressBar,
-} from './helpers/progress-bar';
-import {Log} from './log';
+} from '../../helpers/progress-bar';
+import {Log} from '../../log';
-export const UPLOAD_COMMAND = 'upload';
+export const SITES_UPLOAD_SUBCOMMAND = 'create';
-export const uploadCommand = async () => {
- const fileName = parsedLambdaCli._[1];
+export const sitesUploadSubcommand = async (args: string[]) => {
+ const fileName = args[0];
if (!fileName) {
Log.error('No entry file passed.');
Log.info(
diff --git a/packages/lambda/src/cli/help.ts b/packages/lambda/src/cli/help.ts
index 36aa3fcfbd..41d4eae1a9 100644
--- a/packages/lambda/src/cli/help.ts
+++ b/packages/lambda/src/cli/help.ts
@@ -4,7 +4,6 @@ import {CLEANUP_COMMAND} from './cleanup';
import {FUNCTIONS_COMMAND} from './commands/functions';
import {Log} from './log';
import {RENDER_COMMAND} from './render';
-import {UPLOAD_COMMAND} from './upload';
const packagejson = require('../../package.json');
@@ -18,10 +17,6 @@ export const printHelp = () => {
Log.info('Available commands:');
Log.info('');
- Log.info(`${BINARY_NAME} ${UPLOAD_COMMAND} <index-file.ts>`);
- Log.info(CliInternals.chalk.gray('Upload a Remotion project to S3.'));
- Log.info();
-
Log.info(`${BINARY_NAME} ${RENDER_COMMAND} <s3-url>`);
Log.info(CliInternals.chalk.gray('Render a video on the cloud.'));
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index 55e6ee9121..1ca392c877 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -7,7 +7,6 @@ import {printHelp} from './help';
import {Log} from './log';
import {policiesCommand, POLICIES_COMMAND} from './policies';
import {renderCommand, RENDER_COMMAND} from './render';
-import {uploadCommand, UPLOAD_COMMAND} from './upload';
const matchCommand = async () => {
if (parsedLambdaCli.help || parsedLambdaCli._.length === 0) {
@@ -15,12 +14,8 @@ const matchCommand = async () => {
process.exit(0);
}
- if (parsedLambdaCli._[0] === UPLOAD_COMMAND) {
- return uploadCommand();
- }
-
if (parsedLambdaCli._[0] === RENDER_COMMAND) {
- return renderCommand();
+ return renderCommand(parsedLambdaCli._.slice(1));
}
if (parsedLambdaCli._[0] === FUNCTIONS_COMMAND) {
@@ -39,6 +34,20 @@ const matchCommand = async () => {
return sitesCommand(parsedLambdaCli._.slice(1));
}
+ if (parsedLambdaCli._[0] === 'upload') {
+ Log.info('The command has been renamed.');
+ Log.info('Before: remotion-lambda upload <entry-point>');
+ Log.info('After: remotion-lambda sites create <entry-point>');
+ process.exit(1);
+ }
+
+ if (parsedLambdaCli._[0] === 'deploy') {
+ Log.info('The command has been renamed.');
+ Log.info('Before: remotion-lambda deploy');
+ Log.info('After: remotion-lambda functions deploy');
+ process.exit(1);
+ }
+
Log.error(`Command ${parsedLambdaCli._[0]} not found.`);
printHelp();
process.exit(1);
diff --git a/packages/lambda/src/cli/render.ts b/packages/lambda/src/cli/render.ts
index 863d735f67..30bd7842b0 100644
--- a/packages/lambda/src/cli/render.ts
+++ b/packages/lambda/src/cli/render.ts
@@ -13,20 +13,27 @@ import {Log} from './log';
export const RENDER_COMMAND = 'render';
-export const renderCommand = async () => {
- const serveUrl = parsedLambdaCli._[1];
+export const renderCommand = async (args: string[]) => {
+ const serveUrl = args[0];
if (!serveUrl) {
Log.error('No serve URL passed.');
Log.info(
'Pass an additional argument specifying a URL where your Remotion project is hosted.'
);
Log.info();
- Log.info(
- `${BINARY_NAME} ${RENDER_COMMAND} <http://remotion.s3.amazonaws.com>`
- );
+ Log.info(`${BINARY_NAME} ${RENDER_COMMAND} <serve-url> <composition-id>`);
process.exit(1);
}
+ const composition = args[1];
+ if (!composition) {
+ Log.error('No composition ID passed.');
+ Log.info('Pass an additional argument specifying the composition ID.');
+ Log.info();
+ // TODO: Rename serveURL
+ Log.info(`${BINARY_NAME} ${RENDER_COMMAND} <serve-url> <composition-id>`);
+ }
+
// TODO: Redundancy with CLI
if (!parsedLambdaCli._[2]) {
Log.error('Composition ID not passed.');
@@ -48,9 +55,10 @@ export const renderCommand = async () => {
process.exit(1);
}
+ // TODO: Should only trigger if more than 1 function of the same version
if (remotionLambdas.length > 1) {
Log.error(
- 'More than lambda function found in your account. This is an 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(
@@ -78,6 +86,7 @@ export const renderCommand = async () => {
region: getAwsRegion(),
// TODO: Unhardcode retries
maxRetries: 3,
+ composition,
});
for (let i = 0; i < 3000; i++) {
await sleep(1000);