From: Chocobozzz Date: Fri, 13 Nov 2020 09:16:22 +0000 (+0100) Subject: Fix live sha segments with multiple resolutions X-Git-Tag: v3.0.0-rc.1~333 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=786b855af726599a9c877eefa6fa8508c36e1aca;p=github%2FChocobozzz%2FPeerTube.git Fix live sha segments with multiple resolutions --- 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) {