X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fserver-commands%2Fvideos%2Flive.ts;h=3b09d3ff81c9ef01003109cbdd3f9d1431555f1d;hb=fabe350bcac2d24c8524d4b6bb776dba7e374c8d;hp=7a7faa9115fa147d999094ac27dda1c6597ae728;hpb=c3edc5b074aa4bb1861ed0a94d3713808e87170f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/server-commands/videos/live.ts b/shared/server-commands/videos/live.ts index 7a7faa911..3b09d3ff8 100644 --- a/shared/server-commands/videos/live.ts +++ b/shared/server-commands/videos/live.ts @@ -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 }