+ // Add 30% margin to input bitrate
+ const inputBitrateWithMargin = inputBitrate + (inputBitrate * 0.3)
+
+ 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`
+ ]