]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/videos/videos.ts
store uploaded video filename (#4885)
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / videos / videos.ts
index 26597cf7b7865662b3a73b9fc5671a24230f9c59..c75c3640bef2ca2244b1dc6f0f51b833b1c5194a 100644 (file)
@@ -152,7 +152,7 @@ const videosAddResumableValidator = [
 
     if (!await isVideoAccepted(req, res, file)) return cleanup()
 
-    res.locals.videoFileResumable = file
+    res.locals.videoFileResumable = { ...file, originalname: file.filename }
 
     return next()
   }
@@ -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
 }