import { app } from 'electron' import fs from 'node:fs' import path from 'node:path' export function resolveFfmpegPath(): string { const envPath = process.env.FFMPEG_PATH?.trim() if (envPath) return envPath const exe = process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg' const bundledPath = path.join(process.resourcesPath, 'bin', process.platform, exe) if (isUsableBinary(bundledPath)) return bundledPath return 'ffmpeg' } export function missingFfmpegMessage(): string { if (app.isPackaged) { return 'ffmpeg is not bundled with this RUWIO build, or it cannot be executed. Install ffmpeg or set FFMPEG_PATH to export MP4.' } return 'ffmpeg was not found. Install ffmpeg or set FFMPEG_PATH to export MP4.' } function isUsableBinary(file: string): boolean { try { fs.accessSync(file, process.platform === 'win32' ? fs.constants.F_OK : fs.constants.X_OK) return true } catch { return false } }