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.
Showing the changes to libavcodec (2 of 2 files). Show all
Unified · Split
| @@ -76,6 +76,8 @@ typedef struct MediaCodecEncContext { · 75 unmodified lines | ||
| 76 | 76 | int level; |
| 77 | 77 | int pts_as_dts; |
| 78 | 78 | int extract_extradata; |
| 79 | + // Ref. MediaFormat KEY_OPERATING_RATE | |
| 80 | + int operating_rate; | |
| 79 | 81 | } MediaCodecEncContext; |
| 80 | 82 | |
| 81 | 83 | enum { |
| @@ -354,6 +356,8 @@ static av_cold int mediacodec_init(AVCodecContext *avctx) · 272 unmodified lines | ||
| 354 | 356 | } |
| 355 | 357 | if (s->pts_as_dts == -1) |
| 356 | 358 | 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); | |
| 357 | 361 | |
| 358 | 362 | ret = ff_AMediaCodec_getConfigureFlagEncode(s->codec); |
| 359 | 363 | 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 | ||
| 764 | 768 | { "pts_as_dts", "Use PTS as DTS. It is enabled automatically if avctx max_b_frames <= 0, " \ |
| 765 | 769 | "since most of Android devices don't output B frames by default.", \ |
| 766 | 770 | 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 }, \ | |
| 768 | 773 | |
| 769 | 774 | #define MEDIACODEC_ENCODER_CLASS(name) \ |
| 770 | 775 | static const AVClass name ## _mediacodec_class = { \ |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "version_major.h" |
| 31 | 31 | |
| 32 | 32 | #define LIBAVCODEC_VERSION_MINOR 25 |
| 33 | −#define LIBAVCODEC_VERSION_MICRO 100 | |
| 33 | +#define LIBAVCODEC_VERSION_MICRO 101 | |
| 34 | 34 | |
| 35 | 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 36 | 36 | LIBAVCODEC_VERSION_MINOR, \ |