aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/transcoding/video-transcoding-profiles.ts27
1 files changed, 19 insertions, 8 deletions
diff --git a/server/lib/transcoding/video-transcoding-profiles.ts b/server/lib/transcoding/video-transcoding-profiles.ts
index 34a364415..dcc8d4c5c 100644
--- a/server/lib/transcoding/video-transcoding-profiles.ts
+++ b/server/lib/transcoding/video-transcoding-profiles.ts
@@ -23,10 +23,9 @@ const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = (options: EncoderOpt
23 23
24 return { 24 return {
25 outputOptions: [ 25 outputOptions: [
26 `-preset veryfast`, 26 ...getCommonOutputOptions(targetBitrate),
27 `-r ${fps}`, 27
28 `-maxrate ${targetBitrate}`, 28 `-r ${fps}`
29 `-bufsize ${targetBitrate * 2}`
30 ] 29 ]
31 } 30 }
32} 31}
@@ -38,11 +37,10 @@ const defaultX264LiveOptionsBuilder: EncoderOptionsBuilder = (options: EncoderOp
38 37
39 return { 38 return {
40 outputOptions: [ 39 outputOptions: [
41 `-preset veryfast`, 40 ...getCommonOutputOptions(targetBitrate),
41
42 `${buildStreamSuffix('-r:v', streamNum)} ${fps}`, 42 `${buildStreamSuffix('-r:v', streamNum)} ${fps}`,
43 `${buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`, 43 `${buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`
44 `-maxrate ${targetBitrate}`,
45 `-bufsize ${targetBitrate * 2}`
46 ] 44 ]
47 } 45 }
48} 46}
@@ -257,3 +255,16 @@ function capBitrate (inputBitrate: number, targetBitrate: number) {
257 255
258 return Math.min(targetBitrate, inputBitrateWithMargin) 256 return Math.min(targetBitrate, inputBitrateWithMargin)
259} 257}
258
259function getCommonOutputOptions (targetBitrate: number) {
260 return [
261 `-preset veryfast`,
262 `-maxrate ${targetBitrate}`,
263 `-bufsize ${targetBitrate * 2}`,
264
265 // NOTE: b-strategy 1 - heuristic algorithm, 16 is optimal B-frames for it
266 `-b_strategy 1`,
267 // NOTE: Why 16: https://github.com/Chocobozzz/PeerTube/pull/774. b-strategy 2 -> B-frames<16
268 `-bf 16`
269 ]
270}