Skip to content

Commit

Permalink
fix: ffmpeg helper
Browse files Browse the repository at this point in the history
  • Loading branch information
vaultec81 committed Mar 24, 2021
1 parent ee1abf2 commit 98851a7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/core/ffmpeg_helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var os = require('os');
var fs = require('fs');
var path = require('path').posix;
var path = require('path');
var appRoot = require('app-root-path');
function verifyFile(file) {
try {
Expand All @@ -19,27 +19,27 @@ function GetFfmpegPath() {
throw 'Unsupported platform/architecture: ' + platform;
}


var appRootPath = appRoot.path;//.split(require('path').sep).join(path.posix.sep);

var binary = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';

var topLevelPath = path.resolve(__dirname.substr(0, __dirname.indexOf('node_modules')), 'node_modules', '@ffmpeg-installer', platform);
var npm3Path = path.resolve(appRoot.path, '..', platform);
var npm2Path = path.resolve(appRoot.path, 'node_modules', '@ffmpeg-installer', platform);
var npm4Path = path.resolve(appRoot.path, '..', 'node_modules', '@ffmpeg-installer', platform);
var topLevelPath = path.resolve(appRootPath.substr(0, appRootPath.indexOf('node_modules')), 'node_modules', '@ffmpeg-installer', platform);
var npm3Path = path.resolve(appRootPath, '..', platform);
var npm2Path = path.resolve(appRootPath, 'node_modules', '@ffmpeg-installer', platform);
var npm4Path = path.resolve(appRootPath, '..', 'node_modules', '@ffmpeg-installer', platform);

var topLevelBinary = path.join(topLevelPath, binary);
var npm3Binary = path.join(npm3Path, binary);
var npm2Binary = path.join(npm2Path, binary);
var npm4Binary = path.resolve(npm4Path, binary);

var npm4Binary = path.join(npm4Path, binary);
var ffmpegPath, packageJson;

if (verifyFile(npm3Binary)) {
ffmpegPath = npm3Binary;
var topLevelPackage = `${npm3Path}/package.json`
packageJson = JSON.parse(fs.readFileSync(topLevelPackage));
} else if (verifyFile(npm2Binary)) {
console.log(npm2Binary)
ffmpegPath = npm2Binary;
var topLevelPackage = `${npm2Path}/package.json`
packageJson = JSON.parse(fs.readFileSync(topLevelPackage));
Expand All @@ -49,7 +49,7 @@ function GetFfmpegPath() {
packageJson = JSON.parse(fs.readFileSync(topLevelPackage));
} else if (verifyFile(npm4Binary)) {
ffmpegPath = npm4Binary;
var topLevelPackage = `${npm4Binary}/package.json`
var topLevelPackage = `${npm4Path}/package.json`
packageJson = JSON.parse(fs.readFileSync(topLevelPackage)); //Fix for webpack in production
} else {
throw 'Could not find ffmpeg executable, tried "' + npm4Binary + '", "' + npm3Binary + '", "' + npm2Binary + '" and "' + topLevelBinary + '"';
Expand Down

0 comments on commit 98851a7

Please sign in to comment.