aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-live-ending.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/job-queue/handlers/video-live-ending.ts')
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts18
1 files changed, 6 insertions, 12 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index e3c11caa2..4daf9249b 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -73,8 +73,8 @@ async function saveLive (video: MVideo, live: MVideoLive) {
73 73
74 for (const file of rootFiles) { 74 for (const file of rootFiles) {
75 // Move remaining files in the replay directory 75 // Move remaining files in the replay directory
76 if (file.endsWith('.ts') || file.endsWith('.m3u8')) { 76 if (file.endsWith('.ts')) {
77 await copy(join(hlsDirectory, file), join(replayDirectory, file)) 77 await LiveManager.Instance.addSegmentToReplay(hlsDirectory, join(hlsDirectory, file))
78 } 78 }
79 79
80 if (file.endsWith('.m3u8') && file !== 'master.m3u8') { 80 if (file.endsWith('.m3u8') && file !== 'master.m3u8') {
@@ -100,23 +100,17 @@ async function saveLive (video: MVideo, live: MVideoLive) {
100 await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id) 100 await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id)
101 hlsPlaylist.VideoFiles = [] 101 hlsPlaylist.VideoFiles = []
102 102
103 const replayFiles = await readdir(replayDirectory)
104 let durationDone: boolean 103 let durationDone: boolean
105 104
106 for (const playlistFile of playlistFiles) { 105 for (const playlistFile of playlistFiles) {
107 const playlistPath = join(replayDirectory, playlistFile) 106 const concatenatedTsFile = LiveManager.Instance.buildConcatenatedName(playlistFile)
108 const { videoFileResolution, isPortraitMode } = await getVideoFileResolution(playlistPath) 107 const concatenatedTsFilePath = join(replayDirectory, concatenatedTsFile)
109 108
110 // Playlist name is for example 3.m3u8 109 const { videoFileResolution, isPortraitMode } = await getVideoFileResolution(concatenatedTsFilePath)
111 // Segments names are 3-0.ts 3-1.ts etc
112 const shouldStartWith = playlistFile.replace(/\.m3u8$/, '') + '-'
113
114 const segmentFiles = replayFiles.filter(f => f.startsWith(shouldStartWith) && f.endsWith('.ts'))
115 110
116 const outputPath = await generateHlsPlaylistFromTS({ 111 const outputPath = await generateHlsPlaylistFromTS({
117 video: videoWithFiles, 112 video: videoWithFiles,
118 replayDirectory, 113 concatenatedTsFilePath,
119 segmentFiles,
120 resolution: videoFileResolution, 114 resolution: videoFileResolution,
121 isPortraitMode 115 isPortraitMode
122 }) 116 })