Skip to content

🎥 Make videos programmatically with React

fix `ffmpegExecutable` not being respected for stitchFramesToVideo

Jonny Burgerdd84a4665833
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.ts
index 9d68f0aa2c..a153b692f6 100644
--- a/packages/cli/src/get-cli-options.ts
+++ b/packages/cli/src/get-cli-options.ts
@@ -107,7 +107,7 @@ const getAndValidateShouldOutputImageSequence = async (
const shouldOutputImageSequence =
Internals.getShouldOutputImageSequence(frameRange);
if (!shouldOutputImageSequence) {
- await RenderInternals.validateFfmpeg();
+ await RenderInternals.validateFfmpeg(Internals.getCustomFfmpegExecutable());
}
return shouldOutputImageSequence;
diff --git a/packages/renderer/src/stitcher.ts b/packages/renderer/src/stitcher.ts
index 8f3eafc78b..8477647c3c 100644
--- a/packages/renderer/src/stitcher.ts
+++ b/packages/renderer/src/stitcher.ts
@@ -66,7 +66,7 @@ export const stitchFramesToVideo = async (options: {
const crf = options.crf ?? Internals.getDefaultCrfForCodec(codec);
const imageFormat = options.imageFormat ?? DEFAULT_IMAGE_FORMAT;
const pixelFormat = options.pixelFormat ?? Internals.DEFAULT_PIXEL_FORMAT;
- await validateFfmpeg();
+ await validateFfmpeg(options.ffmpegExecutable ?? null);
const encoderName = getCodecName(codec);
const audioCodecName = getAudioCodecName(codec);
@@ -78,7 +78,7 @@ export const stitchFramesToVideo = async (options: {
if (options.verbose) {
console.log(
'[verbose] ffmpeg',
- Internals.getCustomFfmpegExecutable() ?? 'ffmpeg in PATH'
+ options.ffmpegExecutable ?? 'ffmpeg in PATH'
);
console.log('[verbose] encoder', encoderName);
console.log('[verbose] audioCodec', audioCodecName);
@@ -184,11 +184,9 @@ export const stitchFramesToVideo = async (options: {
.reduce<(string | null)[]>((acc, val) => acc.concat(val), [])
.filter(Boolean) as string[];
- const task = execa(
- Internals.getCustomFfmpegExecutable() ?? 'ffmpeg',
- ffmpegString,
- {cwd: options.dir}
- );
+ const task = execa(options.ffmpegExecutable ?? 'ffmpeg', ffmpegString, {
+ cwd: options.dir,
+ });
task.stderr?.on('data', (data: Buffer) => {
if (options.onProgress) {
diff --git a/packages/renderer/src/validate-ffmpeg.ts b/packages/renderer/src/validate-ffmpeg.ts
index 5796d6b78a..da91c2b262 100644
--- a/packages/renderer/src/validate-ffmpeg.ts
+++ b/packages/renderer/src/validate-ffmpeg.ts
@@ -5,12 +5,14 @@ import {Internals} from 'remotion';
const existsMap: {[key: string]: boolean} = {};
-export const binaryExists = async (name: 'ffmpeg' | 'brew') => {
+export const binaryExists = async (
+ name: 'ffmpeg' | 'brew',
+ localFFmpeg: string | null
+) => {
if (typeof existsMap[name] !== 'undefined') {
return existsMap[name];
}
- const localFFmpeg = Internals.getCustomFfmpegExecutable();
if (name === 'ffmpeg' && localFFmpeg) {
try {
statSync(localFFmpeg);
@@ -35,11 +37,13 @@ export const binaryExists = async (name: 'ffmpeg' | 'brew') => {
};
export const isHomebrewInstalled = async (): Promise<boolean> => {
- return binaryExists('brew');
+ return binaryExists('brew', null);
};
-export const validateFfmpeg = async (): Promise<void> => {
- const ffmpegExists = await binaryExists('ffmpeg');
+export const validateFfmpeg = async (
+ customFfmpegBinary: string | null
+): Promise<void> => {
+ const ffmpegExists = await binaryExists('ffmpeg', customFfmpegBinary);
if (!ffmpegExists) {
if (Internals.getCustomFfmpegExecutable()) {
console.error('FFmpeg executable not found:');