Skip to content

🎥 Make videos programmatically with React

allow to download still

Jonny Burgerd04d7eab32eb
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index 0928dd1a8f..bc32030d56 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -1,16 +1,20 @@
import {CliInternals} from '@remotion/cli';
import {StillImageFormat} from 'remotion';
+import {downloadVideo} from '../..';
import {renderStillOnLambda} from '../../api/render-still-on-lambda';
import {
BINARY_NAME,
DEFAULT_MAX_RETRIES,
DEFAULT_OUTPUT_PRIVACY,
+ LambdaRoutines,
} from '../../shared/constants';
import {validatePrivacy} from '../../shared/validate-privacy';
import {validateMaxRetries} from '../../shared/validate-retries';
import {parsedLambdaCli} from '../args';
import {getAwsRegion} from '../get-aws-region';
import {findFunctionName} from '../helpers/find-function-name';
+import {formatBytes} from '../helpers/format-bytes';
+import {getCloudwatchStreamUrl} from '../helpers/get-cloudwatch-stream-url';
import {quit} from '../helpers/quit';
import {Log} from '../log';
@@ -18,6 +22,7 @@ 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(
@@ -34,10 +39,14 @@ export const stillCommand = async (args: string[]) => {
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>`);
+ Log.info(
+ `${BINARY_NAME} ${STILL_COMMAND} <serve-url> <composition-id> [output-location]`
+ );
quit(1);
}
+ const outName = args[2] ?? null;
+
const cliOptions = await CliInternals.getCliOptions({
type: 'still',
isLambda: true,
@@ -66,7 +75,32 @@ export const stillCommand = async (args: string[]) => {
logLevel: cliOptions.logLevel,
});
- Log.info(`Finished video!`);
- Log.info();
- Log.info(res.url);
+ Log.verbose(
+ CliInternals.chalk.gray(
+ `Bucket = ${res.bucketName}, renderId = ${res.renderId}, functionName = ${functionName}`
+ )
+ );
+ Log.verbose(
+ `CloudWatch logs (if enabled): ${getCloudwatchStreamUrl({
+ functionName,
+ region: getAwsRegion(),
+ renderId: res.renderId,
+ method: LambdaRoutines.still,
+ })}`
+ );
+
+ if (outName) {
+ Log.info('Finished rendering. Downloading...');
+ const {outputPath, sizeInBytes} = await downloadVideo({
+ bucketName: res.bucketName,
+ outPath: outName,
+ region: getAwsRegion(),
+ renderId: res.renderId,
+ });
+ Log.info('Done!', outputPath, formatBytes(sizeInBytes));
+ } else {
+ Log.info(`Finished still!`);
+ Log.info();
+ Log.info(res.url);
+ }
};