From f692fc8d6f186c0535599c5c2321d896e41bdb98 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Apr 2022 11:20:10 +0200 Subject: [PATCH] Support uploads of videos with unknown duration --- server/middlewares/validators/videos/videos.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 26597cf7b..0b6b8bfe5 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -646,9 +646,10 @@ export async function isVideoAccepted ( } async function addDurationToVideo (videoFile: { path: string, duration?: number }) { - const duration: number = await getVideoStreamDuration(videoFile.path) + const duration = await getVideoStreamDuration(videoFile.path) - if (isNaN(duration)) throw new Error(`Couldn't get video duration`) - - videoFile.duration = duration + // FFmpeg may not be able to guess video duration + // For example with m2v files: https://trac.ffmpeg.org/ticket/9726#comment:2 + if (isNaN(duration)) videoFile.duration = 0 + else videoFile.duration = duration } -- 2.41.0