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

穿精又带淫゛_ 提交于 2020-08-08 05:18:06

问题


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.


回答1:


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.




回答2:


Basically, it has such API for android 6.0+ (MarshMallow version), you can check more detail here getMaxSupportedInstances

For Android 4.4, no, it doesn't have such API for developers to check how many media codec instances this device supports(but remember, even you find that device can create 10 media codec instances, it doesn't mean you can open that many).

You can check my code snap here. Check Media Code Instances



来源:https://stackoverflow.com/questions/24734872/detect-the-capability-of-using-multiple-mediacodec-as-video-encoder-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!