Skip to content

🎥 Make videos programmatically with React

fix CWD, at least on macos

Jonny Burger4149ef9139f3
diff --git a/packages/cli/src/ffmpeg.ts b/packages/cli/src/ffmpeg.ts
index fda79aa3c3..1e67f2aed5 100644
--- a/packages/cli/src/ffmpeg.ts
+++ b/packages/cli/src/ffmpeg.ts
@@ -1,9 +1,31 @@
+import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import {spawnSync} from 'node:child_process';
import {chmodSync} from 'node:fs';
import path from 'node:path';
import {ConfigInternals} from './config';
+export const dynamicLibEnv = (indent: boolean, logLevel: LogLevel) => {
+ const lib = path.dirname(
+ RenderInternals.getExecutablePath('compositor', indent, logLevel),
+ );
+
+ return {
+ RUST_BACKTRACE: 'full',
+ ...(process.platform === 'darwin'
+ ? {
+ DYLD_LIBRARY_PATH: lib,
+ }
+ : process.platform === 'win32'
+ ? {
+ PATH: `${lib};${process.env.PATH}`,
+ }
+ : {
+ LD_LIBRARY_PATH: lib,
+ }),
+ };
+};
+
export const ffmpegCommand = (_root: string, args: string[]) => {
const logLevel = ConfigInternals.Logging.getLogLevel();
@@ -13,8 +35,8 @@ export const ffmpegCommand = (_root: string, args: string[]) => {
}
const done = spawnSync(binary, args, {
- cwd: path.dirname(binary),
stdio: 'inherit',
+ env: dynamicLibEnv(false, logLevel),
});
process.exit(done.status as number);
};
@@ -30,6 +52,7 @@ export const ffprobeCommand = (_root: string, args: string[]) => {
const done = spawnSync(binary, args, {
cwd: path.dirname(binary),
stdio: 'inherit',
+ env: dynamicLibEnv(false, logLevel),
});
process.exit(done.status as number);
};