Fix live invalid save replay duration
This commit is contained in:
parent
09c55770bc
commit
4a54a93941
|
@ -164,7 +164,7 @@ async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.Ffprobe
|
||||||
async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||||
const metadata = await getMetadataFromFile(path, existingProbe)
|
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) {
|
async function getVideoStreamFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ async function saveLive (video: MVideo, live: MVideoLive) {
|
||||||
hlsPlaylist.VideoFiles = []
|
hlsPlaylist.VideoFiles = []
|
||||||
|
|
||||||
const replayFiles = await readdir(replayDirectory)
|
const replayFiles = await readdir(replayDirectory)
|
||||||
let duration: number
|
let durationDone: boolean
|
||||||
|
|
||||||
for (const playlistFile of playlistFiles) {
|
for (const playlistFile of playlistFiles) {
|
||||||
const playlistPath = join(replayDirectory, playlistFile)
|
const playlistPath = join(replayDirectory, playlistFile)
|
||||||
|
@ -109,9 +109,11 @@ async function saveLive (video: MVideo, live: MVideoLive) {
|
||||||
isPortraitMode
|
isPortraitMode
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!duration) {
|
if (!durationDone) {
|
||||||
videoWithFiles.duration = await getDurationFromVideoFile(outputPath)
|
videoWithFiles.duration = await getDurationFromVideoFile(outputPath)
|
||||||
await videoWithFiles.save()
|
await videoWithFiles.save()
|
||||||
|
|
||||||
|
durationDone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +128,7 @@ async function saveLive (video: MVideo, live: MVideoLive) {
|
||||||
await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.PREVIEW)
|
await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.PREVIEW)
|
||||||
}
|
}
|
||||||
|
|
||||||
await publishAndFederateIfNeeded(video, true)
|
await publishAndFederateIfNeeded(videoWithFiles, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
|
async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
|
||||||
|
|
Loading…
Reference in New Issue