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