From c826f34a45757b324a20f71665b44ed10e6953b5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 6 Aug 2021 10:39:40 +0200 Subject: Limit live bitrate --- shared/extra-utils/videos/live.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'shared/extra-utils/videos/live.ts') diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts index 94f5f5b59..6aa405b19 100644 --- a/shared/extra-utils/videos/live.ts +++ b/shared/extra-utils/videos/live.ts @@ -7,16 +7,29 @@ import { join } from 'path' import { buildAbsoluteFixturePath, wait } from '../miscs' import { PeerTubeServer } from '../server/server' -function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') { +function sendRTMPStream (options: { + rtmpBaseUrl: string + streamKey: string + fixtureName?: string // default video_short.mp4 + copyCodecs?: boolean // default false +}) { + const { rtmpBaseUrl, streamKey, fixtureName = 'video_short.mp4', copyCodecs = false } = options + const fixture = buildAbsoluteFixturePath(fixtureName) const command = ffmpeg(fixture) command.inputOption('-stream_loop -1') command.inputOption('-re') - command.outputOption('-c:v libx264') - command.outputOption('-g 50') - command.outputOption('-keyint_min 2') - command.outputOption('-r 60') + + if (copyCodecs) { + command.outputOption('-c:v libx264') + command.outputOption('-g 50') + command.outputOption('-keyint_min 2') + command.outputOption('-r 60') + } else { + command.outputOption('-c copy') + } + command.outputOption('-f flv') const rtmpUrl = rtmpBaseUrl + '/' + streamKey -- cgit v1.2.3