[FFmpeg-cvslog] avcodec/mediacodecenc: set quality in cq mode
Zhao Zhili
git at videolan.org
Thu Dec 21 05:38:14 EET 2023
ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Sun Dec 17 20:50:53 2023 +0800| [287e22f745c0b7290ce1e80fc7cd161b41ca6997] | committer: Zhao Zhili
avcodec/mediacodecenc: set quality in cq mode
>From AOSP doc, these values are device and codec specific, but lower
values generally result in more efficient (smaller-sized) encoding.
For example, global_quality 50 on Pixel 6 results a 1080P 30 FPS
HEVC with 3744 kb/s, while global_quality 80 results 28178 kb/s.
Fix #10689
Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=287e22f745c0b7290ce1e80fc7cd161b41ca6997
---
libavcodec/mediacodecenc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index a1ae5d5ec5..7eae542248 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -268,8 +268,11 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
if (avctx->bit_rate)
ff_AMediaFormat_setInt32(format, "bitrate", avctx->bit_rate);
- if (s->bitrate_mode >= 0)
+ if (s->bitrate_mode >= 0) {
ff_AMediaFormat_setInt32(format, "bitrate-mode", s->bitrate_mode);
+ if (s->bitrate_mode == BITRATE_MODE_CQ && avctx->global_quality > 0)
+ ff_AMediaFormat_setInt32(format, "quality", avctx->global_quality);
+ }
// frame-rate and i-frame-interval are required to configure codec
if (avctx->framerate.num >= avctx->framerate.den && avctx->framerate.den > 0) {
s->fps = avctx->framerate.num / avctx->framerate.den;
More information about the ffmpeg-cvslog
mailing list