From 7ac7488d549e1ec180a5ba45a4775569d9ab03e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 30 Oct 2025 11:29:54 +0800 Subject: [PATCH] Refactor addon path resolution and rename Windows addon Simplifies the logic for resolving the ffmpeg addon path by dynamically constructing the filename from process.platform and process.arch. Also renames the Windows x64 addon file to ffmpegAddon.win32.x64.node for consistency. --- src/common/ffmpeg-addon-adapter.ts | 16 ++++------------ ....win.x64.node => ffmpegAddon.win32.x64.node} | Bin 2 files changed, 4 insertions(+), 12 deletions(-) rename src/native/ffmpeg/{ffmpegAddon.win.x64.node => ffmpegAddon.win32.x64.node} (100%) diff --git a/src/common/ffmpeg-addon-adapter.ts b/src/common/ffmpeg-addon-adapter.ts index a906d6e1..19b85562 100644 --- a/src/common/ffmpeg-addon-adapter.ts +++ b/src/common/ffmpeg-addon-adapter.ts @@ -19,20 +19,12 @@ function getAddonPath(binaryPath: string): string { const platformName = platform(); const archName = arch(); - let addonFileName: string; - - if (platformName === 'win32' && archName === 'x64') { - addonFileName = 'ffmpegAddon.win.x64.node'; - } else if (platformName === 'linux' && archName === 'x64') { - addonFileName = 'ffmpegAddon.linux.x64.node'; - } else if (platformName === 'linux' && archName === 'arm64') { - addonFileName = 'ffmpegAddon.linux.arm64.node'; - } else if (platformName === 'darwin' && archName === 'arm64') { - addonFileName = 'ffmpegAddon.darwin.arm64.node'; - } else { + let addonFileName: string = process.platform + '.' + process.arch; + let addonPath = path.join(binaryPath, "./native/ffmpeg/", `${addonFileName}.node`); + if (existsSync(addonPath)) { throw new Error(`Unsupported platform: ${platformName} ${archName}`); } - return path.join(binaryPath, "./native/ffmpeg/", addonFileName); + return addonPath; } /** diff --git a/src/native/ffmpeg/ffmpegAddon.win.x64.node b/src/native/ffmpeg/ffmpegAddon.win32.x64.node similarity index 100% rename from src/native/ffmpeg/ffmpegAddon.win.x64.node rename to src/native/ffmpeg/ffmpegAddon.win32.x64.node