From 0ae05ccb8d83641db18763a7fecceabcdee2e1e9 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: Fri, 13 Mar 2026 19:48:31 +0800 Subject: [PATCH] Use default duration if getDuration fails Add a fallback for video duration by including this.getDuration(videoPath).catch(() => 60) in the Promise.all alongside fileTypeFromFile. This prevents Promise.all from rejecting when duration retrieval fails and supplies a sensible default (60s) for downstream processing (e.g., thumbnail generation). --- packages/napcat-core/helper/ffmpeg/ffmpeg-exec-adapter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/napcat-core/helper/ffmpeg/ffmpeg-exec-adapter.ts b/packages/napcat-core/helper/ffmpeg/ffmpeg-exec-adapter.ts index ff04b273..3eb0fe27 100644 --- a/packages/napcat-core/helper/ffmpeg/ffmpeg-exec-adapter.ts +++ b/packages/napcat-core/helper/ffmpeg/ffmpeg-exec-adapter.ts @@ -101,6 +101,7 @@ export class FFmpegExecAdapter implements IFFmpegAdapter { // 获取文件大小和类型 const [fileType, duration] = await Promise.all([ fileTypeFromFile(videoPath).catch(() => null), + this.getDuration(videoPath).catch(() => 60), ]); // 创建临时缩略图路径