]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/server-commands/videos/live.ts
Translated using Weblate (Ukrainian)
[github/Chocobozzz/PeerTube.git] / shared / server-commands / videos / live.ts
index 7a7faa9115fa147d999094ac27dda1c6597ae728..3b09d3ff81c9ef01003109cbdd3f9d1431555f1d 100644 (file)
@@ -1,5 +1,6 @@
 import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
 import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
+import { VideoDetails, VideoInclude, VideoPrivacy } from '@shared/models'
 import { PeerTubeServer } from '../server/server'
 
 function sendRTMPStream (options: {
@@ -20,8 +21,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')
   }
 
@@ -38,6 +39,7 @@ function sendRTMPStream (options: {
 
   if (process.env.DEBUG) {
     command.on('stderr', data => console.log(data))
+    command.on('stdout', data => console.log(data))
   }
 
   command.run()
@@ -84,17 +86,36 @@ async function waitUntilLivePublishedOnAllServers (servers: PeerTubeServer[], vi
   }
 }
 
-async function waitUntilLiveSavedOnAllServers (servers: PeerTubeServer[], videoId: string) {
+async function waitUntilLiveWaitingOnAllServers (servers: PeerTubeServer[], videoId: string) {
   for (const server of servers) {
-    await server.live.waitUntilSaved({ videoId })
+    await server.live.waitUntilWaiting({ videoId })
   }
 }
 
+async function waitUntilLiveReplacedByReplayOnAllServers (servers: PeerTubeServer[], videoId: string) {
+  for (const server of servers) {
+    await server.live.waitUntilReplacedByReplay({ videoId })
+  }
+}
+
+async function findExternalSavedVideo (server: PeerTubeServer, liveDetails: VideoDetails) {
+  const include = VideoInclude.BLACKLISTED
+  const privacyOneOf = [ VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.PUBLIC, VideoPrivacy.UNLISTED ]
+
+  const { data } = await server.videos.list({ token: server.accessToken, sort: '-publishedAt', include, privacyOneOf })
+
+  return data.find(v => v.name === liveDetails.name + ' - ' + new Date(liveDetails.publishedAt).toLocaleString())
+}
+
 export {
   sendRTMPStream,
   waitFfmpegUntilError,
   testFfmpegStreamError,
   stopFfmpeg,
+
   waitUntilLivePublishedOnAllServers,
-  waitUntilLiveSavedOnAllServers
+  waitUntilLiveReplacedByReplayOnAllServers,
+  waitUntilLiveWaitingOnAllServers,
+
+  findExternalSavedVideo
 }