I am trying to save some videos in specific bitrate (8000k) and for this, I used the following code:
ffmpeg -i input_1080p60 -c:v libx264 -pix_fmt yuv420p -b:v 8000K -bufsize 8000K -minrate 8000K -maxrate 8000K -x264opts keyint=120:min-keyint=120 -preset veryfast -profile:v high out_1080p.264
but after saving the videos, I find out each video has a different bitrate except 8000k ( for example 5000k, 6000k, 7500k,...). but I define the minrate 8000k. do you know what is the problem and how can I force the above code to have the specific bitrate? Thank you.
That's what 2-pass encoding is for. See FFmpeg Wiki
The idea behind 2-pass encoding is that by running FFmpeg twice it can first analyze the video to decide how to best allocate the bits to meet the specific bitrate then the second pass does the actual encoding.
So your command should be modified like this:
ffmpeg -i input_1080p60 \
-pass 1 \
-c:v libx264 -pix_fmt yuv420p -b:v 8000K -bufsize 8000K \
-x264opts keyint=120:min-keyint=120 \
-preset veryfast -profile:v high /dev/null
ffmpeg -i input_1080p60 \
-pass 2 \
-c:v libx264 -pix_fmt yuv420p -b:v 8000K -bufsize 8000K \
-x264opts keyint=120:min-keyint=120 \
-preset veryfast -profile:v high out_1080p.264
If you are in Windows, use NUL
instead of /dev/null
.