I'm using MediaCodec
to encode video from the camera:
MediaFormat format = MediaFormat.createVideoFormat("video/avc", width, height);
format.setInteger(MediaFormat.KEY_BIT_RATE, 250000);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1);
format.setInteger(MediaFormat.KEY_FRAME_RATE, 15);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
_mediaCodec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
What I've found is that depending on the resolution I give it there is some minimum valid bit rate to set. If I set a bit rate under that amount, it's entirely ignored. If I set a bit rate above this invisible threshold it works as intended. What I would like to do is query what the minimum bit rate I can set for KEY_BIT_RATE
is for any given resolution. No errors are thrown or anything when I set a bit rate that doesn't have any effect.
Minimal bitrate is a part of google requirements for resolutions that are required to be supported by vendors: https://source.android.com/compatibility/android-cdd.pdf. Look at 5.2
For other resolutions the behavior is undefined. Resolutions not listed in the doc can also introduce other unexpected issues because are not included in Google certification tests (CTS) and there is no guarantee that device vendors make them working correctly
And there is no API in android to check minimal supported bitrate for exact resolution
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With