diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-10-08 10:13:59 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-10-08 10:13:59 +0200 |
commit | 1a4e0aff72b1766a63328543dd09b91a2f7148b6 (patch) | |
tree | 5ddea71bd54774fbc528200359bf13d803047f4c /src/main.cpp | |
parent | 88d06478d31759f8d0830c432f9022bd9ccd1f96 (diff) |
Better tune quality options for different resolutions
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp index 8c5c7aa..e036e82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -645,7 +645,7 @@ static AVCodecContext *create_video_codec_context(AVFormatContext *av_format_con codec_context->codec_tag = MKTAG('h', 'v', 'c', '1'); switch(video_quality) { case VideoQuality::MEDIUM: - codec_context->bit_rate = 4500000 + (codec_context->width * codec_context->height) / 2; + codec_context->bit_rate = 6500000 + (codec_context->width * codec_context->height)*0.75; /* if(use_hevc) { codec_context->qmin = 20; @@ -661,13 +661,13 @@ static AVCodecContext *create_video_codec_context(AVFormatContext *av_format_con //av_opt_set(codec_context->priv_data, "preset", "p4", 0); break; case VideoQuality::HIGH: - codec_context->bit_rate = 8000000 + (codec_context->width * codec_context->height) / 2; + codec_context->bit_rate = 10000000-5000000 + (codec_context->width * codec_context->height)*0.75; break; case VideoQuality::VERY_HIGH: - codec_context->bit_rate = 10000000 + (codec_context->width * codec_context->height) / 2; + codec_context->bit_rate = 10000000-5000000 + (codec_context->width * codec_context->height)*0.75; break; case VideoQuality::ULTRA: - codec_context->bit_rate = 12500000 + (codec_context->width * codec_context->height) / 2; + codec_context->bit_rate = 10000000-5000000 + (codec_context->width * codec_context->height)*0.75; break; } //codec_context->profile = FF_PROFILE_H264_MAIN; @@ -797,10 +797,11 @@ static void open_video(AVCodecContext *codec_context, switch(video_quality) { case VideoQuality::MEDIUM: av_dict_set_int(&options, "qp", 35, 0); + av_dict_set(&options, "rc", "vbr", 0); //av_dict_set(&options, "preset", "hq", 0); break; case VideoQuality::HIGH: - av_dict_set_int(&options, "qp", 31, 0); + av_dict_set_int(&options, "qp", 34, 0); //av_dict_set(&options, "preset", "hq", 0); break; case VideoQuality::VERY_HIGH: @@ -808,7 +809,7 @@ static void open_video(AVCodecContext *codec_context, //av_dict_set(&options, "preset", "hq", 0); break; case VideoQuality::ULTRA: - av_dict_set_int(&options, "qp", 18, 0); + av_dict_set_int(&options, "qp", 22, 0); //av_dict_set(&options, "preset", "slow", 0); break; } @@ -818,8 +819,6 @@ static void open_video(AVCodecContext *codec_context, //av_dict_set(&options, "preset", "llhq", 0); } - av_dict_set(&options, "rc", "vbr", 0); - ret = avcodec_open2(codec_context, codec_context->codec, &options); if (ret < 0) { fprintf(stderr, "Error: Could not open video codec: %s\n", |