aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2024-11-06 20:31:21 +0800
committerZhao Zhili <zhilizhao@tencent.com>2024-11-20 19:22:58 +0800
commitfa2ff5effcf3767fadbfcde1b8e826f1acb505c1 (patch)
tree39706b357bc44d816b8ed201e60f92a75dc8789e
parent46ad1abd361f2486bfd9ee28ab80aea28e890f2f (diff)
downloadffmpeg-fa2ff5effcf3767fadbfcde1b8e826f1acb505c1.tar.gz
avcodec/mediacodecenc: Add operating_rate option
For example, with ./ffmpeg -operating_rate 400 -hwaccel mediacodec -i test.mp4 -an \ -c:v h264_mediacodec -operating_rate 400 -b:v 5M -f null - The transcoding speed is 254 FPS. Without -operating_rate on dec/enc, the speed is 148 FPS. With -operating_rate on decoder only, the speed is 239 FPS. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r--libavcodec/mediacodecenc.c7
-rw-r--r--libavcodec/version.h2
2 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 3880ea2fe9..e79fe29964 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -76,6 +76,8 @@ typedef struct MediaCodecEncContext {
int level;
int pts_as_dts;
int extract_extradata;
+ // Ref. MediaFormat KEY_OPERATING_RATE
+ int operating_rate;
} MediaCodecEncContext;
enum {
@@ -354,6 +356,8 @@ static av_cold int mediacodec_init(AVCodecContext *avctx)
}
if (s->pts_as_dts == -1)
s->pts_as_dts = avctx->max_b_frames <= 0;
+ if (s->operating_rate > 0)
+ ff_AMediaFormat_setInt32(format, "operating-rate", s->operating_rate);
ret = ff_AMediaCodec_getConfigureFlagEncode(s->codec);
ret = ff_AMediaCodec_configure(s->codec, format, s->window, NULL, ret);
@@ -764,7 +768,8 @@ static const AVCodecHWConfigInternal *const mediacodec_hw_configs[] = {
{ "pts_as_dts", "Use PTS as DTS. It is enabled automatically if avctx max_b_frames <= 0, " \
"since most of Android devices don't output B frames by default.", \
OFFSET(pts_as_dts), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, \
-
+ { "operating_rate", "The desired operating rate that the codec will need to operate at, zero for unspecified", \
+ OFFSET(operating_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE }, \
#define MEDIACODEC_ENCODER_CLASS(name) \
static const AVClass name ## _mediacodec_class = { \
diff --git a/libavcodec/version.h b/libavcodec/version.h
index a744e7469f..aa3a484c51 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 25
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \