From: Chocobozzz Date: Thu, 3 Dec 2020 08:38:24 +0000 (+0100) Subject: Fix live invalid save replay duration X-Git-Tag: v3.0.0-rc.1~171 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=4a54a93941d1c095bf249331df799c51e39c3774;hp=09c55770bcc96785fb1f199b4cd8ce66b545486a;p=github%2FChocobozzz%2FPeerTube.git Fix live invalid save replay duration --- diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts index 1cf397767..4dea6283c 100644 --- a/server/helpers/ffprobe-utils.ts +++ b/server/helpers/ffprobe-utils.ts @@ -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) { diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 55bee0b83..d3c84ce75 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts @@ -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) {