I'm using MediaCodec
to encode H.264 video from camera, the problem is, when I move my phone, the output video's quality is very pool, full of mosaic/visual blocks in the video.
Belows are some details:
My encoder bitrate is 500 kbps, and bitrate-mode is BITRATE_MODE_VBR
.
I try to change bitrate to 800 kbps, the output video quality improves a lot, and if I change bitrate-mode into BITRATE_MODE_CQ
, the output video quality is perfect, but the bitrate will increase up to 1400 kbps.
I want to keep the average bitrate at a low level, e.g. 500 kbps, but allowing the bitrate burst into some bigger bitrate when the phone is moving, e.g. 800 kbps. In iOS VideoToolBox, there is an API kVTCompressionPropertyKey_DataRateLimits
to set the average bitrate and the max bitrate, but in Android, how could I achieve that average-max bitrate control?
I noticed that there is a hide "max-bitrate" parameter when configure the MediaCodec, but it has no effect (because Android framework ignore this parameter, see http://androidxref.com/7.1.1_r6/xref/frameworks/av/media/libstagefright/ACodec.cpp#configureCodec), I also noticed that there is a hide “quality” parameter, but it also has no effect.