import { MVideo, MVideoLive, MVideoLiveSession, MVideoWithAllFiles } from '@server/types/models'
import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
import { logger, loggerTagsFactory } from '../../../helpers/logger'
+import { VideoPathManager } from '@server/lib/video-path-manager'
+import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting'
const lTags = loggerTagsFactory('live', 'job')
return cleanupLiveAndFederate({ permanentLive, video, streamingPlaylistId: payload.streamingPlaylistId })
}
- return replaceLiveByReplay({ video, liveSession, live, permanentLive, replayDirectory: payload.replayDirectory })
+ return replaceLiveByReplay({
+ video,
+ liveSession,
+ live,
+ permanentLive,
+ replayDirectory: payload.replayDirectory
+ })
}
// ---------------------------------------------------------------------------
}) {
const { liveVideo, liveSession, publishedAt, replayDirectory } = options
+ const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId)
+
const replayVideo = new VideoModel({
name: `${liveVideo.name} - ${new Date(publishedAt).toLocaleString()}`,
isLive: false,
nsfw: liveVideo.nsfw,
description: liveVideo.description,
support: liveVideo.support,
- privacy: liveVideo.privacy,
+ privacy: replaySettings.privacy,
channelId: liveVideo.channelId
}) as MVideoWithAllFiles
}) {
const { video, liveSession, live, permanentLive, replayDirectory } = options
+ const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId)
const videoWithFiles = await VideoModel.loadFull(video.id)
const hlsPlaylist = videoWithFiles.getHLSPlaylist()
await live.destroy()
videoWithFiles.isLive = false
+ videoWithFiles.privacy = replaySettings.privacy
videoWithFiles.waitTranscoding = true
videoWithFiles.state = VideoState.TO_TRANSCODE
const concatenatedTsFiles = await readdir(replayDirectory)
for (const concatenatedTsFile of concatenatedTsFiles) {
+ const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid)
+
const concatenatedTsFilePath = join(replayDirectory, concatenatedTsFile)
const probe = await ffprobePromise(concatenatedTsFilePath)
const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe)
const { resolution } = await getVideoStreamDimensionsInfo(concatenatedTsFilePath, probe)
- await generateHlsPlaylistResolutionFromTS({
- video,
- concatenatedTsFilePath,
- resolution,
- isAAC: audioStream?.codec_name === 'aac'
- })
+ try {
+ await generateHlsPlaylistResolutionFromTS({
+ video,
+ inputFileMutexReleaser,
+ concatenatedTsFilePath,
+ resolution,
+ isAAC: audioStream?.codec_name === 'aac'
+ })
+ } catch (err) {
+ logger.error('Cannot generate HLS playlist resolution from TS files.', { err })
+ }
+
+ inputFileMutexReleaser()
}
return video