From 8a61f5a03f40351066f6c9acf5288130d24ddc81 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: Sat, 9 Nov 2024 12:22:28 +0800 Subject: [PATCH] fix: #503 --- src/core/apis/file.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts index 122fa946..9f9ae2ea 100644 --- a/src/core/apis/file.ts +++ b/src/core/apis/file.ts @@ -175,14 +175,18 @@ export class NTQQFileApi { const thumbPath = pathLib.join(thumb, thumbFileName); ffmpeg(filePath) .on('error', (err) => { - logger.logDebug('获取视频封面失败,使用默认封面', err); - if (diyThumbPath) { - fsPromises.copyFile(diyThumbPath, thumbPath).then(() => { + try { + logger.logDebug('获取视频封面失败,使用默认封面', err); + if (diyThumbPath) { + fsPromises.copyFile(diyThumbPath, thumbPath).then(() => { + resolve(thumbPath); + }).catch(reject); + } else { + fs.writeFileSync(thumbPath, Buffer.from(defaultVideoThumbB64, 'base64')); resolve(thumbPath); - }).catch(reject); - } else { - fs.writeFileSync(thumbPath, Buffer.from(defaultVideoThumbB64, 'base64')); - resolve(thumbPath); + } + } catch (error) { + logger.logError.bind(logger)('获取视频封面失败,使用默认封面失败', error); } }) .screenshots({