From aac9b9cde7540045507d3877f5a58c6253967ee2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 5 Nov 2024 01:08:56 +0100 Subject: Fix incorrect bitrate calculation for constant bitrate --- src/main.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index b8c8f71..2ce15ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -585,7 +585,7 @@ static AVCodecContext *create_video_codec_context(AVPixelFormat pix_fmt, codec_context->global_quality = 120 * quality_multiply; break; case VideoQuality::VERY_HIGH: - codec_context->global_quality = 100 * quality_multiply; + codec_context->global_quality = 115 * quality_multiply; break; case VideoQuality::ULTRA: codec_context->global_quality = 90 * quality_multiply; @@ -600,7 +600,7 @@ static AVCodecContext *create_video_codec_context(AVPixelFormat pix_fmt, codec_context->global_quality = 30 * quality_multiply; break; case VideoQuality::VERY_HIGH: - codec_context->global_quality = 20 * quality_multiply; + codec_context->global_quality = 25 * quality_multiply; break; case VideoQuality::ULTRA: codec_context->global_quality = 10 * quality_multiply; @@ -615,7 +615,7 @@ static AVCodecContext *create_video_codec_context(AVPixelFormat pix_fmt, codec_context->global_quality = 30 * quality_multiply; break; case VideoQuality::VERY_HIGH: - codec_context->global_quality = 20 * quality_multiply; + codec_context->global_quality = 25 * quality_multiply; break; case VideoQuality::ULTRA: codec_context->global_quality = 10 * quality_multiply; @@ -779,10 +779,10 @@ static void video_software_set_qp(AVCodecContext *codec_context, VideoQuality vi av_dict_set_int(options, "qp", 30 * qp_multiply, 0); break; case VideoQuality::VERY_HIGH: - av_dict_set_int(options, "qp", 23 * qp_multiply, 0); + av_dict_set_int(options, "qp", 25 * qp_multiply, 0); break; case VideoQuality::ULTRA: - av_dict_set_int(options, "qp", 20 * qp_multiply, 0); + av_dict_set_int(options, "qp", 22 * qp_multiply, 0); break; } } else { @@ -873,7 +873,7 @@ static void video_hardware_set_qp(AVCodecContext *codec_context, VideoQuality vi av_dict_set_int(options, "qp", 30 * qp_multiply, 0); break; case VideoQuality::VERY_HIGH: - av_dict_set_int(options, "qp", 25 * qp_multiply, 0); + av_dict_set_int(options, "qp", 27 * qp_multiply, 0); break; case VideoQuality::ULTRA: av_dict_set_int(options, "qp", 22 * qp_multiply, 0); @@ -882,16 +882,16 @@ static void video_hardware_set_qp(AVCodecContext *codec_context, VideoQuality vi } else if(codec_context->codec_id == AV_CODEC_ID_H264) { switch(video_quality) { case VideoQuality::MEDIUM: - av_dict_set_int(options, "qp", 34 * qp_multiply, 0); + av_dict_set_int(options, "qp", 35 * qp_multiply, 0); break; case VideoQuality::HIGH: av_dict_set_int(options, "qp", 30 * qp_multiply, 0); break; case VideoQuality::VERY_HIGH: - av_dict_set_int(options, "qp", 23 * qp_multiply, 0); + av_dict_set_int(options, "qp", 27 * qp_multiply, 0); break; case VideoQuality::ULTRA: - av_dict_set_int(options, "qp", 20 * qp_multiply, 0); + av_dict_set_int(options, "qp", 22 * qp_multiply, 0); break; } } else if(codec_context->codec_id == AV_CODEC_ID_HEVC) { @@ -903,7 +903,7 @@ static void video_hardware_set_qp(AVCodecContext *codec_context, VideoQuality vi av_dict_set_int(options, "qp", 30 * qp_multiply, 0); break; case VideoQuality::VERY_HIGH: - av_dict_set_int(options, "qp", 25 * qp_multiply, 0); + av_dict_set_int(options, "qp", 27 * qp_multiply, 0); break; case VideoQuality::ULTRA: av_dict_set_int(options, "qp", 22 * qp_multiply, 0); @@ -918,7 +918,7 @@ static void video_hardware_set_qp(AVCodecContext *codec_context, VideoQuality vi av_dict_set_int(options, "qp", 30 * qp_multiply, 0); break; case VideoQuality::VERY_HIGH: - av_dict_set_int(options, "qp", 25 * qp_multiply, 0); + av_dict_set_int(options, "qp", 27 * qp_multiply, 0); break; case VideoQuality::ULTRA: av_dict_set_int(options, "qp", 22 * qp_multiply, 0); @@ -931,16 +931,16 @@ static void video_hardware_set_qp(AVCodecContext *codec_context, VideoQuality vi } else if(codec_context->codec_id == AV_CODEC_ID_H264) { switch(video_quality) { case VideoQuality::MEDIUM: - av_dict_set_int(options, "qp", 34 * qp_multiply, 0); + av_dict_set_int(options, "qp", 35 * qp_multiply, 0); break; case VideoQuality::HIGH: av_dict_set_int(options, "qp", 30 * qp_multiply, 0); break; case VideoQuality::VERY_HIGH: - av_dict_set_int(options, "qp", 23 * qp_multiply, 0); + av_dict_set_int(options, "qp", 27 * qp_multiply, 0); break; case VideoQuality::ULTRA: - av_dict_set_int(options, "qp", 20 * qp_multiply, 0); + av_dict_set_int(options, "qp", 22 * qp_multiply, 0); break; } } else if(codec_context->codec_id == AV_CODEC_ID_HEVC) { @@ -952,7 +952,7 @@ static void video_hardware_set_qp(AVCodecContext *codec_context, VideoQuality vi av_dict_set_int(options, "qp", 30 * qp_multiply, 0); break; case VideoQuality::VERY_HIGH: - av_dict_set_int(options, "qp", 25 * qp_multiply, 0); + av_dict_set_int(options, "qp", 27 * qp_multiply, 0); break; case VideoQuality::ULTRA: av_dict_set_int(options, "qp", 22 * qp_multiply, 0); @@ -967,7 +967,7 @@ static void video_hardware_set_qp(AVCodecContext *codec_context, VideoQuality vi av_dict_set_int(options, "qp", 30 * qp_multiply, 0); break; case VideoQuality::VERY_HIGH: - av_dict_set_int(options, "qp", 25 * qp_multiply, 0); + av_dict_set_int(options, "qp", 27 * qp_multiply, 0); break; case VideoQuality::ULTRA: av_dict_set_int(options, "qp", 22 * qp_multiply, 0); @@ -3108,7 +3108,7 @@ int main(int argc, char **argv) { usage(); } - video_bitrate *= 1000LL; + video_bitrate *= 1024LL * 8LL; } else { if(!quality_str) quality_str = "very_high"; -- cgit v1.2.3