当前位置: 首页 > article >正文

Android 获取系统编解码器

媒体编解码器 官网说明。

通过 MediaCodecInfo 拿到解码器信息:

  • getName() :获取编解码器名字。
  • isEncoder() :如果是编码器返回 true 。如果是编码器,返回 false 。
  • isHardwareAccelerated() :如果是硬解码返回 true 。
  • isVendor() :如果编解码器由设备供应商提供,则返回 true;如果由 Android 平台提供,则返回 false。
  • getSupportedTypes() :获取支持的媒体类型。
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;

    private void MediaCodecInfo(){
        MediaCodecList list = null;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
            MediaCodecInfo[] supportCodes = list.getCodecInfos();
            if (null != supportCodes && supportCodes.length > 0) {
                for (MediaCodecInfo info : supportCodes){
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                        StringBuilder strTypes = new StringBuilder();
                        String[] types = info.getSupportedTypes();
                        for (int j = 0; j < types.length; j++) {
                            strTypes.append(types[j]).append(",");
                        }
                        Log.d(TAG , "[MainActivity] -- MediaCodecInfo -- "
                                + "find MediaCodecInfo " + info.getName()
                                + " , isEncoder:" + info.isEncoder()
                                + " , isHardwareAccelerated:" + info.isHardwareAccelerated()
                                + " , isVendor:" + info.isVendor()
                                + " , supportedTypes:" + strTypes);
                    }
                }
            }
        }
    }

模拟器运行结果,

find MediaCodecInfo OMX.google.aac.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/mp4a-latm,
find MediaCodecInfo OMX.google.amrnb.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/3gpp,
find MediaCodecInfo OMX.google.amrwb.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/amr-wb,
find MediaCodecInfo OMX.google.flac.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/flac,
find MediaCodecInfo OMX.google.g711.alaw.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/g711-alaw,
find MediaCodecInfo OMX.google.g711.mlaw.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/g711-mlaw,
find MediaCodecInfo OMX.google.gsm.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/gsm,
find MediaCodecInfo OMX.google.mp3.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/mpeg,
find MediaCodecInfo OMX.google.opus.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/opus,
find MediaCodecInfo OMX.google.raw.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/raw,
find MediaCodecInfo OMX.google.vorbis.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/vorbis,
find MediaCodecInfo OMX.google.aac.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/mp4a-latm,
find MediaCodecInfo OMX.google.amrnb.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/3gpp,
find MediaCodecInfo OMX.google.amrwb.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/amr-wb,
find MediaCodecInfo OMX.google.flac.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/flac,
find MediaCodecInfo OMX.google.h264.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/avc,
find MediaCodecInfo OMX.google.h263.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/3gpp,
find MediaCodecInfo OMX.google.hevc.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/hevc,
find MediaCodecInfo OMX.google.mpeg4.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/mp4v-es,
find MediaCodecInfo OMX.google.vp8.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/x-vnd.on2.vp8,
find MediaCodecInfo OMX.google.vp9.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/x-vnd.on2.vp9,
find MediaCodecInfo OMX.google.h264.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/avc,
find MediaCodecInfo OMX.google.h263.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/3gpp,
find MediaCodecInfo OMX.google.mpeg4.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/mp4v-es,
find MediaCodecInfo OMX.google.vp8.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/x-vnd.on2.vp8,
find MediaCodecInfo OMX.google.vp9.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/x-vnd.on2.vp9,

真机运行结果,

find MediaCodecInfo OMX.google.aac.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/mp4a-latm,
find MediaCodecInfo OMX.google.amrnb.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/3gpp,
find MediaCodecInfo OMX.google.amrwb.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/amr-wb,
find MediaCodecInfo OMX.google.flac.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/flac,
find MediaCodecInfo OMX.google.g711.alaw.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/g711-alaw,
find MediaCodecInfo OMX.google.g711.mlaw.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/g711-mlaw,
find MediaCodecInfo OMX.google.mp3.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/mpeg,
find MediaCodecInfo OMX.google.opus.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/opus,
find MediaCodecInfo OMX.google.raw.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/raw,
find MediaCodecInfo OMX.google.vorbis.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/vorbis,
find MediaCodecInfo OMX.google.aac.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/mp4a-latm,
find MediaCodecInfo OMX.google.amrnb.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/3gpp,
find MediaCodecInfo OMX.google.amrwb.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/amr-wb,
find MediaCodecInfo OMX.google.flac.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:audio/flac,
find MediaCodecInfo OMX.MS.AC3.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/ac3,audio/ac3p,audio/eac3,
find MediaCodecInfo OMX.MS.AC4.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/ac4,
find MediaCodecInfo OMX.MS.ADPCM.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/x-adpcm-ima,audio/x-adpcm-ms,
find MediaCodecInfo OMX.MS.DRA.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/vnd.dra,
find MediaCodecInfo OMX.MS.FLAC.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/flac,
find MediaCodecInfo OMX.MS.AAC.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/mp4a-latm-hw,
find MediaCodecInfo OMX.MS.MP1.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/mpeg-L1,
find MediaCodecInfo OMX.MS.MP2.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/mpeg-L2,
find MediaCodecInfo OMX.MS.MP3.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/mpeg,
find MediaCodecInfo OMX.MS.OPUS.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/opus,
find MediaCodecInfo OMX.MS.Passthrough.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/passthrough,
find MediaCodecInfo OMX.MS.VORBIS.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:audio/vorbis,
find MediaCodecInfo OMX.MS.AV1.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/av01,
find MediaCodecInfo OMX.MS.AVC.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/avc,
find MediaCodecInfo OMX.MS.AVS.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/avs,
find MediaCodecInfo OMX.MS.AVS2.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/avs2,
find MediaCodecInfo OMX.MS.FLV.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/flv,
find MediaCodecInfo OMX.MS.H263.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/3gpp,
find MediaCodecInfo OMX.MS.HEVC.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/hevc,
find MediaCodecInfo OMX.MS.MJPG.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/x-motion-jpeg,
find MediaCodecInfo OMX.MS.MPEG2.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/mpeg2,
find MediaCodecInfo OMX.MS.M4V.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/mp4v-es,
find MediaCodecInfo OMX.MS.VC1.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/VC1,
find MediaCodecInfo OMX.MS.VP8.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/x-vnd.on2.vp8,
find MediaCodecInfo OMX.MS.VP9.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/x-vnd.on2.vp9,
find MediaCodecInfo OMX.MS.WMV3.Decoder , isEncoder:false , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/x-ms-wmv,
find MediaCodecInfo OMX.MS.AVC.Encoder , isEncoder:true , isHardwareAccelerated:true , isVendor:true , supportedTypes:video/avc,
find MediaCodecInfo OMX.google.h263.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/3gpp,
find MediaCodecInfo OMX.google.mpeg4.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/mp4v-es,
find MediaCodecInfo OMX.google.vp8.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/x-vnd.on2.vp8,
find MediaCodecInfo OMX.google.vp9.decoder , isEncoder:false , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/x-vnd.on2.vp9,
find MediaCodecInfo OMX.google.h264.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/avc,
find MediaCodecInfo OMX.google.h263.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/3gpp,
find MediaCodecInfo OMX.google.mpeg4.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/mp4v-es,
find MediaCodecInfo OMX.google.vp8.encoder , isEncoder:true , isHardwareAccelerated:false , isVendor:false , supportedTypes:video/x-vnd.on2.vp8,

http://www.kler.cn/a/133478.html

相关文章:

  • sqlsever 分布式存储查询
  • Mysql篇-三大日志
  • 网络技术-网桥模式
  • MySQL高级(二):一条更新语句是如何执行的
  • Unity 性能优化方案
  • git入门环境搭建
  • Argo Rollouts结合Service进行Blue-Green部署
  • 关于Hbase的一些问题
  • JQuery ajax 提交数据提示:Uncaught TypeError:Illegal invocation
  • pom.xml格式化快捷键
  • WSL2环境下Debian 12的Docker安装与配置
  • Android13 Launcher3 定制
  • 怎样备份电脑文件比较安全
  • “腾易视连”构建汽车生态新格局 星选计划赋能创作者价值提升
  • Windows安装Java环境(OracleJDK)
  • 【Feign】 基于 Feign 远程调用、 自定义配置、性能优化、实现 Feign 最佳实践
  • 基于鼠群算法优化概率神经网络PNN的分类预测 - 附代码
  • 量化交易:借助talib使用技术分析指标
  • 如何构建风险矩阵?3大注意事项
  • 【小沐学GIS】电子海图OpenCPN源代码编译和运行(VS2017 + Win10)
  • VScode 配置用户片段
  • 基于libcurl+libopenssl开源库编译出curl下载工具及代码集成curl功能
  • Linux QT交叉编译环境安装
  • Vite 启动默认只能访问localhost解决方法
  • 基于枚举实现的桥接模式
  • 物联网赋能:WIFI HaLow在无线连接中的优势