Support uploads of videos with unknown duration

pull/4903/head
Chocobozzz 2022-04-19 11:20:10 +02:00
parent acc6a1cba7
commit f692fc8d6f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 5 additions and 4 deletions

View File

@ -646,9 +646,10 @@ export async function isVideoAccepted (
} }
async function addDurationToVideo (videoFile: { path: string, duration?: number }) { 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`) // FFmpeg may not be able to guess video duration
// For example with m2v files: https://trac.ffmpeg.org/ticket/9726#comment:2
videoFile.duration = duration if (isNaN(duration)) videoFile.duration = 0
else videoFile.duration = duration
} }