import * as Bull from 'bull'
import { readdir, remove } from 'fs-extra'
import { join } from 'path'
-import { getDurationFromVideoFile, getVideoFileResolution, hlsPlaylistToFragmentedMP4 } from '@server/helpers/ffmpeg-utils'
+import { hlsPlaylistToFragmentedMP4 } from '@server/helpers/ffmpeg-utils'
+import { getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils'
+import { generateVideoMiniature } from '@server/lib/thumbnail'
import { publishAndFederateIfNeeded } from '@server/lib/video'
import { getHLSDirectory } from '@server/lib/video-paths'
import { generateHlsPlaylist } from '@server/lib/video-transcoding'
import { VideoLiveModel } from '@server/models/video/video-live'
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models'
-import { VideoLiveEndingPayload, VideoState } from '@shared/models'
+import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
import { logger } from '../../../helpers/logger'
async function processVideoLiveEnding (job: Bull.Job) {
const segmentFiles = files.filter(f => f.startsWith(shouldStartWith) && f.endsWith('.ts'))
await hlsPlaylistToFragmentedMP4(hlsDirectory, segmentFiles, mp4TmpPath)
- for (const file of segmentFiles) {
- await remove(join(hlsDirectory, file))
- }
-
if (!duration) {
duration = await getDurationFromVideoFile(mp4TmpPath)
}
await live.destroy()
video.isLive = false
+ // Reinit views
+ video.views = 0
video.state = VideoState.TO_TRANSCODE
video.duration = duration
await remove(videoInputPath)
}
+ // Regenerate the thumbnail & preview?
+ if (videoWithFiles.getMiniature().automaticallyGenerated === true) {
+ await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.MINIATURE)
+ }
+
+ if (videoWithFiles.getPreview().automaticallyGenerated === true) {
+ await generateVideoMiniature(videoWithFiles, videoWithFiles.getMaxQualityFile(), ThumbnailType.PREVIEW)
+ }
+
await publishAndFederateIfNeeded(video, true)
}
async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
- const hlsDirectory = getHLSDirectory(video, false)
+ const hlsDirectory = getHLSDirectory(video)
await remove(hlsDirectory)