]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix live invalid save replay duration
authorChocobozzz <me@florianbigard.com>
Thu, 3 Dec 2020 08:38:24 +0000 (09:38 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 3 Dec 2020 09:05:10 +0000 (10:05 +0100)
server/helpers/ffprobe-utils.ts
server/lib/job-queue/handlers/video-live-ending.ts

index 1cf397767e807a2ce06947ecdca5b793524afeb3..4dea6283cc060725f53e0b1a09966277e6e760d1 100644 (file)
@@ -164,7 +164,7 @@ async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.Ffprobe
 async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
   const metadata = await getMetadataFromFile(path, existingProbe)
 
-  return Math.floor(metadata.format.duration)
+  return Math.round(metadata.format.duration)
 }
 
 async function getVideoStreamFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
index 55bee0b838b52d3fadae28616df44f90fa5ec3ab..d3c84ce75d6c170c6ada2cec89b79f2b4b2624e0 100644 (file)
@@ -89,7 +89,7 @@ async function saveLive (video: MVideo, live: MVideoLive) {
   hlsPlaylist.VideoFiles = []
 
   const replayFiles = await readdir(replayDirectory)
-  let duration: number
+  let durationDone: boolean
 
   for (const playlistFile of playlistFiles) {
     const playlistPath = join(replayDirectory, playlistFile)
@@ -109,9 +109,11 @@ async function saveLive (video: MVideo, live: MVideoLive) {
       isPortraitMode
     })
 
-    if (!duration) {
+    if (!durationDone) {
       videoWithFiles.duration = await getDurationFromVideoFile(outputPath)
       await videoWithFiles.save()
+
+      durationDone = true
     }
   }
 
@@ -126,7 +128,7 @@ async function saveLive (video: MVideo, live: MVideoLive) {
     await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.PREVIEW)
   }
 
-  await publishAndFederateIfNeeded(video, true)
+  await publishAndFederateIfNeeded(videoWithFiles, true)
 }
 
 async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {