From 53023be33af420675d0060eb95c99a8038457564 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 23 Jun 2022 10:29:43 +0200 Subject: Fix fast restream in saved permanent live --- server/lib/job-queue/handlers/video-live-ending.ts | 14 +++++++------- server/lib/live/live-utils.ts | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'server/lib') diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index feec257fc..450bda2fd 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts @@ -4,7 +4,7 @@ import { join } from 'path' 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, @@ -22,15 +22,17 @@ import { VideoLiveSessionModel } from '@server/models/video/video-live-session' 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) @@ -73,8 +75,6 @@ async function saveReplayToExternalVideo (options: { }) { const { liveVideo, liveSession, publishedAt, replayDirectory } = options - await cleanupTMPLiveFiles(getLiveDirectory(liveVideo)) - const video = new VideoModel({ name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`, isLive: false, @@ -243,7 +243,7 @@ async function cleanupLiveAndFederate (options: { if (live.permanentLive) { await cleanupPermanentLive(video, streamingPlaylist) } else { - await cleanupNormalLive(video, streamingPlaylist) + await cleanupUnsavedNormalLive(video, streamingPlaylist) } } diff --git a/server/lib/live/live-utils.ts b/server/lib/live/live-utils.ts index 6365e23db..6305a97a8 100644 --- a/server/lib/live/live-utils.ts +++ b/server/lib/live/live-utils.ts @@ -10,20 +10,20 @@ function buildConcatenatedName (segmentOrPlaylistPath: string) { return 'concat-' + num[1] + '.ts' } -async function cleanupPermanentLive (video: MVideo, streamingPlaylist?: MStreamingPlaylist) { +async function cleanupPermanentLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { const hlsDirectory = getLiveDirectory(video) await cleanupTMPLiveFiles(hlsDirectory) - if (streamingPlaylist) await streamingPlaylist.destroy() + await streamingPlaylist.destroy() } -async function cleanupNormalLive (video: MVideo, streamingPlaylist?: MStreamingPlaylist) { +async function cleanupUnsavedNormalLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { const hlsDirectory = getLiveDirectory(video) await remove(hlsDirectory) - if (streamingPlaylist) await streamingPlaylist.destroy() + await streamingPlaylist.destroy() } async function cleanupTMPLiveFiles (hlsDirectory: string) { @@ -49,7 +49,7 @@ async function cleanupTMPLiveFiles (hlsDirectory: string) { export { cleanupPermanentLive, - cleanupNormalLive, + cleanupUnsavedNormalLive, cleanupTMPLiveFiles, buildConcatenatedName } -- cgit v1.2.3