🎥 Make videos programmatically with React
Merge branch 'main' into ffmpeg-autoinstall
Patric Salvisbergc94118fdd725
diff --cc packages/renderer/src/validate-ffmpeg.tsindex 5e416e0069,9b2e2368b9..4c672abebe--- a/packages/renderer/src/validate-ffmpeg.ts+++ b/packages/renderer/src/validate-ffmpeg.ts@@@ -1,13 -1,7 +1,13 @@@import execa from 'execa';- import {statSync} from 'fs';+ import {existsSync, statSync} from 'fs';import os from 'os';-import {getFfmpegBuildInfo, getFfmpegVersion} from './ffmpeg-flags';+import {+ downloadBinary,+ ffmpegInNodeModules,+ getFfmpegBuildInfo,+ getFfmpegDownloadUrl,+ getFfmpegVersion,+} from './ffmpeg-flags';import {warnAboutFfmpegVersion} from './warn-about-ffmpeg-version';const existsMap: {[key: string]: boolean} = {};@@@ -76,62 -54,48 +76,71 @@@ export const checkAndValidateFfmpegVers};export const validateFfmpeg = async (- customFfmpegBinary: string | null+ customFfmpegBinary: string | null,+ remotionRoot: string): Promise<void> => {- if (binaryExists('ffmpeg', customFfmpegBinary)) {- return;+ if (process.platform === 'linux' && existsSync('/opt/bin/ffmpeg')) {+ return Promise.resolve();}+- if (ffmpegInNodeModules(remotionRoot, 'ffmpeg')) {- return;- }+ 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 (- os.platform() === 'darwin' ||- (os.platform() === 'win32' && process.arch === 'x64') ||- (os.platform() === 'linux' && process.arch === 'x64')- ) {- await downloadBinary(- remotionRoot,- getFfmpegDownloadUrl('ffmpeg').url,- 'ffmpeg'- );- return validateFfmpeg(customFfmpegBinary, remotionRoot);- }++ if (ffmpegInNodeModules(remotionRoot, 'ffmpeg')) {++ return;++ }+- if (customFfmpegBinary) {- console.error('FFmpeg executable not found:');- console.error(customFfmpegBinary);- throw new Error('FFmpeg not found');- }++ if (++ os.platform() === 'darwin' ||++ (os.platform() === 'win32' && process.arch === 'x64') ||++ (os.platform() === 'linux' && process.arch === 'x64')++ ) {++ await downloadBinary(++ remotionRoot,++ getFfmpegDownloadUrl('ffmpeg').url,++ 'ffmpeg'++ );++ return validateFfmpeg(customFfmpegBinary, remotionRoot);++ }+- 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 (customFfmpegBinary) {++ console.error('FFmpeg executable not found:');++ console.error(customFfmpegBinary);++ throw new Error('FFmpeg not found');++ }+- process.exit(1);+ 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');++ process.exit(1);+ }-- await checkAndValidateFfmpegVersion({ffmpegExecutable: customFfmpegBinary});};