Skip to content

🎥 Make videos programmatically with React

still command

Jonny Burger98f9d33dda68
diff --git a/packages/docs/docs/renderstillonlambda.md b/packages/docs/docs/renderstillonlambda.md
index 8fde3fc13d..5e1ba1b55c 100644
--- a/packages/docs/docs/renderstillonlambda.md
+++ b/packages/docs/docs/renderstillonlambda.md
@@ -8,7 +8,7 @@ Renders a still image inside a lambda function and writes it to the specified ou
If you want to render a video instead, use [`renderVideoOnLamda()`](/docs/lambda/rendervideoonlambda) instead.
-If you want to render a still locally instead, use [`renderStill()`](/docs/renderstill) instead.
+If you want to render a still locally instead, use [`renderStill()`](/docs/render-still) instead.
## Example
@@ -120,4 +120,4 @@ The size of the output image in bytes.
## See also
- [renderVideoOnLambda()](/docs/lambda/rendervideoonlambda)
-- [renderStill()](/docs/lambda/renderstill)
+- [renderStill()](/docs/render-still)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 0789b9e514..bda81fe74c 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -140,7 +140,7 @@ module.exports = {
"get-compositions",
"render-frames",
"stitch-frames-to-video",
- "render-still",
+ "renderstill",
],
},
{
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index 9a5ec570f4..4044bf125b 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -64,5 +64,6 @@ export const renderStillOnLambda = async ({
estimatedPrice: res.estimatedPrice,
url: res.output,
size: res.size,
+ bucketName: res.bucketName,
};
};
diff --git a/packages/lambda/src/api/render-video-on-lambda.ts b/packages/lambda/src/api/render-video-on-lambda.ts
index dce97bd8e7..6c573b2b0d 100644
--- a/packages/lambda/src/api/render-video-on-lambda.ts
+++ b/packages/lambda/src/api/render-video-on-lambda.ts
@@ -2,6 +2,8 @@ import {ImageFormat, PixelFormat, ProResProfile} from 'remotion';
import {AwsRegion} from '../pricing/aws-regions';
import {callLambda} from '../shared/call-lambda';
import {LambdaRoutines} from '../shared/constants';
+
+// TODO: `privacy` field
/**
* @description Triggers a render on a lambda given a composition and a lambda function.
* @link https://remotion.dev/docs/lambda/rendervideoonlambda
diff --git a/packages/lambda/src/cli/commands/render.ts b/packages/lambda/src/cli/commands/render.ts
index 8f95361f23..c9b1cc8bd8 100644
--- a/packages/lambda/src/cli/commands/render.ts
+++ b/packages/lambda/src/cli/commands/render.ts
@@ -1,14 +1,11 @@
import {CliInternals} from '@remotion/cli';
-import {getFunctions} from '../api/get-functions';
-import {getRenderProgress} from '../api/get-render-progress';
-import {renderVideoOnLambda} from '../api/render-video-on-lambda';
-import {BINARY_NAME, CURRENT_VERSION} from '../shared/constants';
-import {sleep} from '../shared/sleep';
-import {CLEANUP_COMMAND, CLEANUP_LAMBDAS_SUBCOMMAND} from './cleanup';
-import {FUNCTIONS_COMMAND} from './commands/functions';
-import {FUNCTIONS_DEPLOY_SUBCOMMAND} from './commands/functions/deploy';
-import {getAwsRegion} from './get-aws-region';
-import {Log} from './log';
+import {getRenderProgress} from '../../api/get-render-progress';
+import {renderVideoOnLambda} from '../../api/render-video-on-lambda';
+import {BINARY_NAME} from '../../shared/constants';
+import {sleep} from '../../shared/sleep';
+import {getAwsRegion} from '../get-aws-region';
+import {findFunctionName} from '../helpers/find-function-name';
+import {Log} from '../log';
export const RENDER_COMMAND = 'render';
@@ -36,51 +33,13 @@ export const renderCommand = async (args: string[]) => {
// TODO: Further validate serveUrl
- const remotionLambdas = await getFunctions({
- region: getAwsRegion(),
- compatibleOnly: false,
- });
- const lambdasWithMatchingVersion = remotionLambdas.filter(
- (l) => l.version === CURRENT_VERSION
- );
-
- if (lambdasWithMatchingVersion.length === 0) {
- Log.error(
- `No lambda functions with version ${CURRENT_VERSION} found in your account.`
- );
- if (remotionLambdas.length > 0) {
- Log.error(
- 'Other functions were found, but are not compatible with this version of the CLI.'
- );
- }
-
- Log.info('Run');
- Log.info(
- ` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_DEPLOY_SUBCOMMAND}`
- );
- Log.info(`to deploy a new lambda function.`);
- process.exit(1);
- }
-
- 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} ${CLEANUP_COMMAND} ${CLEANUP_LAMBDAS_SUBCOMMAND}`
- );
- Log.info('to delete all lambda functions.');
- process.exit(1);
- }
-
- const {functionName} = lambdasWithMatchingVersion[0];
-
const cliOptions = await CliInternals.getCliOptions({
type: 'series',
isLambda: true,
});
+ const functionName = await findFunctionName();
+
const res = await renderVideoOnLambda({
functionName,
serveUrl,
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
new file mode 100644
index 0000000000..7f2fb89961
--- /dev/null
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -0,0 +1,59 @@
+import {CliInternals} from '@remotion/cli';
+import {StillImageFormat} from 'remotion';
+import {renderStillOnLambda} from '../../api/render-still-on-lambda';
+import {BINARY_NAME} from '../../shared/constants';
+import {getAwsRegion} from '../get-aws-region';
+import {findFunctionName} from '../helpers/find-function-name';
+import {Log} from '../log';
+
+export const STILL_COMMAND = 'still';
+
+export const stillCommand = 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} ${STILL_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} ${STILL_COMMAND} <serve-url> <composition-id>`);
+ process.exit(1);
+ }
+
+ const cliOptions = await CliInternals.getCliOptions({
+ type: 'still',
+ isLambda: true,
+ });
+
+ const functionName = await findFunctionName();
+
+ const res = await renderStillOnLambda({
+ functionName,
+ serveUrl,
+ inputProps: cliOptions.inputProps,
+ imageFormat: cliOptions.imageFormat as StillImageFormat,
+ composition,
+ // TODO: Make configurable
+ privacy: 'public',
+ region: getAwsRegion(),
+ // TODO: Unhardcdoe retries
+ maxRetries: 3,
+ envVariables: cliOptions.envVariables,
+ frame: cliOptions.stillFrame,
+ quality: cliOptions.quality,
+ });
+
+ Log.info(`Finished video!`);
+ Log.info();
+ Log.info(res.url);
+};
diff --git a/packages/lambda/src/cli/help.ts b/packages/lambda/src/cli/help.ts
index 49a1f05587..db97ff588c 100644
--- a/packages/lambda/src/cli/help.ts
+++ b/packages/lambda/src/cli/help.ts
@@ -3,6 +3,7 @@ import {BINARY_NAME} from '../shared/constants';
import {CLEANUP_COMMAND} from './cleanup';
import {FUNCTIONS_COMMAND} from './commands/functions';
import {RENDER_COMMAND} from './commands/render';
+import {STILL_COMMAND} from './commands/still';
import {Log} from './log';
const packagejson = require('../../package.json');
@@ -17,8 +18,11 @@ export const printHelp = () => {
Log.info('Available commands:');
Log.info('');
- Log.info(`${BINARY_NAME} ${RENDER_COMMAND} <s3-url>`);
- Log.info(CliInternals.chalk.gray('Render a video on the cloud.'));
+ Log.info(`${BINARY_NAME} ${RENDER_COMMAND} <s3-url> <composition-id>`);
+ Log.info(CliInternals.chalk.gray('Render a video in the cloud.'));
+
+ Log.info(`${BINARY_NAME} ${STILL_COMMAND} <s3-url> <composiiton-id>`);
+ Log.info(CliInternals.chalk.gray('Render a still image in the cloud.'));
Log.info();
Log.info(`${BINARY_NAME} ${CLEANUP_COMMAND}`);
diff --git a/packages/lambda/src/cli/helpers/find-function-name.ts b/packages/lambda/src/cli/helpers/find-function-name.ts
new file mode 100644
index 0000000000..369cb3cbe6
--- /dev/null
+++ b/packages/lambda/src/cli/helpers/find-function-name.ts
@@ -0,0 +1,51 @@
+import {getFunctions} from '../../api/get-functions';
+import {BINARY_NAME, CURRENT_VERSION} from '../../shared/constants';
+import {CLEANUP_COMMAND, CLEANUP_LAMBDAS_SUBCOMMAND} from '../cleanup';
+import {FUNCTIONS_COMMAND} from '../commands/functions';
+import {FUNCTIONS_DEPLOY_SUBCOMMAND} from '../commands/functions/deploy';
+import {getAwsRegion} from '../get-aws-region';
+import {Log} from '../log';
+
+export const findFunctionName = async () => {
+ const remotionLambdas = await getFunctions({
+ region: getAwsRegion(),
+ compatibleOnly: false,
+ });
+ const lambdasWithMatchingVersion = remotionLambdas.filter(
+ (l) => l.version === CURRENT_VERSION
+ );
+
+ if (lambdasWithMatchingVersion.length === 0) {
+ Log.error(
+ `No lambda functions with version ${CURRENT_VERSION} found in your account.`
+ );
+ if (remotionLambdas.length > 0) {
+ Log.error(
+ 'Other functions were found, but are not compatible with this version of the CLI.'
+ );
+ }
+
+ Log.info('Run');
+ Log.info(
+ ` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_DEPLOY_SUBCOMMAND}`
+ );
+ Log.info(`to deploy a new lambda function.`);
+ process.exit(1);
+ }
+
+ 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} ${CLEANUP_COMMAND} ${CLEANUP_LAMBDAS_SUBCOMMAND}`
+ );
+ Log.info('to delete all lambda functions.');
+ process.exit(1);
+ }
+
+ const {functionName} = lambdasWithMatchingVersion[0];
+
+ return functionName;
+};
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index 483b80a386..51808fd0b4 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -6,6 +6,7 @@ import {functionsCommand, FUNCTIONS_COMMAND} from './commands/functions';
import {policiesCommand, POLICIES_COMMAND} from './commands/policies/policies';
import {renderCommand, RENDER_COMMAND} from './commands/render';
import {sitesCommand, SITES_COMMAND} from './commands/sites';
+import {stillCommand, STILL_COMMAND} from './commands/still';
import {printHelp} from './help';
import {Log} from './log';
@@ -20,6 +21,10 @@ const matchCommand = async (args: string[]) => {
return renderCommand(args.slice(1));
}
+ if (args[0] === STILL_COMMAND) {
+ return stillCommand(args.slice(1));
+ }
+
if (args[0] === FUNCTIONS_COMMAND) {
return functionsCommand(args.slice(1));
}