Skip to content

🎥 Make videos programmatically with React

getting there

Jonny Burger38a2f1550918
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index a1b912fe2f..8c63e0f250 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -279,6 +279,7 @@ export const benchmarkCommand = async (
quiet: quietFlagProvided(),
cancelSignal: null,
updatesDontOverwrite: shouldUseNonOverlayingLogger({logLevel}),
+ indent: false,
});
Log.info();
Log.info(
diff --git a/packages/cli/src/download-progress.ts b/packages/cli/src/download-progress.ts
index ad61451521..dfa230c351 100644
--- a/packages/cli/src/download-progress.ts
+++ b/packages/cli/src/download-progress.ts
@@ -1,5 +1,4 @@
import {formatBytes} from './format-bytes';
-import {INDENT_TOKEN} from './log';
import {makeProgressBar} from './make-progress-bar';
import type {DownloadProgress} from './progress-types';
import {truthy} from './truthy';
@@ -10,10 +9,7 @@ export const getFileSizeDownloadBar = (downloaded: number) => {
return `[${formatBytes(downloaded).padEnd(desiredLength - 2, ' ')}]`;
};
-export const makeMultiDownloadProgress = (
- progresses: DownloadProgress[],
- indent: boolean
-) => {
+export const makeMultiDownloadProgress = (progresses: DownloadProgress[]) => {
if (progresses.length === 0) {
return null;
}
@@ -25,7 +21,6 @@ export const makeMultiDownloadProgress = (
? progress.name.substring(0, 57) + '...'
: progress.name;
return [
- indent ? INDENT_TOKEN : null,
` +`,
progress.progress
? makeProgressBar(progress.progress)
@@ -41,7 +36,6 @@ export const makeMultiDownloadProgress = (
);
return [
- indent ? INDENT_TOKEN : null,
// TODO: Shifted 1 character to the right in v4
` +`,
everyFileHasContentLength
diff --git a/packages/cli/src/print-error.ts b/packages/cli/src/print-error.ts
index 1d0e42c42e..5ac0f9826c 100644
--- a/packages/cli/src/print-error.ts
+++ b/packages/cli/src/print-error.ts
@@ -12,6 +12,7 @@ export const printError = async (err: Error, logLevel: LogLevel) => {
quiet: false,
cancelSignal: null,
updatesDontOverwrite: shouldUseNonOverlayingLogger({logLevel}),
+ indent: false,
});
output.update(
chalk.red('Symbolicating minified error message...\n' + err.message)
diff --git a/packages/cli/src/progress-bar.ts b/packages/cli/src/progress-bar.ts
index 441600d3e2..db8cd5d3ba 100644
--- a/packages/cli/src/progress-bar.ts
+++ b/packages/cli/src/progress-bar.ts
@@ -23,6 +23,7 @@ export const createOverwriteableCliOutput = (options: {
quiet: boolean;
cancelSignal: CancelSignal | null;
updatesDontOverwrite: boolean;
+ indent: boolean;
}): OverwriteableCliOutput => {
if (options.quiet) {
return {
@@ -33,7 +34,19 @@ export const createOverwriteableCliOutput = (options: {
if (options.updatesDontOverwrite) {
return {
update: (up: string) => {
- process.stdout.write(up + '\n');
+ if (options.indent) {
+ process.stdout.write(
+ up
+ .split('\n')
+ .map((l) => {
+ return `${INDENT_TOKEN} ${l}`;
+ })
+ .join('\n') + '\n'
+ );
+ } else {
+ process.stdout.write(up + '\n');
+ }
+
return true;
},
};
@@ -46,25 +59,35 @@ export const createOverwriteableCliOutput = (options: {
});
return {
- update: (up: string): boolean => process.stdout.write(diff.update(up)),
+ update: (up: string): boolean => {
+ if (options.indent) {
+ return process.stdout.write(
+ diff.update(
+ up
+ .split('\n')
+ .map((l) => `${INDENT_TOKEN} ${l}`)
+ .join('\n')
+ )
+ );
+ }
+
+ return process.stdout.write(diff.update(up));
+ },
};
};
const makeBundlingProgress = ({
bundlingState,
- indent,
bundlingStep,
steps,
}: {
bundlingState: BundlingState;
- indent: boolean;
bundlingStep: number;
steps: number;
}) => {
const {doneIn, progress} = bundlingState;
return [
- indent ? INDENT_TOKEN : null,
`(${bundlingStep + 1}/${steps})`,
makeProgressBar(progress),
`${doneIn ? 'Bundled' : 'Bundling'} code`,
@@ -76,14 +99,13 @@ const makeBundlingProgress = ({
.join(' ');
};
-const makeCopyingProgress = (options: CopyingState, indent: boolean) => {
+const makeCopyingProgress = (options: CopyingState) => {
// Don't show copy progress lower than 200MB
if (options.bytes < 1000 * 1000 * 200) {
return null;
}
return [
- indent ? INDENT_TOKEN : null,
' +',
options.doneIn ? makeProgressBar(1) : getFileSizeDownloadBar(options.bytes),
'Copying public dir',
@@ -93,7 +115,7 @@ const makeCopyingProgress = (options: CopyingState, indent: boolean) => {
.join(' ');
};
-const makeSymlinkProgress = (options: SymbolicLinksState, indent: boolean) => {
+const makeSymlinkProgress = (options: SymbolicLinksState) => {
if (options.symlinks.length === 0) {
return null;
}
@@ -103,11 +125,7 @@ const makeSymlinkProgress = (options: SymbolicLinksState, indent: boolean) => {
chalk.gray(` Found a symbolic link in the public folder:`),
chalk.gray(' ' + options.symlinks[0]),
chalk.gray(' The symlink will be forwarded in to the bundle.'),
- ]
- .map((l) => {
- return indent ? `${INDENT_TOKEN} ${l}` : null;
- })
- .join('\n');
+ ].join('\n');
}
return [
@@ -115,11 +133,7 @@ const makeSymlinkProgress = (options: SymbolicLinksState, indent: boolean) => {
` Found ${options.symlinks.length} symbolic links in the public folder.`
),
chalk.gray(' The symlinks will be forwarded in to the bundle.'),
- ]
- .map((l) => {
- return indent ? `${INDENT_TOKEN} ${l}` : null;
- })
- .join('\n');
+ ].join('\n');
};
export type CopyingState = {
@@ -144,31 +158,31 @@ export const makeBundlingAndCopyProgress = (
copying: CopyingState;
symLinks: SymbolicLinksState;
},
- indent: boolean,
bundlingStep: number,
steps: number
) => {
return [
makeBundlingProgress({
bundlingState: bundling,
- indent,
bundlingStep,
steps,
}),
- makeCopyingProgress(copying, indent),
- makeSymlinkProgress(symLinks, indent),
+ makeCopyingProgress(copying),
+ makeSymlinkProgress(symLinks),
]
.filter(truthy)
.join('\n');
};
-const makeRenderingProgress = (
- {frames, totalFrames, steps, concurrency, doneIn}: RenderingProgressInput,
- indent: boolean
-) => {
+const makeRenderingProgress = ({
+ frames,
+ totalFrames,
+ steps,
+ concurrency,
+ doneIn,
+}: RenderingProgressInput) => {
const progress = frames / totalFrames;
return [
- indent ? INDENT_TOKEN : null,
`(${steps.indexOf('rendering') + 1}/${steps.length})`,
makeProgressBar(progress),
[doneIn ? 'Rendered' : 'Rendering', `frames (${concurrency}x)`]
@@ -182,12 +196,10 @@ const makeRenderingProgress = (
const makeStitchingProgress = ({
stitchingProgress,
- indent,
steps,
stitchingStep,
}: {
stitchingProgress: StitchingProgressInput;
- indent: boolean;
steps: number;
stitchingStep: number;
}) => {
@@ -201,7 +213,6 @@ const makeStitchingProgress = ({
: 'video';
return [
- indent ? INDENT_TOKEN : null,
`(${stitchingStep + 1}/${steps})`,
makeProgressBar(progress),
stage === 'muxing' && RenderInternals.canUseParallelEncoding(codec)
@@ -215,12 +226,10 @@ const makeStitchingProgress = ({
export const makeRenderingAndStitchingProgress = ({
prog,
- indent,
steps,
stitchingStep,
}: {
prog: AggregateRenderProgress;
- indent: boolean;
steps: number;
stitchingStep: number;
}): {
@@ -230,13 +239,12 @@ export const makeRenderingAndStitchingProgress = ({
} => {
const {rendering, stitching, downloads, bundling} = prog;
const output = [
- rendering ? makeRenderingProgress(rendering, indent) : null,
- makeMultiDownloadProgress(downloads, indent),
+ rendering ? makeRenderingProgress(rendering) : null,
+ makeMultiDownloadProgress(downloads),
stitching === null
? null
: makeStitchingProgress({
stitchingProgress: stitching,
- indent,
steps,
stitchingStep,
}),
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index 616b95c512..645c06afa5 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -164,6 +164,7 @@ export const renderVideoFlow = async ({
quiet,
cancelSignal,
updatesDontOverwrite,
+ indent,
});
const steps: RenderStep[] = [
@@ -195,7 +196,6 @@ export const renderVideoFlow = async ({
const {output, message, progress} = makeRenderingAndStitchingProgress({
prog: aggregateRenderProgress,
- indent,
steps: steps.length,
stitchingStep: steps.indexOf('bundling'),
});
@@ -297,10 +297,14 @@ export const renderVideoFlow = async ({
logLevel,
});
+ Log.verboseAdvanced(
+ {indent, logLevel, tag: 'config'},
+ chalk.gray(`Entry point = ${fullEntryPoint} (${entryPointReason})`)
+ );
Log.infoAdvanced(
{indent, logLevel},
chalk.gray(
- `Entry point = ${fullEntryPoint} (${entryPointReason}), Composition = ${compositionId} (${reason}), Codec = ${codec} (${codecReason}), Output = ${relativeOutputLocation}`
+ `Composition = ${compositionId} (${reason}), Codec = ${codec} (${codecReason}), Output = ${relativeOutputLocation}`
)
);
@@ -394,7 +398,7 @@ export const renderVideoFlow = async ({
updateRenderProgress();
process.stdout.write('\n');
- Log.infoAdvanced({indent, logLevel}, chalk.cyan(`▶ ${absoluteOutputFile}`));
+ Log.infoAdvanced({indent, logLevel}, chalk.blue(`▶ ${absoluteOutputFile}`));
return;
}
@@ -477,8 +481,7 @@ export const renderVideoFlow = async ({
});
updateRenderProgress();
- process.stdout.write('\n');
- Log.infoAdvanced({indent, logLevel}, chalk.cyan(`▶ ${absoluteOutputFile}`));
+ Log.infoAdvanced({indent, logLevel}, chalk.blue(`▶ ${absoluteOutputFile}`));
for (const line of RenderInternals.perf.getPerf()) {
Log.verboseAdvanced({indent, logLevel}, line);
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index 352d08084b..65eee0e865 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -101,6 +101,8 @@ export const renderStillFlow = async ({
const downloads: DownloadProgress[] = [];
const aggregate: AggregateRenderProgress = initialAggregateRenderProgress();
+ const updatesDontOverwrite = shouldUseNonOverlayingLogger({logLevel});
+
let renderProgress: OverwriteableCliOutput | null = null;
const steps: RenderStep[] = [
@@ -111,12 +113,11 @@ export const renderStillFlow = async ({
const updateProgress = () => {
const {output, progress, message} = makeRenderingAndStitchingProgress({
prog: aggregate,
- indent: indentOutput,
steps: steps.length,
stitchingStep: steps.indexOf('stitching'),
});
if (renderProgress) {
- renderProgress.update(output);
+ renderProgress.update(updatesDontOverwrite ? message : output);
}
onProgress({message, value: progress, ...aggregate});
@@ -159,7 +160,7 @@ export const renderStillFlow = async ({
RenderInternals.deleteDirectory(dir);
});
},
- quietProgress: false,
+ quietProgress: updatesDontOverwrite,
}
);
@@ -218,10 +219,14 @@ export const renderStillFlow = async ({
recursive: true,
});
+ Log.verboseAdvanced(
+ {indent: indentOutput, logLevel, tag: 'config'},
+ chalk.gray(`Entry point = ${fullEntryPoint} (${entryPointReason})`)
+ );
Log.infoAdvanced(
{indent: indentOutput, logLevel},
chalk.gray(
- `Entry point = ${fullEntryPoint} (${entryPointReason}), Output = ${relativeOutputLocation}, Format = ${imageFormat} (${source}), Composition = ${compositionId} (${reason})`
+ `Composition = ${compositionId} (${reason}), Format = ${imageFormat} (${source}), Output = ${relativeOutputLocation}`
)
);
@@ -229,6 +234,7 @@ export const renderStillFlow = async ({
quiet: quietFlagProvided(),
cancelSignal,
updatesDontOverwrite: shouldUseNonOverlayingLogger({logLevel}),
+ indent: indentOutput,
});
const renderStart = Date.now();
@@ -292,6 +298,6 @@ export const renderStillFlow = async ({
Log.infoAdvanced({indent: indentOutput, logLevel});
Log.infoAdvanced(
{indent: indentOutput, logLevel},
- chalk.cyan(`▶️ ${absoluteOutputLocation}`)
+ chalk.blue(`▶️ ${absoluteOutputLocation}`)
);
};
diff --git a/packages/cli/src/setup-cache.ts b/packages/cli/src/setup-cache.ts
index af19de9fe6..5f5835089a 100644
--- a/packages/cli/src/setup-cache.ts
+++ b/packages/cli/src/setup-cache.ts
@@ -126,7 +126,6 @@ const bundleOnCli = async ({
copying: copyingState,
symLinks: symlinkState,
},
- indent,
bundlingStep,
steps
) + (newline ? '\n' : '')
@@ -197,6 +196,7 @@ const bundleOnCli = async ({
quiet: quietProgress || quietFlagProvided(),
cancelSignal: null,
updatesDontOverwrite: shouldUseNonOverlayingLogger({logLevel}),
+ indent,
});
let bundlingState: BundlingState = {
diff --git a/packages/renderer/src/prespawn-ffmpeg.ts b/packages/renderer/src/prespawn-ffmpeg.ts
index e2604b86bf..02e0341569 100644
--- a/packages/renderer/src/prespawn-ffmpeg.ts
+++ b/packages/renderer/src/prespawn-ffmpeg.ts
@@ -2,7 +2,6 @@ import {Internals} from 'remotion';
import {callFf} from './call-ffmpeg';
import type {Codec} from './codec';
import {DEFAULT_CODEC} from './codec';
-import {getExecutablePath} from './compositor/get-executable-path';
import {validateQualitySettings} from './crf';
import type {FfmpegOverrideFn} from './ffmpeg-override';
import {getCodecName} from './get-codec-name';
@@ -71,18 +70,55 @@ export const prespawnFfmpeg = (options: PreStitcherOptions) => {
const supportsCrf = codec !== 'prores';
- if (options.verbose) {
- console.log('[verbose] ffmpeg', getExecutablePath('ffmpeg'));
- console.log('[verbose] encoder', encoderName);
- console.log('[verbose] pixelFormat', pixelFormat);
- if (supportsCrf) {
- console.log('[verbose] crf', options.crf);
- }
-
- console.log('[verbose] codec', codec);
- console.log('[verbose] proResProfileName', proResProfileName);
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'encoder',
+ encoderName
+ );
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'pixelFormat',
+ pixelFormat
+ );
+ if (supportsCrf) {
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'pixelFormat',
+ options.crf
+ );
}
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'codec',
+ codec
+ );
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'proResProfileName',
+ proResProfileName
+ );
+
validateSelectedPixelFormatAndCodecCombination(pixelFormat, codec);
const ffmpegArgs = [
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index 97cc2d84d3..8c9a50846c 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -17,7 +17,6 @@ import {callFf} from './call-ffmpeg';
import type {Codec} from './codec';
import {DEFAULT_CODEC} from './codec';
import {codecSupportsMedia} from './codec-supports-media';
-import {getExecutablePath} from './compositor/get-executable-path';
import {convertNumberOfGifLoopsToFfmpegSyntax} from './convert-number-of-gif-loops-to-ffmpeg';
import {validateQualitySettings} from './crf';
import {deleteDirectory} from './delete-directory';
@@ -229,21 +228,69 @@ const spawnFfmpeg = async (
`out.${getFileExtensionFromCodec(codec, resolvedAudioCodec)}`
);
- if (options.verbose) {
- console.log('[verbose] ffmpeg', getExecutablePath('ffmpeg'));
- console.log('[verbose] encoder', encoderName);
- console.log('[verbose] audioCodec', resolvedAudioCodec);
- console.log('[verbose] pixelFormat', pixelFormat);
-
- if (options.ffmpegOverride) {
- console.log('[verbose] ffmpegOverride', options.ffmpegOverride);
- }
-
- console.log('[verbose] codec', codec);
- console.log('[verbose] shouldRenderAudio', shouldRenderAudio);
- console.log('[verbose] shouldRenderVideo', shouldRenderVideo);
- console.log('[verbose] proResProfileName', proResProfileName);
- }
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'encoder',
+ encoderName
+ );
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'audioCodec',
+ resolvedAudioCodec
+ );
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'pixelFormat',
+ pixelFormat
+ );
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'codec',
+ codec
+ );
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'shouldRenderAudio',
+ shouldRenderAudio
+ );
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'shouldRenderVideo',
+ shouldRenderVideo
+ );
+ Log.verboseAdvanced(
+ {
+ indent: options.indent,
+ logLevel: options.verbose ? 'verbose' : 'info',
+ tag: 'encoder',
+ },
+ 'proResProfileName',
+ proResProfileName
+ );
validateQualitySettings({
crf: options.crf,
@@ -380,23 +427,6 @@ const spawnFfmpeg = async (
options.outputLocation ?? tempFile,
];
- Log.verboseAdvanced(
- {
- indent: options.indent,
- logLevel: options.verbose ? 'verbose' : 'info',
- tag: 'encoder',
- },
- 'Generated FFMPEG command:'
- );
- Log.verboseAdvanced(
- {
- indent: options.indent,
- logLevel: options.verbose ? 'verbose' : 'info',
- tag: 'encoder',
- },
- ffmpegArgs.join(' ')
- );
-
const ffmpegString = ffmpegArgs.flat(2).filter(Boolean) as string[];
const finalFfmpegString = options.ffmpegOverride
? options.ffmpegOverride({type: 'stitcher', args: ffmpegString})