问题描述
是否可以找出使用MediaCodec.createDecoderByType(type)接收到的解码器是硬件解码器还是软件解码器?
Is there a way to find out if the decoder that received using MediaCodec.createDecoderByType(type) is a hardware decoder or a software decoder?
推荐答案
没有真正的正式标志来指示编解码器是硬件还是软件编解码器.实际上,您可以执行以下操作:
There is no real formal flag for indicating whether a codec is a hardware or software codec. In practice, you can do this, though:
MediaCodec codec = MediaCodec.createDecoderByType(type);
if (codec.getName().startsWith("OMX.google.")) {
// Is a software codec
}
(从API级别18开始提供MediaCodec.getName()
方法.对于较低的API级别,您需要遍历MediaCodecList
中的条目,并手动选择适合您需求的正确编解码器.)
(The MediaCodec.getName()
method is available since API level 18. For lower API levels, you instead need to iterate over the entries in MediaCodecList
and manually pick the right codec that fits your needs instead.)
这篇关于如何知道Android解码器MediaCodec.createDecoderByType(type)是硬件还是软件解码器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!