Skip to content

🎥 Make videos programmatically with React

verbose output

Jonny Burger03f0547e8ff8
diff --git a/packages/cli/src/load-config.ts b/packages/cli/src/load-config.ts
index 416e1d7537..06420fc58c 100644
--- a/packages/cli/src/load-config.ts
+++ b/packages/cli/src/load-config.ts
@@ -4,7 +4,7 @@ import typescript from 'typescript';
import {isDefaultConfigFile} from './get-config-file-name';
import {Log} from './log';
-export const loadConfigFile = (configFileName: string) => {
+export const loadConfigFile = (configFileName: string): string | null => {
const configFile = path.resolve(process.cwd(), configFileName);
const tsconfigJson = path.join(process.cwd(), 'tsconfig.json');
if (!fs.existsSync(tsconfigJson)) {
@@ -20,7 +20,7 @@ export const loadConfigFile = (configFileName: string) => {
);
process.exit(1);
}
- return;
+ return null;
}
const tsConfig = typescript.readConfigFile(
@@ -43,5 +43,5 @@ export const loadConfigFile = (configFileName: string) => {
eval(output.outputText);
- Log.Verbose(`Applied configuration from ${configFileName}.`);
+ return configFileName;
};
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index 18a73cdf8f..0cc588a2fc 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -29,8 +29,11 @@ export const render = async () => {
const fullPath = path.join(process.cwd(), file);
const configFileName = getConfigFileName();
- loadConfigFile(configFileName);
+ const appliedName = loadConfigFile(configFileName);
parseCommandLine();
+ if (appliedName) {
+ Log.Verbose(`Applied configuration from ${appliedName}.`);
+ }
const parallelism = Internals.getConcurrency();
const frameRange = Internals.getRange();
if (typeof frameRange === 'number') {
@@ -152,6 +155,7 @@ export const render = async () => {
}
);
bundlingProgress.stop();
+ Log.Verbose('Bundled under', bundled);
const cacheExistedAfter = cacheExists('production', null);
if (cacheExistedAfter && !cacheExistedBefore) {
Log.Info('⚡️ Cached bundle. Subsequent builds will be faster.');
@@ -171,6 +175,8 @@ export const render = async () => {
? absoluteOutputFile
: await fs.promises.mkdtemp(path.join(os.tmpdir(), 'react-motion-render'));
+ Log.Verbose('Output dir', outputDir);
+
const renderProgress = new cliProgress.Bar(
{
clearOnComplete: true,
@@ -200,6 +206,7 @@ export const render = async () => {
browser,
frameRange: frameRange ?? null,
assetsOnly: Internals.isAudioCodec(codec),
+ dumpBrowserLogs: Internals.Logging.isEqualOrBelowLogLevel('verbose'),
});
renderProgress.stop();
if (process.env.DEBUG) {
@@ -239,6 +246,7 @@ export const render = async () => {
Log.Info('\n');
Log.Info('Downloading asset... ', src);
},
+ verbose: Internals.Logging.isEqualOrBelowLogLevel('verbose'),
});
stitchingProgress.stop();
diff --git a/packages/renderer/src/stitcher.ts b/packages/renderer/src/stitcher.ts
index 5de8f8372d..7a6eb26696 100644
--- a/packages/renderer/src/stitcher.ts
+++ b/packages/renderer/src/stitcher.ts
@@ -64,6 +64,7 @@ export const stitchFramesToVideo = async (options: {
parallelism?: number | null;
onProgress?: (num: number) => void;
onDownload?: (src: string) => void;
+ verbose?: boolean;
}): Promise<void> => {
const codec = options.codec ?? Internals.DEFAULT_CODEC;
const crf = options.crf ?? Internals.getDefaultCrfForCodec(codec);
@@ -84,6 +85,18 @@ export const stitchFramesToVideo = async (options: {
const encoderName = getCodecName(codec);
const audioCodecName = getAudioCodecName(codec);
const isAudioOnly = encoderName === null;
+
+ if (options.verbose) {
+ console.log('[verbose] encoder', encoderName);
+ console.log('[verbose] audioCodec', audioCodecName);
+ console.log('[verbose] pixelFormat', pixelFormat);
+ console.log('[verbose] files', JSON.stringify(files));
+ console.log('[verbose] imageFormat', imageFormat);
+ console.log('[verbose] crf', crf);
+ console.log('[verbose] codec', codec);
+ console.log('[verbose] isAudioOnly', isAudioOnly);
+ }
+
Internals.validateSelectedCrfAndCodecCombination(crf, codec);
Internals.validateSelectedPixelFormatAndImageFormatCombination(
pixelFormat,
@@ -115,7 +128,6 @@ export const stitchFramesToVideo = async (options: {
fps: options.fps,
videoTrackCount: isAudioOnly ? 0 : 1,
});
-
const ffmpegArgs = [
['-r', String(options.fps)],
isAudioOnly ? null : ['-f', 'image2'],
@@ -143,11 +155,18 @@ export const stitchFramesToVideo = async (options: {
isAudioOnly ? null : ['-map', '0:v'],
options.force ? '-y' : null,
options.outputLocation,
- ]
+ ];
+
+ if (options.verbose) {
+ console.log('Generated FFMPEG command:');
+ console.log(ffmpegArgs);
+ }
+
+ const ffmpegString = ffmpegArgs
.reduce<(string | null)[]>((acc, val) => acc.concat(val), [])
.filter(Boolean) as string[];
- const task = execa('ffmpeg', ffmpegArgs, {cwd: options.dir});
+ const task = execa('ffmpeg', ffmpegString, {cwd: options.dir});
task.stderr?.on('data', (data: Buffer) => {
if (options.onProgress) {