From 98851a77cfedce8c0678f2fab72f4f7474e03172 Mon Sep 17 00:00:00 2001 From: vaultec <47548474+vaultec81@users.noreply.github.com> Date: Tue, 23 Mar 2021 22:37:06 -0700 Subject: [PATCH] fix: ffmpeg helper --- src/main/core/ffmpeg_helper.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/core/ffmpeg_helper.js b/src/main/core/ffmpeg_helper.js index 5d2afad..3967210 100644 --- a/src/main/core/ffmpeg_helper.js +++ b/src/main/core/ffmpeg_helper.js @@ -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 { @@ -19,19 +19,20 @@ 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)) { @@ -39,7 +40,6 @@ function GetFfmpegPath() { 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)); @@ -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 + '"';