Skip to content

🎥 Make videos programmatically with React

new colors

Jonny Burger775534c604b1
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index 00593cb968..877e65cb9e 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -27,7 +27,11 @@ import {BooleanFlags, parsedCli, quietFlagProvided} from './parsed-cli';
import {printCompositions} from './print-compositions';
import {printError} from './print-error';
import {printHelp} from './print-help';
-import {createOverwriteableCliOutput} from './progress-bar';
+import {
+ LABEL_WIDTH,
+ createOverwriteableCliOutput,
+ printFact,
+} from './progress-bar';
import {render} from './render';
import {shouldUseNonOverlayingLogger} from './should-use-non-overlaying-logger';
import {still} from './still';
@@ -159,4 +163,6 @@ export const CliInternals = {
shouldUseNonOverlayingLogger,
getCompositionWithDimensionOverride,
defaultBrowserDownloadProgress,
+ LABEL_WIDTH,
+ printFact,
};
diff --git a/packages/cli/src/make-progress-bar.ts b/packages/cli/src/make-progress-bar.ts
index 2018edac68..4aa6e30289 100644
--- a/packages/cli/src/make-progress-bar.ts
+++ b/packages/cli/src/make-progress-bar.ts
@@ -1,23 +1,27 @@
-const full = '─';
-const half = '╴';
+import {RenderInternals} from '@remotion/renderer';
+import {chalk} from './chalk';
+
+const full = '━';
+const half = '╸';
+const half_right = '╺';
+const totalBars = 18;
export const makeProgressBar = (percentage: number) => {
- const totalBars = 18;
+ const color = RenderInternals.isColorSupported();
const barsToShow = Math.floor(percentage * totalBars);
const extraBar = (percentage * totalBars) % barsToShow;
+ const grayBars = totalBars - barsToShow;
- const base = full.repeat(barsToShow) + (extraBar > 0.5 ? half : '');
- if (percentage === 0) {
- return `${' '.repeat(totalBars + 1)}`;
- }
+ const showHalf = extraBar > 0.5;
- if (percentage > 0 && barsToShow < 1) {
- return `╷${' '.repeat(totalBars)}`;
- }
+ const base = full.repeat(barsToShow) + (showHalf ? half : '');
- if (percentage >= 1) {
- return `╭${base.substring(0, base.length - 1)}╮`;
+ const gray = (RenderInternals.isColorSupported() ? full : ' ')
+ .repeat(grayBars - (showHalf ? 1 : 0))
+ .split('');
+ if (!showHalf && barsToShow > 0 && gray.length > 0 && color) {
+ gray[0] = half_right;
}
- return `╭${base.padEnd(totalBars, ' ')}`;
+ 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 d1e4fb14a8..baf1968034 100644
--- a/packages/cli/src/progress-bar.ts
+++ b/packages/cli/src/progress-bar.ts
@@ -21,7 +21,7 @@ export type OverwriteableCliOutput = {
update: (up: string, newline: boolean) => boolean;
};
-const LABEL_WIDTH = 22;
+export const LABEL_WIDTH = 18;
export const createOverwriteableCliOutput = (options: {
quiet: boolean;
@@ -91,7 +91,7 @@ const makeBundlingProgress = ({
const {doneIn, progress} = bundlingState;
return [
- `${doneIn ? 'Bundled' : 'Bundling'} code`.padStart(LABEL_WIDTH, ' '),
+ `${doneIn ? 'Bundled' : 'Bundling'} code`.padEnd(LABEL_WIDTH, ' '),
makeProgressBar(progress),
doneIn === null
? (progress * 100).toFixed(0) + '%'
@@ -108,9 +108,8 @@ const makeCopyingProgress = (options: CopyingState) => {
}
return [
- ' +',
+ 'Copying public dir'.padEnd(LABEL_WIDTH, ' '),
options.doneIn ? makeProgressBar(1) : getFileSizeDownloadBar(options.bytes),
- 'Copying public dir'.padStart(LABEL_WIDTH, ' '),
options.doneIn === null ? null : chalk.gray(`${options.doneIn}ms`),
]
.filter(truthy)
@@ -171,7 +170,7 @@ const makeRenderingProgress = ({
[doneIn ? 'Rendered' : 'Rendering', totalFrames === 1 ? 'still' : 'frames']
.filter(truthy)
.join(' ')
- .padStart(LABEL_WIDTH, ' '),
+ .padEnd(LABEL_WIDTH, ' '),
makeProgressBar(progress),
doneIn === null
? [
@@ -210,7 +209,7 @@ const makeStitchingProgress = ({
(stage === 'muxing' && isUsingParallelEncoding
? `${doneIn ? 'Muxed' : 'Muxing'} ${mediaType}`
: `${doneIn ? 'Encoded' : 'Encoding'} ${mediaType}`
- ).padStart(LABEL_WIDTH, ' '),
+ ).padEnd(LABEL_WIDTH, ' '),
makeProgressBar(progress),
doneIn === null
? `${String(frames).padStart(String(totalFrames).length, ' ')}/${totalFrames}`
@@ -311,18 +310,32 @@ export const printFact =
logLevel,
left,
right,
+ color,
}: {
indent: boolean;
logLevel: LogLevel;
left: string;
right: string;
+ color: 'blue' | 'gray' | undefined;
}) => {
+ const fn = (str: string) => {
+ if (color === 'gray') {
+ return chalk.gray(str);
+ }
+
+ if (color === 'blue') {
+ return chalk.blue(str);
+ }
+
+ return str;
+ };
+
if (RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose')) {
- Log[printLevel]({indent, logLevel}, chalk.gray(`${left} = ${right}`));
+ Log[printLevel]({indent, logLevel}, fn(`${left} = ${right}`));
return;
}
- const leftPadded = left.padStart(LABEL_WIDTH, ' ');
- Log[printLevel]({indent, logLevel}, chalk.gray(`${leftPadded} ${right}`));
+ const leftPadded = left.padEnd(LABEL_WIDTH, ' ');
+ Log[printLevel]({indent, logLevel}, fn(`${leftPadded} ${right}`));
};
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index b46953d456..05bca00f3c 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -43,6 +43,7 @@ import {Log} from '../log';
import {makeOnDownload} from '../make-on-download';
import {parsedCli, quietFlagProvided} from '../parsed-cli';
import {
+ LABEL_WIDTH,
createOverwriteableCliOutput,
makeRenderingAndStitchingProgress,
printFact,
@@ -168,6 +169,7 @@ export const renderVideoFlow = async ({
right: [fullEntryPoint, isVerbose ? `(${entryPointReason})` : null]
.filter(truthy)
.join(' '),
+ color: 'gray',
});
const downloads: DownloadProgress[] = [];
const onBrowserDownload = defaultBrowserDownloadProgress({
@@ -364,6 +366,7 @@ export const renderVideoFlow = async ({
right: [compositionId, isVerbose ? `(${reason})` : null]
.filter(truthy)
.join(' '),
+ color: 'gray',
});
printFact('info')({
indent,
@@ -372,18 +375,21 @@ export const renderVideoFlow = async ({
right: [codec, isVerbose ? `(${codecReason})` : null]
.filter(truthy)
.join(' '),
+ color: 'gray',
});
printFact('info')({
indent,
logLevel,
left: 'Output',
right: relativeOutputLocation,
+ color: 'gray',
});
printFact('info')({
indent,
logLevel,
left: 'Concurrency',
right: `${actualConcurrency}x`,
+ color: 'gray',
});
const absoluteOutputFile = getAndValidateAbsoluteOutputFile(
@@ -577,13 +583,17 @@ export const renderVideoFlow = async ({
Log.info(
{indent, logLevel},
- chalk.blue(`${exists ? '○' : '+'} ${absoluteOutputFile}`),
+ chalk.blue(
+ `${(exists ? '○' : '+').padEnd(LABEL_WIDTH)} ${relativeOutputLocation}`,
+ ),
);
if (absoluteSeparateAudioTo) {
Log.info(
{indent, logLevel},
- chalk.blue(`${audioExists ? '○' : '+'} ${absoluteSeparateAudioTo}`),
+ chalk.blue(
+ `${(audioExists ? '○' : '+').padEnd(LABEL_WIDTH, ' ')} ${absoluteSeparateAudioTo}`,
+ ),
);
}
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index 915612ad6c..de5c19a0b5 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -29,6 +29,7 @@ import {makeOnDownload} from '../make-on-download';
import {parsedCli, quietFlagProvided} from '../parsed-cli';
import type {OverwriteableCliOutput} from '../progress-bar';
import {
+ LABEL_WIDTH,
createOverwriteableCliOutput,
makeRenderingAndStitchingProgress,
printFact,
@@ -275,6 +276,7 @@ export const renderStillFlow = async ({
right: [compositionId, isVerbose ? `(${reason})` : null]
.filter(truthy)
.join(' '),
+ color: 'gray',
});
printFact('info')({
indent,
@@ -283,12 +285,14 @@ export const renderStillFlow = async ({
right: [imageFormat, isVerbose ? `(${source})` : null]
.filter(truthy)
.join(' '),
+ color: 'gray',
});
printFact('info')({
indent,
left: 'Output',
logLevel,
right: relativeOutputLocation,
+ color: 'gray',
});
const renderStart = Date.now();
@@ -361,6 +365,8 @@ export const renderStillFlow = async ({
});
Log.info(
{indent, logLevel},
- chalk.blue(`${exists ? '○' : '+'} ${absoluteOutputLocation}`),
+ chalk.blue(
+ `${(exists ? '○' : '+').padEnd(LABEL_WIDTH)} ${relativeOutputLocation}`,
+ ),
);
};
diff --git a/packages/cloudrun/src/cli/commands/sites/create.ts b/packages/cloudrun/src/cli/commands/sites/create.ts
index 33fd5a8bd7..789b2e3321 100644
--- a/packages/cloudrun/src/cli/commands/sites/create.ts
+++ b/packages/cloudrun/src/cli/commands/sites/create.ts
@@ -201,7 +201,7 @@ export const sitesCreateSubcommand = async (
Log.info(
{indent: false, logLevel},
CliInternals.chalk.blueBright(
- 'ℹ️ If you make changes to your code, you need to redeploy the site. You can overwrite the existing site by running:',
+ 'ℹ️ Redeploy your site everytime you make changes to it. You can overwrite the existing site by running:',
),
);
Log.info(
diff --git a/packages/cloudrun/src/cli/helpers/progress-bar.ts b/packages/cloudrun/src/cli/helpers/progress-bar.ts
index 6e54363044..9fb8aa6f1e 100644
--- a/packages/cloudrun/src/cli/helpers/progress-bar.ts
+++ b/packages/cloudrun/src/cli/helpers/progress-bar.ts
@@ -8,9 +8,11 @@ export type BundleProgress = {
export const makeBundleProgress = ({progress, doneIn}: BundleProgress) => {
return [
- `(1/3)`,
+ `${doneIn === null ? 'Bundling' : 'Bundled'} video`.padEnd(
+ CliInternals.LABEL_WIDTH,
+ ' ',
+ ),
CliInternals.makeProgressBar(progress / 100),
- `${doneIn === null ? 'Bundling' : 'Bundled'} video`,
doneIn === null
? `${Math.round(progress)}%`
: CliInternals.chalk.gray(`${doneIn}ms`),
@@ -59,9 +61,8 @@ export const makeBucketProgress = ({
}
return [
- `(2/3)`,
+ creationState.padEnd(CliInternals.LABEL_WIDTH, ' '),
CliInternals.makeProgressBar(progress),
- creationState,
doneIn === null
? `${statesFinished} / ${3}`
: CliInternals.chalk.gray(`${doneIn}ms`),
@@ -109,14 +110,16 @@ export const makeDeployProgressBar = ({
}: DeployToStorageProgress) => {
const progress = totalSize === null ? 0 : sizeUploaded / totalSize;
return [
- `(3/3)`,
+ `${doneIn === null ? 'Uploading' : 'Uploaded'} to GCP Storage Bucket`.padEnd(
+ CliInternals.LABEL_WIDTH,
+ ' ',
+ ),
CliInternals.makeProgressBar(progress),
- `${doneIn === null ? 'Uploading' : 'Uploaded'} to GCP Storage Bucket`,
doneIn === null
? typeof totalSize === 'number'
? `${CliInternals.formatBytes(sizeUploaded)}/${CliInternals.formatBytes(
totalSize,
- )}`
+ )}`
: ''
: CliInternals.chalk.gray(`${doneIn}ms`),
makeUploadDiff({stats}),
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index 09cb1dffa9..30e06a6d62 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -32,15 +32,15 @@ type MultiRenderProgress = {
const makeInvokeProgress = (
invokeProgress: LambdaInvokeProgress,
- totalSteps: number,
retriesInfo: ChunkRetry[],
) => {
const {lambdasInvoked, totalLambdas} = invokeProgress;
const progress = totalLambdas === null ? 0 : lambdasInvoked / totalLambdas;
return [
- `(1/${totalSteps})`,
+ `${progress === 0 ? 'Invoked' : 'Invoking'} lambdas`.padEnd(
+ CliInternals.LABEL_WIDTH,
+ ),
CliInternals.makeProgressBar(progress),
- `${progress === 0 ? 'Invoked' : 'Invoking'} lambdas`,
progress === 1
? CliInternals.chalk.gray('100%')
: `${Math.round(progress * 100)}%`,
@@ -50,10 +50,8 @@ const makeInvokeProgress = (
const makeRenderProgress = ({
chunkProgress,
- totalSteps,
}: {
chunkProgress: ChunkProgress;
- totalSteps: number;
}) => {
const {chunksEncoded, totalChunks, doneIn} = chunkProgress;
const renderProgress =
@@ -66,21 +64,25 @@ const makeRenderProgress = ({
const frames =
chunkProgress.totalFrames === null
? null
- : `(${chunkProgress.framesRendered}/${chunkProgress.totalFrames})`;
+ : `${chunkProgress.framesRendered}/${chunkProgress.totalFrames}`;
const first = [
- `(2/${totalSteps})`,
+ (doneIn === null ? 'Rendering frames' : 'Rendered frames').padEnd(
+ CliInternals.LABEL_WIDTH,
+ ' ',
+ ),
CliInternals.makeProgressBar(renderProgress),
- doneIn === null ? 'Rendering frames' : 'Rendered frames',
doneIn === null ? frames : CliInternals.chalk.gray(`${doneIn}ms`),
]
.filter(truthy)
.join(' ');
const second = [
- `(3/${totalSteps})`,
+ `${doneIn === null ? 'Encoding' : 'Encoded'} chunks`.padEnd(
+ CliInternals.LABEL_WIDTH,
+ ' ',
+ ),
CliInternals.makeProgressBar(encodingProgress),
- `${doneIn === null ? 'Encoding' : 'Encoded'} chunks`,
doneIn === null
? `${Math.round(encodingProgress * 100)}%`
: CliInternals.chalk.gray(`${doneIn}ms`),
@@ -92,13 +94,11 @@ const makeRenderProgress = ({
const makeEncodingProgress = ({
encodingProgress,
chunkProgress,
- totalSteps,
totalFrames,
timeToEncode,
}: {
encodingProgress: EncodingProgress;
chunkProgress: ChunkProgress;
- totalSteps: number;
totalFrames: number | null;
timeToEncode: number | null;
}) => {
@@ -111,9 +111,11 @@ const makeEncodingProgress = ({
}
return [
- `(4/${totalSteps})`,
+ `${timeToEncode === null ? 'Combining' : 'Combined'} videos`.padEnd(
+ CliInternals.LABEL_WIDTH,
+ ' ',
+ ),
CliInternals.makeProgressBar(progress),
- `${timeToEncode === null ? 'Combining' : 'Combined'} videos`,
timeToEncode === null
? `${Math.round(progress * 100)}%`
: CliInternals.chalk.gray(`${timeToEncode}ms`),
@@ -122,7 +124,6 @@ const makeEncodingProgress = ({
const makeCleanupProgress = (
cleanupInfo: CleanupInfo | null,
- totalSteps: number,
skipped: boolean,
) => {
if (!cleanupInfo) {
@@ -131,7 +132,6 @@ const makeCleanupProgress = (
if (skipped) {
return [
- `(5/${totalSteps})`,
CliInternals.chalk.blueBright(
`Not cleaning up because --log=verbose was set`,
),
@@ -141,7 +141,6 @@ const makeCleanupProgress = (
const {doneIn, filesDeleted, minFilesToDelete} = cleanupInfo;
const progress = filesDeleted / minFilesToDelete;
return [
- `(5/${totalSteps})`,
CliInternals.makeProgressBar(progress),
`${doneIn === null ? 'Cleaning up' : 'Cleaned up'} artifacts`,
doneIn === null
@@ -228,19 +227,17 @@ export const makeProgressString = ({
totalFrames: number | null;
}) => {
return [
- makeInvokeProgress(progress.lambdaInvokeProgress, steps, retriesInfo),
+ makeInvokeProgress(progress.lambdaInvokeProgress, retriesInfo),
...makeRenderProgress({
chunkProgress: progress.chunkProgress,
- totalSteps: steps,
}),
makeEncodingProgress({
encodingProgress: progress.encodingProgress,
chunkProgress: progress.chunkProgress,
- totalSteps: steps,
timeToEncode,
totalFrames,
}),
- makeCleanupProgress(progress.cleanupInfo, steps, logLevel === 'verbose'),
+ makeCleanupProgress(progress.cleanupInfo, logLevel === 'verbose'),
downloadInfo ? makeDownloadProgress(downloadInfo, steps) : null,
]
.filter(NoReactInternals.truthy)
diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.ts
index 2916337b40..fce8c71456 100644
--- a/packages/lambda/src/cli/commands/sites/create.ts
+++ b/packages/lambda/src/cli/commands/sites/create.ts
@@ -97,14 +97,14 @@ export const sitesCreateSubcommand = async (
},
};
- const updateProgress = () => {
+ const updateProgress = (newLine: boolean) => {
progressBar.update(
[
makeBundleProgress(multiProgress.bundleProgress),
makeBucketProgress(multiProgress.bucketProgress),
makeDeployProgressBar(multiProgress.deployProgress),
].join('\n'),
- false,
+ newLine,
);
};
@@ -125,7 +125,7 @@ export const sitesCreateSubcommand = async (
).bucketName;
multiProgress.bucketProgress.doneIn = Date.now() - bucketStart;
- updateProgress();
+ updateProgress(false);
const bundleStart = Date.now();
let uploadStart = Date.now();
@@ -154,7 +154,7 @@ export const sitesCreateSubcommand = async (
uploadStart = Date.now();
}
- updateProgress();
+ updateProgress(false);
},
onUploadProgress: (p) => {
multiProgress.deployProgress = {
@@ -163,7 +163,7 @@ export const sitesCreateSubcommand = async (
doneIn: null,
stats: null,
};
- updateProgress();
+ updateProgress(false);
},
enableCaching: ConfigInternals.getWebpackCaching(),
webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),
@@ -189,20 +189,28 @@ export const sitesCreateSubcommand = async (
untouchedFiles: stats.untouchedFiles,
},
};
- updateProgress();
+ updateProgress(true);
- Log.info({indent: false, logLevel});
- Log.info({indent: false, logLevel});
- Log.info({indent: false, logLevel}, 'Deployed to S3!');
-
- Log.info({indent: false, logLevel}, `Serve URL: ${serveUrl}`);
- Log.info({indent: false, logLevel}, `Site Name: ${siteName}`);
+ CliInternals.printFact('info')({
+ indent: false,
+ left: 'Serve URL',
+ logLevel,
+ right: serveUrl,
+ color: 'blue',
+ });
+ CliInternals.printFact('info')({
+ indent: false,
+ left: 'Site name',
+ logLevel,
+ right: siteName,
+ color: 'blue',
+ });
Log.info({indent: false, logLevel});
Log.info(
{indent: false, logLevel},
CliInternals.chalk.blueBright(
- 'ℹ️ If you make changes to your code, you need to redeploy the site. You can overwrite the existing site by running:',
+ 'ℹ️ Redeploy your site everytime you make changes to it. You can overwrite the existing site by running:',
),
);
Log.info(
diff --git a/packages/lambda/src/cli/helpers/progress-bar.ts b/packages/lambda/src/cli/helpers/progress-bar.ts
index 6c581073d6..ee722d3468 100644
--- a/packages/lambda/src/cli/helpers/progress-bar.ts
+++ b/packages/lambda/src/cli/helpers/progress-bar.ts
@@ -8,9 +8,11 @@ export type BundleProgress = {
export const makeBundleProgress = ({progress, doneIn}: BundleProgress) => {
return [
- `(1/3)`,
+ `${doneIn === null ? 'Bundling' : 'Bundled'} video`.padEnd(
+ CliInternals.LABEL_WIDTH,
+ ' ',
+ ),
CliInternals.makeProgressBar(progress / 100),
- `${doneIn === null ? 'Bundling' : 'Bundled'} video`,
doneIn === null
? `${Math.round(progress)}%`
: CliInternals.chalk.gray(`${doneIn}ms`),
@@ -25,9 +27,11 @@ export const makeBucketProgress = ({doneIn}: BucketCreationProgress) => {
const progress = doneIn === null ? 0 : 1;
return [
- `(2/3)`,
+ `${doneIn === null ? 'Creating' : 'Created'} bucket`.padEnd(
+ CliInternals.LABEL_WIDTH,
+ ' ',
+ ),
CliInternals.makeProgressBar(progress),
- `${doneIn === null ? 'Creating' : 'Created'} bucket`,
doneIn === null ? `0/1` : CliInternals.chalk.gray(`${doneIn}ms`),
].join(' ');
};
@@ -73,9 +77,11 @@ export const makeDeployProgressBar = ({
}: DeployToS3Progress) => {
const progress = totalSize === null ? 0 : sizeUploaded / totalSize;
return [
- `(3/3)`,
+ `${doneIn === null ? 'Uploading' : 'Uploaded'} to S3`.padEnd(
+ CliInternals.LABEL_WIDTH,
+ ' ',
+ ),
CliInternals.makeProgressBar(progress),
- `${doneIn === null ? 'Uploading' : 'Uploaded'} to S3`,
doneIn === null
? typeof totalSize === 'number'
? `${CliInternals.formatBytes(sizeUploaded)}/${CliInternals.formatBytes(