diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-20 15:06:56 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-20 15:11:31 +0100 |
commit | d218e7de9400938ae6ac593d9ae5842e23abd4f0 (patch) | |
tree | f73795a2e9bea35d53923c8ac6a12098357152b9 /server/helpers | |
parent | da2516fde1ad8f049c99ba5fd98c37425f379199 (diff) | |
download | PeerTube-d218e7de9400938ae6ac593d9ae5842e23abd4f0.tar.gz PeerTube-d218e7de9400938ae6ac593d9ae5842e23abd4f0.tar.zst PeerTube-d218e7de9400938ae6ac593d9ae5842e23abd4f0.zip |
Do not transcode to an higher bitrate
Thanks bkil https://github.com/bkil
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 1d610eff2..c8d6969ff 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -674,7 +674,12 @@ async function presetH264 (command: ffmpeg.FfmpegCommand, input: string, resolut | |||
674 | // Constrained Encoding (VBV) | 674 | // Constrained Encoding (VBV) |
675 | // https://slhck.info/video/2017/03/01/rate-control.html | 675 | // https://slhck.info/video/2017/03/01/rate-control.html |
676 | // https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate | 676 | // https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate |
677 | const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS) | 677 | let targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS) |
678 | |||
679 | // Don't transcode to an higher bitrate than the original file | ||
680 | const fileBitrate = await getVideoFileBitrate(input) | ||
681 | targetBitrate = Math.min(targetBitrate, fileBitrate) | ||
682 | |||
678 | localCommand = localCommand.outputOptions([ `-maxrate ${targetBitrate}`, `-bufsize ${targetBitrate * 2}` ]) | 683 | localCommand = localCommand.outputOptions([ `-maxrate ${targetBitrate}`, `-bufsize ${targetBitrate * 2}` ]) |
679 | 684 | ||
680 | // Keyframe interval of 2 seconds for faster seeking and resolution switching. | 685 | // Keyframe interval of 2 seconds for faster seeking and resolution switching. |