History

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.

Zhao Zhili committed 2 years ago

Commit fa2ff5e1 parent 46ad1ab2 files · +7 −2Browse files

Unified · Split

2 files
  1. libavcodec/mediacodecenc.c +6 −1
  2. libavcodec/version.h +1 −1
libavcodec/mediacodecenc.c+6−1
@@ -76,6 +76,8 @@ typedef struct MediaCodecEncContext { · 75 unmodified lines
7676 int level;
7777 int pts_as_dts;
7878 int extract_extradata;
79+ // Ref. MediaFormat KEY_OPERATING_RATE
80+ int operating_rate;
7981 } MediaCodecEncContext;
8082
8183 enum {
@@ -354,6 +356,8 @@ static av_cold int mediacodec_init(AVCodecContext *avctx) · 272 unmodified lines
354356 }
355357 if (s->pts_as_dts == -1)
356358 s->pts_as_dts = avctx->max_b_frames <= 0;
359+ if (s->operating_rate > 0)
360+ ff_AMediaFormat_setInt32(format, "operating-rate", s->operating_rate);
357361
358362 ret = ff_AMediaCodec_getConfigureFlagEncode(s->codec);
359363 ret = ff_AMediaCodec_configure(s->codec, format, s->window, NULL, ret);
@@ -764,7 +768,8 @@ static const AVCodecHWConfigInternal *const mediacodec_hw_configs[] = { · 404 unmodified lines
764768 { "pts_as_dts", "Use PTS as DTS. It is enabled automatically if avctx max_b_frames <= 0, " \
765769 "since most of Android devices don't output B frames by default.", \
766770 OFFSET(pts_as_dts), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, \
767−
771+ { "operating_rate", "The desired operating rate that the codec will need to operate at, zero for unspecified", \
772+ OFFSET(operating_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE }, \
768773
769774 #define MEDIACODEC_ENCODER_CLASS(name) \
770775 static const AVClass name ## _mediacodec_class = { \
libavcodec/version.h+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "version_major.h"
3131
3232 #define LIBAVCODEC_VERSION_MINOR 25
33−#define LIBAVCODEC_VERSION_MICRO 100
33+#define LIBAVCODEC_VERSION_MICRO 101
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3636 LIBAVCODEC_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t