[FFmpeg-trac] #10689(avcodec:new): [Android] Provide options to tweak h264_mediacodec encoder quality vs bitrate vs speed (was: [Android] Provide options to tweak h264_mediacodec encoder encoding quality vs bitrate vs encoding speed)

FFmpeg trac at avcodec.org
Fri Nov 24 14:15:10 EET 2023


#10689: [Android] Provide options to tweak h264_mediacodec encoder quality vs
bitrate vs speed
-------------------------------------+-----------------------------------
             Reporter:  bubbleguuum  |                    Owner:  (none)
                 Type:  enhancement  |                   Status:  new
             Priority:  normal       |                Component:  avcodec
              Version:  unspecified  |               Resolution:
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-----------------------------------
Changes (by bubbleguuum):

 * summary:
     [Android] Provide options to tweak h264_mediacodec encoder encoding
     quality vs bitrate vs encoding speed
     =>
     [Android] Provide options to tweak h264_mediacodec encoder quality vs
     bitrate vs speed


Old description:

> As of FFmpeg v6.1, there is very little that you can do to tweak the
> video quality output of the h264_mediacodec encoder vs the bitrate
> required (think the equivalent of the libx264 -preset option).
>
> For improving quality, the only way I found is to increase the bitrate
> with the -b:v parameter.
> When that parameter is specified, the encoder will honor it: it acts as a
> max bitrate setting.
> The higher the bitrate specified with -b:v, the higher the quality.
>
> In my experience, it requires a quite high bitrate for an acceptable
> video quality. For example, for 1080p output, at least 10Mbit is required
> for acceptable quality. At 5Mbit, output is very blocky. In that regard,
> it seems to operate very much like the libx264 ultrafast or superfast
> presets.
>
> It would be great to have more control on quality (vs encoding speed and
> bitrate). I'm not super familiar with the MediaCodec encoder API but I
> believe there are settings to tweak quality. Although AFAIK, no h264
> encoder implementation on Android support constant quality (thus
> '-bitrate_mode cq' encoder specific option is not supported) so something
> like -crf cannot probably be implemented. Only VBR and CBR are broadly
> supported.

New description:

 As of FFmpeg v6.1, there is very little that you can do to tweak the video
 quality output of the h264_mediacodec encoder vs the bitrate required
 (think the equivalent of the libx264 -preset option).

 For improving quality, the only way I found is to increase the bitrate
 with the -b:v parameter.
 When that parameter is specified, the encoder will honor it: it acts as a
 max bitrate setting.
 The higher the bitrate specified with -b:v, the higher the quality.

 In my experience, it requires a quite high bitrate for an acceptable video
 quality. For example, for 1080p output, at least 10Mbit is required for
 acceptable quality. At 5Mbit, output is very blocky. In that regard, it
 seems to operate very much like the libx264 ultrafast or superfast
 presets.

 It would be great to have more control on quality (vs encoding speed and
 bitrate). I'm not super familiar with the MediaCodec encoder API but I
 believe there are settings to tweak quality. Although AFAIK, no h264
 encoder implementation on Android support constant quality (thus
 '-bitrate_mode cq' encoder specific option is not supported) so something
 like -crf cannot probably be implemented. Only VBR and CBR are broadly
 supported.

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10689#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list