import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamDuration } from '@server/helpers/ffmpeg'
import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
-import { cleanupNormalLive, cleanupPermanentLive, cleanupTMPLiveFiles, LiveSegmentShaStore } from '@server/lib/live'
+import { cleanupUnsavedNormalLive, cleanupPermanentLive, cleanupTMPLiveFiles, LiveSegmentShaStore } from '@server/lib/live'
import {
generateHLSMasterPlaylistFilename,
generateHlsSha256SegmentsFilename,
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@server/types/models'
import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
-import { logger } from '../../../helpers/logger'
+import { logger, loggerTagsFactory } from '../../../helpers/logger'
+
+const lTags = loggerTagsFactory('live', 'job')
async function processVideoLiveEnding (job: Job) {
const payload = job.data as VideoLiveEndingPayload
- logger.info('Processing video live ending for %s.', payload.videoId, { payload })
+ logger.info('Processing video live ending for %s.', payload.videoId, { payload, ...lTags() })
function logError () {
- logger.warn('Video live %d does not exist anymore. Cannot process live ending.', payload.videoId)
+ logger.warn('Video live %d does not exist anymore. Cannot process live ending.', payload.videoId, lTags())
}
const liveVideo = await VideoModel.load(payload.videoId)
LiveSegmentShaStore.Instance.cleanupShaSegments(liveVideo.uuid)
if (live.saveReplay !== true) {
- return cleanupLiveAndFederate({ live, video: liveVideo })
+ return cleanupLiveAndFederate({ live, video: liveVideo, streamingPlaylistId: payload.streamingPlaylistId })
}
if (live.permanentLive) {
await saveReplayToExternalVideo({ liveVideo, liveSession, publishedAt: payload.publishedAt, replayDirectory: payload.replayDirectory })
- return cleanupLiveAndFederate({ live, video: liveVideo })
+ return cleanupLiveAndFederate({ live, video: liveVideo, streamingPlaylistId: payload.streamingPlaylistId })
}
return replaceLiveByReplay({ liveVideo, live, liveSession, replayDirectory: payload.replayDirectory })
}) {
const { liveVideo, liveSession, publishedAt, replayDirectory } = options
- await cleanupTMPLiveFiles(getLiveDirectory(liveVideo))
-
const video = new VideoModel({
name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`,
isLive: false,
async function cleanupLiveAndFederate (options: {
live: MVideoLive
video: MVideo
+ streamingPlaylistId: number
}) {
- const { live, video } = options
+ const { live, video, streamingPlaylistId } = options
- const streamingPlaylist = await VideoStreamingPlaylistModel.loadHLSPlaylistByVideo(video.id)
+ const streamingPlaylist = await VideoStreamingPlaylistModel.loadWithVideo(streamingPlaylistId)
- if (live.permanentLive) {
- await cleanupPermanentLive(video, streamingPlaylist)
- } else {
- await cleanupNormalLive(video, streamingPlaylist)
+ if (streamingPlaylist) {
+ if (live.permanentLive) {
+ await cleanupPermanentLive(video, streamingPlaylist)
+ } else {
+ await cleanupUnsavedNormalLive(video, streamingPlaylist)
+ }
}
try {