aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/transcoding/video-transcoding-profiles.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-14 10:39:52 +0100
committerChocobozzz <me@florianbigard.com>2021-12-14 10:46:31 +0100
commit14857212f15256ff4dd0d36ff5158005f1d7caae (patch)
treed4aab7b8f5deb75018da86b7a83fc74d2b3da5cd /server/lib/transcoding/video-transcoding-profiles.ts
parent9234110650495c05e04abee6a5934a27eb2f32a9 (diff)
downloadPeerTube-14857212f15256ff4dd0d36ff5158005f1d7caae.tar.gz
PeerTube-14857212f15256ff4dd0d36ff5158005f1d7caae.tar.zst
PeerTube-14857212f15256ff4dd0d36ff5158005f1d7caae.zip
Move b frame strategy in transcoding profile
We may use a too high value for some encoders and it allows to specify custom values/strategy
Diffstat (limited to 'server/lib/transcoding/video-transcoding-profiles.ts')
-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}