Skip to content

🎥 Make videos programmatically with React

hmm

Jonny Burgerf8d3b524892b
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index a6a15eb315..5dd03e11f5 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -153,8 +153,6 @@ export const benchmarkCommand = async (
inputProps,
envVariables,
browserExecutable,
- ffmpegExecutable,
- ffprobeExecutable,
chromiumOptions,
port,
puppeteerTimeout,
@@ -194,8 +192,6 @@ export const benchmarkCommand = async (
envVariables,
chromiumOptions,
timeoutInMilliseconds: puppeteerTimeout,
- ffmpegExecutable,
- ffprobeExecutable,
port,
puppeteerInstance,
});
diff --git a/packages/cli/src/compositions.ts b/packages/cli/src/compositions.ts
index 0caf9ec8b6..cb04570bda 100644
--- a/packages/cli/src/compositions.ts
+++ b/packages/cli/src/compositions.ts
@@ -31,8 +31,6 @@ export const listCompositionsCommand = async (
const {
browserExecutable,
- ffmpegExecutable,
- ffprobeExecutable,
chromiumOptions,
envVariables,
inputProps,
@@ -55,8 +53,6 @@ export const listCompositionsCommand = async (
const compositions = await getCompositions(bundled, {
browserExecutable,
- ffmpegExecutable,
- ffprobeExecutable,
chromiumOptions,
envVariables,
inputProps,
diff --git a/packages/cli/src/config/ffmpeg-executable.ts b/packages/cli/src/config/ffmpeg-executable.ts
deleted file mode 100644
index 5db4748fc7..0000000000
--- a/packages/cli/src/config/ffmpeg-executable.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type {FfmpegExecutable} from '@remotion/renderer';
-
-let currentFfmpegExecutablePath: FfmpegExecutable = null;
-let currentFfprobeExecutablePath: FfmpegExecutable = null;
-
-export const setFfmpegExecutable = (ffmpegPath: FfmpegExecutable) => {
- currentFfmpegExecutablePath = ffmpegPath;
-};
-
-export const getCustomFfmpegExecutable = () => {
- return currentFfmpegExecutablePath;
-};
-
-export const setFfprobeExecutable = (ffprobePath: FfmpegExecutable) => {
- currentFfprobeExecutablePath = ffprobePath;
-};
-
-export const getCustomFfprobeExecutable = () => {
- return currentFfprobeExecutablePath;
-};
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index a4186e8775..6388a75255 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -11,10 +11,6 @@ import {
import {getOutputCodecOrUndefined} from './codec';
import {getConcurrency} from './concurrency';
import {getDotEnvLocation} from './env-file';
-import {
- getCustomFfmpegExecutable,
- getCustomFfprobeExecutable,
-} from './ffmpeg-executable';
import {getRange, setFrameRangeFromCli} from './frame-range';
import {getUserPreferredImageFormat} from './image-format';
import {getShouldOutputImageSequence} from './image-sequence';
@@ -63,7 +59,6 @@ import {
import {getEntryPoint, setEntryPoint} from './entry-point';
import {setDotEnvLocation} from './env-file';
import {getEveryNthFrame, setEveryNthFrame} from './every-nth-frame';
-import {setFfmpegExecutable, setFfprobeExecutable} from './ffmpeg-executable';
import {
getFfmpegOverrideFunction,
setFfmpegOverrideFunction,
@@ -136,8 +131,6 @@ const Rendering = {
setQuality,
setImageFormat,
setFrameRange,
- setFfmpegExecutable,
- setFfprobeExecutable,
setScale,
setEveryNthFrame,
setNumberOfGifLoops,
@@ -185,13 +178,11 @@ export type {Concurrency, WebpackConfiguration, WebpackOverrideFn};
export const ConfigInternals = {
getRange,
getOutputCodecOrUndefined,
- getCustomFfmpegExecutable,
getBrowser,
getPixelFormat,
getProResProfile,
getShouldOverwrite,
getBrowserExecutable,
- getCustomFfprobeExecutable,
getScale,
getServerPort,
getChromiumDisableWebSecurity,
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.ts
index 386c7badea..1703724e5e 100644
--- a/packages/cli/src/get-cli-options.ts
+++ b/packages/cli/src/get-cli-options.ts
@@ -27,60 +27,6 @@ const getAndValidateFrameRange = () => {
return frameRange;
};
-export const validateFfmpegCanUseCodec = async (
- codec: Codec,
- remotionRoot: string
-) => {
- const ffmpegExecutable = ConfigInternals.getCustomFfmpegExecutable();
- if (
- codec === 'vp8' &&
- !(await RenderInternals.ffmpegHasFeature({
- feature: 'enable-libvpx',
- ffmpegExecutable,
- remotionRoot,
- }))
- ) {
- Log.error(
- "The Vp8 codec has been selected, but your FFMPEG binary wasn't compiled with the --enable-lipvpx flag."
- );
- Log.error(
- 'This does not work, please switch out your FFMPEG binary or choose a different codec.'
- );
- }
-
- if (
- codec === 'h265' &&
- !(await RenderInternals.ffmpegHasFeature({
- feature: 'enable-gpl',
- ffmpegExecutable,
- remotionRoot,
- }))
- ) {
- Log.error(
- "The H265 codec has been selected, but your FFMPEG binary wasn't compiled with the --enable-gpl flag."
- );
- Log.error(
- 'This does not work, please recompile your FFMPEG binary with --enable-gpl --enable-libx265 or choose a different codec.'
- );
- }
-
- if (
- codec === 'h265' &&
- !(await RenderInternals.ffmpegHasFeature({
- feature: 'enable-libx265',
- ffmpegExecutable,
- remotionRoot,
- }))
- ) {
- Log.error(
- "The H265 codec has been selected, but your FFMPEG binary wasn't compiled with the --enable-libx265 flag."
- );
- Log.error(
- 'This does not work, please recompile your FFMPEG binary with --enable-gpl --enable-libx265 or choose a different codec.'
- );
- }
-};
-
export const getFinalCodec = (options: {
downloadName: string | null;
outName: string | null;
@@ -116,25 +62,13 @@ export const getAndValidateAbsoluteOutputFile = (
return absoluteOutputFile;
};
-const getAndValidateShouldOutputImageSequence = async ({
+const getAndValidateShouldOutputImageSequence = ({
frameRange,
- isLambda,
- remotionRoot,
}: {
frameRange: FrameRange | null;
- isLambda: boolean;
- remotionRoot: string;
}) => {
const shouldOutputImageSequence =
ConfigInternals.getShouldOutputImageSequence(frameRange);
- // When parsing options locally, we don't need FFMPEG because the render will happen on Lambda
- if (!shouldOutputImageSequence && !isLambda) {
- await RenderInternals.validateFfmpeg(
- ConfigInternals.getCustomFfmpegExecutable(),
- remotionRoot,
- 'ffmpeg'
- );
- }
return shouldOutputImageSequence;
};
@@ -176,10 +110,8 @@ export const getCliOptions = async (options: {
const shouldOutputImageSequence =
options.type === 'still'
? true
- : await getAndValidateShouldOutputImageSequence({
+ : getAndValidateShouldOutputImageSequence({
frameRange,
- isLambda: options.isLambda,
- remotionRoot: options.remotionRoot,
});
const overwrite = ConfigInternals.getShouldOverwrite({
@@ -191,8 +123,6 @@ export const getCliOptions = async (options: {
const pixelFormat = ConfigInternals.getPixelFormat();
const proResProfile = getProResProfile();
const browserExecutable = ConfigInternals.getBrowserExecutable();
- const ffmpegExecutable = ConfigInternals.getCustomFfmpegExecutable();
- const ffprobeExecutable = ConfigInternals.getCustomFfprobeExecutable();
const scale = ConfigInternals.getScale();
const port = ConfigInternals.getServerPort();
@@ -230,8 +160,6 @@ export const getCliOptions = async (options: {
numberOfGifLoops,
stillFrame: ConfigInternals.getStillFrame(),
browserExecutable,
- ffmpegExecutable,
- ffprobeExecutable,
logLevel: ConfigInternals.Logging.getLogLevel(),
scale,
chromiumOptions,
diff --git a/packages/cli/src/get-render-media-options.ts b/packages/cli/src/get-render-media-options.ts
index 5dea3edf98..a879919d63 100644
--- a/packages/cli/src/get-render-media-options.ts
+++ b/packages/cli/src/get-render-media-options.ts
@@ -29,8 +29,6 @@ export const getRenderMediaOptions = async ({
crf,
pixelFormat,
browserExecutable,
- ffmpegExecutable,
- ffprobeExecutable,
scale,
chromiumOptions,
port,
@@ -61,8 +59,6 @@ export const getRenderMediaOptions = async ({
},
crf,
envVariables,
- ffmpegExecutable,
- ffprobeExecutable,
frameRange,
imageFormat,
inputProps,
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsx
index 6bcf583f77..462ab3d6c9 100644
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@ -13,7 +13,6 @@ import {loadConfig} from './get-config-file-name';
import {handleCommonError} from './handle-common-errors';
import {getImageFormat} from './image-formats';
import {initializeCli} from './initialize-cli';
-import {installCommand, INSTALL_COMMAND} from './install';
import {lambdaCommand} from './lambda-command';
import {listOfRemotionPackages} from './list-of-remotion-packages';
import {Log} from './log';
@@ -67,8 +66,6 @@ export const cli = async () => {
await upgrade(remotionRoot, parsedCli['package-manager']);
} else if (command === VERSIONS_COMMAND) {
await versionsCommand(remotionRoot);
- } else if (command === INSTALL_COMMAND) {
- await installCommand(remotionRoot, args);
} else if (command === 'benchmark') {
await benchmarkCommand(remotionRoot, args);
} else if (command === 'help') {
diff --git a/packages/cli/src/install.ts b/packages/cli/src/install.ts
deleted file mode 100644
index f4caef6bbc..0000000000
--- a/packages/cli/src/install.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import {ensureFfmpeg, ensureFfprobe} from '@remotion/renderer';
-import {Log} from './log';
-
-export const INSTALL_COMMAND = 'install' as const;
-
-export const installCommand = async (remotionRoot: string, args: string[]) => {
- const firstArg = args[0];
- if (firstArg === 'ffmpeg') {
- const {wasAlreadyInstalled} = await ensureFfmpeg({remotionRoot});
- if (wasAlreadyInstalled) {
- Log.info('FFmpeg is already installed');
- } else {
- Log.info('Successfully installed FFmpeg');
- }
-
- return;
- }
-
- if (firstArg === 'ffprobe') {
- const {wasAlreadyInstalled} = await ensureFfprobe({remotionRoot});
- if (wasAlreadyInstalled) {
- Log.info('FFmpeg is already installed');
- } else {
- Log.info('Successfully installed FFmpeg');
- }
-
- return;
- }
-
- Log.error(
- 'Please specify either "ffmpeg" or "ffprobe" as the first argument to the install command'
- );
- Log.error();
-
- Log.info('Example Usage: ');
- Log.info(' remotion install ffmpeg');
- Log.info(' remotion install ffprobe');
-
- process.exit(1);
-};
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index df79684dc2..c28aa9e93b 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -2,7 +2,6 @@ import type {
AudioCodec,
BrowserExecutable,
Codec,
- FfmpegExecutable,
ImageFormat,
LogLevel,
OpenGlRenderer,
@@ -11,14 +10,11 @@ import type {
} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import minimist from 'minimist';
-import {resolve} from 'path';
import {Config, ConfigInternals} from './config';
import {Log} from './log';
export type CommandLineOptions = {
['browser-executable']: BrowserExecutable;
- ['ffmpeg-executable']: FfmpegExecutable;
- ['ffprobe-executable']: FfmpegExecutable;
['pixel-format']: PixelFormat;
['image-format']: ImageFormat;
['prores-profile']: ProResProfile;
@@ -109,18 +105,10 @@ export const parseCommandLine = () => {
Config.setBrowserExecutable(parsedCli['browser-executable']);
}
- if (parsedCli['ffmpeg-executable']) {
- Config.setFfmpegExecutable(resolve(parsedCli['ffmpeg-executable']));
- }
-
if (parsedCli['number-of-gif-loops']) {
Config.setNumberOfGifLoops(parsedCli['number-of-gif-loops']);
}
- if (parsedCli['ffprobe-executable']) {
- Config.setFfprobeExecutable(resolve(parsedCli['ffprobe-executable']));
- }
-
if (typeof parsedCli['bundle-cache'] !== 'undefined') {
Config.setCachingEnabled(parsedCli['bundle-cache'] !== 'false');
}
diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.ts
index 1ebf256830..2543679409 100644
--- a/packages/cli/src/print-help.ts
+++ b/packages/cli/src/print-help.ts
@@ -1,5 +1,4 @@
import {chalk} from './chalk';
-import {INSTALL_COMMAND} from './install';
import {Log} from './log';
import {VERSIONS_COMMAND} from './versions';
@@ -78,9 +77,6 @@ export const printHelp = () => {
chalk.gray('Prints and validates versions of all Remotion packages.')
);
Log.info();
- Log.info(`remotion ${INSTALL_COMMAND} <ffmpeg|ffprobe>`);
- Log.info(chalk.gray('Installs dependencies of Remotion'));
- Log.info();
Log.info('remotion upgrade');
Log.info(chalk.gray('Ensure Remotion is on the newest version.'));
printFlags([
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index 01ac0215c1..8c38737984 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -19,7 +19,6 @@ import {
getAndValidateAbsoluteOutputFile,
getCliOptions,
getFinalCodec,
- validateFfmpegCanUseCodec,
} from './get-cli-options';
import {getCompositionWithDimensionOverride} from './get-composition-with-dimension-override';
import {getOutputFilename} from './get-filename';
@@ -74,8 +73,6 @@ export const render = async (remotionRoot: string, args: string[]) => {
quality,
browser,
browserExecutable,
- ffmpegExecutable,
- ffprobeExecutable,
scale,
chromiumOptions,
port,
@@ -90,14 +87,6 @@ export const render = async (remotionRoot: string, args: string[]) => {
remotionRoot,
});
- const ffmpegVersion = await RenderInternals.getFfmpegVersion({
- ffmpegExecutable,
- remotionRoot,
- });
- Log.verbose(
- 'FFMPEG Version:',
- ffmpegVersion ? ffmpegVersion.join('.') : 'Built from source'
- );
Log.verbose('Browser executable: ', browserExecutable);
const browserInstance = openBrowser(browser, {
@@ -169,7 +158,6 @@ export const render = async (remotionRoot: string, args: string[]) => {
downloadName: null,
outName: getUserPassedOutputLocation(argsAfterComposition),
});
- await validateFfmpegCanUseCodec(codec, remotionRoot);
RenderInternals.validateEvenDimensionsWithCodec({
width: config.width,
@@ -305,8 +293,6 @@ export const render = async (remotionRoot: string, args: string[]) => {
timeoutInMilliseconds: puppeteerTimeout,
chromiumOptions,
scale,
- ffmpegExecutable,
- ffprobeExecutable,
browserExecutable,
port,
downloadMap,
diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.ts
index 814c00bf6e..00859cdfdd 100644
--- a/packages/cli/src/still.ts
+++ b/packages/cli/src/still.ts
@@ -64,8 +64,6 @@ export const still = async (remotionRoot: string, args: string[]) => {
browserExecutable,
chromiumOptions,
scale,
- ffmpegExecutable,
- ffprobeExecutable,
overwrite,
puppeteerTimeout,
port,
@@ -111,8 +109,6 @@ export const still = async (remotionRoot: string, args: string[]) => {
chromiumOptions,
port,
browserExecutable,
- ffmpegExecutable,
- ffprobeExecutable,
downloadMap,
});
@@ -212,7 +208,6 @@ export const still = async (remotionRoot: string, args: string[]) => {
chromiumOptions,
timeoutInMilliseconds: ConfigInternals.getCurrentPuppeteerTimeout(),
scale,
- ffmpegExecutable,
browserExecutable,
overwrite,
onDownload,
diff --git a/packages/compositor-darwin-arm64/index.d.ts b/packages/compositor-darwin-arm64/index.d.ts
index 75ec011f2b..d27ac2a4a0 100644
--- a/packages/compositor-darwin-arm64/index.d.ts
+++ b/packages/compositor-darwin-arm64/index.d.ts
@@ -1 +1,4 @@
export const binaryPath: string;
+export const ffmpegPath: string;
+export const ffprobePath: string;
+export const ffmpegCwd: string;
diff --git a/packages/compositor-darwin-arm64/index.js b/packages/compositor-darwin-arm64/index.js
index 9b0f2f590b..c6aa1482a8 100644
--- a/packages/compositor-darwin-arm64/index.js
+++ b/packages/compositor-darwin-arm64/index.js
@@ -1 +1,4 @@
exports.binaryPath = require.resolve("./compositor");
+exports.ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+exports.ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+exports.ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-darwin-arm64/index.mjs b/packages/compositor-darwin-arm64/index.mjs
index 12e54ac786..1e562530f7 100644
--- a/packages/compositor-darwin-arm64/index.mjs
+++ b/packages/compositor-darwin-arm64/index.mjs
@@ -1,5 +1,9 @@
import { createRequire } from "module";
-
+import * as url from "url";
+const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const require = createRequire(import.meta.url);
export const binaryPath = require.resolve("./compositor");
+export const ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+export const ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+export const ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-darwin-x64/index.d.ts b/packages/compositor-darwin-x64/index.d.ts
index 75ec011f2b..d27ac2a4a0 100644
--- a/packages/compositor-darwin-x64/index.d.ts
+++ b/packages/compositor-darwin-x64/index.d.ts
@@ -1 +1,4 @@
export const binaryPath: string;
+export const ffmpegPath: string;
+export const ffprobePath: string;
+export const ffmpegCwd: string;
diff --git a/packages/compositor-darwin-x64/index.js b/packages/compositor-darwin-x64/index.js
index 9b0f2f590b..c6aa1482a8 100644
--- a/packages/compositor-darwin-x64/index.js
+++ b/packages/compositor-darwin-x64/index.js
@@ -1 +1,4 @@
exports.binaryPath = require.resolve("./compositor");
+exports.ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+exports.ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+exports.ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-darwin-x64/index.mjs b/packages/compositor-darwin-x64/index.mjs
index 12e54ac786..5d637db720 100644
--- a/packages/compositor-darwin-x64/index.mjs
+++ b/packages/compositor-darwin-x64/index.mjs
@@ -1,5 +1,10 @@
import { createRequire } from "module";
+import * as url from "url";
+const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const require = createRequire(import.meta.url);
export const binaryPath = require.resolve("./compositor");
+export const ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+export const ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+export const ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-linux-arm64-gnu/index.d.ts b/packages/compositor-linux-arm64-gnu/index.d.ts
index 75ec011f2b..d27ac2a4a0 100644
--- a/packages/compositor-linux-arm64-gnu/index.d.ts
+++ b/packages/compositor-linux-arm64-gnu/index.d.ts
@@ -1 +1,4 @@
export const binaryPath: string;
+export const ffmpegPath: string;
+export const ffprobePath: string;
+export const ffmpegCwd: string;
diff --git a/packages/compositor-linux-arm64-gnu/index.js b/packages/compositor-linux-arm64-gnu/index.js
index 9b0f2f590b..c6aa1482a8 100644
--- a/packages/compositor-linux-arm64-gnu/index.js
+++ b/packages/compositor-linux-arm64-gnu/index.js
@@ -1 +1,4 @@
exports.binaryPath = require.resolve("./compositor");
+exports.ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+exports.ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+exports.ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-linux-arm64-gnu/index.mjs b/packages/compositor-linux-arm64-gnu/index.mjs
index 12e54ac786..5d637db720 100644
--- a/packages/compositor-linux-arm64-gnu/index.mjs
+++ b/packages/compositor-linux-arm64-gnu/index.mjs
@@ -1,5 +1,10 @@
import { createRequire } from "module";
+import * as url from "url";
+const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const require = createRequire(import.meta.url);
export const binaryPath = require.resolve("./compositor");
+export const ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+export const ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+export const ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-linux-arm64-musl/index.d.ts b/packages/compositor-linux-arm64-musl/index.d.ts
index 75ec011f2b..d27ac2a4a0 100644
--- a/packages/compositor-linux-arm64-musl/index.d.ts
+++ b/packages/compositor-linux-arm64-musl/index.d.ts
@@ -1 +1,4 @@
export const binaryPath: string;
+export const ffmpegPath: string;
+export const ffprobePath: string;
+export const ffmpegCwd: string;
diff --git a/packages/compositor-linux-arm64-musl/index.js b/packages/compositor-linux-arm64-musl/index.js
index 9b0f2f590b..c6aa1482a8 100644
--- a/packages/compositor-linux-arm64-musl/index.js
+++ b/packages/compositor-linux-arm64-musl/index.js
@@ -1 +1,4 @@
exports.binaryPath = require.resolve("./compositor");
+exports.ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+exports.ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+exports.ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-linux-arm64-musl/index.mjs b/packages/compositor-linux-arm64-musl/index.mjs
index 12e54ac786..5d637db720 100644
--- a/packages/compositor-linux-arm64-musl/index.mjs
+++ b/packages/compositor-linux-arm64-musl/index.mjs
@@ -1,5 +1,10 @@
import { createRequire } from "module";
+import * as url from "url";
+const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const require = createRequire(import.meta.url);
export const binaryPath = require.resolve("./compositor");
+export const ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+export const ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+export const ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-linux-x64-gnu/index.d.ts b/packages/compositor-linux-x64-gnu/index.d.ts
index 75ec011f2b..d27ac2a4a0 100644
--- a/packages/compositor-linux-x64-gnu/index.d.ts
+++ b/packages/compositor-linux-x64-gnu/index.d.ts
@@ -1 +1,4 @@
export const binaryPath: string;
+export const ffmpegPath: string;
+export const ffprobePath: string;
+export const ffmpegCwd: string;
diff --git a/packages/compositor-linux-x64-gnu/index.js b/packages/compositor-linux-x64-gnu/index.js
index 9b0f2f590b..c6aa1482a8 100644
--- a/packages/compositor-linux-x64-gnu/index.js
+++ b/packages/compositor-linux-x64-gnu/index.js
@@ -1 +1,4 @@
exports.binaryPath = require.resolve("./compositor");
+exports.ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+exports.ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+exports.ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-linux-x64-gnu/index.mjs b/packages/compositor-linux-x64-gnu/index.mjs
index 12e54ac786..5d637db720 100644
--- a/packages/compositor-linux-x64-gnu/index.mjs
+++ b/packages/compositor-linux-x64-gnu/index.mjs
@@ -1,5 +1,10 @@
import { createRequire } from "module";
+import * as url from "url";
+const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const require = createRequire(import.meta.url);
export const binaryPath = require.resolve("./compositor");
+export const ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+export const ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+export const ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-linux-x64-musl/index.d.ts b/packages/compositor-linux-x64-musl/index.d.ts
index 75ec011f2b..d27ac2a4a0 100644
--- a/packages/compositor-linux-x64-musl/index.d.ts
+++ b/packages/compositor-linux-x64-musl/index.d.ts
@@ -1 +1,4 @@
export const binaryPath: string;
+export const ffmpegPath: string;
+export const ffprobePath: string;
+export const ffmpegCwd: string;
diff --git a/packages/compositor-linux-x64-musl/index.js b/packages/compositor-linux-x64-musl/index.js
index 9b0f2f590b..c6aa1482a8 100644
--- a/packages/compositor-linux-x64-musl/index.js
+++ b/packages/compositor-linux-x64-musl/index.js
@@ -1 +1,4 @@
exports.binaryPath = require.resolve("./compositor");
+exports.ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+exports.ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+exports.ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-linux-x64-musl/index.mjs b/packages/compositor-linux-x64-musl/index.mjs
index 12e54ac786..5d637db720 100644
--- a/packages/compositor-linux-x64-musl/index.mjs
+++ b/packages/compositor-linux-x64-musl/index.mjs
@@ -1,5 +1,10 @@
import { createRequire } from "module";
+import * as url from "url";
+const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const require = createRequire(import.meta.url);
export const binaryPath = require.resolve("./compositor");
+export const ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+export const ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+export const ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-win32-x64-msvc/index.d.ts b/packages/compositor-win32-x64-msvc/index.d.ts
index 75ec011f2b..d27ac2a4a0 100644
--- a/packages/compositor-win32-x64-msvc/index.d.ts
+++ b/packages/compositor-win32-x64-msvc/index.d.ts
@@ -1 +1,4 @@
export const binaryPath: string;
+export const ffmpegPath: string;
+export const ffprobePath: string;
+export const ffmpegCwd: string;
diff --git a/packages/compositor-win32-x64-msvc/index.js b/packages/compositor-win32-x64-msvc/index.js
index d86d8c2fff..2762adf8be 100644
--- a/packages/compositor-win32-x64-msvc/index.js
+++ b/packages/compositor-win32-x64-msvc/index.js
@@ -1 +1,4 @@
exports.binaryPath = require.resolve("./compositor.exe");
+exports.ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg.exe");
+exports.ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe.exe");
+exports.ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/compositor-win32-x64-msvc/index.mjs b/packages/compositor-win32-x64-msvc/index.mjs
index 61744db92d..f8c10438b2 100644
--- a/packages/compositor-win32-x64-msvc/index.mjs
+++ b/packages/compositor-win32-x64-msvc/index.mjs
@@ -1,5 +1,10 @@
import { createRequire } from "module";
+import * as url from "url";
+const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
const require = createRequire(import.meta.url);
export const binaryPath = require.resolve("./compositor.exe");
+export const ffmpegPath = require.resolve("./ffmpeg/remotion/bin/ffmpeg");
+export const ffprobePath = require.resolve("./ffmpeg/remotion/bin/ffprobe");
+export const ffmpegCwd = __dirname + "/ffmpeg";
diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts
index 2a5e4bccd7..87fabb5ae8 100644
--- a/packages/core/src/config.ts
+++ b/packages/core/src/config.ts
@@ -6,7 +6,6 @@
type Concurrency = number | null;
type BrowserExecutable = string | null;
type FrameRange = number | [number, number];
-type FfmpegExecutable = string | null;
type Loop = number | null;
type CodecOrUndefined =
| 'h264'
@@ -200,16 +199,6 @@ declare global {
* The frame count starts at 0.
*/
readonly setFrameRange: (newFrameRange: FrameRange | null) => void;
- /**
- * Specify local ffmpeg executable.
- * Default: null, which will use ffmpeg available in PATH.
- */
- readonly setFfmpegExecutable: (ffmpegPath: FfmpegExecutable) => void;
- /**
- * Specify local ffprobe executable.
- * Default: null, which will use ffprobe available in PATH.
- */
- readonly setFfprobeExecutable: (ffprobePath: FfmpegExecutable) => void;
/**
* Scales the output dimensions by a factor.
* Default: 1.
diff --git a/packages/example/src/simulate-lambda.ts b/packages/example/src/simulate-lambda.ts
index 291b4fc4fa..5a9195500d 100644
--- a/packages/example/src/simulate-lambda.ts
+++ b/packages/example/src/simulate-lambda.ts
@@ -47,8 +47,6 @@ const start = async () => {
onProgress: () => console.log('progress'),
output: 'out/combined.mp4',
numberOfGifLoops: null,
- ffmpegExecutable: null,
- remotionRoot: process.cwd(),
audioCodec: 'aac',
});
};
diff --git a/packages/example/src/test/stills.test.ts b/packages/example/src/test/stills.test.ts
index dbde8df830..012061ea0c 100644
--- a/packages/example/src/test/stills.test.ts
+++ b/packages/example/src/test/stills.test.ts
@@ -33,8 +33,6 @@ test(
onError: (err) => {
throw err;
},
- ffmpegExecutable: null,
- ffprobeExecutable: null,
downloadMap: RenderInternals.makeDownloadMap(),
remotionRoot: process.cwd(),
});
diff --git a/packages/it-tests/src/rendering/base64-audio.test.ts b/packages/it-tests/src/rendering/base64-audio.test.ts
index 8c967c56a8..35f6c40679 100644
--- a/packages/it-tests/src/rendering/base64-audio.test.ts
+++ b/packages/it-tests/src/rendering/base64-audio.test.ts
@@ -26,8 +26,9 @@ test("Should be able to render a MP3 audio file", async () => {
expect(exists).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [outputPath]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [outputPath],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("mp3");
diff --git a/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts b/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts
index bcc738cf78..cc15bf6679 100644
--- a/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts
+++ b/packages/it-tests/src/rendering/frame-accuracy-gif.test.ts
@@ -38,7 +38,7 @@ const getMissedFramesforCodec = async () => {
console.log(outputPath);
await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffmpeg"),
+ await RenderInternals.getExecutablePath("ffmpeg"),
[
"-i",
outputPath,
@@ -46,7 +46,8 @@ const getMissedFramesforCodec = async () => {
"image2",
path.join(outputDir, "out%2d.jpeg"),
"-y",
- ]
+ ],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
let missedFrames = 0;
diff --git a/packages/it-tests/src/rendering/frame-accuracy-video.test.ts b/packages/it-tests/src/rendering/frame-accuracy-video.test.ts
index 98634cdba2..4f98053ed8 100644
--- a/packages/it-tests/src/rendering/frame-accuracy-video.test.ts
+++ b/packages/it-tests/src/rendering/frame-accuracy-video.test.ts
@@ -28,7 +28,7 @@ const getMissedFramesforCodec = async () => {
);
await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffmpeg"),
+ await RenderInternals.getExecutablePath("ffmpeg"),
[
"-i",
outputPath,
@@ -36,7 +36,10 @@ const getMissedFramesforCodec = async () => {
"image2",
path.join(outputDir, "out%3d.jpeg"),
"-y",
- ]
+ ],
+ {
+ cwd: RenderInternals.getExecutablePath("ffmpeg-cwd"),
+ }
);
let missedFrames = 0;
diff --git a/packages/it-tests/src/rendering/render-scale.test.ts b/packages/it-tests/src/rendering/render-scale.test.ts
index a9dd1b4060..b7e067b09e 100644
--- a/packages/it-tests/src/rendering/render-scale.test.ts
+++ b/packages/it-tests/src/rendering/render-scale.test.ts
@@ -39,8 +39,11 @@ test("Should be able to render video with scale 2", async () => {
expect(exists).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [outputPath]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [outputPath],
+ {
+ cwd: RenderInternals.getExecutablePath("ffmpeg-cwd"),
+ }
);
const data = info.stderr;
expect(data).toContain("Video: h264");
@@ -76,8 +79,9 @@ test("Should be able to render video with scale 0.1", async () => {
expect(exists).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [outputPath]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [outputPath],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("Video: h264");
diff --git a/packages/it-tests/src/rendering/rendering.test.ts b/packages/it-tests/src/rendering/rendering.test.ts
index b26bfea7fd..c351e2cd6b 100644
--- a/packages/it-tests/src/rendering/rendering.test.ts
+++ b/packages/it-tests/src/rendering/rendering.test.ts
@@ -35,8 +35,9 @@ test("Should be able to render video with custom port", async () => {
expect(exists).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [outputPath]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [outputPath],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("Video: h264");
@@ -138,8 +139,9 @@ test("Should render a ProRes video", async () => {
expect(exists).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [out]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [out],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data.includes("prores (4444)") || data.includes("prores (ap4h")).toBe(
@@ -163,8 +165,9 @@ test("Should render a still image if single frame specified", async () => {
expect(fs.existsSync(outImg)).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [outImg]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [outImg],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("Video: png");
@@ -189,8 +192,9 @@ test("Should be able to render a WAV audio file", async () => {
expect(exists).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [out]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [out],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("pcm_s16le");
@@ -217,8 +221,9 @@ test("Should be able to render a MP3 audio file", async () => {
expect(exists).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [out]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [out],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("mp3");
@@ -246,8 +251,11 @@ test("Should be able to render a AAC audio file", async () => {
expect(exists).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [out]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [out],
+ {
+ cwd: RenderInternals.getExecutablePath("ffmpeg-cwd"),
+ }
);
const data = info.stderr;
expect(data).toContain("aac");
@@ -273,8 +281,9 @@ test("Should render a video with GIFs", async () => {
expect(fs.existsSync(outputPath)).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [outputPath]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [outputPath],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("Video: h264");
@@ -299,8 +308,9 @@ test("Should render a video with Offline Audio-context", async () => {
expect(fs.existsSync(out)).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [out]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [out],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("Stream #0:0: Audio: mp3");
@@ -320,8 +330,9 @@ test("Should succeed to render an audio file that doesn't have any audio inputs"
);
expect(task.exitCode).toBe(0);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [out]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [out],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
const data = info.stderr;
expect(data).toContain("Duration: 00:00:00.36");
@@ -372,19 +383,16 @@ test("Dynamic duration should work, and render from inside src/", async () => {
expect(fs.existsSync(outputPath)).toBe(true);
const info = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [outputPath]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [outputPath],
+ {
+ cwd: RenderInternals.getExecutablePath("ffmpeg-cwd"),
+ }
);
const data = info.stderr;
expect(data).toContain("Video: h264");
const expectedDuration = (randomDuration / 30).toFixed(2);
- const ffmpegVersion = await RenderInternals.getFfmpegVersion({
- ffmpegExecutable: null,
- remotionRoot: process.cwd(),
- });
- if (ffmpegVersion && ffmpegVersion[0] === 4 && ffmpegVersion[1] > 1) {
- expect(data).toContain(`Duration: 00:00:0${expectedDuration}`);
- }
+ expect(data).toContain(`Duration: 00:00:0${expectedDuration}`);
fs.unlinkSync(outputPath);
});
diff --git a/packages/it-tests/src/ssr/render-frames.test.ts b/packages/it-tests/src/ssr/render-frames.test.ts
index faa4de0a5b..5e731bea9c 100644
--- a/packages/it-tests/src/ssr/render-frames.test.ts
+++ b/packages/it-tests/src/ssr/render-frames.test.ts
@@ -59,8 +59,9 @@ test("Legacy SSR way of rendering videos should still work", async () => {
});
expect(fs.existsSync(outPath)).toBe(true);
const probe = await execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), "ffprobe"),
- [outPath]
+ await RenderInternals.getExecutablePath("ffprobe"),
+ [outPath],
+ { cwd: RenderInternals.getExecutablePath("ffmpeg-cwd") }
);
expect(probe.stderr).toMatch(/Video: h264/);
await puppeteerInstance.close();
diff --git a/packages/it-tests/tsconfig.json b/packages/it-tests/tsconfig.json
index 1ef68be266..db4bf79774 100644
--- a/packages/it-tests/tsconfig.json
+++ b/packages/it-tests/tsconfig.json
@@ -7,7 +7,7 @@
"sourceMap": true,
"lib": ["es2018", "dom"],
"jsx": "react-jsx",
- "noEmit": false,
+ "noEmit": true,
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
diff --git a/packages/lambda/src/admin/bundle-lambda.ts b/packages/lambda/src/admin/bundle-lambda.ts
index 96df5da570..202a352d71 100644
--- a/packages/lambda/src/admin/bundle-lambda.ts
+++ b/packages/lambda/src/admin/bundle-lambda.ts
@@ -31,7 +31,14 @@ const bundleLambda = async (arch: LambdaArchitecture) => {
outfile,
entryPoints: [template],
treeShaking: true,
- external: ['./compositor', './compositor.exe'],
+ external: [
+ './compositor',
+ './compositor.exe',
+ './ffmpeg/remotion/bin/ffprobe',
+ './ffmpeg/remotion/bin/ffprobe.exe',
+ './ffmpeg/remotion/bin/ffmpeg',
+ './ffmpeg/remotion/bin/ffmpeg.exe',
+ ],
});
const compositorFile = `${outdir}/compositor`;
diff --git a/packages/lambda/src/functions/compositions.ts b/packages/lambda/src/functions/compositions.ts
index 83cac38e09..c41adaf0ab 100644
--- a/packages/lambda/src/functions/compositions.ts
+++ b/packages/lambda/src/functions/compositions.ts
@@ -64,8 +64,6 @@ export const compositionsHandler = async (
puppeteerInstance: browserInstance,
inputProps,
envVariables: lambdaParams.envVariables,
- ffmpegExecutable: null,
- ffprobeExecutable: null,
timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
chromiumOptions: lambdaParams.chromiumOptions,
port: null,
diff --git a/packages/lambda/src/functions/helpers/concat-videos.ts b/packages/lambda/src/functions/helpers/concat-videos.ts
index 953239b6c1..172ccdaee5 100644
--- a/packages/lambda/src/functions/helpers/concat-videos.ts
+++ b/packages/lambda/src/functions/helpers/concat-videos.ts
@@ -1,4 +1,4 @@
-import type {AudioCodec, FfmpegExecutable} from '@remotion/renderer';
+import type {AudioCodec} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import fs, {createWriteStream, promises} from 'fs';
import path, {join} from 'path';
@@ -177,8 +177,6 @@ export const concatVideosS3 = async ({
codec,
fps,
numberOfGifLoops,
- ffmpegExecutable,
- remotionRoot,
files,
outdir,
audioCodec,
@@ -188,8 +186,6 @@ export const concatVideosS3 = async ({
codec: LambdaCodec;
fps: number;
numberOfGifLoops: number | null;
- ffmpegExecutable: FfmpegExecutable;
- remotionRoot: string;
files: string[];
outdir: string;
audioCodec: AudioCodec | null;
@@ -210,8 +206,6 @@ export const concatVideosS3 = async ({
codec,
fps,
numberOfGifLoops,
- ffmpegExecutable,
- remotionRoot,
audioCodec,
});
combine.end();
diff --git a/packages/lambda/src/functions/helpers/validate-composition.ts b/packages/lambda/src/functions/helpers/validate-composition.ts
index 93383b56fe..ec4e67ecbd 100644
--- a/packages/lambda/src/functions/helpers/validate-composition.ts
+++ b/packages/lambda/src/functions/helpers/validate-composition.ts
@@ -1,7 +1,6 @@
import type {
ChromiumOptions,
DownloadMap,
- FfmpegExecutable,
openBrowser,
} from '@remotion/renderer';
import {getCompositions} from '@remotion/renderer';
@@ -15,8 +14,6 @@ type ValidateCompositionOptions = {
browserInstance: Await<ReturnType<typeof openBrowser>>;
inputProps: unknown;
envVariables: Record<string, string> | undefined;
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
timeoutInMilliseconds: number;
chromiumOptions: ChromiumOptions;
port: number | null;
@@ -32,8 +29,6 @@ export const validateComposition = async ({
inputProps,
envVariables,
timeoutInMilliseconds,
- ffmpegExecutable,
- ffprobeExecutable,
chromiumOptions,
port,
downloadMap,
@@ -44,8 +39,6 @@ export const validateComposition = async ({
puppeteerInstance: browserInstance,
inputProps: inputProps as object,
envVariables,
- ffmpegExecutable,
- ffprobeExecutable,
timeoutInMilliseconds,
chromiumOptions,
port,
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index 4001dd6d21..46658071c5 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -172,8 +172,6 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
browserInstance,
inputProps: await inputPropsPromise,
envVariables: params.envVariables,
- ffmpegExecutable: null,
- ffprobeExecutable: null,
timeoutInMilliseconds: params.timeoutInMilliseconds,
chromiumOptions: params.chromiumOptions,
port: null,
@@ -469,8 +467,6 @@ const innerLaunchHandler = async (params: LambdaPayload, options: Options) => {
codec: params.codec,
fps,
numberOfGifLoops: params.numberOfGifLoops,
- ffmpegExecutable: null,
- remotionRoot: process.cwd(),
files,
outdir,
audioCodec: params.audioCodec,
diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.ts
index fc6db7bf61..8831d2f6b3 100644
--- a/packages/lambda/src/functions/still.ts
+++ b/packages/lambda/src/functions/still.ts
@@ -110,8 +110,6 @@ const innerStillHandler = async (
composition: lambdaParams.composition,
inputProps,
envVariables: lambdaParams.envVariables,
- ffmpegExecutable: null,
- ffprobeExecutable: null,
chromiumOptions: lambdaParams.chromiumOptions,
timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
port: null,
diff --git a/packages/lambda/src/test/integration/renders/gif.test.ts b/packages/lambda/src/test/integration/renders/gif.test.ts
index bb4e2c69ce..0db2c68234 100644
--- a/packages/lambda/src/test/integration/renders/gif.test.ts
+++ b/packages/lambda/src/test/integration/renders/gif.test.ts
@@ -94,8 +94,9 @@ test('Should make a distributed GIF', async () => {
file.pipe(createWriteStream('gif.gif')).on('close', () => resolve());
});
const probe = await RenderInternals.execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), 'ffprobe'),
- ['gif.gif']
+ await RenderInternals.getExecutablePath('ffprobe'),
+ ['gif.gif'],
+ {cwd: RenderInternals.getExecutablePath('ffmpeg-cwd')}
);
expect(probe.stderr).toMatch(/Video: gif, bgra, 1080x1080/);
}, 90000);
diff --git a/packages/lambda/src/test/integration/renders/other-bucket.test.ts b/packages/lambda/src/test/integration/renders/other-bucket.test.ts
index 19aed23191..975334dd84 100644
--- a/packages/lambda/src/test/integration/renders/other-bucket.test.ts
+++ b/packages/lambda/src/test/integration/renders/other-bucket.test.ts
@@ -94,10 +94,11 @@ test('Should be able to render to another bucket', async () => {
region: 'eu-central-1',
});
const probe = await RenderInternals.execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), 'ffprobe'),
+ await RenderInternals.getExecutablePath('ffprobe'),
['-'],
{
stdin: file,
+ cwd: RenderInternals.getExecutablePath('ffmpeg-cwd'),
}
);
expect(probe.stderr).toMatch(/Stream #0:0/);
diff --git a/packages/lambda/src/test/integration/renders/silent-audio.test.ts b/packages/lambda/src/test/integration/renders/silent-audio.test.ts
index 5ac8528356..c90149131c 100644
--- a/packages/lambda/src/test/integration/renders/silent-audio.test.ts
+++ b/packages/lambda/src/test/integration/renders/silent-audio.test.ts
@@ -91,10 +91,11 @@ test('Should add silent audio if there is no audio', async () => {
region: 'eu-central-1',
});
const probe = await RenderInternals.execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), 'ffprobe'),
+ await RenderInternals.getExecutablePath('ffprobe'),
['-'],
{
stdin: file,
+ cwd: RenderInternals.getExecutablePath('ffmpeg-cwd'),
}
);
expect(probe.stderr).toMatch(/Stream #0:0/);
diff --git a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts b/packages/lambda/src/test/integration/renders/transparent-webm.test.ts
index a0ae49707c..1d5c2727c2 100644
--- a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts
+++ b/packages/lambda/src/test/integration/renders/transparent-webm.test.ts
@@ -105,8 +105,9 @@ test('Should make a transparent video', async () => {
file.on('close', () => resolve());
});
const probe = await RenderInternals.execa(
- await RenderInternals.getExecutableBinary(null, process.cwd(), 'ffprobe'),
- [out]
+ await RenderInternals.getExecutablePath('ffprobe'),
+ [out],
+ {cwd: RenderInternals.getExecutablePath('ffmpeg-cwd')}
);
expect(probe.stderr).toMatch(/ALPHA_MODE(\s+): 1/);
expect(probe.stderr).toMatch(/Video: vp8, yuv420p/);
diff --git a/packages/renderer/src/assets/get-audio-channels.ts b/packages/renderer/src/assets/get-audio-channels.ts
index a616e9c3cc..b6c57bc5e4 100644
--- a/packages/renderer/src/assets/get-audio-channels.ts
+++ b/packages/renderer/src/assets/get-audio-channels.ts
@@ -1,6 +1,5 @@
import execa from 'execa';
-import type {FfmpegExecutable} from '../ffmpeg-executable';
-import {getExecutableBinary} from '../ffmpeg-flags';
+import {getExecutablePath} from '../compositor/get-executable-path';
import {pLimit} from '../p-limit';
import type {
AudioChannelsAndDurationResultCache,
@@ -11,9 +10,7 @@ const limit = pLimit(1);
async function getAudioChannelsAndDurationUnlimited(
downloadMap: DownloadMap,
- src: string,
- ffprobeExecutable: FfmpegExecutable,
- remotionRoot: string
+ src: string
): Promise<AudioChannelsAndDurationResultCache> {
if (downloadMap.durationOfAssetCache[src]) {
return downloadMap.durationOfAssetCache[src];
@@ -28,10 +25,7 @@ async function getAudioChannelsAndDurationUnlimited(
.reduce<(string | null)[]>((acc, val) => acc.concat(val), [])
.filter(Boolean) as string[];
- const task = await execa(
- await getExecutableBinary(ffprobeExecutable, remotionRoot, 'ffprobe'),
- args
- );
+ const task = await execa(getExecutablePath('ffprobe'), args);
const channels = task.stdout.match(/channels=([0-9]+)/);
const duration = task.stdout.match(/duration=([0-9.]+)/);
@@ -48,16 +42,7 @@ async function getAudioChannelsAndDurationUnlimited(
export const getAudioChannelsAndDuration = (
downloadMap: DownloadMap,
- src: string,
- ffprobeExecutable: FfmpegExecutable,
- remotionRoot: string
+ src: string
): Promise<AudioChannelsAndDurationResultCache> => {
- return limit(() =>
- getAudioChannelsAndDurationUnlimited(
- downloadMap,
- src,
- ffprobeExecutable,
- remotionRoot
- )
- );
+ return limit(() => getAudioChannelsAndDurationUnlimited(downloadMap, src));
};
diff --git a/packages/renderer/src/assets/get-video-stream-duration.ts b/packages/renderer/src/assets/get-video-stream-duration.ts
index b09677106d..8ed2e971ec 100644
--- a/packages/renderer/src/assets/get-video-stream-duration.ts
+++ b/packages/renderer/src/assets/get-video-stream-duration.ts
@@ -1,6 +1,5 @@
import execa from 'execa';
-import type {FfmpegExecutable} from '../ffmpeg-executable';
-import {getExecutableBinary} from '../ffmpeg-flags';
+import {getExecutablePath} from '../compositor/get-executable-path';
import {pLimit} from '../p-limit';
import type {DownloadMap, VideoDurationResult} from './download-map';
@@ -49,15 +48,7 @@ export const parseVideoStreamDuration = (stdout: string) => {
return result;
};
-export async function getVideoStreamDurationwithoutCache({
- src,
- ffprobeExecutable,
- remotionRoot,
-}: {
- src: string;
- ffprobeExecutable: FfmpegExecutable;
- remotionRoot: string;
-}) {
+export async function getVideoStreamDurationwithoutCache({src}: {src: string}) {
const args = [
['-v', 'error'],
['-select_streams', 'v:0'],
@@ -67,10 +58,7 @@ export async function getVideoStreamDurationwithoutCache({
.reduce<(string | null)[]>((acc, val) => acc.concat(val), [])
.filter(Boolean) as string[];
- const task = await execa(
- await getExecutableBinary(ffprobeExecutable, remotionRoot, 'ffprobe'),
- args
- );
+ const task = await execa(getExecutablePath('ffprobe'), args);
const result: VideoDurationResult = parseVideoStreamDuration(task.stdout);
@@ -79,9 +67,7 @@ export async function getVideoStreamDurationwithoutCache({
async function getVideoStreamDurationUnlimited(
downloadMap: DownloadMap,
- src: string,
- ffprobeExecutable: FfmpegExecutable,
- remotionRoot: string
+ src: string
): Promise<VideoDurationResult> {
if (downloadMap.videoDurationResultCache[src]) {
return downloadMap.videoDurationResultCache[src];
@@ -89,8 +75,6 @@ async function getVideoStreamDurationUnlimited(
const result: VideoDurationResult = await getVideoStreamDurationwithoutCache({
src,
- ffprobeExecutable,
- remotionRoot,
});
downloadMap.videoDurationResultCache[src] = result;
@@ -100,16 +84,7 @@ async function getVideoStreamDurationUnlimited(
export const getVideoStreamDuration = (
downloadMap: DownloadMap,
- src: string,
- ffprobeExecutable: FfmpegExecutable,
- remotionRoot: string
+ src: string
): Promise<VideoDurationResult> => {
- return limit(() =>
- getVideoStreamDurationUnlimited(
- downloadMap,
- src,
- ffprobeExecutable,
- remotionRoot
- )
- );
+ return limit(() => getVideoStreamDurationUnlimited(downloadMap, src));
};
diff --git a/packages/renderer/src/combine-videos.ts b/packages/renderer/src/combine-videos.ts
index 024e54467c..a4bb3c5d70 100644
--- a/packages/renderer/src/combine-videos.ts
+++ b/packages/renderer/src/combine-videos.ts
@@ -9,8 +9,7 @@ import {
mapAudioCodecToFfmpegAudioCodecName,
} from './audio-codec';
import type {Codec} from './codec';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
+import {getExecutablePath} from './compositor/get-executable-path';
import {isAudioCodec} from './is-audio-codec';
import {parseFfmpegProgress} from './parse-ffmpeg-progress';
import {truthy} from './truthy';
@@ -24,8 +23,6 @@ type Options = {
codec: Codec;
fps: number;
numberOfGifLoops: number | null;
- remotionRoot: string;
- ffmpegExecutable: FfmpegExecutable;
audioCodec: AudioCodec | null;
};
@@ -39,8 +36,6 @@ export const combineVideos = async (options: Options) => {
codec,
fps,
numberOfGifLoops,
- ffmpegExecutable,
- remotionRoot,
audioCodec,
} = options;
const fileList = files.map((p) => `file '${p}'`).join('\n');
@@ -53,7 +48,7 @@ export const combineVideos = async (options: Options) => {
try {
const task = execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
+ getExecutablePath('ffmpeg'),
[
isAudioCodec(codec) ? null : '-r',
isAudioCodec(codec) ? null : String(fps),
@@ -82,7 +77,8 @@ export const combineVideos = async (options: Options) => {
codec === 'h264' ? 'faststart' : null,
'-y',
output,
- ].filter(truthy)
+ ].filter(truthy),
+ {cwd: getExecutablePath('ffmpeg-cwd')}
);
task.stderr?.on('data', (data: Buffer) => {
if (onProgress) {
diff --git a/packages/renderer/src/compositor/compose.ts b/packages/renderer/src/compositor/compose.ts
index 9f97a8fff7..028671ee03 100644
--- a/packages/renderer/src/compositor/compose.ts
+++ b/packages/renderer/src/compositor/compose.ts
@@ -32,7 +32,7 @@ export const compose = async ({
downloadMap: DownloadMap;
output: string;
}) => {
- const bin = getExecutablePath();
+ const bin = getExecutablePath('compositor');
const hash = getCompositorHash({height, width, layers, imageFormat});
if (downloadMap.compositorCache[hash]) {
diff --git a/packages/renderer/src/compositor/get-executable-path.ts b/packages/renderer/src/compositor/get-executable-path.ts
index b0d9761c27..843a2e5f72 100644
--- a/packages/renderer/src/compositor/get-executable-path.ts
+++ b/packages/renderer/src/compositor/get-executable-path.ts
@@ -6,12 +6,23 @@ function isMusl() {
return !glibcVersionRuntime;
}
-export const getExecutablePath = () => {
+export const getExecutablePath = (
+ type: 'compositor' | 'ffmpeg' | 'ffprobe' | 'ffmpeg-cwd'
+) => {
+ const key =
+ type === 'compositor'
+ ? 'binaryPath'
+ : type === 'ffmpeg'
+ ? 'ffmpegPath'
+ : type === 'ffprobe'
+ ? 'ffprobePath'
+ : 'ffmpegCwd';
+
switch (process.platform) {
case 'win32':
switch (process.arch) {
case 'x64':
- return require('@remotion/compositor-win32-x64-msvc').binaryPath;
+ return require('@remotion/compositor-win32-x64-msvc')[key];
default:
throw new Error(
`Unsupported architecture on Windows: ${process.arch}`
@@ -21,9 +32,9 @@ export const getExecutablePath = () => {
case 'darwin':
switch (process.arch) {
case 'x64':
- return require('@remotion/compositor-darwin-x64').binaryPath;
+ return require('@remotion/compositor-darwin-x64')[key];
case 'arm64':
- return require('@remotion/compositor-darwin-arm64').binaryPath;
+ return require('@remotion/compositor-darwin-arm64')[key];
default:
throw new Error(`Unsupported architecture on macOS: ${process.arch}`);
}
@@ -32,16 +43,16 @@ export const getExecutablePath = () => {
switch (process.arch) {
case 'x64':
if (isMusl()) {
- return require('@remotion/compositor-linux-x64-musl').binaryPath;
+ return require('@remotion/compositor-linux-x64-musl')[key];
}
- return require('@remotion/compositor-linux-x64-gnu').binaryPath;
+ return require('@remotion/compositor-linux-x64-gnu')[key];
case 'arm64':
if (isMusl()) {
- return require('@remotion/compositor-linux-arm64-musl').binaryPath;
+ return require('@remotion/compositor-linux-arm64-musl')[key];
}
- return require('@remotion/compositor-linux-arm64-gnu').binaryPath;
+ return require('@remotion/compositor-linux-arm64-gnu')[key];
default:
throw new Error(`Unsupported architecture on Linux: ${process.arch}`);
diff --git a/packages/renderer/src/convert-to-pcm.ts b/packages/renderer/src/convert-to-pcm.ts
index 271a334ac3..da3c43abe0 100644
--- a/packages/renderer/src/convert-to-pcm.ts
+++ b/packages/renderer/src/convert-to-pcm.ts
@@ -1,21 +1,16 @@
import execa from 'execa';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
+import {getExecutablePath} from './compositor/get-executable-path';
import {DEFAULT_SAMPLE_RATE} from './sample-rate';
export const convertToPcm = async ({
- ffmpegExecutable,
input,
outName,
- remotionRoot,
}: {
- ffmpegExecutable: FfmpegExecutable;
input: string;
outName: string;
- remotionRoot: string;
}) => {
await execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
+ getExecutablePath('ffmpeg'),
[
'-i',
input,
@@ -24,6 +19,9 @@ export const convertToPcm = async ({
'-ar',
String(DEFAULT_SAMPLE_RATE),
outName,
- ]
+ ],
+ {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ }
);
};
diff --git a/packages/renderer/src/create-silent-audio.ts b/packages/renderer/src/create-silent-audio.ts
index c1433a81ee..f0abf43b9c 100644
--- a/packages/renderer/src/create-silent-audio.ts
+++ b/packages/renderer/src/create-silent-audio.ts
@@ -1,21 +1,16 @@
import execa from 'execa';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
+import {getExecutablePath} from './compositor/get-executable-path';
import {DEFAULT_SAMPLE_RATE} from './sample-rate';
export const createSilentAudio = async ({
- ffmpegExecutable,
numberOfSeconds,
outName,
- remotionRoot,
}: {
- ffmpegExecutable: FfmpegExecutable;
numberOfSeconds: number;
outName: string;
- remotionRoot: string;
}) => {
await execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
+ getExecutablePath('ffmpeg'),
[
'-f',
'lavfi',
@@ -28,6 +23,9 @@ export const createSilentAudio = async ({
'-ar',
String(DEFAULT_SAMPLE_RATE),
outName,
- ]
+ ],
+ {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ }
);
};
diff --git a/packages/renderer/src/ensure-ffmpeg.ts b/packages/renderer/src/ensure-ffmpeg.ts
deleted file mode 100644
index c9ad62bd9a..0000000000
--- a/packages/renderer/src/ensure-ffmpeg.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import {existsSync} from 'fs';
-import os from 'os';
-import {
- downloadBinary,
- ffmpegInNodeModules,
- getBinaryDownloadUrl,
- lambdaFfmpegPaths,
-} from './ffmpeg-flags';
-import {binaryExists} from './validate-ffmpeg';
-
-export type EnsureFfmpegOptions = {
- remotionRoot?: string;
-};
-
-type Result = {
- result: 'found-in-path' | 'found-in-node-modules' | 'installed';
- wasAlreadyInstalled: boolean;
-};
-
-const ensureFfmpegOrFfprobe = async (
- binary: 'ffmpeg' | 'ffprobe',
- options?: EnsureFfmpegOptions
-): Promise<Result> => {
- const exists = binaryExists(binary);
-
- const remotionRoot = options?.remotionRoot ?? process.cwd();
-
- if (exists) {
- return {
- wasAlreadyInstalled: true,
- result: 'found-in-path',
- };
- }
-
- if (process.platform === 'linux' && existsSync(lambdaFfmpegPaths[binary])) {
- return {
- wasAlreadyInstalled: true,
- result: 'found-in-path',
- };
- }
-
- if (ffmpegInNodeModules(remotionRoot, binary)) {
- return {
- result: 'found-in-node-modules',
- wasAlreadyInstalled: true,
- };
- }
-
- const binaryUrl = getBinaryDownloadUrl(binary);
-
- if (binaryUrl) {
- await downloadBinary(remotionRoot, binaryUrl.url, binary);
- return {
- result: 'installed',
- wasAlreadyInstalled: false,
- };
- }
-
- throw new Error(
- `${binary} could not be installed automatically. Your architecture and OS combination (os = ${os.platform()}, arch = ${
- process.arch
- }) is not supported. Please install ${binary} manually and add "${binary}" to your PATH.`
- );
-};
-
-export const ensureFfmpeg = (options?: EnsureFfmpegOptions) => {
- return ensureFfmpegOrFfprobe('ffmpeg', options);
-};
-
-export const ensureFfprobe = (options?: EnsureFfmpegOptions) => {
- return ensureFfmpegOrFfprobe('ffprobe', options);
-};
diff --git a/packages/renderer/src/ensure-presentation-timestamp.ts b/packages/renderer/src/ensure-presentation-timestamp.ts
index d0cb1798e7..72e8fae20e 100644
--- a/packages/renderer/src/ensure-presentation-timestamp.ts
+++ b/packages/renderer/src/ensure-presentation-timestamp.ts
@@ -1,8 +1,7 @@
import execa from 'execa';
import path from 'path';
import type {DownloadMap} from './assets/download-map';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
+import {getExecutablePath} from './compositor/get-executable-path';
import {guessExtensionForVideo} from './guess-extension-for-media';
import {truthy} from './truthy';
@@ -13,15 +12,7 @@ type Callback = {
let callbacks: Callback[] = [];
-const getTemporaryOutputName = async ({
- src,
- remotionRoot,
- ffprobeBinary,
-}: {
- src: string;
- remotionRoot: string;
- ffprobeBinary: string | null;
-}) => {
+const getTemporaryOutputName = async ({src}: {src: string}) => {
const parts = src.split(path.sep);
// If there is no file extension for the video, then we need to temporarily add an extension
@@ -31,8 +22,6 @@ const getTemporaryOutputName = async ({
? null
: await guessExtensionForVideo({
src,
- remotionRoot,
- ffprobeBinary,
});
return parts
@@ -48,24 +37,16 @@ const getTemporaryOutputName = async ({
export const ensurePresentationTimestampWithoutCache = async ({
src,
- remotionRoot,
- ffmpegExecutable,
- ffprobeExecutable,
}: {
src: string;
- remotionRoot: string;
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
}) => {
// If there is no file extension for the video, then we need to tempoa
const output = await getTemporaryOutputName({
src,
- remotionRoot,
- ffprobeBinary: ffprobeExecutable,
});
await execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
+ getExecutablePath('ffmpeg'),
[
'-i',
src,
@@ -77,7 +58,10 @@ export const ensurePresentationTimestampWithoutCache = async ({
'copy',
output,
'-y',
- ]
+ ],
+ {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ }
);
return output;
@@ -86,15 +70,9 @@ export const ensurePresentationTimestampWithoutCache = async ({
export const ensurePresentationTimestamps = async ({
downloadMap,
src,
- remotionRoot,
- ffmpegExecutable,
- ffprobeExecutable,
}: {
downloadMap: DownloadMap;
src: string;
- remotionRoot: string;
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
}): Promise<string> => {
const elem = downloadMap.ensureFileHasPresentationTimestamp[src];
if (elem?.type === 'encoding') {
@@ -113,9 +91,6 @@ export const ensurePresentationTimestamps = async ({
downloadMap.ensureFileHasPresentationTimestamp[src] = {type: 'encoding'};
const output = await ensurePresentationTimestampWithoutCache({
- ffmpegExecutable,
- ffprobeExecutable,
- remotionRoot,
src,
});
diff --git a/packages/renderer/src/extract-frame-from-video.ts b/packages/renderer/src/extract-frame-from-video.ts
index f5c5644af5..91d1fe3e51 100644
--- a/packages/renderer/src/extract-frame-from-video.ts
+++ b/packages/renderer/src/extract-frame-from-video.ts
@@ -2,11 +2,10 @@ import execa from 'execa';
import type {OffthreadVideoImageFormat} from 'remotion';
import type {DownloadMap} from './assets/download-map';
import {getVideoStreamDuration} from './assets/get-video-stream-duration';
+import {getExecutablePath} from './compositor/get-executable-path';
import {determineResizeParams} from './determine-resize-params';
import {determineVcodecFfmpegFlags} from './determine-vcodec-ffmpeg-flags';
import {ensurePresentationTimestamps} from './ensure-presentation-timestamp';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
import {frameToFfmpegTimestamp} from './frame-to-ffmpeg-timestamp';
import {ACCEPTABLE_OFFSET_THRESHOLD} from './get-can-extract-frames-fast';
import {getFrameOfVideoSlow} from './get-frame-of-video-slow';
@@ -28,19 +27,13 @@ const mainLimit = pLimit(5);
const getLastFrameOfVideoFastUnlimited = async (
options: LastFrameOptions
): Promise<Buffer> => {
- const {ffmpegExecutable, ffprobeExecutable, offset, src, downloadMap} =
- options;
+ const {offset, src, downloadMap} = options;
const fromCache = getLastFrameFromCache({...options, offset: 0});
if (fromCache) {
return fromCache;
}
- const {duration, fps} = await getVideoStreamDuration(
- downloadMap,
- src,
- ffprobeExecutable,
- options.remotionRoot
- );
+ const {duration, fps} = await getVideoStreamDuration(downloadMap, src);
if (duration === null) {
throw new Error(
@@ -54,14 +47,12 @@ const getLastFrameOfVideoFastUnlimited = async (
) {
const last = await getFrameOfVideoSlow({
duration,
- ffmpegExecutable,
src,
imageFormat: options.imageFormat,
specialVCodecForTransparency: options.specialVCodecForTransparency,
needsResize: options.needsResize,
offset: offset - 1000 / (fps === null ? 10 : fps),
fps,
- remotionRoot: options.remotionRoot,
});
return last;
}
@@ -69,10 +60,8 @@ const getLastFrameOfVideoFastUnlimited = async (
const actualOffset = `${duration * 1000 - offset}ms`;
const [stdErr, stdoutBuffer] = await tryToExtractFrameOfVideoFast({
actualOffset,
- ffmpegExecutable,
imageFormat: options.imageFormat,
needsResize: options.needsResize,
- remotionRoot: options.remotionRoot,
specialVCodecForTransparency: options.specialVCodecForTransparency,
src,
});
@@ -80,16 +69,13 @@ const getLastFrameOfVideoFastUnlimited = async (
const isEmpty = stdErr.includes('Output file is empty');
if (isEmpty) {
const unlimited = await getLastFrameOfVideoFastUnlimited({
- ffmpegExecutable,
// Decrement in 10ms increments, or 1 frame (e.g. fps = 25 --> 40ms)
offset: offset + (fps === null ? 10 : 1000 / fps),
src,
- ffprobeExecutable,
imageFormat: options.imageFormat,
specialVCodecForTransparency: options.specialVCodecForTransparency,
needsResize: options.needsResize,
downloadMap: options.downloadMap,
- remotionRoot: options.remotionRoot,
});
return unlimited;
@@ -113,8 +99,6 @@ export const getLastFrameOfVideo = async (
type Options = {
time: number;
src: string;
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
imageFormat: OffthreadVideoImageFormat;
downloadMap: DownloadMap;
remotionRoot: string;
@@ -122,8 +106,6 @@ type Options = {
const extractFrameFromVideoFn = async ({
time,
- ffmpegExecutable,
- ffprobeExecutable,
imageFormat,
downloadMap,
remotionRoot,
@@ -134,22 +116,13 @@ const extractFrameFromVideoFn = async ({
const src = await ensurePresentationTimestamps({
downloadMap,
src: options.src,
- remotionRoot,
- ffmpegExecutable,
- ffprobeExecutable,
});
const {specialVcodecForTransparency: specialVcodec, needsResize} =
- await getVideoInfo(downloadMap, src, ffprobeExecutable, remotionRoot);
+ await getVideoInfo(downloadMap, src);
if (specialVcodec === 'vp8') {
- const {fps} = await getVideoStreamDuration(
- downloadMap,
- src,
- ffprobeExecutable,
- remotionRoot
- );
+ const {fps} = await getVideoStreamDuration(downloadMap, src);
return getFrameOfVideoSlow({
- ffmpegExecutable,
imageFormat,
specialVCodecForTransparency: specialVcodec,
src,
@@ -157,28 +130,24 @@ const extractFrameFromVideoFn = async ({
needsResize,
offset: 0,
fps,
- remotionRoot,
});
}
if (isBeyondLastFrame(downloadMap, src, time)) {
const lastFrame = await getLastFrameOfVideo({
- ffmpegExecutable,
- ffprobeExecutable,
offset: 0,
src,
imageFormat,
specialVCodecForTransparency: specialVcodec,
needsResize,
downloadMap,
- remotionRoot,
});
return lastFrame;
}
const ffmpegTimestamp = frameToFfmpegTimestamp(time);
const {stdout, stderr} = execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
+ getExecutablePath('ffmpeg'),
[
'-ss',
ffmpegTimestamp,
@@ -196,6 +165,7 @@ const extractFrameFromVideoFn = async ({
].filter(truthy),
{
buffer: false,
+ cwd: getExecutablePath('ffmpeg-cwd'),
}
);
@@ -232,15 +202,12 @@ const extractFrameFromVideoFn = async ({
if (stderrStr.includes('Output file is empty')) {
markAsBeyondLastFrame(downloadMap, src, time);
const last = await getLastFrameOfVideo({
- ffmpegExecutable,
- ffprobeExecutable,
offset: 0,
src,
imageFormat,
specialVCodecForTransparency: specialVcodec,
needsResize,
downloadMap,
- remotionRoot,
});
return last;
diff --git a/packages/renderer/src/ffmpeg-executable.ts b/packages/renderer/src/ffmpeg-executable.ts
deleted file mode 100644
index 5d42af474f..0000000000
--- a/packages/renderer/src/ffmpeg-executable.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type FfmpegExecutable = string | null;
diff --git a/packages/renderer/src/ffmpeg-flags.ts b/packages/renderer/src/ffmpeg-flags.ts
deleted file mode 100644
index b4a593873b..0000000000
--- a/packages/renderer/src/ffmpeg-flags.ts
+++ /dev/null
@@ -1,362 +0,0 @@
-import execa from 'execa';
-import fs from 'fs';
-import os from 'os';
-import path from 'path';
-import {_downloadFile} from './browser/BrowserFetcher';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {binaryExists, customExecutableExists} from './validate-ffmpeg';
-
-let buildConfig: string | null = null;
-const listeners: Record<string, ((path: string) => void)[]> = {};
-const isDownloading: Record<string, boolean> = {};
-
-export type FfmpegVersion = [number, number, number] | null;
-
-export const getFfmpegBuildInfo = async (options: {
- ffmpegExecutable: string | null;
- remotionRoot: string;
-}) => {
- if (buildConfig !== null) {
- return buildConfig;
- }
-
- const data = await execa(
- await getExecutableBinary(
- options.ffmpegExecutable,
- options.remotionRoot,
- 'ffmpeg'
- ),
- ['-buildconf'],
- {
- reject: false,
- }
- );
- buildConfig = data.stderr;
- return buildConfig;
-};
-
-const getFfmpegFolderName = (remotionRoot: string): string => {
- return path.resolve(remotionRoot, 'node_modules/.ffmpeg');
-};
-
-const binaryPrefix = {ffmpeg: 'ffmpeg-', ffprobe: 'ffprobe-'} as const;
-const randomFfmpegRuntimeId = String(Math.random()).replace('0.', '');
-
-export const ffmpegInNodeModules = (
- remotionRoot: string,
- binary: 'ffmpeg' | 'ffprobe'
-): string | null => {
- const folderName = getFfmpegFolderName(remotionRoot);
- if (!fs.existsSync(folderName)) {
- fs.mkdirSync(folderName, {
- recursive: true,
- });
- }
-
- // Check if a version of FFMPEG is already installed.
- // To qualify, it must have the expected file size
- // to avoid finding binaries that are still being downloaded
- // A random ID is being assigned to the download to avoid conflicts when multiple Remotion processes are running
- const ffmpegInstalled = fs.readdirSync(folderName).find((filename) => {
- if (!filename.startsWith(binaryPrefix[binary])) {
- return false;
- }
-
- const dlUrl = getBinaryDownloadUrl(binary);
-
- if (!dlUrl) {
- return false;
- }
-
- const expectedLength = dlUrl.contentLength;
-
- if (fs.statSync(path.join(folderName, filename)).size === expectedLength) {
- return true;
- }
-
- return false;
- });
-
- if (ffmpegInstalled) {
- return path.join(folderName, ffmpegInstalled);
- }
-
- return null;
-};
-
-const getFfmpegAbsolutePath = (
- remotionRoot: string,
- binary: 'ffmpeg' | 'ffprobe'
-): string => {
- const folderName = getFfmpegFolderName(remotionRoot);
- if (!fs.existsSync(folderName)) {
- fs.mkdirSync(folderName);
- }
-
- if (os.platform() === 'win32') {
- return path.resolve(
- folderName,
- `${binaryPrefix[binary]}${randomFfmpegRuntimeId}.exe`
- );
- }
-
- return path.resolve(
- folderName,
- `${binaryPrefix[binary]}${randomFfmpegRuntimeId}`
- );
-};
-
-export const ffmpegHasFeature = async ({
- ffmpegExecutable,
- feature,
- remotionRoot,
-}: {
- ffmpegExecutable: string | null;
- feature: 'enable-gpl' | 'enable-libx265' | 'enable-libvpx';
- remotionRoot: string;
-}) => {
- if (ffmpegExecutable && !customExecutableExists(ffmpegExecutable)) {
- return false;
- }
-
- if (!binaryExists('ffmpeg')) {
- return false;
- }
-
- const config = await getFfmpegBuildInfo({ffmpegExecutable, remotionRoot});
- return config.includes(feature);
-};
-
-export const parseFfmpegVersion = (buildconf: string): FfmpegVersion => {
- const match = buildconf.match(
- /ffmpeg version ([0-9]+).([0-9]+)(?:.([0-9]+))?/
- );
- if (!match) {
- return null;
- }
-
- return [Number(match[1]), Number(match[2]), Number(match[3] ?? 0)];
-};
-
-export const getFfmpegVersion = async (options: {
- ffmpegExecutable: string | null;
- remotionRoot: string;
-}): Promise<FfmpegVersion> => {
- const buildInfo = await getFfmpegBuildInfo({
- ffmpegExecutable: options.ffmpegExecutable,
- remotionRoot: options.remotionRoot,
- });
- return parseFfmpegVersion(buildInfo);
-};
-
-const waitForFfmpegToBeDownloaded = (url: string) => {
- return new Promise<string>((resolve) => {
- if (!listeners[url]) {
- listeners[url] = [];
- }
-
- listeners[url].push((src) => resolve(src));
- });
-};
-
-const onProgress = (
- downloadedBytes: number,
- totalBytesToDownload: number,
- binary: 'ffmpeg' | 'ffprobe'
-) => {
- console.log(
- 'Downloading ',
- binary,
- `${toMegabytes(downloadedBytes)}/${toMegabytes(totalBytesToDownload)}`
- );
-};
-
-export const downloadBinary = async (
- remotionRoot: string,
- url: string,
- binary: 'ffmpeg' | 'ffprobe'
-): Promise<string> => {
- const destinationPath = getFfmpegAbsolutePath(remotionRoot, binary);
-
- const onProgressCallback = (downloadedBytes: number, _totalBytes: number) => {
- onProgress(downloadedBytes, _totalBytes, binary);
- };
-
- isDownloading[url] = true;
- const totalBytes = await _downloadFile(
- url,
- destinationPath,
- onProgressCallback
- );
- onProgress(totalBytes, totalBytes, binary);
- if (os.platform() !== 'win32') {
- fs.chmodSync(destinationPath, '777');
- }
-
- isDownloading[url] = false;
- if (!listeners[url]) {
- listeners[url] = [];
- }
-
- listeners[url].forEach((listener) => listener(destinationPath));
- listeners[url] = [];
-
- return destinationPath;
-};
-
-export const lambdaFfmpegPaths = {
- ffmpeg: '/opt/bin/ffmpeg',
- ffprobe: '/opt/bin/ffprobe',
-} as const;
-
-export const getExecutableBinary = (
- ffmpegExecutable: FfmpegExecutable,
- remotionRoot: string,
- binary: 'ffmpeg' | 'ffprobe'
-) => {
- if (fs.existsSync(lambdaFfmpegPaths[binary])) {
- return lambdaFfmpegPaths[binary];
- }
-
- if (ffmpegExecutable && customExecutableExists(ffmpegExecutable)) {
- return ffmpegExecutable;
- }
-
- if (binaryExists(binary)) {
- return binary;
- }
-
- const dlUrl = getBinaryDownloadUrl(binary);
-
- if (dlUrl && isDownloading[dlUrl.url]) {
- return waitForFfmpegToBeDownloaded(dlUrl.url);
- }
-
- const inNodeMod = ffmpegInNodeModules(remotionRoot, binary);
-
- if (inNodeMod) {
- return inNodeMod;
- }
-
- if (!dlUrl) {
- throw new Error(
- `${binary} could not be installed automatically. Your architecture and OS combination (os = ${os.platform()}, arch = ${
- process.arch
- }) is not supported. Please install ${binary} manually and add "${binary}" to your PATH.`
- );
- }
-
- return downloadBinary(remotionRoot, dlUrl.url, binary);
-};
-
-function toMegabytes(bytes: number) {
- const mb = bytes / 1024 / 1024;
- return `${Math.round(mb * 10) / 10} Mb`;
-}
-
-export const getBinaryDownloadUrl = (
- binary: 'ffmpeg' | 'ffprobe'
-): {
- url: string;
- contentLength: number;
-} | null => {
- if (os.platform() === 'win32' && process.arch === 'x64') {
- return binary === 'ffmpeg'
- ? {
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffmpeg-win-x86.exe',
- contentLength: 127531008,
- }
- : {
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffprobe-win-x86.exe',
- contentLength: 127425536,
- };
- }
-
- if (os.platform() === 'darwin' && process.arch === 'arm64') {
- return binary === 'ffmpeg'
- ? {
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffmpeg-macos-arm64',
- contentLength: 42093320,
- }
- : {
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffprobe-macos-arm64-v2',
- contentLength: 46690008,
- };
- }
-
- if (os.platform() === 'darwin' && process.arch === 'x64') {
- return binary === 'ffmpeg'
- ? {
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffmpeg-macos-x86',
- contentLength: 78380700,
- }
- : {
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffprobe-macos-x86',
- contentLength: 77364284,
- };
- }
-
- if (os.platform() === 'linux' && process.arch === 'x64') {
- return binary === 'ffmpeg'
- ? {
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffmpeg-linux-amd64',
- contentLength: 78502560,
- }
- : {
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffprobe-linux-amd64',
- contentLength: 78400704,
- };
- }
-
- return null;
-};
-
-const printMessage = (ffmpegVersion: NonNullable<FfmpegVersion>) => {
- console.warn('⚠️Old FFMPEG version detected: ' + ffmpegVersion.join('.'));
- console.warn(' You need at least version 4.1.0.');
- console.warn(' Upgrade FFMPEG to get rid of this warning.');
-};
-
-const printBuildConfMessage = () => {
- console.error('⚠️ Unsupported FFMPEG version detected.');
- console.error(" Your version doesn't support the -buildconf flag");
- console.error(
- ' Audio will not be supported and you may experience other issues.'
- );
- console.error(
- ' Upgrade FFMPEG to at least v4.1.0 to get rid of this warning.'
- );
-};
-
-export const warnAboutFfmpegVersion = ({
- ffmpegVersion,
- buildConf,
-}: {
- ffmpegVersion: FfmpegVersion;
- buildConf: string | null;
-}) => {
- if (buildConf === null) {
- printBuildConfMessage();
- return;
- }
-
- if (ffmpegVersion === null) {
- return null;
- }
-
- const [major, minor] = ffmpegVersion;
- // 3.x and below definitely is too old
- if (major < 4) {
- printMessage(ffmpegVersion);
- return;
- }
-
- // 5.x will be all good
- if (major > 4) {
- return;
- }
-
- if (minor < 1) {
- printMessage(ffmpegVersion);
- }
-};
diff --git a/packages/renderer/src/get-can-extract-frames-fast.ts b/packages/renderer/src/get-can-extract-frames-fast.ts
index 419edca7ef..f1bdc16779 100644
--- a/packages/renderer/src/get-can-extract-frames-fast.ts
+++ b/packages/renderer/src/get-can-extract-frames-fast.ts
@@ -1,8 +1,6 @@
import fs from 'fs';
import {getVideoStreamDurationwithoutCache} from './assets/get-video-stream-duration';
import {ensurePresentationTimestampWithoutCache} from './ensure-presentation-timestamp';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {findRemotionRoot} from './find-closest-package-json';
import {getVideoInfoUncached} from './get-video-info';
import {tryToExtractFrameOfVideoFast} from './try-to-extract-frame-of-video-fast';
@@ -10,28 +8,18 @@ export const ACCEPTABLE_OFFSET_THRESHOLD = 50;
export const getCanExtractFramesFast = async ({
src,
- ffmpegExecutable,
- ffprobeExecutable,
}: {
src: string;
- ffmpegExecutable?: FfmpegExecutable;
- ffprobeExecutable?: FfmpegExecutable;
}): Promise<{
canExtractFramesFast: boolean;
shouldReencode: boolean;
}> => {
- const remotionRoot = findRemotionRoot();
const out = await ensurePresentationTimestampWithoutCache({
- ffmpegExecutable: ffmpegExecutable ?? null,
- ffprobeExecutable: ffprobeExecutable ?? null,
- remotionRoot,
src,
});
const {specialVcodecForTransparency: specialVcodec} =
await getVideoInfoUncached({
src: out,
- ffprobeExecutable: ffprobeExecutable ?? null,
- remotionRoot,
});
if (specialVcodec === 'vp8') {
@@ -43,8 +31,6 @@ export const getCanExtractFramesFast = async ({
}
const {duration} = await getVideoStreamDurationwithoutCache({
- ffprobeExecutable: ffprobeExecutable ?? null,
- remotionRoot,
src: out,
});
@@ -59,11 +45,9 @@ export const getCanExtractFramesFast = async ({
const [stdErr] = await tryToExtractFrameOfVideoFast({
actualOffset,
- ffmpegExecutable: ffmpegExecutable ?? null,
imageFormat: 'jpeg',
// Intentionally leaving needsResize as null, because we don't need to resize
needsResize: null,
- remotionRoot,
specialVCodecForTransparency: specialVcodec,
src: out,
});
diff --git a/packages/renderer/src/get-compositions.ts b/packages/renderer/src/get-compositions.ts
index d9c52e5ed1..df84dd677d 100644
--- a/packages/renderer/src/get-compositions.ts
+++ b/packages/renderer/src/get-compositions.ts
@@ -6,7 +6,6 @@ import type {BrowserLog} from './browser-log';
import type {Browser} from './browser/Browser';
import type {Page} from './browser/BrowserPage';
import {handleJavascriptException} from './error-handling/handle-javascript-exception';
-import type {FfmpegExecutable} from './ffmpeg-executable';
import {findRemotionRoot} from './find-closest-package-json';
import {getPageAndCleanupFn} from './get-browser-instance';
import type {ChromiumOptions} from './open-browser';
@@ -14,7 +13,6 @@ import {prepareServer} from './prepare-server';
import {puppeteerEvaluateWithCatch} from './puppeteer-evaluate';
import {waitForReady} from './seek-to-frame';
import {setPropsAndEnv} from './set-props-and-env';
-import {validateFfmpeg} from './validate-ffmpeg';
import {validatePuppeteerTimeout} from './validate-puppeteer-timeout';
type GetCompositionsConfig = {
@@ -25,8 +23,6 @@ type GetCompositionsConfig = {
browserExecutable?: BrowserExecutable;
timeoutInMilliseconds?: number;
chromiumOptions?: ChromiumOptions;
- ffmpegExecutable?: FfmpegExecutable;
- ffprobeExecutable?: FfmpegExecutable;
port?: number | null;
/**
* @deprecated Only for Remotion internal usage
@@ -93,17 +89,6 @@ export const getCompositions = async (
serveUrlOrWebpackUrl: string,
config?: GetCompositionsConfig
) => {
- await validateFfmpeg(
- config?.ffmpegExecutable ?? null,
- findRemotionRoot(),
- 'ffmpeg'
- );
- await validateFfmpeg(
- config?.ffprobeExecutable ?? null,
- findRemotionRoot(),
- 'ffprobe'
- );
-
const downloadMap = config?.downloadMap ?? makeDownloadMap();
const {page, cleanup} = await getPageAndCleanupFn({
@@ -126,8 +111,6 @@ export const getCompositions = async (
webpackConfigOrServeUrl: serveUrlOrWebpackUrl,
onDownload: () => undefined,
onError,
- ffmpegExecutable: config?.ffmpegExecutable ?? null,
- ffprobeExecutable: config?.ffprobeExecutable ?? null,
port: config?.port ?? null,
downloadMap,
remotionRoot: findRemotionRoot(),
diff --git a/packages/renderer/src/get-frame-of-video-slow.ts b/packages/renderer/src/get-frame-of-video-slow.ts
index cb3e2e3fb0..3c347540d2 100644
--- a/packages/renderer/src/get-frame-of-video-slow.ts
+++ b/packages/renderer/src/get-frame-of-video-slow.ts
@@ -3,23 +3,19 @@
import execa from 'execa';
import type {OffthreadVideoImageFormat} from 'remotion';
import type {SpecialVCodecForTransparency} from './assets/download-map';
+import {getExecutablePath} from './compositor/get-executable-path';
import {determineResizeParams} from './determine-resize-params';
import {determineVcodecFfmpegFlags} from './determine-vcodec-ffmpeg-flags';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
import {truthy} from './truthy';
export const getFrameOfVideoSlow = async ({
src,
duration,
- ffmpegExecutable,
imageFormat,
specialVCodecForTransparency,
needsResize,
offset,
fps,
- remotionRoot,
}: {
- ffmpegExecutable: FfmpegExecutable;
src: string;
duration: number;
imageFormat: OffthreadVideoImageFormat;
@@ -27,7 +23,6 @@ export const getFrameOfVideoSlow = async ({
needsResize: [number, number] | null;
offset: number;
fps: number | null;
- remotionRoot: string;
}): Promise<Buffer> => {
console.warn(
`\nUsing a slow method to extract the frame at ${duration}ms of ${src}. See https://remotion.dev/docs/slow-method-to-extract-frame for advice`
@@ -50,10 +45,9 @@ export const getFrameOfVideoSlow = async ({
'-',
].filter(truthy);
- const {stdout, stderr} = execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
- command
- );
+ const {stdout, stderr} = execa(getExecutablePath('ffmpeg'), command, {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ });
if (!stderr) {
throw new Error('unexpectedly did not get stderr');
@@ -93,7 +87,6 @@ export const getFrameOfVideoSlow = async ({
}
return getFrameOfVideoSlow({
- ffmpegExecutable,
duration,
// Decrement in 10ms increments, or 1 frame (e.g. fps = 25 --> 40ms)
offset: offset + (fps === null ? 10 : 1000 / fps),
@@ -102,7 +95,6 @@ export const getFrameOfVideoSlow = async ({
specialVCodecForTransparency,
needsResize,
fps,
- remotionRoot,
});
}
diff --git a/packages/renderer/src/get-video-info.ts b/packages/renderer/src/get-video-info.ts
index 6809854ba6..9ad0f7d314 100644
--- a/packages/renderer/src/get-video-info.ts
+++ b/packages/renderer/src/get-video-info.ts
@@ -1,25 +1,19 @@
import execa from 'execa';
import type {DownloadMap, Vp9Result} from './assets/download-map';
import {calculateDisplayVideoSize} from './calculate-sar-dar-pixels';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
+import {getExecutablePath} from './compositor/get-executable-path';
import {pLimit} from './p-limit';
const limit = pLimit(1);
export async function getVideoInfoUncached({
src,
- ffprobeExecutable,
- remotionRoot,
}: {
src: string;
- ffprobeExecutable: FfmpegExecutable;
- remotionRoot: string;
}): Promise<Vp9Result> {
- const task = await execa(
- await getExecutableBinary(ffprobeExecutable, remotionRoot, 'ffprobe'),
- [src]
- );
+ const task = await execa(getExecutablePath('ffprobe'), [src], {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ });
const isVp9 = task.stderr.includes('Video: vp9');
const isVp8 = task.stderr.includes('Video: vp8');
@@ -61,17 +55,13 @@ export async function getVideoInfoUncached({
async function getVideoInfoUnlimited(
downloadMap: DownloadMap,
- src: string,
- ffprobeExecutable: FfmpegExecutable,
- remotionRoot: string
+ src: string
): Promise<Vp9Result> {
if (typeof downloadMap.isVp9VideoCache[src] !== 'undefined') {
return downloadMap.isVp9VideoCache[src];
}
const result = await getVideoInfoUncached({
- ffprobeExecutable,
- remotionRoot,
src,
});
@@ -82,11 +72,7 @@ async function getVideoInfoUnlimited(
export const getVideoInfo = (
downloadMap: DownloadMap,
- src: string,
- ffprobeExecutable: FfmpegExecutable,
- remotionRoot: string
+ src: string
): Promise<Vp9Result> => {
- return limit(() =>
- getVideoInfoUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot)
- );
+ return limit(() => getVideoInfoUnlimited(downloadMap, src));
};
diff --git a/packages/renderer/src/guess-extension-for-media.ts b/packages/renderer/src/guess-extension-for-media.ts
index e20ab2377c..02da232b1e 100644
--- a/packages/renderer/src/guess-extension-for-media.ts
+++ b/packages/renderer/src/guess-extension-for-media.ts
@@ -1,19 +1,10 @@
import execa from 'execa';
-import {getExecutableBinary} from './ffmpeg-flags';
+import {getExecutablePath} from './compositor/get-executable-path';
-export const guessExtensionForVideo = async ({
- src,
- remotionRoot,
- ffprobeBinary,
-}: {
- src: string;
- remotionRoot: string;
- ffprobeBinary: string | null;
-}) => {
- const {stderr} = await execa(
- await getExecutableBinary(ffprobeBinary, remotionRoot, 'ffprobe'),
- [src]
- );
+export const guessExtensionForVideo = async ({src}: {src: string}) => {
+ const {stderr} = await execa(getExecutablePath('ffprobe'), [src], {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ });
if (stderr.includes('mp3,')) {
return 'mp3';
diff --git a/packages/renderer/src/index.ts b/packages/renderer/src/index.ts
index 82ca0497c0..3a1844b7ee 100644
--- a/packages/renderer/src/index.ts
+++ b/packages/renderer/src/index.ts
@@ -8,16 +8,12 @@ import {canUseParallelEncoding} from './can-use-parallel-encoding';
import {checkNodeVersionAndWarnAboutRosetta} from './check-apple-silicon';
import {DEFAULT_CODEC, validCodecs} from './codec';
import {combineVideos} from './combine-videos';
+import {getExecutablePath} from './compositor/get-executable-path';
import {convertToPositiveFrameIndex} from './convert-to-positive-frame-index';
import {deleteDirectory} from './delete-directory';
import {ensureOutputDirectory} from './ensure-output-directory';
import {symbolicateError} from './error-handling/symbolicate-error';
import {SymbolicateableError} from './error-handling/symbolicateable-error';
-import {
- ffmpegHasFeature,
- getExecutableBinary,
- getFfmpegVersion,
-} from './ffmpeg-flags';
import {defaultFileExtensionMap, supportedAudioCodecs} from './file-extensions';
import {findRemotionRoot} from './find-closest-package-json';
import {validateFrameRange} from './frame-range';
@@ -47,7 +43,6 @@ import {serveStatic} from './serve-static';
import {tmpDir} from './tmp-dir';
import {validateConcurrency} from './validate-concurrency';
import {validateEvenDimensionsWithCodec} from './validate-even-dimensions-with-codec';
-import {validateFfmpeg} from './validate-ffmpeg';
import {validateFrame} from './validate-frame';
import {
DEFAULT_OPENGL_RENDERER,
@@ -67,14 +62,7 @@ export {BrowserExecutable} from './browser-executable';
export {BrowserLog} from './browser-log';
export {Codec, CodecOrUndefined} from './codec';
export {Crf} from './crf';
-export {
- ensureFfmpeg,
- EnsureFfmpegOptions,
- ensureFfprobe,
-} from './ensure-ffmpeg';
export {ErrorWithStackFrame} from './error-handling/handle-javascript-exception';
-export {FfmpegExecutable} from './ffmpeg-executable';
-export {FfmpegVersion} from './ffmpeg-flags';
export type {FfmpegOverrideFn} from './ffmpeg-override';
export {FileExtension} from './file-extensions';
export {FrameRange} from './frame-range';
@@ -110,9 +98,7 @@ export {validateOutputFilename} from './validate-output-filename';
export const RenderInternals = {
ensureLocalBrowser,
- ffmpegHasFeature,
getActualConcurrency,
- validateFfmpeg,
serveStatic,
validateEvenDimensionsWithCodec,
getFileExtensionFromCodec,
@@ -159,9 +145,7 @@ export const RenderInternals = {
cleanDownloadMap,
convertToPositiveFrameIndex,
findRemotionRoot,
- getExecutableBinary,
validateBitrate,
- getFfmpegVersion,
combineVideos,
getDefaultAudioCodec,
validAudioCodecs,
@@ -169,6 +153,7 @@ export const RenderInternals = {
supportedAudioCodecs,
makeFileExtensionMap,
defaultCodecsForFileExtension,
+ getExecutablePath,
};
// Warn of potential performance issues with Apple Silicon (M1 chip under Rosetta)
diff --git a/packages/renderer/src/last-frame-from-video-cache.ts b/packages/renderer/src/last-frame-from-video-cache.ts
index 3843a216af..b644d0abc6 100644
--- a/packages/renderer/src/last-frame-from-video-cache.ts
+++ b/packages/renderer/src/last-frame-from-video-cache.ts
@@ -5,18 +5,14 @@ import type {
DownloadMap,
SpecialVCodecForTransparency,
} from './assets/download-map';
-import type {FfmpegExecutable} from './ffmpeg-executable';
export type LastFrameOptions = {
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
offset: number;
src: string;
specialVCodecForTransparency: SpecialVCodecForTransparency;
imageFormat: OffthreadVideoImageFormat;
needsResize: [number, number] | null;
downloadMap: DownloadMap;
- remotionRoot: string;
};
const MAX_CACHE_SIZE = 50 * 1024 * 1024; // 50MB
@@ -25,7 +21,6 @@ let bufferSize = 0;
const makeLastFrameCacheKey = (options: LastFrameOptions) => {
return [
- options.ffmpegExecutable,
options.offset,
options.src,
options.imageFormat,
diff --git a/packages/renderer/src/merge-audio-track.ts b/packages/renderer/src/merge-audio-track.ts
index c542fc2ed8..4b6e44aae5 100644
--- a/packages/renderer/src/merge-audio-track.ts
+++ b/packages/renderer/src/merge-audio-track.ts
@@ -2,18 +2,16 @@ import execa from 'execa';
import path from 'path';
import type {DownloadMap} from './assets/download-map';
import {chunk} from './chunk';
+import {getExecutablePath} from './compositor/get-executable-path';
import {convertToPcm} from './convert-to-pcm';
import {createFfmpegComplexFilter} from './create-ffmpeg-complex-filter';
import {createSilentAudio} from './create-silent-audio';
import {deleteDirectory} from './delete-directory';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
import {pLimit} from './p-limit';
import {tmpDir} from './tmp-dir';
import {truthy} from './truthy';
type Options = {
- ffmpegExecutable: FfmpegExecutable;
files: string[];
outName: string;
numberOfSeconds: number;
@@ -22,7 +20,6 @@ type Options = {
};
const mergeAudioTrackUnlimited = async ({
- ffmpegExecutable,
outName,
files,
numberOfSeconds,
@@ -32,9 +29,7 @@ const mergeAudioTrackUnlimited = async ({
if (files.length === 0) {
await createSilentAudio({
outName,
- ffmpegExecutable,
numberOfSeconds,
- remotionRoot,
});
return;
}
@@ -42,9 +37,7 @@ const mergeAudioTrackUnlimited = async ({
if (files.length === 1) {
await convertToPcm({
outName,
- ffmpegExecutable,
input: files[0],
- remotionRoot,
});
return;
}
@@ -58,7 +51,6 @@ const mergeAudioTrackUnlimited = async ({
chunked.map(async (chunkFiles, i) => {
const chunkOutname = path.join(tempPath, `chunk-${i}.wav`);
await mergeAudioTrack({
- ffmpegExecutable,
files: chunkFiles,
numberOfSeconds,
outName: chunkOutname,
@@ -70,7 +62,6 @@ const mergeAudioTrackUnlimited = async ({
);
await mergeAudioTrack({
- ffmpegExecutable,
files: chunkNames,
numberOfSeconds,
outName,
@@ -93,10 +84,9 @@ const mergeAudioTrackUnlimited = async ({
]
.filter(truthy)
.flat(2);
- const task = execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
- args
- );
+ const task = execa(getExecutablePath('ffmpeg'), args, {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ });
await task;
cleanup();
};
diff --git a/packages/renderer/src/offthread-video-server.ts b/packages/renderer/src/offthread-video-server.ts
index 3b4067a162..1a1115e18c 100644
--- a/packages/renderer/src/offthread-video-server.ts
+++ b/packages/renderer/src/offthread-video-server.ts
@@ -6,7 +6,6 @@ import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-fi
import {downloadAsset} from './assets/download-and-map-assets-to-file';
import type {DownloadMap} from './assets/download-map';
import {extractFrameFromVideo} from './extract-frame-from-video';
-import type {FfmpegExecutable} from './ffmpeg-executable';
export const extractUrlAndSourceFromUrl = (url: string) => {
const parsed = new URL(url, 'http://localhost');
@@ -44,15 +43,11 @@ export const extractUrlAndSourceFromUrl = (url: string) => {
};
export const startOffthreadVideoServer = ({
- ffmpegExecutable,
- ffprobeExecutable,
onDownload,
onError,
downloadMap,
remotionRoot,
}: {
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
onDownload: RenderMediaOnDownload;
onError: (err: Error) => void;
downloadMap: DownloadMap;
@@ -94,8 +89,6 @@ export const startOffthreadVideoServer = ({
return extractFrameFromVideo({
time,
src: to,
- ffmpegExecutable,
- ffprobeExecutable,
imageFormat,
downloadMap,
remotionRoot,
diff --git a/packages/renderer/src/prepare-server.ts b/packages/renderer/src/prepare-server.ts
index f451b4838f..23f0240247 100644
--- a/packages/renderer/src/prepare-server.ts
+++ b/packages/renderer/src/prepare-server.ts
@@ -2,14 +2,11 @@ import {existsSync} from 'fs';
import path from 'path';
import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';
import type {DownloadMap} from './assets/download-map';
-import type {FfmpegExecutable} from './ffmpeg-executable';
import {isServeUrl} from './is-serve-url';
import {serveStatic} from './serve-static';
import {waitForSymbolicationToBeDone} from './wait-for-symbolication-error-to-be-done';
export const prepareServer = async ({
- ffmpegExecutable,
- ffprobeExecutable,
onDownload,
onError,
webpackConfigOrServeUrl,
@@ -20,8 +17,6 @@ export const prepareServer = async ({
webpackConfigOrServeUrl: string;
onDownload: RenderMediaOnDownload;
onError: (err: Error) => void;
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
port: number | null;
downloadMap: DownloadMap;
remotionRoot: string;
@@ -34,8 +29,6 @@ export const prepareServer = async ({
const {port: offthreadPort, close: closeProxy} = await serveStatic(null, {
onDownload,
onError,
- ffmpegExecutable,
- ffprobeExecutable,
port,
downloadMap,
remotionRoot,
@@ -62,8 +55,6 @@ export const prepareServer = async ({
const {port: serverPort, close} = await serveStatic(webpackConfigOrServeUrl, {
onDownload,
onError,
- ffmpegExecutable,
- ffprobeExecutable,
port,
downloadMap,
remotionRoot,
diff --git a/packages/renderer/src/preprocess-audio-track.ts b/packages/renderer/src/preprocess-audio-track.ts
index b6b2c82e3a..c06ba22c60 100644
--- a/packages/renderer/src/preprocess-audio-track.ts
+++ b/packages/renderer/src/preprocess-audio-track.ts
@@ -3,38 +3,29 @@ import type {DownloadMap} from './assets/download-map';
import {getAudioChannelsAndDuration} from './assets/get-audio-channels';
import type {MediaAsset} from './assets/types';
import {calculateFfmpegFilter} from './calculate-ffmpeg-filters';
-import type {FfmpegExecutable} from './ffmpeg-executable';
+import {getExecutablePath} from './compositor/get-executable-path';
import {makeFfmpegFilterFile} from './ffmpeg-filter-file';
-import {getExecutableBinary} from './ffmpeg-flags';
import {pLimit} from './p-limit';
import {resolveAssetSrc} from './resolve-asset-src';
type Options = {
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
outName: string;
asset: MediaAsset;
expectedFrames: number;
fps: number;
downloadMap: DownloadMap;
- remotionRoot: string;
};
const preprocessAudioTrackUnlimited = async ({
- ffmpegExecutable,
- ffprobeExecutable,
outName,
asset,
expectedFrames,
fps,
downloadMap,
- remotionRoot,
}: Options): Promise<string | null> => {
const {channels, duration} = await getAudioChannelsAndDuration(
downloadMap,
- resolveAssetSrc(asset.src),
- ffprobeExecutable,
- remotionRoot
+ resolveAssetSrc(asset.src)
);
const filter = calculateFfmpegFilter({
@@ -59,10 +50,9 @@ const preprocessAudioTrackUnlimited = async ({
['-y', outName],
].flat(2);
- await execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
- args
- );
+ await execa(getExecutablePath('ffmpeg'), args, {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ });
cleanup();
return outName;
diff --git a/packages/renderer/src/prespawn-ffmpeg.ts b/packages/renderer/src/prespawn-ffmpeg.ts
index 1e9ec9c471..5371976b0d 100644
--- a/packages/renderer/src/prespawn-ffmpeg.ts
+++ b/packages/renderer/src/prespawn-ffmpeg.ts
@@ -2,9 +2,8 @@ import execa from 'execa';
import {Internals} from 'remotion';
import type {Codec} from './codec';
import {DEFAULT_CODEC} from './codec';
+import {getExecutablePath} from './compositor/get-executable-path';
import {validateQualitySettings} from './crf';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
import type {FfmpegOverrideFn} from './ffmpeg-override';
import {getCodecName} from './get-codec-name';
import {getProResProfileName} from './get-prores-profile-name';
@@ -18,7 +17,6 @@ import {
} from './pixel-format';
import type {ProResProfile} from './prores-profile';
import {validateEvenDimensionsWithCodec} from './validate-even-dimensions-with-codec';
-import {validateFfmpeg} from './validate-ffmpeg';
type PreSticherOptions = {
fps: number;
@@ -31,17 +29,13 @@ type PreSticherOptions = {
onProgress: (progress: number) => void;
proResProfile: ProResProfile | undefined;
verbose: boolean;
- ffmpegExecutable: FfmpegExecutable | undefined;
imageFormat: ImageFormat;
ffmpegOverride: FfmpegOverrideFn;
signal: CancelSignal;
videoBitrate: string | null;
};
-export const prespawnFfmpeg = async (
- options: PreSticherOptions,
- remotionRoot: string
-) => {
+export const prespawnFfmpeg = (options: PreSticherOptions) => {
Internals.validateDimension(
options.height,
'height',
@@ -65,11 +59,6 @@ export const prespawnFfmpeg = async (
scale: 1,
});
const pixelFormat = options.pixelFormat ?? DEFAULT_PIXEL_FORMAT;
- await validateFfmpeg(
- options.ffmpegExecutable ?? null,
- remotionRoot,
- 'ffmpeg'
- );
const encoderName = getCodecName(codec);
const proResProfileName = getProResProfileName(codec, options.proResProfile);
@@ -81,10 +70,7 @@ export const prespawnFfmpeg = async (
const supportsCrf = codec !== 'prores';
if (options.verbose) {
- console.log(
- '[verbose] ffmpeg',
- options.ffmpegExecutable ?? 'ffmpeg in PATH'
- );
+ console.log('[verbose] ffmpeg', getExecutablePath('ffmpeg'));
console.log('[verbose] encoder', encoderName);
console.log('[verbose] pixelFormat', pixelFormat);
if (supportsCrf) {
@@ -136,14 +122,9 @@ export const prespawnFfmpeg = async (
? options.ffmpegOverride({type: 'pre-stitcher', args: ffmpegString})
: ffmpegString;
- const task = execa(
- await getExecutableBinary(
- options.ffmpegExecutable ?? null,
- remotionRoot,
- 'ffmpeg'
- ),
- finalFfmpegString
- );
+ const task = execa(getExecutablePath('ffmpeg'), finalFfmpegString, {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ });
options.signal(() => {
task.kill();
diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.ts
index b592cd7d97..c1afc55347 100644
--- a/packages/renderer/src/render-frames.ts
+++ b/packages/renderer/src/render-frames.ts
@@ -16,7 +16,6 @@ import type {ConsoleMessage} from './browser/ConsoleMessage';
import {compressAsset} from './compress-assets';
import {cycleBrowserTabs} from './cycle-browser-tabs';
import {handleJavascriptException} from './error-handling/handle-javascript-exception';
-import type {FfmpegExecutable} from './ffmpeg-executable';
import {findRemotionRoot} from './find-closest-package-json';
import type {FrameRange} from './frame-range';
import {getActualConcurrency} from './get-concurrency';
@@ -96,8 +95,6 @@ type RenderFramesOptions = {
timeoutInMilliseconds?: number;
chromiumOptions?: ChromiumOptions;
scale?: number;
- ffmpegExecutable?: FfmpegExecutable;
- ffprobeExecutable?: FfmpegExecutable;
port?: number | null;
cancelSignal?: CancelSignal;
/**
@@ -574,8 +571,6 @@ export const renderFrames = (
webpackConfigOrServeUrl: selectedServeUrl,
onDownload,
onError,
- ffmpegExecutable: options.ffmpegExecutable ?? null,
- ffprobeExecutable: options.ffprobeExecutable ?? null,
port: options.port ?? null,
downloadMap,
remotionRoot: findRemotionRoot(),
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 2878ca7400..b40adcfd51 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -18,9 +18,7 @@ import {validateQualitySettings} from './crf';
import {deleteDirectory} from './delete-directory';
import {ensureFramesInOrder} from './ensure-frames-in-order';
import {ensureOutputDirectory} from './ensure-output-directory';
-import type {FfmpegExecutable} from './ffmpeg-executable';
import type {FfmpegOverrideFn} from './ffmpeg-override';
-import {findRemotionRoot} from './find-closest-package-json';
import type {FrameRange} from './frame-range';
import {getFramesToRender} from './get-duration-from-frame-range';
import {getFileExtensionFromCodec} from './get-extension-from-codec';
@@ -48,7 +46,6 @@ import {stitchFramesToVideo} from './stitch-frames-to-video';
import type {OnStartData} from './types';
import {validateEvenDimensionsWithCodec} from './validate-even-dimensions-with-codec';
import {validateEveryNthFrame} from './validate-every-nth-frame';
-import {validateFfmpeg} from './validate-ffmpeg';
import {validateFfmpegOverride} from './validate-ffmpeg-override';
import {validateOutputFilename} from './validate-output-filename';
import {validateScale} from './validate-scale';
@@ -77,8 +74,6 @@ export type RenderMediaOptions = {
inputProps?: unknown;
crf?: number | null;
imageFormat?: 'png' | 'jpeg' | 'none';
- ffmpegExecutable?: FfmpegExecutable;
- ffprobeExecutable?: FfmpegExecutable;
pixelFormat?: PixelFormat;
envVariables?: Record<string, string>;
quality?: number;
@@ -153,8 +148,6 @@ export const renderMedia = ({
proResProfile,
crf,
composition,
- ffmpegExecutable,
- ffprobeExecutable,
inputProps,
pixelFormat,
codec,
@@ -183,8 +176,6 @@ export const renderMedia = ({
audioCodec,
...options
}: RenderMediaOptions): Promise<Buffer | null> => {
- const remotionRoot = findRemotionRoot();
- validateFfmpeg(ffmpegExecutable ?? null, remotionRoot, 'ffmpeg');
validateQuality(options.quality);
validateQualitySettings({crf, codec, videoBitrate});
validateBitrate(audioBitrate, 'audioBitrate');
@@ -324,31 +315,27 @@ export const renderMedia = ({
const fps = composition.fps / (everyNthFrame ?? 1);
Internals.validateFps(fps, 'in "renderMedia()"', codec === 'gif');
- const createPrestitcherIfNecessary = async () => {
+ const createPrestitcherIfNecessary = () => {
if (preEncodedFileLocation) {
- preStitcher = await prespawnFfmpeg(
- {
- width: composition.width * (scale ?? 1),
- height: composition.height * (scale ?? 1),
- fps,
- outputLocation: preEncodedFileLocation,
- pixelFormat,
- codec,
- proResProfile,
- crf,
- onProgress: (frame: number) => {
- encodedFrames = frame;
- callUpdate();
- },
- verbose: options.verbose ?? false,
- ffmpegExecutable,
- imageFormat,
- signal: cancelPrestitcher.cancelSignal,
- ffmpegOverride: ffmpegOverride ?? (({args}) => args),
- videoBitrate: videoBitrate ?? null,
+ preStitcher = prespawnFfmpeg({
+ width: composition.width * (scale ?? 1),
+ height: composition.height * (scale ?? 1),
+ fps,
+ outputLocation: preEncodedFileLocation,
+ pixelFormat,
+ codec,
+ proResProfile,
+ crf,
+ onProgress: (frame: number) => {
+ encodedFrames = frame;
+ callUpdate();
},
- remotionRoot
- );
+ verbose: options.verbose ?? false,
+ imageFormat,
+ signal: cancelPrestitcher.cancelSignal,
+ ffmpegOverride: ffmpegOverride ?? (({args}) => args),
+ videoBitrate: videoBitrate ?? null,
+ });
stitcherFfmpeg = preStitcher.task;
}
};
@@ -398,7 +385,7 @@ export const renderMedia = ({
minTime = slowestFrames[slowestFrames.length - 1]?.time ?? minTime;
};
- const happyPath = createPrestitcherIfNecessary()
+ const happyPath = Promise.resolve(() => createPrestitcherIfNecessary())
.then(() => {
const renderFramesProc = renderFrames({
config: composition,
@@ -448,8 +435,6 @@ export const renderMedia = ({
timeoutInMilliseconds,
chromiumOptions,
scale,
- ffmpegExecutable,
- ffprobeExecutable,
browserExecutable,
port,
cancelSignal: cancelRenderFrames.cancelSignal,
@@ -488,8 +473,6 @@ export const renderMedia = ({
proResProfile,
crf,
assetsInfo,
- ffmpegExecutable,
- ffprobeExecutable,
onProgress: (frame: number) => {
stitchStage = 'muxing';
encodedFrames = frame;
diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.ts
index ad6417d20d..83d844d312 100644
--- a/packages/renderer/src/render-still.ts
+++ b/packages/renderer/src/render-still.ts
@@ -11,7 +11,6 @@ import type {Browser as PuppeteerBrowser} from './browser/Browser';
import {convertToPositiveFrameIndex} from './convert-to-positive-frame-index';
import {ensureOutputDirectory} from './ensure-output-directory';
import {handleJavascriptException} from './error-handling/handle-javascript-exception';
-import type {FfmpegExecutable} from './ffmpeg-executable';
import {findRemotionRoot} from './find-closest-package-json';
import type {StillImageFormat} from './image-format';
import {validateNonNullImageFormat} from './image-format';
@@ -48,8 +47,6 @@ type InnerStillOptions = {
scale?: number;
onDownload?: RenderMediaOnDownload;
cancelSignal?: CancelSignal;
- ffmpegExecutable?: FfmpegExecutable;
- ffprobeExecutable?: FfmpegExecutable;
/**
* @deprecated Only for Remotion internal usage
*/
@@ -277,8 +274,6 @@ export const renderStill = (
webpackConfigOrServeUrl: selectedServeUrl,
onDownload,
onError,
- ffmpegExecutable: options.ffmpegExecutable ?? null,
- ffprobeExecutable: options.ffprobeExecutable ?? null,
port: options.port ?? null,
downloadMap,
remotionRoot: findRemotionRoot(),
diff --git a/packages/renderer/src/serve-static.ts b/packages/renderer/src/serve-static.ts
index 5f13e1fd76..80426aa44d 100644
--- a/packages/renderer/src/serve-static.ts
+++ b/packages/renderer/src/serve-static.ts
@@ -2,7 +2,6 @@ import http from 'http';
import type {Socket} from 'net';
import type {RenderMediaOnDownload} from './assets/download-and-map-assets-to-file';
import type {DownloadMap} from './assets/download-map';
-import type {FfmpegExecutable} from './ffmpeg-executable';
import {getDesiredPort} from './get-port';
import {startOffthreadVideoServer} from './offthread-video-server';
import {serveHandler} from './serve-handler';
@@ -11,8 +10,6 @@ export const serveStatic = async (
path: string | null,
options: {
port: number | null;
- ffmpegExecutable: FfmpegExecutable;
- ffprobeExecutable: FfmpegExecutable;
onDownload: RenderMediaOnDownload;
onError: (err: Error) => void;
downloadMap: DownloadMap;
@@ -23,8 +20,6 @@ export const serveStatic = async (
close: () => Promise<void>;
}> => {
const offthreadRequest = startOffthreadVideoServer({
- ffmpegExecutable: options.ffmpegExecutable,
- ffprobeExecutable: options.ffprobeExecutable,
onDownload: options.onDownload,
onError: options.onError,
downloadMap: options.downloadMap,
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index a03c4d25fd..de572ab050 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -17,11 +17,10 @@ import {
import type {Codec} from './codec';
import {DEFAULT_CODEC} from './codec';
import {codecSupportsMedia} from './codec-supports-media';
+import {getExecutablePath} from './compositor/get-executable-path';
import {convertNumberOfGifLoopsToFfmpegSyntax} from './convert-number-of-gif-loops-to-ffmpeg';
import {validateQualitySettings} from './crf';
import {deleteDirectory} from './delete-directory';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
import type {FfmpegOverrideFn} from './ffmpeg-override';
import {findRemotionRoot} from './find-closest-package-json';
import {getCodecName} from './get-codec-name';
@@ -42,7 +41,6 @@ import type {ProResProfile} from './prores-profile';
import {validateSelectedCodecAndProResCombination} from './prores-profile';
import {truthy} from './truthy';
import {validateEvenDimensionsWithCodec} from './validate-even-dimensions-with-codec';
-import {validateFfmpeg} from './validate-ffmpeg';
import {validateBitrate} from './validate-videobitrate';
const packageJsonPath = path.join(__dirname, '..', 'package.json');
@@ -69,8 +67,6 @@ export type StitcherOptions = {
onDownload?: RenderMediaOnDownload;
proResProfile?: ProResProfile;
verbose?: boolean;
- ffmpegExecutable?: FfmpegExecutable;
- ffprobeExecutable?: FfmpegExecutable;
dir?: string;
cancelSignal?: CancelSignal;
internalOptions?: {
@@ -94,8 +90,6 @@ const getAssetsData = async ({
fps,
expectedFrames,
verbose,
- ffmpegExecutable,
- ffprobeExecutable,
onProgress,
downloadMap,
remotionRoot,
@@ -105,8 +99,6 @@ const getAssetsData = async ({
fps: number;
expectedFrames: number;
verbose: boolean;
- ffmpegExecutable: FfmpegExecutable | null;
- ffprobeExecutable: FfmpegExecutable | null;
onProgress: (progress: number) => void;
downloadMap: DownloadMap;
remotionRoot: string;
@@ -137,14 +129,11 @@ const getAssetsData = async ({
assetPositions.map(async (asset, index) => {
const filterFile = path.join(downloadMap.audioMixing, `${index}.wav`);
const result = await preprocessAudioTrack({
- ffmpegExecutable: ffmpegExecutable ?? null,
- ffprobeExecutable: ffprobeExecutable ?? null,
outName: filterFile,
asset,
expectedFrames,
fps,
downloadMap,
- remotionRoot,
});
preprocessProgress[index] = 1;
updateProgress();
@@ -156,7 +145,6 @@ const getAssetsData = async ({
const outName = path.join(downloadMap.audioPreprocessing, `audio.wav`);
await mergeAudioTrack({
- ffmpegExecutable: ffmpegExecutable ?? null,
files: preprocessed,
outName,
numberOfSeconds: Number((expectedFrames / fps).toFixed(3)),
@@ -207,11 +195,6 @@ export const spawnFfmpeg = async (
Internals.validateFps(options.fps, 'in `stitchFramesToVideo()`', false);
const pixelFormat = options.pixelFormat ?? DEFAULT_PIXEL_FORMAT;
- await validateFfmpeg(
- options.ffmpegExecutable ?? null,
- remotionRoot,
- 'ffmpeg'
- );
const encoderName = getCodecName(codec);
const proResProfileName = getProResProfileName(codec, options.proResProfile);
@@ -246,10 +229,7 @@ export const spawnFfmpeg = async (
);
if (options.verbose) {
- console.log(
- '[verbose] ffmpeg',
- options.ffmpegExecutable ?? 'ffmpeg in PATH'
- );
+ console.log('[verbose] ffmpeg', getExecutablePath('ffmpeg'));
console.log('[verbose] encoder', encoderName);
console.log('[verbose] audioCodec', resolvedAudioCodec);
console.log('[verbose] pixelFormat', pixelFormat);
@@ -286,8 +266,6 @@ export const spawnFfmpeg = async (
fps: options.fps,
expectedFrames,
verbose: options.verbose ?? false,
- ffmpegExecutable: options.ffmpegExecutable ?? null,
- ffprobeExecutable: options.ffprobeExecutable ?? null,
onProgress: (prog) => updateProgress(prog, 0),
downloadMap: options.assetsInfo.downloadMap,
remotionRoot,
@@ -302,11 +280,7 @@ export const spawnFfmpeg = async (
}
const ffmpegTask = execa(
- await getExecutableBinary(
- options.ffmpegExecutable ?? null,
- remotionRoot,
- 'ffmpeg'
- ),
+ getExecutablePath('ffmpeg'),
[
'-i',
audio,
@@ -317,7 +291,8 @@ export const spawnFfmpeg = async (
options.audioBitrate ?? '320k',
options.force ? '-y' : null,
options.outputLocation ?? tempFile,
- ].filter(Internals.truthy)
+ ].filter(Internals.truthy),
+ {cwd: getExecutablePath('ffmpeg-cwd')}
);
options.cancelSignal?.(() => {
@@ -420,17 +395,10 @@ export const spawnFfmpeg = async (
console.log(finalFfmpegString);
}
- const task = execa(
- await getExecutableBinary(
- options.ffmpegExecutable ?? null,
- remotionRoot,
- 'ffmpeg'
- ),
- finalFfmpegString,
- {
- cwd: options.dir,
- }
- );
+ const task = execa(getExecutablePath('ffmpeg'), finalFfmpegString, {
+ // TODO: overriden from `options.dir`
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ });
options.cancelSignal?.(() => {
task.kill();
});
diff --git a/packages/renderer/src/test/extract-frame-from-video.test.ts b/packages/renderer/src/test/extract-frame-from-video.test.ts
index a8e1462f46..d1e2053c8d 100644
--- a/packages/renderer/src/test/extract-frame-from-video.test.ts
+++ b/packages/renderer/src/test/extract-frame-from-video.test.ts
@@ -15,8 +15,6 @@ const src = path.join(
test('Should be able to extract a frame from a video', async () => {
const str = await extractFrameFromVideo({
- ffmpegExecutable: null,
- ffprobeExecutable: null,
src,
time: 1,
imageFormat: 'jpeg',
@@ -29,8 +27,6 @@ test('Should be able to extract a frame from a video', async () => {
test('Should be able to extract a frame from a video as PNG', async () => {
const str = await extractFrameFromVideo({
- ffmpegExecutable: null,
- ffprobeExecutable: null,
src,
time: 1,
imageFormat: 'png',
@@ -43,8 +39,6 @@ test('Should be able to extract a frame from a video as PNG', async () => {
test('Should get the last frame if out of range', async () => {
const str = await extractFrameFromVideo({
- ffmpegExecutable: null,
- ffprobeExecutable: null,
src,
time: 100,
imageFormat: 'jpeg',
diff --git a/packages/renderer/src/test/get-audio-channels.test.ts b/packages/renderer/src/test/get-audio-channels.test.ts
index d78318eee5..ef36571b63 100644
--- a/packages/renderer/src/test/get-audio-channels.test.ts
+++ b/packages/renderer/src/test/get-audio-channels.test.ts
@@ -19,9 +19,7 @@ test('Get audio channels for video', async () => {
expect(existsSync(videoWithoutAudio)).toEqual(true);
const channels = await getAudioChannelsAndDuration(
downloadMap,
- videoWithoutAudio,
- null,
- process.cwd()
+ videoWithoutAudio
);
expect(channels).toEqual({channels: 2, duration: 10});
}, 90000);
@@ -41,9 +39,7 @@ test('Get audio channels for video without music', async () => {
expect(existsSync(videoWithAudio)).toEqual(true);
const channels = await getAudioChannelsAndDuration(
downloadMap,
- videoWithAudio,
- null,
- process.cwd()
+ videoWithAudio
);
expect(channels.channels).toEqual(0);
expect(channels.duration).toBeCloseTo(3.334, 2);
@@ -62,12 +58,7 @@ test('Get audio channels for video with music', async () => {
'sound1.mp3'
);
expect(existsSync(audio)).toEqual(true);
- const channels = await getAudioChannelsAndDuration(
- downloadMap,
- audio,
- null,
- process.cwd()
- );
+ const channels = await getAudioChannelsAndDuration(downloadMap, audio);
expect(channels).toEqual({channels: 2, duration: 56.529});
}, 90000);
@@ -76,6 +67,6 @@ test('Throw error if parsing a non video file', () => {
const tsFile = path.join(__dirname, '..', 'ffmpeg-flags.ts');
expect(existsSync(tsFile)).toEqual(true);
expect(() =>
- getAudioChannelsAndDuration(downloadMap, tsFile, null, process.cwd())
+ getAudioChannelsAndDuration(downloadMap, tsFile)
).rejects.toThrow(/Invalid data found when processing input/);
});
diff --git a/packages/renderer/src/test/get-last-frame-of-corrupted-video.test.ts b/packages/renderer/src/test/get-last-frame-of-corrupted-video.test.ts
index 86561c194b..0264e3627d 100644
--- a/packages/renderer/src/test/get-last-frame-of-corrupted-video.test.ts
+++ b/packages/renderer/src/test/get-last-frame-of-corrupted-video.test.ts
@@ -1,13 +1,10 @@
import path from 'path';
-import process from 'process';
import {test} from 'vitest';
import {makeDownloadMap} from '../assets/download-map';
import {getLastFrameOfVideo} from '../extract-frame-from-video';
test('Get last frame of corrupted video', async () => {
await getLastFrameOfVideo({
- ffmpegExecutable: null,
- ffprobeExecutable: null,
offset: 0,
src: path.join(
__dirname,
@@ -22,6 +19,5 @@ test('Get last frame of corrupted video', async () => {
specialVCodecForTransparency: 'none',
needsResize: null,
downloadMap: makeDownloadMap(),
- remotionRoot: process.cwd(),
});
}, 90000);
diff --git a/packages/renderer/src/test/guess-extension-for-media.test.ts b/packages/renderer/src/test/guess-extension-for-media.test.ts
index 7dfa258f8c..4a39ca21ea 100644
--- a/packages/renderer/src/test/guess-extension-for-media.test.ts
+++ b/packages/renderer/src/test/guess-extension-for-media.test.ts
@@ -13,8 +13,6 @@ test('Guess extension for media - H264', async () => {
'public',
'framermp4withoutfileextension'
),
- remotionRoot: process.cwd(),
- ffprobeBinary: null,
});
expect(extension).toBe('mp4');
@@ -31,8 +29,6 @@ test('Guess extension for media - WebM', async () => {
'public',
'framer.webm'
),
- remotionRoot: process.cwd(),
- ffprobeBinary: null,
});
expect(extension).toBe('webm');
@@ -49,8 +45,6 @@ test('Guess extension for media - WAV', async () => {
'public',
'22khz.wav'
),
- remotionRoot: process.cwd(),
- ffprobeBinary: null,
});
expect(extension).toBe('wav');
diff --git a/packages/renderer/src/test/last-frame-video-cache.test.ts b/packages/renderer/src/test/last-frame-video-cache.test.ts
index 42b78a91cd..8b9d9c7c3d 100644
--- a/packages/renderer/src/test/last-frame-video-cache.test.ts
+++ b/packages/renderer/src/test/last-frame-video-cache.test.ts
@@ -9,60 +9,50 @@ import {
setLastFrameInCache,
} from '../last-frame-from-video-cache';
-const makeKey = (
- id: string,
- downloadMap: DownloadMap,
- remotionRoot: string
-): LastFrameOptions => {
+const makeKey = (id: string, downloadMap: DownloadMap): LastFrameOptions => {
return {
- ffmpegExecutable: null,
- ffprobeExecutable: null,
offset: 10,
src: id,
imageFormat: 'jpeg',
specialVCodecForTransparency: 'none',
needsResize: null,
downloadMap,
- remotionRoot,
};
};
test('Last frame video cache', () => {
const downloadMap = makeDownloadMap();
- expect(getLastFrameFromCache(makeKey('1', downloadMap, process.cwd()))).toBe(
- null
- );
+ expect(getLastFrameFromCache(makeKey('1', downloadMap))).toBe(null);
const buf = crypto.randomBytes(10 * 1024 * 1024);
- setLastFrameInCache(makeKey('1', downloadMap, process.cwd()), buf);
- expect(
- getLastFrameFromCache(makeKey('1', downloadMap, process.cwd()))?.byteLength
- ).toBe(10 * 1024 * 1024);
- setLastFrameInCache(makeKey('2', downloadMap, process.cwd()), buf);
- setLastFrameInCache(makeKey('3', downloadMap, process.cwd()), buf);
- setLastFrameInCache(makeKey('4', downloadMap, process.cwd()), buf);
- setLastFrameInCache(makeKey('5', downloadMap, process.cwd()), buf);
- setLastFrameInCache(makeKey('6', downloadMap, process.cwd()), buf);
+ setLastFrameInCache(makeKey('1', downloadMap), buf);
+ expect(getLastFrameFromCache(makeKey('1', downloadMap))?.byteLength).toBe(
+ 10 * 1024 * 1024
+ );
+ setLastFrameInCache(makeKey('2', downloadMap), buf);
+ setLastFrameInCache(makeKey('3', downloadMap), buf);
+ setLastFrameInCache(makeKey('4', downloadMap), buf);
+ setLastFrameInCache(makeKey('5', downloadMap), buf);
+ setLastFrameInCache(makeKey('6', downloadMap), buf);
expect(
- getLastFrameFromCache(makeKey('1', downloadMap, process.cwd()))
- ?.byteLength ?? 0
+ getLastFrameFromCache(makeKey('1', downloadMap))?.byteLength ?? 0
).toBe(0);
- expect(
- getLastFrameFromCache(makeKey('2', downloadMap, process.cwd()))?.byteLength
- ).toBe(10 * 1024 * 1024);
- expect(
- getLastFrameFromCache(makeKey('3', downloadMap, process.cwd()))?.byteLength
- ).toBe(10 * 1024 * 1024);
- expect(
- getLastFrameFromCache(makeKey('4', downloadMap, process.cwd()))?.byteLength
- ).toBe(10 * 1024 * 1024);
- expect(
- getLastFrameFromCache(makeKey('5', downloadMap, process.cwd()))?.byteLength
- ).toBe(10 * 1024 * 1024);
- expect(
- getLastFrameFromCache(makeKey('6', downloadMap, process.cwd()))?.byteLength
- ).toBe(10 * 1024 * 1024);
+ expect(getLastFrameFromCache(makeKey('2', downloadMap))?.byteLength).toBe(
+ 10 * 1024 * 1024
+ );
+ expect(getLastFrameFromCache(makeKey('3', downloadMap))?.byteLength).toBe(
+ 10 * 1024 * 1024
+ );
+ expect(getLastFrameFromCache(makeKey('4', downloadMap))?.byteLength).toBe(
+ 10 * 1024 * 1024
+ );
+ expect(getLastFrameFromCache(makeKey('5', downloadMap))?.byteLength).toBe(
+ 10 * 1024 * 1024
+ );
+ expect(getLastFrameFromCache(makeKey('6', downloadMap))?.byteLength).toBe(
+ 10 * 1024 * 1024
+ );
clearLastFileCache(downloadMap);
});
diff --git a/packages/renderer/src/test/parse-ffmpeg-version.test.ts b/packages/renderer/src/test/parse-ffmpeg-version.test.ts
deleted file mode 100644
index a1a8fdd3f1..0000000000
--- a/packages/renderer/src/test/parse-ffmpeg-version.test.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import {expect, test} from 'vitest';
-import {parseFfmpegVersion} from '../ffmpeg-flags';
-
-test('Should parse a normal FFFMPEG version', () => {
- const buildconf = `
- ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
- built with Apple clang version 12.0.0 (clang-1200.0.32.28)
- configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_9 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack
- `;
- expect(parseFfmpegVersion(buildconf)).toEqual([4, 3, 1]);
-});
-
-test('Should return null if running a git version', () => {
- const buildconf = `
- ffmpeg -version
- ffmpeg version git-2020-08-31-4a11a6f Copyright (c) 2000-2020 the FFmpeg developers
- built with gcc 10.2.1 (GCC) 20200805
- configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr
- --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid
- --enable-libaom --enable-libgsm --enable-librav1e --enable-libsvtav1 --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
- `;
- expect(parseFfmpegVersion(buildconf)).toEqual(null);
-});
diff --git a/packages/renderer/src/try-to-extract-frame-of-video-fast.ts b/packages/renderer/src/try-to-extract-frame-of-video-fast.ts
index 7c63f76456..a39c40077f 100644
--- a/packages/renderer/src/try-to-extract-frame-of-video-fast.ts
+++ b/packages/renderer/src/try-to-extract-frame-of-video-fast.ts
@@ -4,22 +4,18 @@ import type {
NeedsResize,
SpecialVCodecForTransparency,
} from './assets/download-map';
+import {getExecutablePath} from './compositor/get-executable-path';
import {determineResizeParams} from './determine-resize-params';
import {determineVcodecFfmpegFlags} from './determine-vcodec-ffmpeg-flags';
-import type {FfmpegExecutable} from './ffmpeg-executable';
-import {getExecutableBinary} from './ffmpeg-flags';
import {truthy} from './truthy';
+
export const tryToExtractFrameOfVideoFast = async ({
- ffmpegExecutable,
- remotionRoot,
specialVCodecForTransparency,
imageFormat,
needsResize,
src,
actualOffset,
}: {
- ffmpegExecutable: FfmpegExecutable;
- remotionRoot: string;
imageFormat: OffthreadVideoImageFormat;
needsResize: NeedsResize;
src: string;
@@ -27,7 +23,7 @@ export const tryToExtractFrameOfVideoFast = async ({
actualOffset: string;
}) => {
const {stdout, stderr} = execa(
- await getExecutableBinary(ffmpegExecutable, remotionRoot, 'ffmpeg'),
+ getExecutablePath('ffmpeg'),
[
'-ss',
actualOffset,
@@ -42,7 +38,10 @@ export const tryToExtractFrameOfVideoFast = async ({
'image2pipe',
...determineResizeParams(needsResize),
'-',
- ].filter(truthy)
+ ].filter(truthy),
+ {
+ cwd: getExecutablePath('ffmpeg-cwd'),
+ }
);
if (!stderr) {
throw new Error('unexpectedly did not get stderr');
diff --git a/packages/renderer/src/validate-ffmpeg.ts b/packages/renderer/src/validate-ffmpeg.ts
deleted file mode 100644
index d2fb8c37e8..0000000000
--- a/packages/renderer/src/validate-ffmpeg.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-import execa from 'execa';
-import {existsSync, statSync} from 'fs';
-import os from 'os';
-import {
- downloadBinary,
- ffmpegInNodeModules,
- getBinaryDownloadUrl,
- getFfmpegBuildInfo,
- getFfmpegVersion,
- lambdaFfmpegPaths,
-} from './ffmpeg-flags';
-import {warnAboutFfmpegVersion} from './warn-about-ffmpeg-version';
-
-const existsMap: {[key: string]: boolean} = {};
-
-export const customExecutableExists = (localExecutable: string): boolean => {
- try {
- statSync(localExecutable);
- existsMap[localExecutable] = true;
- } catch (err) {
- existsMap[localExecutable] = false;
- }
-
- return existsMap[localExecutable];
-};
-
-export const binaryExists = (name: 'ffmpeg' | 'ffprobe') => {
- if (typeof existsMap[name] !== 'undefined') {
- return existsMap[name];
- }
-
- const isWin = os.platform() === 'win32';
- const where = isWin ? 'where' : 'which';
- try {
- execa.sync(where, [name]);
- existsMap[name] = true;
- return true;
- } catch (err) {
- existsMap[name] = false;
- return false;
- }
-};
-
-export const checkAndValidateFfmpegVersion = async (options: {
- ffmpegExecutable: string | null;
- remotionRoot: string;
-}) => {
- const ffmpegVersion = await getFfmpegVersion({
- ffmpegExecutable: options.ffmpegExecutable,
- remotionRoot: options.remotionRoot,
- });
- const buildConf = await getFfmpegBuildInfo({
- ffmpegExecutable: options.ffmpegExecutable,
- remotionRoot: options.remotionRoot,
- });
- warnAboutFfmpegVersion({ffmpegVersion, buildConf});
-};
-
-export const validateFfmpeg = async (
- customFfmpegBinary: string | null,
- remotionRoot: string,
- binary: 'ffmpeg' | 'ffprobe'
-): Promise<void> => {
- const ffmpegExists = binaryExists(binary);
- if (ffmpegExists) {
- return;
- }
-
- if (customFfmpegBinary) {
- if (!customExecutableExists(customFfmpegBinary)) {
- throw new Error(
- 'Custom FFmpeg executable not found: ' + customFfmpegBinary
- );
- }
-
- return;
- }
-
- if (process.platform === 'linux' && existsSync(lambdaFfmpegPaths[binary])) {
- return;
- }
-
- if (ffmpegInNodeModules(remotionRoot, binary)) {
- return;
- }
-
- const binaryUrl = getBinaryDownloadUrl(binary);
-
- if (binaryUrl) {
- await downloadBinary(remotionRoot, binaryUrl.url, binary);
- return validateFfmpeg(customFfmpegBinary, remotionRoot, binary);
- }
-
- throw new Error(
- `${binary} could not be installed automatically. Your architecture and OS combination (os = ${os.platform()}, arch = ${
- process.arch
- }) is not supported. Please install ${binary} manually and add "${binary}" to your PATH.`
- );
-};
diff --git a/packages/renderer/src/warn-about-ffmpeg-version.ts b/packages/renderer/src/warn-about-ffmpeg-version.ts
deleted file mode 100644
index 906db75697..0000000000
--- a/packages/renderer/src/warn-about-ffmpeg-version.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import type {FfmpegVersion} from './ffmpeg-flags';
-
-const printMessage = (ffmpegVersion: NonNullable<FfmpegVersion>) => {
- console.warn('⚠️Old FFMPEG version detected: ' + ffmpegVersion.join('.'));
- console.warn(' For audio support, you need at least version 4.1.0.');
- console.warn(' Upgrade FFMPEG to get rid of this warning.');
-};
-
-const printBuildConfMessage = () => {
- console.error('⚠️ Unsupported FFMPEG version detected.');
- console.error(" Your version doesn't support the -buildconf flag");
- console.error(
- ' Audio will not be supported and you may experience other issues.'
- );
- console.error(
- ' Upgrade FFMPEG to at least v4.1.0 to get rid of this warning.'
- );
-};
-
-export const warnAboutFfmpegVersion = ({
- ffmpegVersion,
- buildConf,
-}: {
- ffmpegVersion: FfmpegVersion;
- buildConf: string | null;
-}) => {
- if (buildConf === null) {
- printBuildConfMessage();
- return;
- }
-
- if (ffmpegVersion === null) {
- return null;
- }
-
- const [major, minor] = ffmpegVersion;
- // 3.x and below definitely is too old
- if (major < 4) {
- printMessage(ffmpegVersion);
- return;
- }
-
- // 5.x will be all good
- if (major > 4) {
- return;
- }
-
- if (minor < 1) {
- printMessage(ffmpegVersion);
- }
-};