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).
This commit is contained in:
@@ -101,6 +101,7 @@ export class FFmpegExecAdapter implements IFFmpegAdapter {
|
||||
// 获取文件大小和类型
|
||||
const [fileType, duration] = await Promise.all([
|
||||
fileTypeFromFile(videoPath).catch(() => null),
|
||||
this.getDuration(videoPath).catch(() => 60),
|
||||
]);
|
||||
|
||||
// 创建临时缩略图路径
|
||||
|
||||
Reference in New Issue
Block a user