Skip to content

🎥 Make videos programmatically with React

simplify logic

Jonny Burgera4a493ec3a81
diff --git a/packages/renderer/src/validate-ffmpeg.ts b/packages/renderer/src/validate-ffmpeg.ts
index 7d1e083bbc..ddcd555c50 100644
--- a/packages/renderer/src/validate-ffmpeg.ts
+++ b/packages/renderer/src/validate-ffmpeg.ts
@@ -71,63 +71,65 @@ export const validateFfmpeg = async (
}
const ffmpegExists = binaryExists('ffmpeg', customFfmpegBinary);
- if (!ffmpegExists) {
- if (customFfmpegBinary) {
- console.error('FFmpeg executable not found:');
- console.error(customFfmpegBinary);
- throw new Error('FFmpeg not found');
- }
-
- if (ffmpegInNodeModules(remotionRoot, 'ffmpeg')) {
- return;
- }
+ if (ffmpegExists) {
+ return;
+ }
- if (
- os.platform() === 'darwin' ||
- (os.platform() === 'win32' && process.arch === 'x64') ||
- (os.platform() === 'linux' && process.arch === 'x64')
- ) {
- await downloadBinary(
- remotionRoot,
- getBinaryDownloadUrl('ffmpeg').url,
- 'ffmpeg'
- );
- return validateFfmpeg(customFfmpegBinary, remotionRoot);
- }
+ if (customFfmpegBinary) {
+ console.error('FFmpeg executable not found:');
+ console.error(customFfmpegBinary);
+ throw new Error('FFmpeg not found');
+ }
- if (customFfmpegBinary) {
- console.error('FFmpeg executable not found:');
- console.error(customFfmpegBinary);
- throw new Error('FFmpeg not found');
- }
+ if (ffmpegInNodeModules(remotionRoot, 'ffmpeg')) {
+ return;
+ }
- console.error('It looks like FFMPEG is not installed');
- if (os.platform() === 'darwin' && isHomebrewInstalled()) {
- console.error('Run `brew install ffmpeg` to install ffmpeg');
- } else if (os.platform() === 'win32') {
- console.error('1. Install FFMPEG for Windows here:');
- console.error(
- 'https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg#installing-ffmpeg-in-windows'
- );
- console.error('2. Add FFMPEG to your PATH');
- console.error(' a. Go to the settings app.');
- console.error(' b. Click System.');
- console.error(' c. Click About.');
- console.error(' d. Click Advanced system settings.');
- console.error(' e. Click Environment variables.');
- console.error(
- ' f. Search for PATH environemnt variable, click edit and the folder where you installed FFMPEG.'
- );
- console.error(
- ' g. Important: Restart your terminal completely to apply the new PATH.'
- );
- console.error('3. Re-run this command.');
- } else {
- console.error(
- 'See https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg on how to install FFMPEG.'
- );
- }
+ if (
+ os.platform() === 'darwin' ||
+ (os.platform() === 'win32' && process.arch === 'x64') ||
+ (os.platform() === 'linux' && process.arch === 'x64')
+ ) {
+ await downloadBinary(
+ remotionRoot,
+ getBinaryDownloadUrl('ffmpeg').url,
+ 'ffmpeg'
+ );
+ return validateFfmpeg(customFfmpegBinary, remotionRoot);
+ }
+ if (customFfmpegBinary) {
+ console.error('FFmpeg executable not found:');
+ console.error(customFfmpegBinary);
throw new Error('FFmpeg not found');
}
+
+ console.error('It looks like FFMPEG is not installed');
+ if (os.platform() === 'darwin' && isHomebrewInstalled()) {
+ console.error('Run `brew install ffmpeg` to install ffmpeg');
+ } else if (os.platform() === 'win32') {
+ console.error('1. Install FFMPEG for Windows here:');
+ console.error(
+ 'https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg#installing-ffmpeg-in-windows'
+ );
+ console.error('2. Add FFMPEG to your PATH');
+ console.error(' a. Go to the settings app.');
+ console.error(' b. Click System.');
+ console.error(' c. Click About.');
+ console.error(' d. Click Advanced system settings.');
+ console.error(' e. Click Environment variables.');
+ console.error(
+ ' f. Search for PATH environemnt variable, click edit and the folder where you installed FFMPEG.'
+ );
+ console.error(
+ ' g. Important: Restart your terminal completely to apply the new PATH.'
+ );
+ console.error('3. Re-run this command.');
+ } else {
+ console.error(
+ 'See https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg on how to install FFMPEG.'
+ );
+ }
+
+ throw new Error('FFmpeg not found');
};