Search code examples
androidvideomultiple-instancesandroid-mediacodecencoder

Detect the capability of using multiple MediaCodec as video encoder in Android


Refer to this question, it is device-dependent that whether an APP can use multiple MediaCodec instances as video encoder or not. Is there a recommended way to detect the capability of this on devices?

For example, if there is an Android API to query the support of multiple video encoder or its max count, or this can be checked when creating/initializing the MediaCodec instance before the encoding process? I want to detect the device capability in my APP without the need of encoding bad videos or even crashes.


Solution

  • As of Android 4.4, there is no such API.

    The only way I'm aware of to do this is to try to set up the encoders and see if it fails. The "screenrecord" command does something similar: it tries to encode video at the full display resolution. If that fails, it falls back to 720p and tries again.