Skip to content

The swiss army knife of lossless video/audio editing

add LD_LIBRARY_PATH on linux

Mikael Finstad759570ea8fc0
diff --git a/public/ffmpeg.js b/public/ffmpeg.js
index 17bbde3d..3815b57b 100644
--- a/public/ffmpeg.js
+++ b/public/ffmpeg.js
@@ -3,7 +3,7 @@ const isDev = require('electron-is-dev');
const readline = require('readline');
const stringToStream = require('string-to-stream');
-const { platform, arch, isWindows, isMac } = require('./util');
+const { platform, arch, isWindows, isMac, isLinux } = require('./util');
const execaPromise = import('execa');
@@ -88,11 +88,18 @@ function handleProgress(process, durationIn, onProgress, customMatcher = () => {
});
}
+function getExecaOptions({ env, ...customExecaOptions } = {}) {
+ const execaOptions = { ...customExecaOptions, env: { ...env } };
+ // https://github.com/mifi/lossless-cut/issues/1143#issuecomment-1500883489
+ if (isLinux && !isDev && !customFfPath) execaOptions.env.LD_LIBRARY_PATH = process.resourcesPath;
+}
+
// todo collect warnings from ffmpeg output and show them after export? example: https://github.com/mifi/lossless-cut/issues/1469
-function runFfmpegProcess(args, execaOptions, { logCli = true } = {}) {
+function runFfmpegProcess(args, customExecaOptions, { logCli = true } = {}) {
const ffmpegPath = getFfmpegPath();
if (logCli) console.log(getFfCommandLine('ffmpeg', args));
- const process = execa(ffmpegPath, args, execaOptions);
+
+ const process = execa(ffmpegPath, args, getExecaOptions(customExecaOptions));
(async () => {
runningFfmpegs.add(process);
@@ -126,7 +133,7 @@ async function runFfmpegWithProgress({ ffmpegArgs, duration, onProgress }) {
async function runFfprobe(args, { timeout = isDev ? 10000 : 30000 } = {}) {
const ffprobePath = getFfprobePath();
console.log(getFfCommandLine('ffprobe', args));
- const ps = execa(ffprobePath, args);
+ const ps = execa(ffprobePath, args, getExecaOptions());
const timer = setTimeout(() => {
console.warn('killing timed out ffprobe');
ps.kill();
diff --git a/public/util.js b/public/util.js
index 94056679..eb11f816 100644
--- a/public/util.js
+++ b/public/util.js
@@ -2,17 +2,19 @@ const os = require('os');
const frontendBuildDir = 'vite-dist';
-// todo dedupe between renderer and main
const platform = os.platform();
const arch = os.arch();
+// todo dedupe between renderer and main
const isWindows = platform === 'win32';
const isMac = platform === 'darwin';
+const isLinux = platform === 'linux';
module.exports = {
frontendBuildDir,
isWindows,
isMac,
+ isLinux,
platform,
arch,
};