Skip to content

🎥 Make videos programmatically with React

videos with alpha channel

Jonny Burger61245f3419c7
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index 122dfe0211..15e7ead03b 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -19,12 +19,11 @@ export type CommandLineOptions = {
export const parsedCli = minimist<CommandLineOptions>(process.argv.slice(2));
export const parseCommandLine = () => {
- console.log(parsedCli);
if (parsedCli['pixel-format']) {
- Config.Output.setPixelFormat(parsedCli.pixelFormat);
+ Config.Output.setPixelFormat(parsedCli['pixel-format']);
}
if (parsedCli['image-format']) {
- Config.Rendering.setImageFormat(parsedCli.imageFormat);
+ Config.Rendering.setImageFormat(parsedCli['image-format']);
}
if (parsedCli.concurrency) {
Config.Rendering.setConcurrency(parsedCli.concurrency);
diff --git a/packages/renderer/src/stitcher.ts b/packages/renderer/src/stitcher.ts
index 4e65373c29..7a04158086 100644
--- a/packages/renderer/src/stitcher.ts
+++ b/packages/renderer/src/stitcher.ts
@@ -58,30 +58,32 @@ export const stitchFramesToVideo = async (options: {
);
Internals.validateSelectedPixelFormatAndCodecCombination(pixelFormat, codec);
- const task = execa(
- 'ffmpeg',
- [
- '-r',
- String(options.fps),
- '-f',
- 'image2',
- '-s',
- `${options.width}x${options.height}`,
- '-i',
- `element-%0${numberLength}d.${imageFormat}`,
- '-c:v',
- encoderName,
- '-crf',
- crf,
- '-b:v',
- '1M',
- options.force ? '-y' : null,
- '-pix_fmt',
- pixelFormat,
- options.outputLocation,
- ].filter(Boolean) as string[],
- {cwd: options.dir}
- );
+ const ffmpegArgs = [
+ '-r',
+ String(options.fps),
+ '-f',
+ 'image2',
+ '-s',
+ `${options.width}x${options.height}`,
+ '-i',
+ `element-%0${numberLength}d.${imageFormat}`,
+ '-c:v',
+ encoderName,
+ '-crf',
+ crf,
+ '-b:v',
+ '1M',
+ options.force ? '-y' : null,
+ '-pix_fmt',
+ pixelFormat,
+ // Without explicitly disabling auto-alt-ref,
+ // transparent WebM generation doesn't work
+ pixelFormat === 'yuva420p' ? '-auto-alt-ref' : null,
+ pixelFormat === 'yuva420p' ? '0' : null,
+ options.outputLocation,
+ ].filter(Boolean) as string[];
+
+ const task = execa('ffmpeg', ffmpegArgs, {cwd: options.dir});
task.stderr?.on('data', (data: Buffer) => {
if (options.onProgress) {