Skip to content

πŸŽ₯ Make videos programmatically with React

lambda improvements

Jonny Burger8474cfd20a22
diff --git a/packages/example/runlambda.sh b/packages/example/runlambda.sh
index 935c37f18b..0c9bd57010 100644
--- a/packages/example/runlambda.sh
+++ b/packages/example/runlambda.sh
@@ -7,4 +7,4 @@ cd example
bunx remotion lambda functions rmall -f
bunx remotion lambda functions deploy --memory=3000 --disk=10000
bunx remotion lambda sites create --site-name=testbed-v6 --log=verbose --enable-folder-expiry
-bunx remotion lambda render testbed-v6 subtitle --log=verbose --delete-after="1-day"
+bunx remotion lambda still testbed-v6 subtitle --log=verbose --delete-after="1-day" out-there.png
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index 6b9c6c297c..dd4c2d8ce2 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -5,6 +5,7 @@ import type {
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
+import type {ReceivedAsset} from '../functions/helpers/overall-render-progress';
import type {RenderStillLambdaResponsePayload} from '../functions/still';
import type {AwsRegion} from '../pricing/aws-regions';
import {callLambdaWithStreaming} from '../shared/call-lambda';
@@ -67,6 +68,7 @@ export type RenderStillOnLambdaOutput = {
bucketName: string;
renderId: string;
cloudWatchLogs: string;
+ receivedAssets: ReceivedAsset[];
};
const internalRenderStillOnLambda = async (
@@ -130,6 +132,7 @@ const internalRenderStillOnLambda = async (
renderId: res.renderId,
rendererFunctionName: null,
}),
+ receivedAssets: res.receivedAssets,
};
} catch (err) {
if ((err as Error).stack?.includes('UnrecognizedClientException')) {
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index 316a6a14fe..cfd637d60f 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -2,6 +2,7 @@ import {CliInternals} from '@remotion/cli';
import {RenderInternals} from '@remotion/renderer';
import {NoReactInternals} from 'remotion/no-react';
import type {RenderProgress} from '../../../defaults';
+import type {ReceivedAsset} from '../../../functions/helpers/overall-render-progress';
import {truthy} from '../../../shared/truthy';
type LambdaInvokeProgress = {
@@ -200,8 +201,7 @@ const makeTopRow = (overall: RenderProgress) => {
return CliInternals.chalk.gray(str);
};
-const makeArtifactProgress = (progress: RenderProgress) => {
- const {artifactProgress} = progress;
+export const makeArtifactProgress = (artifactProgress: ReceivedAsset[]) => {
if (artifactProgress.length === 0) {
return null;
}
@@ -209,12 +209,12 @@ const makeArtifactProgress = (progress: RenderProgress) => {
return artifactProgress
.map((artifact) => {
return [
- CliInternals.chalk.blue('+'.padEnd(CliInternals.LABEL_WIDTH)),
+ CliInternals.chalk.blue('+ S3'.padEnd(CliInternals.LABEL_WIDTH)),
CliInternals.chalk.blue(
CliInternals.makeHyperlink({
url: artifact.s3Url,
fallback: artifact.filename,
- text: artifact.filename,
+ text: artifact.s3Key,
}),
),
CliInternals.chalk.gray(
@@ -239,8 +239,8 @@ export const makeProgressString = ({
...makeInvokeProgress(overall),
...makeRenderProgress(overall),
makeCombinationProgress(overall),
- makeArtifactProgress(overall),
downloadInfo ? makeDownloadProgress(downloadInfo) : null,
+ makeArtifactProgress(overall.artifactProgress),
]
.filter(NoReactInternals.truthy)
.join('\n');
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index 332cd2c476..a193a4dfe2 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -3,6 +3,7 @@ import {ConfigInternals} from '@remotion/cli/config';
import type {ChromiumOptions, LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {BrowserSafeApis} from '@remotion/renderer/client';
+import path from 'path';
import {NoReactInternals} from 'remotion/no-react';
import {downloadMedia} from '../../../api/download-media';
import {getRenderProgress} from '../../../api/get-render-progress';
@@ -428,16 +429,11 @@ export const renderCommand = async (
);
if (newStatus.done) {
- progressBar.update(
- makeProgressString({
- downloadInfo: null,
- overall: newStatus,
- }),
- false,
- );
+ let downloadOrNothing;
+
if (downloadName) {
const downloadStart = Date.now();
- const {outputPath, sizeInBytes} = await downloadMedia({
+ const download = await downloadMedia({
bucketName: res.bucketName,
outPath: downloadName,
region: getAwsRegion(),
@@ -457,29 +453,55 @@ export const renderCommand = async (
);
},
});
+ downloadOrNothing = download;
progressBar.update(
makeProgressString({
downloadInfo: {
doneIn: Date.now() - downloadStart,
- downloaded: sizeInBytes,
- totalSize: sizeInBytes,
+ downloaded: download.sizeInBytes,
+ totalSize: download.sizeInBytes,
},
overall: newStatus,
}),
false,
);
- Log.info({indent: false, logLevel});
- Log.info({indent: false, logLevel});
+ }
+
+ Log.info({indent: false, logLevel});
+ Log.info(
+ {indent: false, logLevel},
+ CliInternals.chalk.blue('+ S3 '.padEnd(CliInternals.LABEL_WIDTH)),
+ CliInternals.chalk.blue(
+ CliInternals.makeHyperlink({
+ fallback: newStatus.outputFile as string,
+ text: newStatus.outKey as string,
+ url: newStatus.outputFile as string,
+ }),
+ ),
+ CliInternals.chalk.gray(
+ CliInternals.formatBytes(newStatus.outputSizeInBytes as number),
+ ),
+ );
+
+ if (downloadOrNothing) {
+ const relativeOutputPath = path.relative(
+ process.cwd(),
+ downloadOrNothing.outputPath,
+ );
Log.info(
{indent: false, logLevel},
- 'Done!',
- outputPath,
- CliInternals.formatBytes(sizeInBytes),
+ CliInternals.chalk.blue('↓'.padEnd(CliInternals.LABEL_WIDTH)),
+ CliInternals.chalk.blue(
+ CliInternals.makeHyperlink({
+ url: `file://${downloadOrNothing.outputPath}`,
+ text: relativeOutputPath,
+ fallback: downloadOrNothing.outputPath,
+ }),
+ ),
+ CliInternals.chalk.gray(
+ CliInternals.formatBytes(downloadOrNothing.sizeInBytes),
+ ),
);
- } else {
- Log.info({indent: false, logLevel});
- Log.info({indent: false, logLevel});
- Log.info({indent: false, logLevel}, 'Done! ' + newStatus.outputFile);
}
Log.info(
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index 328e99cad1..4560da05c7 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -3,6 +3,7 @@ import {ConfigInternals} from '@remotion/cli/config';
import type {ChromiumOptions, LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {BrowserSafeApis} from '@remotion/renderer/client';
+import path from 'path';
import {NoReactInternals} from 'remotion/no-react';
import {downloadMedia} from '../../api/download-media';
import {renderStillOnLambda} from '../../api/render-still-on-lambda';
@@ -19,6 +20,7 @@ import {getAwsRegion} from '../get-aws-region';
import {findFunctionName} from '../helpers/find-function-name';
import {quit} from '../helpers/quit';
import {Log} from '../log';
+import {makeArtifactProgress} from './render/progress';
const {
offthreadVideoCacheSizeInBytesOption,
@@ -235,18 +237,46 @@ export const stillCommand = async (
);
Log.verbose(
{indent: false, logLevel},
- `CloudWatch logs (if enabled): ${cloudWatchLogs}`,
+ `${CliInternals.makeHyperlink({
+ text: 'CloudWatch Logs',
+ url: cloudWatchLogs,
+ fallback: `CloudWatch Logs: ${cloudWatchLogs}`,
+ })} (if enabled)`,
);
Log.verbose(
{indent: false, logLevel},
- `Lambda Insights (if enabled): ${lambdaInsightsUrl}`,
+ `${CliInternals.makeHyperlink({
+ text: 'Lambda Insights',
+ url: lambdaInsightsUrl,
+ fallback: `Lambda Insights: ${lambdaInsightsUrl}`,
+ })} (if enabled)`,
);
},
deleteAfter,
});
+ Log.info(
+ {
+ indent: false,
+ logLevel,
+ },
+ makeArtifactProgress(res.receivedAssets),
+ );
+
+ Log.info(
+ {indent: false, logLevel},
+ chalk.blue('+ S3'.padEnd(CliInternals.LABEL_WIDTH)),
+ chalk.blue(
+ CliInternals.makeHyperlink({
+ fallback: res.url,
+ url: res.url,
+ text: res.outKey,
+ }),
+ ),
+ chalk.gray(formatBytes(res.sizeInBytes)),
+ );
+
if (downloadName) {
- Log.info({indent: false, logLevel}, 'Finished rendering. Downloading...');
const {outputPath, sizeInBytes} = await downloadMedia({
bucketName: res.bucketName,
outPath: downloadName,
@@ -254,15 +284,18 @@ export const stillCommand = async (
renderId: res.renderId,
logLevel,
});
+ const relativePath = path.relative(process.cwd(), outputPath);
Log.info(
{indent: false, logLevel},
- 'Done!',
- outputPath,
- formatBytes(sizeInBytes),
+ chalk.blue('↓'.padEnd(CliInternals.LABEL_WIDTH)),
+ chalk.blue(
+ CliInternals.makeHyperlink({
+ url: 'file://' + outputPath,
+ text: relativePath,
+ fallback: outputPath,
+ }),
+ ),
+ chalk.gray(formatBytes(sizeInBytes)),
);
- } else {
- Log.info({indent: false, logLevel}, `Finished still!`);
- Log.info({indent: false, logLevel});
- Log.info({indent: false, logLevel}, res.url);
}
};
diff --git a/packages/lambda/src/functions/helpers/overall-render-progress.ts b/packages/lambda/src/functions/helpers/overall-render-progress.ts
index 68a793d98c..710ad3c7b4 100644
--- a/packages/lambda/src/functions/helpers/overall-render-progress.ts
+++ b/packages/lambda/src/functions/helpers/overall-render-progress.ts
@@ -33,6 +33,7 @@ export type ReceivedAsset = {
filename: string;
sizeInBytes: number;
s3Url: string;
+ s3Key: string;
};
export type OverallProgressHelper = {
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index 2a4932f1d1..9c15005c11 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -371,6 +371,7 @@ const innerLaunchHandler = async ({
filename: artifact.filename,
sizeInBytes: artifact.content.length,
s3Url: `https://s3.${region}.amazonaws.com/${renderBucketName}/${s3Key}`,
+ s3Key,
});
const start = Date.now();
diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.ts
index c741ed64e4..49219e0a70 100644
--- a/packages/lambda/src/functions/still.ts
+++ b/packages/lambda/src/functions/still.ts
@@ -214,6 +214,7 @@ const innerStillHandler = async ({
filename: artifact.filename,
sizeInBytes: artifact.content.length,
s3Url: `https://s3.${region}.amazonaws.com/${renderBucketName}/${s3Key}`,
+ s3Key,
});
const startTime = Date.now();