1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

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
This commit is contained in:
Chocobozzz 2021-12-14 10:39:52 +01:00
parent 9234110650
commit 14857212f1
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 26 additions and 19 deletions

View file

@ -23,10 +23,9 @@ const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = (options: EncoderOpt
return {
outputOptions: [
`-preset veryfast`,
`-r ${fps}`,
`-maxrate ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}`
...getCommonOutputOptions(targetBitrate),
`-r ${fps}`
]
}
}
@ -38,11 +37,10 @@ const defaultX264LiveOptionsBuilder: EncoderOptionsBuilder = (options: EncoderOp
return {
outputOptions: [
`-preset veryfast`,
...getCommonOutputOptions(targetBitrate),
`${buildStreamSuffix('-r:v', streamNum)} ${fps}`,
`${buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`,
`-maxrate ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}`
`${buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`
]
}
}
@ -257,3 +255,16 @@ function capBitrate (inputBitrate: number, targetBitrate: number) {
return Math.min(targetBitrate, inputBitrateWithMargin)
}
function getCommonOutputOptions (targetBitrate: number) {
return [
`-preset veryfast`,
`-maxrate ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}`,
// NOTE: b-strategy 1 - heuristic algorithm, 16 is optimal B-frames for it
`-b_strategy 1`,
// NOTE: Why 16: https://github.com/Chocobozzz/PeerTube/pull/774. b-strategy 2 -> B-frames<16
`-bf 16`
]
}