aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/live
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-06 13:35:25 +0200
committerChocobozzz <me@florianbigard.com>2021-08-06 14:13:26 +0200
commit679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3 (patch)
tree03abf589275db05e5b1fa1c89f57049cd807324a /server/lib/live
parentc826f34a45757b324a20f71665b44ed10e6953b5 (diff)
downloadPeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.gz
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.zst
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.zip
Improve target bitrate calculation
Diffstat (limited to 'server/lib/live')
-rw-r--r--server/lib/live/live-manager.ts13
-rw-r--r--server/lib/live/shared/muxing-session.ts9
2 files changed, 16 insertions, 6 deletions
diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts
index b19ecef6f..2a429fb33 100644
--- a/server/lib/live/live-manager.ts
+++ b/server/lib/live/live-manager.ts
@@ -202,7 +202,7 @@ class LiveManager {
202 const now = Date.now() 202 const now = Date.now()
203 const probe = await ffprobePromise(rtmpUrl) 203 const probe = await ffprobePromise(rtmpUrl)
204 204
205 const [ { videoFileResolution }, fps, bitrate ] = await Promise.all([ 205 const [ { resolution, ratio }, fps, bitrate ] = await Promise.all([
206 getVideoFileResolution(rtmpUrl, probe), 206 getVideoFileResolution(rtmpUrl, probe),
207 getVideoFileFPS(rtmpUrl, probe), 207 getVideoFileFPS(rtmpUrl, probe),
208 getVideoFileBitrate(rtmpUrl, probe) 208 getVideoFileBitrate(rtmpUrl, probe)
@@ -210,13 +210,13 @@ class LiveManager {
210 210
211 logger.info( 211 logger.info(
212 '%s probing took %d ms (bitrate: %d, fps: %d, resolution: %d)', 212 '%s probing took %d ms (bitrate: %d, fps: %d, resolution: %d)',
213 rtmpUrl, Date.now() - now, bitrate, fps, videoFileResolution, lTags(sessionId, video.uuid) 213 rtmpUrl, Date.now() - now, bitrate, fps, resolution, lTags(sessionId, video.uuid)
214 ) 214 )
215 215
216 const allResolutions = this.buildAllResolutionsToTranscode(videoFileResolution) 216 const allResolutions = this.buildAllResolutionsToTranscode(resolution)
217 217
218 logger.info( 218 logger.info(
219 'Will mux/transcode live video of original resolution %d.', videoFileResolution, 219 'Will mux/transcode live video of original resolution %d.', resolution,
220 { allResolutions, ...lTags(sessionId, video.uuid) } 220 { allResolutions, ...lTags(sessionId, video.uuid) }
221 ) 221 )
222 222
@@ -229,6 +229,7 @@ class LiveManager {
229 rtmpUrl, 229 rtmpUrl,
230 fps, 230 fps,
231 bitrate, 231 bitrate,
232 ratio,
232 allResolutions 233 allResolutions
233 }) 234 })
234 } 235 }
@@ -240,9 +241,10 @@ class LiveManager {
240 rtmpUrl: string 241 rtmpUrl: string
241 fps: number 242 fps: number
242 bitrate: number 243 bitrate: number
244 ratio: number
243 allResolutions: number[] 245 allResolutions: number[]
244 }) { 246 }) {
245 const { sessionId, videoLive, streamingPlaylist, allResolutions, fps, bitrate, rtmpUrl } = options 247 const { sessionId, videoLive, streamingPlaylist, allResolutions, fps, bitrate, ratio, rtmpUrl } = options
246 const videoUUID = videoLive.Video.uuid 248 const videoUUID = videoLive.Video.uuid
247 const localLTags = lTags(sessionId, videoUUID) 249 const localLTags = lTags(sessionId, videoUUID)
248 250
@@ -257,6 +259,7 @@ class LiveManager {
257 streamingPlaylist, 259 streamingPlaylist,
258 rtmpUrl, 260 rtmpUrl,
259 bitrate, 261 bitrate,
262 ratio,
260 fps, 263 fps,
261 allResolutions 264 allResolutions
262 }) 265 })
diff --git a/server/lib/live/shared/muxing-session.ts b/server/lib/live/shared/muxing-session.ts
index 62708b14b..a80abc843 100644
--- a/server/lib/live/shared/muxing-session.ts
+++ b/server/lib/live/shared/muxing-session.ts
@@ -54,9 +54,11 @@ class MuxingSession extends EventEmitter {
54 private readonly streamingPlaylist: MStreamingPlaylistVideo 54 private readonly streamingPlaylist: MStreamingPlaylistVideo
55 private readonly rtmpUrl: string 55 private readonly rtmpUrl: string
56 private readonly fps: number 56 private readonly fps: number
57 private readonly bitrate: number
58 private readonly allResolutions: number[] 57 private readonly allResolutions: number[]
59 58
59 private readonly bitrate: number
60 private readonly ratio: number
61
60 private readonly videoId: number 62 private readonly videoId: number
61 private readonly videoUUID: string 63 private readonly videoUUID: string
62 private readonly saveReplay: boolean 64 private readonly saveReplay: boolean
@@ -85,6 +87,7 @@ class MuxingSession extends EventEmitter {
85 rtmpUrl: string 87 rtmpUrl: string
86 fps: number 88 fps: number
87 bitrate: number 89 bitrate: number
90 ratio: number
88 allResolutions: number[] 91 allResolutions: number[]
89 }) { 92 }) {
90 super() 93 super()
@@ -96,7 +99,10 @@ class MuxingSession extends EventEmitter {
96 this.streamingPlaylist = options.streamingPlaylist 99 this.streamingPlaylist = options.streamingPlaylist
97 this.rtmpUrl = options.rtmpUrl 100 this.rtmpUrl = options.rtmpUrl
98 this.fps = options.fps 101 this.fps = options.fps
102
99 this.bitrate = options.bitrate 103 this.bitrate = options.bitrate
104 this.ratio = options.bitrate
105
100 this.allResolutions = options.allResolutions 106 this.allResolutions = options.allResolutions
101 107
102 this.videoId = this.videoLive.Video.id 108 this.videoId = this.videoLive.Video.id
@@ -122,6 +128,7 @@ class MuxingSession extends EventEmitter {
122 resolutions: this.allResolutions, 128 resolutions: this.allResolutions,
123 fps: this.fps, 129 fps: this.fps,
124 bitrate: this.bitrate, 130 bitrate: this.bitrate,
131 ratio: this.ratio,
125 132
126 availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(), 133 availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(),
127 profile: CONFIG.LIVE.TRANSCODING.PROFILE 134 profile: CONFIG.LIVE.TRANSCODING.PROFILE