From ffe54af8d9e5704af995b9c6111b9ec002cc147b 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 22:13:57 +0800 Subject: [PATCH] Fix addon path resolution and error handling Corrects the construction of the ffmpeg addon filename and improves error handling when the addon is not found. Also simplifies the isAvailable method by removing redundant existence checks. --- src/common/ffmpeg-addon-adapter.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/common/ffmpeg-addon-adapter.ts b/src/common/ffmpeg-addon-adapter.ts index 6d22c176..3494f5d8 100644 --- a/src/common/ffmpeg-addon-adapter.ts +++ b/src/common/ffmpeg-addon-adapter.ts @@ -20,9 +20,9 @@ function getAddonPath(binaryPath: string): string { const archName = arch(); 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}`); + let addonPath = path.join(binaryPath, "./native/ffmpeg/", `ffmpegAddon.${addonFileName}.node`); + if (!existsSync(addonPath)) { + throw new Error(`Unsupported platform: ${platformName} ${archName} - Addon not found at ${addonPath}`); } return addonPath; } @@ -44,12 +44,8 @@ export class FFmpegAddonAdapter implements IFFmpegAdapter { */ async isAvailable(): Promise { try { - const addonPath = getAddonPath(this.binaryPath); - if (!existsSync(addonPath)) { - return false; - } let temp_addon = { exports: {} }; - dlopen(temp_addon, addonPath); + dlopen(temp_addon, getAddonPath(this.binaryPath)); this.addon = temp_addon.exports as FFmpeg; return this.addon !== null; } catch (error) {