diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-03 09:38:24 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-12-03 10:05:10 +0100 |
commit | 4a54a93941d1c095bf249331df799c51e39c3774 (patch) | |
tree | 3a2b2958bf6f845e375790818ec475a1cb2dc23c /server | |
parent | 09c55770bcc96785fb1f199b4cd8ce66b545486a (diff) | |
download | PeerTube-4a54a93941d1c095bf249331df799c51e39c3774.tar.gz PeerTube-4a54a93941d1c095bf249331df799c51e39c3774.tar.zst PeerTube-4a54a93941d1c095bf249331df799c51e39c3774.zip |
Fix live invalid save replay duration
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/ffprobe-utils.ts | 2 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-live-ending.ts | 8 |
2 files changed, 6 insertions, 4 deletions
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 | |||
164 | async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) { | 164 | async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) { |
165 | const metadata = await getMetadataFromFile(path, existingProbe) | 165 | const metadata = await getMetadataFromFile(path, existingProbe) |
166 | 166 | ||
167 | return Math.floor(metadata.format.duration) | 167 | return Math.round(metadata.format.duration) |
168 | } | 168 | } |
169 | 169 | ||
170 | async function getVideoStreamFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) { | 170 | 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) { | |||
89 | hlsPlaylist.VideoFiles = [] | 89 | hlsPlaylist.VideoFiles = [] |
90 | 90 | ||
91 | const replayFiles = await readdir(replayDirectory) | 91 | const replayFiles = await readdir(replayDirectory) |
92 | let duration: number | 92 | let durationDone: boolean |
93 | 93 | ||
94 | for (const playlistFile of playlistFiles) { | 94 | for (const playlistFile of playlistFiles) { |
95 | const playlistPath = join(replayDirectory, playlistFile) | 95 | const playlistPath = join(replayDirectory, playlistFile) |
@@ -109,9 +109,11 @@ async function saveLive (video: MVideo, live: MVideoLive) { | |||
109 | isPortraitMode | 109 | isPortraitMode |
110 | }) | 110 | }) |
111 | 111 | ||
112 | if (!duration) { | 112 | if (!durationDone) { |
113 | videoWithFiles.duration = await getDurationFromVideoFile(outputPath) | 113 | videoWithFiles.duration = await getDurationFromVideoFile(outputPath) |
114 | await videoWithFiles.save() | 114 | await videoWithFiles.save() |
115 | |||
116 | durationDone = true | ||
115 | } | 117 | } |
116 | } | 118 | } |
117 | 119 | ||
@@ -126,7 +128,7 @@ async function saveLive (video: MVideo, live: MVideoLive) { | |||
126 | await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.PREVIEW) | 128 | await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.PREVIEW) |
127 | } | 129 | } |
128 | 130 | ||
129 | await publishAndFederateIfNeeded(video, true) | 131 | await publishAndFederateIfNeeded(videoWithFiles, true) |
130 | } | 132 | } |
131 | 133 | ||
132 | async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { | 134 | async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { |