]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix live sha segments with multiple resolutions
authorChocobozzz <me@florianbigard.com>
Fri, 13 Nov 2020 09:16:22 +0000 (10:16 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 13 Nov 2020 11:02:29 +0000 (12:02 +0100)
server/lib/live-manager.ts

index d1a0cee91f129db37f5917f0ec6605893cbd4559..2702437c42549b2e6d24822042e4abd7b236ac78 100644 (file)
@@ -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) {