]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Merge branch 'release/4.0.0' into develop
authorChocobozzz <me@florianbigard.com>
Tue, 7 Dec 2021 12:47:34 +0000 (13:47 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 7 Dec 2021 12:47:34 +0000 (13:47 +0100)
server/lib/live/shared/muxing-session.ts
server/tests/api/server/services.ts

index c71f4e25f365df98c53fc99f17a7b91b783049cc..eccaefcfaf5ddbc498228b959e82966ad3ad3100 100644 (file)
@@ -135,13 +135,20 @@ class MuxingSession extends EventEmitter {
       })
       : getLiveMuxingCommand(this.inputUrl, outPath, this.streamingPlaylist.playlistFilename)
 
-    logger.info('Running live muxing/transcoding for %s.', this.videoUUID, this.lTags)
+    logger.info('Running live muxing/transcoding for %s.', this.videoUUID, this.lTags())
 
     this.watchTSFiles(outPath)
     this.watchMasterFile(outPath)
 
+    let ffmpegShellCommand: string
+    this.ffmpegCommand.on('start', cmdline => {
+      ffmpegShellCommand = cmdline
+
+      logger.debug('Running ffmpeg command for live', { ffmpegShellCommand, ...this.lTags() })
+    })
+
     this.ffmpegCommand.on('error', (err, stdout, stderr) => {
-      this.onFFmpegError(err, stdout, stderr, outPath)
+      this.onFFmpegError({ err, stdout, stderr, outPath, ffmpegShellCommand })
     })
 
     this.ffmpegCommand.on('end', () => this.onFFmpegEnded(outPath))
@@ -161,19 +168,27 @@ class MuxingSession extends EventEmitter {
     this.hasClientSocketInBadHealthWithCache.clear()
   }
 
-  private onFFmpegError (err: any, stdout: string, stderr: string, outPath: string) {
+  private onFFmpegError (options: {
+    err: any
+    stdout: string
+    stderr: string
+    outPath: string
+    ffmpegShellCommand: string
+  }) {
+    const { err, stdout, stderr, outPath, ffmpegShellCommand } = options
+
     this.onFFmpegEnded(outPath)
 
     // Don't care that we killed the ffmpeg process
     if (err?.message?.includes('Exiting normally')) return
 
-    logger.error('Live transcoding error.', { err, stdout, stderr, ...this.lTags })
+    logger.error('Live transcoding error.', { err, stdout, stderr, ffmpegShellCommand, ...this.lTags() })
 
     this.emit('ffmpeg-error', ({ sessionId: this.sessionId }))
   }
 
   private onFFmpegEnded (outPath: string) {
-    logger.info('RTMP transmuxing for video %s ended. Scheduling cleanup', this.inputUrl, this.lTags)
+    logger.info('RTMP transmuxing for video %s ended. Scheduling cleanup', this.inputUrl, this.lTags())
 
     setTimeout(() => {
       // Wait latest segments generation, and close watchers
@@ -188,7 +203,7 @@ class MuxingSession extends EventEmitter {
         .catch(err => {
           logger.error(
             'Cannot close watchers of %s or process remaining hash segments.', outPath,
-            { err, ...this.lTags }
+            { err, ...this.lTags() }
           )
         })
 
@@ -203,7 +218,7 @@ class MuxingSession extends EventEmitter {
       this.emit('master-playlist-created', { videoId: this.videoId })
 
       this.masterWatcher.close()
-        .catch(err => logger.error('Cannot close master watcher of %s.', outPath, { err, ...this.lTags }))
+        .catch(err => logger.error('Cannot close master watcher of %s.', outPath, { err, ...this.lTags() }))
     })
   }
 
@@ -215,7 +230,7 @@ class MuxingSession extends EventEmitter {
     const playlistIdMatcher = /^([\d+])-/
 
     const addHandler = async segmentPath => {
-      logger.debug('Live add handler of %s.', segmentPath, this.lTags)
+      logger.debug('Live add handler of %s.', segmentPath, this.lTags())
 
       const playlistId = basename(segmentPath).match(playlistIdMatcher)[0]
 
@@ -259,7 +274,7 @@ class MuxingSession extends EventEmitter {
 
       return canUpload !== true
     } catch (err) {
-      logger.error('Cannot stat %s or check quota of %d.', segmentPath, this.user.id, { err, ...this.lTags })
+      logger.error('Cannot stat %s or check quota of %d.', segmentPath, this.user.id, { err, ...this.lTags() })
     }
   }
 
@@ -277,7 +292,7 @@ class MuxingSession extends EventEmitter {
       })
 
       VideoFileModel.customUpsert(file, 'streaming-playlist', null)
-        .catch(err => logger.error('Cannot create file for live streaming.', { err, ...this.lTags }))
+        .catch(err => logger.error('Cannot create file for live streaming.', { err, ...this.lTags() }))
     }
   }
 
@@ -313,14 +328,14 @@ class MuxingSession extends EventEmitter {
       if (this.saveReplay) {
         await this.addSegmentToReplay(hlsVideoPath, previousSegment)
       }
-    }).catch(err => logger.error('Cannot process segments in %s', hlsVideoPath, { err, ...this.lTags }))
+    }).catch(err => logger.error('Cannot process segments in %s', hlsVideoPath, { err, ...this.lTags() }))
   }
 
   private hasClientSocketInBadHealth (sessionId: string) {
     const rtmpSession = this.context.sessions.get(sessionId)
 
     if (!rtmpSession) {
-      logger.warn('Cannot get session %s to check players socket health.', sessionId, this.lTags)
+      logger.warn('Cannot get session %s to check players socket health.', sessionId, this.lTags())
       return
     }
 
@@ -328,7 +343,7 @@ class MuxingSession extends EventEmitter {
       const playerSession = this.context.sessions.get(playerSessionId)
 
       if (!playerSession) {
-        logger.error('Cannot get player session %s to check socket health.', playerSession, this.lTags)
+        logger.error('Cannot get player session %s to check socket health.', playerSession, this.lTags())
         continue
       }
 
@@ -349,7 +364,7 @@ class MuxingSession extends EventEmitter {
 
       await appendFile(dest, data)
     } catch (err) {
-      logger.error('Cannot copy segment %s to replay directory.', segmentPath, { err, ...this.lTags })
+      logger.error('Cannot copy segment %s to replay directory.', segmentPath, { err, ...this.lTags() })
     }
   }
 }
index 3a87df981b7a1076e5f3230f5ab0f4d52cb2257e..823630ae43e3c9a2f963f966d9375f9ea6660c75 100644 (file)
@@ -56,7 +56,7 @@ describe('Test services', function () {
         const oembedUrl = server.url + basePath + video.uuid + suffix
 
         const res = await server.services.getOEmbed({ oembedUrl })
-        const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
+        const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups" ' +
           `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
           'frameborder="0" allowfullscreen></iframe>'
         const expectedThumbnailUrl = 'http://localhost:' + server.port + video.previewPath
@@ -79,7 +79,7 @@ describe('Test services', function () {
         const oembedUrl = server.url + basePath + playlistUUID + suffix
 
         const res = await server.services.getOEmbed({ oembedUrl })
-        const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
+        const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups" ' +
           `title="${playlistDisplayName}" src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
           'frameborder="0" allowfullscreen></iframe>'
 
@@ -103,7 +103,7 @@ describe('Test services', function () {
       const maxWidth = 50
 
       const res = await server.services.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
-      const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
+      const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts allow-popups" ' +
         `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
         'frameborder="0" allowfullscreen></iframe>'