diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-06 10:39:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-06 10:39:40 +0200 |
commit | c826f34a45757b324a20f71665b44ed10e6953b5 (patch) | |
tree | ff29bdff8b4519bbdbbcd3aa0d68521ce2b06ff5 /shared/extra-utils/videos | |
parent | 421ff4618da64f0849353383f690a014024c40da (diff) | |
download | PeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.tar.gz PeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.tar.zst PeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.zip |
Limit live bitrate
Diffstat (limited to 'shared/extra-utils/videos')
-rw-r--r-- | shared/extra-utils/videos/live-command.ts | 5 | ||||
-rw-r--r-- | shared/extra-utils/videos/live.ts | 23 |
2 files changed, 21 insertions, 7 deletions
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts index bf9486a05..81ae458e0 100644 --- a/shared/extra-utils/videos/live-command.ts +++ b/shared/extra-utils/videos/live-command.ts | |||
@@ -68,11 +68,12 @@ export class LiveCommand extends AbstractCommand { | |||
68 | async sendRTMPStreamInVideo (options: OverrideCommandOptions & { | 68 | async sendRTMPStreamInVideo (options: OverrideCommandOptions & { |
69 | videoId: number | string | 69 | videoId: number | string |
70 | fixtureName?: string | 70 | fixtureName?: string |
71 | copyCodecs?: boolean | ||
71 | }) { | 72 | }) { |
72 | const { videoId, fixtureName } = options | 73 | const { videoId, fixtureName, copyCodecs } = options |
73 | const videoLive = await this.get({ videoId }) | 74 | const videoLive = await this.get({ videoId }) |
74 | 75 | ||
75 | return sendRTMPStream(videoLive.rtmpUrl, videoLive.streamKey, fixtureName) | 76 | return sendRTMPStream({ rtmpBaseUrl: videoLive.rtmpUrl, streamKey: videoLive.streamKey, fixtureName, copyCodecs }) |
76 | } | 77 | } |
77 | 78 | ||
78 | async runAndTestStreamError (options: OverrideCommandOptions & { | 79 | async runAndTestStreamError (options: OverrideCommandOptions & { |
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' | |||
7 | import { buildAbsoluteFixturePath, wait } from '../miscs' | 7 | import { buildAbsoluteFixturePath, wait } from '../miscs' |
8 | import { PeerTubeServer } from '../server/server' | 8 | import { PeerTubeServer } from '../server/server' |
9 | 9 | ||
10 | function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') { | 10 | function sendRTMPStream (options: { |
11 | rtmpBaseUrl: string | ||
12 | streamKey: string | ||
13 | fixtureName?: string // default video_short.mp4 | ||
14 | copyCodecs?: boolean // default false | ||
15 | }) { | ||
16 | const { rtmpBaseUrl, streamKey, fixtureName = 'video_short.mp4', copyCodecs = false } = options | ||
17 | |||
11 | const fixture = buildAbsoluteFixturePath(fixtureName) | 18 | const fixture = buildAbsoluteFixturePath(fixtureName) |
12 | 19 | ||
13 | const command = ffmpeg(fixture) | 20 | const command = ffmpeg(fixture) |
14 | command.inputOption('-stream_loop -1') | 21 | command.inputOption('-stream_loop -1') |
15 | command.inputOption('-re') | 22 | command.inputOption('-re') |
16 | command.outputOption('-c:v libx264') | 23 | |
17 | command.outputOption('-g 50') | 24 | if (copyCodecs) { |
18 | command.outputOption('-keyint_min 2') | 25 | command.outputOption('-c:v libx264') |
19 | command.outputOption('-r 60') | 26 | command.outputOption('-g 50') |
27 | command.outputOption('-keyint_min 2') | ||
28 | command.outputOption('-r 60') | ||
29 | } else { | ||
30 | command.outputOption('-c copy') | ||
31 | } | ||
32 | |||
20 | command.outputOption('-f flv') | 33 | command.outputOption('-f flv') |
21 | 34 | ||
22 | const rtmpUrl = rtmpBaseUrl + '/' + streamKey | 35 | const rtmpUrl = rtmpBaseUrl + '/' + streamKey |