]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/server-commands/videos/live.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / shared / server-commands / videos / live.ts
index 0d9c32aab4df20d9b2f07853d8f649bd4bc3ca87..cebadb1dbb008b23a367cf772f55b88fd052052e 100644 (file)
@@ -1,6 +1,7 @@
 import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
+import { truncate } from 'lodash'
 import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
-import { VideoDetails, VideoInclude } from '@shared/models'
+import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models'
 import { PeerTubeServer } from '../server/server'
 
 function sendRTMPStream (options: {
@@ -21,8 +22,8 @@ function sendRTMPStream (options: {
     command.outputOption('-c copy')
   } else {
     command.outputOption('-c:v libx264')
-    command.outputOption('-g 50')
-    command.outputOption('-keyint_min 2')
+    command.outputOption('-g 120')
+    command.outputOption('-x264-params "no-scenecut=1"')
     command.outputOption('-r 60')
   }
 
@@ -39,6 +40,7 @@ function sendRTMPStream (options: {
 
   if (process.env.DEBUG) {
     command.on('stderr', data => console.log(data))
+    command.on('stdout', data => console.log(data))
   }
 
   command.run()
@@ -62,7 +64,7 @@ async function testFfmpegStreamError (command: FfmpegCommand, shouldHaveError: b
   let error: Error
 
   try {
-    await waitFfmpegUntilError(command, 35000)
+    await waitFfmpegUntilError(command, 45000)
   } catch (err) {
     error = err
   }
@@ -98,9 +100,18 @@ async function waitUntilLiveReplacedByReplayOnAllServers (servers: PeerTubeServe
 }
 
 async function findExternalSavedVideo (server: PeerTubeServer, liveDetails: VideoDetails) {
-  const { data } = await server.videos.list({ token: server.accessToken, sort: '-publishedAt', include: VideoInclude.BLACKLISTED })
+  const include = VideoInclude.BLACKLISTED
+  const privacyOneOf = [ VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.PUBLIC, VideoPrivacy.UNLISTED ]
 
-  return data.find(v => v.name === liveDetails.name + ' - ' + new Date(liveDetails.publishedAt).toLocaleString())
+  const { data } = await server.videos.list({ token: server.accessToken, sort: '-publishedAt', include, privacyOneOf })
+
+  const videoNameSuffix = ` - ${new Date(liveDetails.publishedAt).toLocaleString()}`
+  const truncatedVideoName = truncate(liveDetails.name, {
+    length: 120 - videoNameSuffix.length
+  })
+  const toFind = truncatedVideoName + videoNameSuffix
+
+  return data.find(v => v.name === toFind)
 }
 
 export {