Fix ffmpeg linux
This commit is contained in:
@ -52,13 +52,19 @@ async function checkFFmpeg() {
|
||||
const basePath = app.isPackaged
|
||||
? process.resourcesPath
|
||||
: join(__dirname, '..');
|
||||
const ffmpegPath = join(basePath, 'ffmpeg', 'bin', process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg');
|
||||
console.log(`[Main] Checking for FFmpeg at: ${ffmpegPath}`); // Add log
|
||||
|
||||
// Determine the correct subdirectory based on platform
|
||||
const platformBinDir = process.platform === 'win32' ? 'bin' : 'linux_bin';
|
||||
const ffmpegBinaryName = process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
|
||||
|
||||
const ffmpegPath = join(basePath, 'ffmpeg', platformBinDir, ffmpegBinaryName);
|
||||
|
||||
console.log(`[Main] Checking for FFmpeg at: ${ffmpegPath}`);
|
||||
await fs.promises.access(ffmpegPath);
|
||||
console.log('[Main] FFmpeg found.'); // Add log
|
||||
console.log('[Main] FFmpeg found.');
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('[Main] FFmpeg check failed:', error); // Add log
|
||||
console.error('[Main] FFmpeg check failed:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -209,16 +215,23 @@ async function getFFmpegPath() {
|
||||
const basePath = app.isPackaged
|
||||
? process.resourcesPath
|
||||
: join(__dirname, '..');
|
||||
const ffmpegPath = join(basePath, 'ffmpeg', 'bin', process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg');
|
||||
|
||||
// Determine the correct subdirectory and binary name based on platform
|
||||
const platformBinDir = process.platform === 'win32' ? 'bin' : 'linux_bin';
|
||||
const ffmpegBinaryName = process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
|
||||
const ffprobeBinaryName = process.platform === 'win32' ? 'ffprobe.exe' : 'ffprobe'; // Also need ffprobe path
|
||||
|
||||
const ffmpegPath = join(basePath, 'ffmpeg', platformBinDir, ffmpegBinaryName);
|
||||
|
||||
// Check access again to be sure
|
||||
try {
|
||||
await fs.promises.access(ffmpegPath);
|
||||
console.log('[Main] Found FFmpeg path for execution:', ffmpegPath);
|
||||
return ffmpegPath;
|
||||
// Return object with both paths, or just ffmpeg path?
|
||||
// Let's return just ffmpeg path for now, processAudioFile needs update
|
||||
return ffmpegPath;
|
||||
} catch (accessError) {
|
||||
console.error('[Main] FFmpeg not accessible at expected path:', ffmpegPath, accessError);
|
||||
// Attempt fallback or throw error? For now, return null
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
@ -230,10 +243,24 @@ async function getFFmpegPath() {
|
||||
// Process audio file with ffmpeg to ensure proper metadata
|
||||
async function processAudioFile(inputPath, outputPath, email) {
|
||||
try {
|
||||
// Check if FFmpeg is installed
|
||||
// Check if FFmpeg is installed (this implicitly gets the path now)
|
||||
const ffmpegPath = await getFFmpegPath();
|
||||
if (!ffmpegPath) {
|
||||
throw new Error('FFmpeg is not installed');
|
||||
throw new Error('FFmpeg executable not found or not accessible.');
|
||||
}
|
||||
|
||||
// Determine platform-specific paths for ffprobe
|
||||
const platformBinDir = process.platform === 'win32' ? 'bin' : 'linux_bin';
|
||||
const ffprobeBinaryName = process.platform === 'win32' ? 'ffprobe.exe' : 'ffprobe';
|
||||
// Construct ffprobe path relative to ffmpeg path or base path
|
||||
const ffprobePath = join(path.dirname(ffmpegPath), ffprobeBinaryName);
|
||||
// Verify ffprobe exists too
|
||||
try {
|
||||
await fs.promises.access(ffprobePath);
|
||||
console.log('[Main] Found FFprobe path for execution:', ffprobePath);
|
||||
} catch (ffprobeAccessError) {
|
||||
console.error('[Main] FFprobe not accessible at expected path:', ffprobePath, ffprobeAccessError);
|
||||
throw new Error('FFprobe executable not found or not accessible.');
|
||||
}
|
||||
|
||||
// Get current date in ISO format
|
||||
@ -260,7 +287,7 @@ async function processAudioFile(inputPath, outputPath, email) {
|
||||
|
||||
console.log('Running FFmpeg command:', ffmpegCommand.join(' '));
|
||||
|
||||
// Run FFmpeg command
|
||||
// Run FFmpeg command using the found path
|
||||
await new Promise((resolve, reject) => {
|
||||
const ffmpeg = spawn(ffmpegPath, ffmpegCommand);
|
||||
|
||||
@ -293,8 +320,7 @@ async function processAudioFile(inputPath, outputPath, email) {
|
||||
throw new Error('FFmpeg produced an empty file');
|
||||
}
|
||||
|
||||
// Verify metadata using FFprobe
|
||||
const ffprobePath = path.join(path.dirname(ffmpegPath), process.platform === 'win32' ? 'ffprobe.exe' : 'ffprobe');
|
||||
// Verify metadata using FFprobe using the found path
|
||||
const ffprobeCommand = [
|
||||
'-v', 'error',
|
||||
'-show_entries', 'format_tags',
|
||||
|
BIN
ffmpeg/linux_bin/ffmpeg
Normal file
BIN
ffmpeg/linux_bin/ffmpeg
Normal file
Binary file not shown.
BIN
ffmpeg/linux_bin/ffplay
Normal file
BIN
ffmpeg/linux_bin/ffplay
Normal file
Binary file not shown.
BIN
ffmpeg/linux_bin/ffprobe
Normal file
BIN
ffmpeg/linux_bin/ffprobe
Normal file
Binary file not shown.
Reference in New Issue
Block a user