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

网站自动识别手机新品发布会视频

网站自动识别手机,新品发布会视频,遵义在线网站建设,windows系统安装wordpress系列文章目录 文章目录 系列文章目录前言一、MediaCodecList 是什么#xff1f;二、MediaCodecList 使用方法1. 获取 MediaCodecList 实例2. 列出设备上支持的编解码器3. 获取编解码器详细信息4. 判断设备是否支持某种编解码器5. 查询默认的编解码器 三、通过 MediaCodecList …系列文章目录 文章目录 系列文章目录前言一、MediaCodecList 是什么二、MediaCodecList 使用方法1. 获取 MediaCodecList 实例2. 列出设备上支持的编解码器3. 获取编解码器详细信息4. 判断设备是否支持某种编解码器5. 查询默认的编解码器 三、通过 MediaCodecList 创建 MediaCodec3.1 创建解码器3.2 创建编码器 总结参考 前言 最近在学习 Android MediaCodec 相关的知识准备开个新坑把学习过程记录下来总结成 MediaCodec 教程。在介绍 MediaCodec 编解码之前让我们学习一些其他与之配套的组件今天要讲的是 MediaCodecList。 提示以下是本篇文章正文内容下面案例可供参考 一、MediaCodecList 是什么 MediaCodecList 是 Android 提供的一个类用于查询设备上可用的编解码器codecs。编解码器是用于编码和解码数据的软件组件例如音频或视频数据。 MediaCodecList 提供了一种方法来获取设备上所有可用的编解码器的信息包括它们的名称、支持的数据格式等。这对于开发需要处理音频或视频数据的应用程序非常有用。 例如你可以使用 MediaCodecList 来查找设备上是否有支持特定视频格式的编解码器如果有你可以使用这个编解码器来处理这种格式的视频数据。 二、MediaCodecList 使用方法 1. 获取 MediaCodecList 实例 可以通过以下方式获取 MediaCodecList 实例 MediaCodecList codecList new MediaCodecList(MediaCodecList.ALL_CODECS);其中ALL_CODECS 表示列出所有编解码器也可以使用 REGULAR_CODECS 表示只列出正常编解码器。在笔者的华为测试机上ALL_CODECS 与 REGULAR_CODECS 有部分差别在 ALL_CODECS 中有一些带 .secure 的解码器类型 例如 OMX.hisi.video.decoder.avc.secure 2. 列出设备上支持的编解码器 可以通过以下方式列出设备上支持的编解码器 MediaCodecInfo[] codecInfos codecList.getCodecInfos();其中codecInfos 是一个包含所有支持的编解码器信息的数组。 3. 获取编解码器详细信息 可以通过以下方式获取编解码器的详细信息 MediaCodecInfo codecInfo codecInfos[i]; String name codecInfo.getName(); // 编解码器名称 String canonicalName codecInfo.getCanonicalName(); // 编解码器规范名称 boolean isEncoder codecInfo.isEncoder(); // 是编码器吗 boolean isVendor codecInfo.isVendor(); // 是厂商提供的吗 boolean isSoftwareOnly codecInfo.isSoftwareOnly(); // 纯软件实现的编解码器 boolean isHardwareAccelerated codecINfo.isHardwareAccelerated(); // 有硬件加速 String[] types codecInfo.getSupportedTypes(); // 支持的媒体类型 MediaCodecInfo.CodecCapabilities capabilities codecInfo.getCapabilitiesForType(type); // 编解码器的配置参数canonicalName 是编码器规范名称在 Android 中一个编解码器可能有多个别名为了保持向后兼容性设备实现可能会为同一个编解码器提供多个别名。getCanonicalName() 方法返回的是编解码器的规范名称它必须是唯一的不能是别名。 isHardwareAccelerated 查询是否有硬件加速很多厂商提供编解码器都有硬件加速。 下面是笔者机器上的编解码器信息 codec: c2.android.aac.decoder, canonicalName: c2.android.aac.decoder, types: [audio/mp4a-latm], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.aac.decoder, canonicalName: c2.android.aac.decoder, types: [audio/mp4a-latm], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.aac.encoder, canonicalName: c2.android.aac.encoder, types: [audio/mp4a-latm], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.aac.encoder, canonicalName: c2.android.aac.encoder, types: [audio/mp4a-latm], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.amrnb.decoder, canonicalName: c2.android.amrnb.decoder, types: [audio/3gpp], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.amrnb.decoder, canonicalName: c2.android.amrnb.decoder, types: [audio/3gpp], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.amrnb.encoder, canonicalName: c2.android.amrnb.encoder, types: [audio/3gpp], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.amrnb.encoder, canonicalName: c2.android.amrnb.encoder, types: [audio/3gpp], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.amrwb.decoder, canonicalName: c2.android.amrwb.decoder, types: [audio/amr-wb], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.amrwb.decoder, canonicalName: c2.android.amrwb.decoder, types: [audio/amr-wb], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.amrwb.encoder, canonicalName: c2.android.amrwb.encoder, types: [audio/amr-wb], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.amrwb.encoder, canonicalName: c2.android.amrwb.encoder, types: [audio/amr-wb], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.flac.decoder, canonicalName: c2.android.flac.decoder, types: [audio/flac], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.flac.decoder, canonicalName: c2.android.flac.decoder, types: [audio/flac], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.flac.encoder, canonicalName: c2.android.flac.encoder, types: [audio/flac], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.flac.encoder, canonicalName: c2.android.flac.encoder, types: [audio/flac], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.g711.alaw.decoder, canonicalName: c2.android.g711.alaw.decoder, types: [audio/g711-alaw], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.g711.alaw.decoder, canonicalName: c2.android.g711.alaw.decoder, types: [audio/g711-alaw], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.g711.mlaw.decoder, canonicalName: c2.android.g711.mlaw.decoder, types: [audio/g711-mlaw], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.g711.mlaw.decoder, canonicalName: c2.android.g711.mlaw.decoder, types: [audio/g711-mlaw], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.gsm.decoder, canonicalName: c2.android.gsm.decoder, types: [audio/gsm], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.gsm.decoder, canonicalName: c2.android.gsm.decoder, types: [audio/gsm], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.mp3.decoder, canonicalName: c2.android.mp3.decoder, types: [audio/mpeg], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.mp3.decoder, canonicalName: c2.android.mp3.decoder, types: [audio/mpeg], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.opus.decoder, canonicalName: c2.android.opus.decoder, types: [audio/opus], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.opus.decoder, canonicalName: c2.android.opus.decoder, types: [audio/opus], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.opus.encoder, canonicalName: c2.android.opus.encoder, types: [audio/opus], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.raw.decoder, canonicalName: c2.android.raw.decoder, types: [audio/raw], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.raw.decoder, canonicalName: c2.android.raw.decoder, types: [audio/raw], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.vorbis.decoder, canonicalName: c2.android.vorbis.decoder, types: [audio/vorbis], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.vorbis.decoder, canonicalName: c2.android.vorbis.decoder, types: [audio/vorbis], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.dolby.ac3.decoder, canonicalName: OMX.dolby.ac3.decoder, types: [audio/ac3], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.dolby.ac4.decoder, canonicalName: OMX.dolby.ac4.decoder, types: [audio/ac4], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.dolby.eac3.decoder, canonicalName: OMX.dolby.eac3.decoder, types: [audio/eac3], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.dolby.eac3_joc.decoder, canonicalName: OMX.dolby.eac3_joc.decoder, types: [audio/eac3-joc], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.avc, canonicalName: OMX.hisi.video.decoder.avc, types: [video/avc], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.avc.secure, canonicalName: OMX.hisi.video.decoder.avc.secure, types: [video/avc], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.hevc, canonicalName: OMX.hisi.video.decoder.hevc, types: [video/hevc], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.hevc.secure, canonicalName: OMX.hisi.video.decoder.hevc.secure, types: [video/hevc], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.mpeg2, canonicalName: OMX.hisi.video.decoder.mpeg2, types: [video/mpeg2], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.mpeg4, canonicalName: OMX.hisi.video.decoder.mpeg4, types: [video/mp4v-es], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.vp8, canonicalName: OMX.hisi.video.decoder.vp8, types: [video/x-vnd.on2.vp8], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.vp9, canonicalName: OMX.hisi.video.decoder.vp9, types: [video/x-vnd.on2.vp9], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.decoder.vp9.secure, canonicalName: OMX.hisi.video.decoder.vp9.secure, types: [video/x-vnd.on2.vp9], isEncoder false, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.encoder.avc, canonicalName: OMX.hisi.video.encoder.avc, types: [video/avc], isEncoder true, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: OMX.hisi.video.encoder.hevc, canonicalName: OMX.hisi.video.encoder.hevc, types: [video/hevc], isEncoder true, isVendor true, isAlias false, isSoftwareOnly false, isHardwareAccelerated true codec: c2.android.av1.decoder, canonicalName: c2.android.av1.decoder, types: [video/av01], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.avc.decoder, canonicalName: c2.android.avc.decoder, types: [video/avc], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.h264.decoder, canonicalName: c2.android.avc.decoder, types: [video/avc], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.avc.encoder, canonicalName: c2.android.avc.encoder, types: [video/avc], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.h264.encoder, canonicalName: c2.android.avc.encoder, types: [video/avc], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.h263.decoder, canonicalName: c2.android.h263.decoder, types: [video/3gpp], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.h263.decoder, canonicalName: c2.android.h263.decoder, types: [video/3gpp], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.h263.encoder, canonicalName: c2.android.h263.encoder, types: [video/3gpp], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.h263.encoder, canonicalName: c2.android.h263.encoder, types: [video/3gpp], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.hevc.decoder, canonicalName: c2.android.hevc.decoder, types: [video/hevc], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.hevc.decoder, canonicalName: c2.android.hevc.decoder, types: [video/hevc], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.hevc.encoder, canonicalName: c2.android.hevc.encoder, types: [video/hevc], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.mpeg4.decoder, canonicalName: c2.android.mpeg4.decoder, types: [video/mp4v-es], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.mpeg4.decoder, canonicalName: c2.android.mpeg4.decoder, types: [video/mp4v-es], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.mpeg4.encoder, canonicalName: c2.android.mpeg4.encoder, types: [video/mp4v-es], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.mpeg4.encoder, canonicalName: c2.android.mpeg4.encoder, types: [video/mp4v-es], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.vp8.decoder, canonicalName: c2.android.vp8.decoder, types: [video/x-vnd.on2.vp8], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.vp8.decoder, canonicalName: c2.android.vp8.decoder, types: [video/x-vnd.on2.vp8], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.vp8.encoder, canonicalName: c2.android.vp8.encoder, types: [video/x-vnd.on2.vp8], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.vp8.encoder, canonicalName: c2.android.vp8.encoder, types: [video/x-vnd.on2.vp8], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.vp9.decoder, canonicalName: c2.android.vp9.decoder, types: [video/x-vnd.on2.vp9], isEncoder false, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.vp9.decoder, canonicalName: c2.android.vp9.decoder, types: [video/x-vnd.on2.vp9], isEncoder false, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false codec: c2.android.vp9.encoder, canonicalName: c2.android.vp9.encoder, types: [video/x-vnd.on2.vp9], isEncoder true, isVendor false, isAlias false, isSoftwareOnly true, isHardwareAccelerated false codec: OMX.google.vp9.encoder, canonicalName: c2.android.vp9.encoder, types: [video/x-vnd.on2.vp9], isEncoder true, isVendor false, isAlias true, isSoftwareOnly true, isHardwareAccelerated false4. 判断设备是否支持某种编解码器 可以使用以下方式判断设备是否支持某种编解码器 boolean isEncoder true; // 是否为编码器 String mimeType video/avc; // 媒体类型 MediaCodecInfo codecInfo codecList.findCodecForType(mimeType); if (codecInfo ! null) {String name codecInfo.getName();if (isEncoder) {MediaCodecInfo.CodecCapabilities capabilities codecInfo.getCapabilitiesForType(mimeType);if (capabilities ! null capabilities.isEncoder()) {// 设备支持该编码器}} else {// 设备支持该解码器} }其中isEncoder 表示是否为编码器mimeType 表示媒体类型。 5. 查询默认的编解码器 对于某种 MediaFormatMediaCodecList 支持查询哪种 Codec 支持这种 Format MediaCodecInfo codecInfo codecList.findEncoderForFormat(format); if (codecInfo ! null) {String name codecInfo.getName();// 使用默认编码器 }其中format 表示媒体格式。 三、通过 MediaCodecList 创建 MediaCodec 3.1 创建解码器 想要解码某个文件首先要创建 MediaCodec 解码器基本步骤是 创建 MediaCodecList 实例使用 MediaExtractor 获取 Track 的 Format 信息根据 Format 找到默认的解码器信息 MediaCodecInfo根据 MediaCodecInfo 中的信息创建 MediaCodec 代码如下 public class Decoder {public void decodeFile(String filePath) {MediaExtractor extractor new MediaExtractor();try {extractor.setDataSource(filePath);} catch (IOException e) {e.printStackTrace();}// 获取文件中的第一个轨道MediaFormat format extractor.getTrackFormat(0);String mime format.getString(MediaFormat.KEY_MIME);// 使用 MediaCodecList 来找到支持这个媒体类型的解码器MediaCodecList codecList new MediaCodecList(MediaCodecList.ALL_CODECS);String decoderName codecList.findDecoderForFormat(format);// 创建 MediaCodec 解码器MediaCodec decoder null;try {decoder MediaCodec.createByCodecName(decoderName);} catch (IOException e) {e.printStackTrace();}// 配置解码器decoder.configure(format, null, null, 0);decoder.start();// ... 这里可以开始解码操作} }3.2 创建编码器 创建 MediaCodecList 实例构建 MediaFormat 用于描述目标编码的格式通过 MediaCodecList 查询 MediaFormat 的默认编码器信息 MediaCodecInfo根据 MediaCodecInfo 中的信息创建 MediaCodec 代码如下 public class Encoder {public void encodeToFormat(String mimeType) {// 创建 MediaCodecList 实例MediaCodecList codecList new MediaCodecList(MediaCodecList.ALL_CODECS);// 构建 MediaFormat 用于描述目标编码的格式MediaFormat format MediaFormat.createVideoFormat(mimeType, 640, 480);// 通过 MediaCodecList 查询 MediaFormat 的默认编码器信息 MediaCodecInfoString encoderName codecList.findEncoderForFormat(format);// 根据 MediaCodecInfo 中的信息创建 MediaCodecMediaCodec encoder null;try {encoder MediaCodec.createByCodecName(encoderName);} catch (IOException e) {e.printStackTrace();}// 配置编码器encoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);encoder.start();// ... 这里可以开始编码操作} }总结 本文介绍了 MediaCodecList 的基本使用方法并展示了如何使用 MediaCodecList 来创建 MediaCodec 编解码器。 参考 MediaCodecList
http://www.zqtcl.cn/news/655857/

相关文章:

  • 权威的顺德网站建设dw不会写代码能建立网站吗
  • 做网站美工的前途怎么样企业通讯软件下载
  • 客户说做网站价格高成都住建局官网住建智慧建管
  • 股票分析网站可以做推广吗网站开发 简历项目经历
  • 军人可以做网站吗学生信息管理系统网页设计教程
  • 使用循环视频做背景的网站青岛网站推广的价格
  • 邯山区建设局网站上海公司招聘
  • 做网站沈阳本地网站忧化 优帮云
  • 网上购物网站开发的目的建筑投标网站
  • 网站开发费用无形资产陕西省住房和城乡建设网站
  • 网站分析与优化如何编程写代码
  • 专业做网站企业百度站长管理平台
  • 网站组建 需求分析阿里巴巴网站装修
  • 网站建设怎么弄轮换图片网站制作公司dedecms
  • 南阳企业网站建设做兼职网站有哪些
  • ps做网站的优点国际设计师网站有哪些
  • 学校网站建立安阳市网站建设
  • 邢台做网站流程摄影工作室网站设计
  • 掉关键词网站重大军事新闻
  • 建材网站建设功能方案上海建筑室内设计有限公司
  • 高端企业网站设计公司怎么帮公司做网站建设
  • 湖北专业网站建设维修电话企业网络管理方案
  • 做网站外链wordpress网页怎么上传
  • wordpress站点优化石景山网站开发
  • 企业网站建设的流程店铺推广引流
  • 北京网站优化wyhseo信息化建设杂志社官方网站
  • 网站图片处理方案动漫制作这个专业怎么样
  • 做写手哪个网站好黄页网站建设黄页网站建设
  • 多语言企业网站免费模板网站哪个好
  • 拟一份饰品网站建设合同襄樊门户网站建设