From 786b855af726599a9c877eefa6fa8508c36e1aca Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 13 Nov 2020 10:16:22 +0100 Subject: [PATCH] Fix live sha segments with multiple resolutions --- server/lib/live-manager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts index d1a0cee91..2702437c4 100644 --- a/server/lib/live-manager.ts +++ b/server/lib/live-manager.ts @@ -273,16 +273,20 @@ class LiveManager { const tsWatcher = chokidar.watch(outPath + '/*.ts') - let segmentsToProcess: string[] = [] + const segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {} + const playlistIdMatcher = /^([\d+])-/ const addHandler = segmentPath => { + const playlistId = basename(segmentPath).match(playlistIdMatcher)[0] + const segmentsToProcess = segmentsToProcessPerPlaylist[playlistId] || [] + // Add sha hash of previous segments, because ffmpeg should have finished generating them for (const previousSegment of segmentsToProcess) { this.addSegmentSha(videoUUID, previousSegment) .catch(err => logger.error('Cannot add sha segment of video %s -> %s.', videoUUID, previousSegment, { err })) } - segmentsToProcess = [ segmentPath ] + segmentsToProcessPerPlaylist[playlistId] = [ segmentPath ] // Duration constraint check if (this.isDurationConstraintValid(startStreamDateTime) !== true) {