检测在Android中使用多个MediaCodec作为视频编码器的功能 [英] Detect the capability of using multiple MediaCodec as video encoder in Android

查看:621
本文介绍了检测在Android中使用多个MediaCodec作为视频编码器的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅这个问题,一个APP是否可以使用多个MediaCodec实例作为视频编码器取决于设备.是否有建议的方法来检测设备上的此功能?

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?

例如,如果有一个Android API来查询对多个视频编码器的支持或其最大计数,或者在编码过程之前创建/初始化MediaCodec实例时可以检查这一点?我想在我的APP中检测设备功能,而无需对不良视频进行编码甚至崩溃.

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.

推荐答案

从Android 4.4开始,没有这样的API.

As of Android 4.4, there is no such API.

我知道要执行此操作的唯一方法是尝试设置编码器,并查看其是否失败. "screenrecord"命令执行类似的操作:它尝试以完整的显示分辨率对视频进行编码.如果失败,则回落至720p,然后重试.

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.

这篇关于检测在Android中使用多个MediaCodec作为视频编码器的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆