Skip to content

🎥 Make videos programmatically with React

cli links

Jonny Burger671a78a393b1
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index 570fee08e6..83967681f4 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -153,7 +153,7 @@ const makeBenchmarkProgressBar = ({
return [
`Rendering (${run + 1} out of ${totalRuns} runs)`,
- makeProgressBar(totalProgress),
+ makeProgressBar(totalProgress, false),
doneIn === null
? `${(totalProgress * 100).toFixed(2)}% `
: chalk.gray(doneIn),
diff --git a/packages/cli/src/browser-download-bar.ts b/packages/cli/src/browser-download-bar.ts
index 1a13b86bf6..592957ae72 100644
--- a/packages/cli/src/browser-download-bar.ts
+++ b/packages/cli/src/browser-download-bar.ts
@@ -20,7 +20,7 @@ const makeDownloadProgress = ({
return [
` +`,
- makeProgressBar(progress),
+ makeProgressBar(progress, false),
`${doneIn ? 'Got' : 'Getting'} Headless Shell`,
doneIn === null
? (progress * 100).toFixed(0) + '%'
diff --git a/packages/cli/src/download-progress.ts b/packages/cli/src/download-progress.ts
index e4ad6ee841..35a20a4790 100644
--- a/packages/cli/src/download-progress.ts
+++ b/packages/cli/src/download-progress.ts
@@ -1,59 +1,72 @@
import type {DownloadProgress} from '@remotion/studio-server';
import {StudioServerInternals} from '@remotion/studio-server';
+import {formatBytes} from '@remotion/studio-shared';
+import {chalk} from './chalk';
+import {makeHyperlink} from './hyperlinks/make-link';
import {makeProgressBar} from './make-progress-bar';
-import {LABEL_WIDTH} from './progress-bar';
+import {LABEL_WIDTH, getRightLabelWidth} from './progress-bar';
import {truthy} from './truthy';
export const getFileSizeDownloadBar = (downloaded: number) => {
- const desiredLength = makeProgressBar(0).length;
+ const desiredLength = makeProgressBar(0, true).length;
return `${StudioServerInternals.formatBytes(downloaded).padEnd(
- desiredLength - 2,
+ desiredLength,
' ',
)}`;
};
-export const makeMultiDownloadProgress = (progresses: DownloadProgress[]) => {
+export const makeMultiDownloadProgress = (
+ progresses: DownloadProgress[],
+ totalFrames: number,
+) => {
if (progresses.length === 0) {
return null;
}
- if (progresses.length === 1) {
- const [progress] = progresses;
- const truncatedFileName =
- progress.name.length >= 60
- ? progress.name.substring(0, 57) + '...'
- : progress.name;
- return [
- (progress.progress === 1
- ? 'Downloaded assets '
- : 'Downloading assets'
- ).padEnd(LABEL_WIDTH, ' '),
- progress.progress
- ? makeProgressBar(progress.progress)
- : getFileSizeDownloadBar(progress.downloaded),
- truncatedFileName,
- ]
- .filter(truthy)
- .join(' ');
- }
-
const everyFileHasContentLength = progresses.every(
(p) => p.totalBytes !== null,
);
- return [
- `Downloading assets`.padEnd(LABEL_WIDTH, ' '),
+ const isDone = progresses.every((p) => p.progress === 1);
+
+ const topRow = [
+ (isDone ? `Downloaded assets` : 'Downloading assets').padEnd(
+ LABEL_WIDTH,
+ ' ',
+ ),
everyFileHasContentLength
? makeProgressBar(
progresses.reduce((a, b) => a + (b.progress as number), 0) /
progresses.length,
+ false,
)
: getFileSizeDownloadBar(
progresses.reduce((a, b) => a + b.downloaded, 0),
),
- `${progresses.length} files`,
+ `${progresses.length} file${progresses.length === 1 ? '' : 's'}`.padStart(
+ getRightLabelWidth(totalFrames),
+ ' ',
+ ),
]
.filter(truthy)
.join(' ');
+
+ const downloadsToShow = progresses
+ .filter((p) => p.progress !== 1)
+ .slice(0, 2);
+
+ return [
+ topRow,
+ ...downloadsToShow.map((toShow) => {
+ const truncatedFileName =
+ toShow.name.length >= 60
+ ? toShow.name.substring(0, 57) + '...'
+ : toShow.name;
+
+ return chalk.gray(
+ `↓ ${formatBytes(toShow.downloaded).padEnd(8, ' ')} ${makeHyperlink({url: toShow.name, fallback: truncatedFileName, text: truncatedFileName})}`,
+ );
+ }),
+ ].join('\n');
};
diff --git a/packages/cli/src/make-progress-bar.ts b/packages/cli/src/make-progress-bar.ts
index 4aa6e30289..c94987f09e 100644
--- a/packages/cli/src/make-progress-bar.ts
+++ b/packages/cli/src/make-progress-bar.ts
@@ -6,8 +6,8 @@ const half = '╸';
const half_right = '╺';
const totalBars = 18;
-export const makeProgressBar = (percentage: number) => {
- const color = RenderInternals.isColorSupported();
+export const makeProgressBar = (percentage: number, noColor: boolean) => {
+ const color = noColor ? false : RenderInternals.isColorSupported();
const barsToShow = Math.floor(percentage * totalBars);
const extraBar = (percentage * totalBars) % barsToShow;
const grayBars = totalBars - barsToShow;
@@ -23,5 +23,9 @@ export const makeProgressBar = (percentage: number) => {
gray[0] = half_right;
}
+ if (!color) {
+ return `${base}${gray.join('')}`;
+ }
+
return `${chalk.blue(base)}${chalk.dim(gray.join(''))}`;
};
diff --git a/packages/cli/src/progress-bar.ts b/packages/cli/src/progress-bar.ts
index eeae982b4b..cc57ecd88e 100644
--- a/packages/cli/src/progress-bar.ts
+++ b/packages/cli/src/progress-bar.ts
@@ -93,7 +93,7 @@ const makeBundlingProgress = ({
return [
`${doneIn ? 'Bundled' : 'Bundling'} code`.padEnd(LABEL_WIDTH, ' '),
- makeProgressBar(progress),
+ makeProgressBar(progress, false),
doneIn === null
? (progress * 100).toFixed(0) + '%'
: chalk.gray(`${doneIn}ms`),
@@ -110,7 +110,9 @@ const makeCopyingProgress = (options: CopyingState) => {
return [
'Copying public dir'.padEnd(LABEL_WIDTH, ' '),
- options.doneIn ? makeProgressBar(1) : getFileSizeDownloadBar(options.bytes),
+ options.doneIn
+ ? makeProgressBar(1, false)
+ : getFileSizeDownloadBar(options.bytes),
options.doneIn === null ? null : chalk.gray(`${options.doneIn}ms`),
]
.filter(truthy)
@@ -172,10 +174,10 @@ const makeRenderingProgress = ({
.filter(truthy)
.join(' ')
.padEnd(LABEL_WIDTH, ' '),
- makeProgressBar(progress),
+ makeProgressBar(progress, false),
doneIn === null
? [
- `${String(frames).padStart(String(totalFrames).length, ' ')}/${totalFrames}`,
+ `${frames}/${totalFrames}`.padStart(getRightLabelWidth(totalFrames)),
timeRemainingInMilliseconds
? chalk.gray(
`${formatEtaString(timeRemainingInMilliseconds)} remaining`,
@@ -190,6 +192,10 @@ const makeRenderingProgress = ({
.join(' ');
};
+export const getRightLabelWidth = (totalFrames: number) => {
+ return `${totalFrames}/${totalFrames}`.length;
+};
+
const makeStitchingProgress = ({
stitchingProgress,
isUsingParallelEncoding,
@@ -211,7 +217,7 @@ const makeStitchingProgress = ({
? `${doneIn ? 'Muxed' : 'Muxing'} ${mediaType}`
: `${doneIn ? 'Encoded' : 'Encoding'} ${mediaType}`
).padEnd(LABEL_WIDTH, ' '),
- makeProgressBar(progress),
+ makeProgressBar(progress, false),
doneIn === null
? `${String(frames).padStart(String(totalFrames).length, ' ')}/${totalFrames}`
: chalk.gray(`${doneIn}ms`),
@@ -234,7 +240,7 @@ export const makeRenderingAndStitchingProgress = ({
const {rendering, stitching, downloads, bundling} = prog;
const output = [
rendering ? makeRenderingProgress(rendering) : null,
- makeMultiDownloadProgress(downloads),
+ makeMultiDownloadProgress(downloads, rendering?.totalFrames ?? 0),
stitching === null
? null
: makeStitchingProgress({
diff --git a/packages/cloudrun/src/cli/commands/render/index.ts b/packages/cloudrun/src/cli/commands/render/index.ts
index a18db60021..f58d4b7556 100644
--- a/packages/cloudrun/src/cli/commands/render/index.ts
+++ b/packages/cloudrun/src/cli/commands/render/index.ts
@@ -215,7 +215,7 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
progressBar.update(
[
`Rendering on Cloud Run: `,
- CliInternals.makeProgressBar(renderProgress.progress),
+ CliInternals.makeProgressBar(renderProgress.progress, false),
`${renderProgress.doneIn === null ? 'Rendering' : 'Rendered'}`,
renderProgress.doneIn === null
? `${Math.round(renderProgress.progress * 100)}%`
diff --git a/packages/cloudrun/src/cli/helpers/progress-bar.ts b/packages/cloudrun/src/cli/helpers/progress-bar.ts
index 0ae887f616..ef9da03500 100644
--- a/packages/cloudrun/src/cli/helpers/progress-bar.ts
+++ b/packages/cloudrun/src/cli/helpers/progress-bar.ts
@@ -12,7 +12,7 @@ export const makeBundleProgress = ({progress, doneIn}: BundleProgress) => {
CliInternals.LABEL_WIDTH,
' ',
),
- CliInternals.makeProgressBar(progress / 100),
+ CliInternals.makeProgressBar(progress / 100, false),
doneIn === null
? `${Math.round(progress)}%`
: CliInternals.chalk.gray(`${doneIn}ms`),
@@ -62,7 +62,7 @@ export const makeBucketProgress = ({
return [
creationState.padEnd(CliInternals.LABEL_WIDTH, ' '),
- CliInternals.makeProgressBar(progress),
+ CliInternals.makeProgressBar(progress, false),
doneIn === null
? `${statesFinished} / ${3}`
: CliInternals.chalk.gray(`${doneIn}ms`),
@@ -114,7 +114,7 @@ export const makeDeployProgressBar = ({
CliInternals.LABEL_WIDTH,
' ',
),
- CliInternals.makeProgressBar(progress),
+ CliInternals.makeProgressBar(progress, false),
doneIn === null
? typeof totalSize === 'number'
? `${CliInternals.formatBytes(sizeUploaded)}/${CliInternals.formatBytes(
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index a4f4087108..a99470c3d5 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -17,7 +17,7 @@ const makeEvaluationProgress = (overall: RenderProgress) => {
if (timeToLaunch) {
return [
`Got composition`.padEnd(CliInternals.LABEL_WIDTH),
- CliInternals.makeProgressBar(1),
+ CliInternals.makeProgressBar(1, false),
CliInternals.chalk.gray(`${timeToLaunch}ms`),
].join(' ');
}
@@ -25,14 +25,14 @@ const makeEvaluationProgress = (overall: RenderProgress) => {
if (overall.serveUrlOpened) {
return [
`Calculating metadata`.padEnd(CliInternals.LABEL_WIDTH),
- CliInternals.makeProgressBar(0.5),
+ CliInternals.makeProgressBar(0.5, false),
`${overall.currentTime - overall.serveUrlOpened}ms`,
].join(' ');
}
return [
`Visiting Site`.padEnd(CliInternals.LABEL_WIDTH),
- CliInternals.makeProgressBar(0),
+ CliInternals.makeProgressBar(0, false),
`${overall.currentTime - overall.functionLaunched}ms`,
].join(' ');
};
@@ -49,7 +49,7 @@ const makeInvokeProgress = (overall: RenderProgress) => {
`${progress === 0 ? 'Invoked' : 'Invoking'} lambdas`.padEnd(
CliInternals.LABEL_WIDTH,
),
- CliInternals.makeProgressBar(progress),
+ CliInternals.makeProgressBar(progress, false),
progress === 1
? CliInternals.chalk.gray(`${lambdasInvoked}/${totalLambdas}`)
: totalLambdas === null
@@ -87,7 +87,7 @@ const makeRenderProgress = (progress: RenderProgress) => {
? 'Rendering frames'
: 'Rendered frames'
).padEnd(CliInternals.LABEL_WIDTH, ' '),
- CliInternals.makeProgressBar(renderProgress),
+ CliInternals.makeProgressBar(renderProgress, false),
progress.timeToRenderFrames === null
? frames
: CliInternals.chalk.gray(`${progress.timeToRenderFrames}ms`),
@@ -100,7 +100,7 @@ const makeRenderProgress = (progress: RenderProgress) => {
CliInternals.LABEL_WIDTH,
' ',
),
- CliInternals.makeProgressBar(encodingProgress),
+ CliInternals.makeProgressBar(encodingProgress, false),
progress.timeToEncode === null
? totalFrames === null
? null
@@ -137,7 +137,7 @@ const makeCombinationProgress = (prog: RenderProgress) => {
CliInternals.LABEL_WIDTH,
' ',
),
- CliInternals.makeProgressBar(progress),
+ CliInternals.makeProgressBar(progress, false),
timeToCombine === null
? `${Math.round(progress * 100)}%`
: CliInternals.chalk.gray(`${timeToCombine}ms`),
@@ -154,6 +154,7 @@ const makeDownloadProgress = (downloadInfo: DownloadedInfo) => {
? CliInternals.getFileSizeDownloadBar(downloadInfo.downloaded)
: CliInternals.makeProgressBar(
downloadInfo.downloaded / downloadInfo.totalSize,
+ false,
),
downloadInfo.doneIn === null
? [
diff --git a/packages/lambda/src/cli/helpers/progress-bar.ts b/packages/lambda/src/cli/helpers/progress-bar.ts
index ee722d3468..60a448223c 100644
--- a/packages/lambda/src/cli/helpers/progress-bar.ts
+++ b/packages/lambda/src/cli/helpers/progress-bar.ts
@@ -12,7 +12,7 @@ export const makeBundleProgress = ({progress, doneIn}: BundleProgress) => {
CliInternals.LABEL_WIDTH,
' ',
),
- CliInternals.makeProgressBar(progress / 100),
+ CliInternals.makeProgressBar(progress / 100, false),
doneIn === null
? `${Math.round(progress)}%`
: CliInternals.chalk.gray(`${doneIn}ms`),
@@ -31,7 +31,7 @@ export const makeBucketProgress = ({doneIn}: BucketCreationProgress) => {
CliInternals.LABEL_WIDTH,
' ',
),
- CliInternals.makeProgressBar(progress),
+ CliInternals.makeProgressBar(progress, false),
doneIn === null ? `0/1` : CliInternals.chalk.gray(`${doneIn}ms`),
].join(' ');
};
@@ -81,7 +81,7 @@ export const makeDeployProgressBar = ({
CliInternals.LABEL_WIDTH,
' ',
),
- CliInternals.makeProgressBar(progress),
+ CliInternals.makeProgressBar(progress, false),
doneIn === null
? typeof totalSize === 'number'
? `${CliInternals.formatBytes(sizeUploaded)}/${CliInternals.formatBytes(