1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Do not transcode to an higher bitrate

Thanks bkil https://github.com/bkil
This commit is contained in:
Chocobozzz 2020-11-20 15:06:56 +01:00
parent da2516fde1
commit d218e7de94
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 59 additions and 3 deletions

View file

@ -674,7 +674,12 @@ async function presetH264 (command: ffmpeg.FfmpegCommand, input: string, resolut
// Constrained Encoding (VBV)
// https://slhck.info/video/2017/03/01/rate-control.html
// https://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate
const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)
let targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)
// Don't transcode to an higher bitrate than the original file
const fileBitrate = await getVideoFileBitrate(input)
targetBitrate = Math.min(targetBitrate, fileBitrate)
localCommand = localCommand.outputOptions([ `-maxrate ${targetBitrate}`, `-bufsize ${targetBitrate * 2}` ])
// Keyframe interval of 2 seconds for faster seeking and resolution switching.