当前位置: 首页 > 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.pierceye.com/news/655857/

相关文章:

  • 做网站推广也要营业执照吗网站关键词排名优化技巧
  • 网站建设需要考啥证广告设计与制作专业课程
  • 泸州市往建局建设银行网站名称广州网站建设 推广公司哪家好
  • 运维网站制作dw设计个人网页
  • 南城网站建设公司信息吉林省建设招标网站
  • 怎么把自己的网站上传到百度wordpress 文章拆分
  • 南湖网站建设公司百度app推广方法
  • 做海报用的图片网站数据库端口 wordpress
  • js面向对象网站开发工业控制软件开发
  • 做网站的时候说需求的专业术语app开发定制外包26
  • 辽源网站建设公司做网站有送企业邮箱吗
  • 哈尔滨网站建设可信赖惠州网站制作专业
  • 中法电商网站建设石家庄手机网站建站
  • 北京pk10做号网站官方网站怎么写
  • 半路出家去学计算机网站开发团购做的好的网站
  • 没有网站怎么做CPC模板网站一天建好
  • 淘客网站模版北京网站优化指导
  • 网站域名更改后怎么做映射石家庄新闻主持人
  • 网站报404错误怎么解决办法禹城市建设局网站
  • asp网站建设运用的技术哪里有做商城的网站
  • 沈阳的网站制作公司哪家好七七鱼竞价托管
  • 网站如何做流量赚钱地推公司
  • 众筹网站建设需要多少资金知己图书网站建设策划书
  • 开源房产网站源码网站建设需要数学
  • 网站建设云技术公司推荐企业内部管理软件
  • 网站建设与维护案列北京梵客装饰
  • 网站建设电销话术海口h5建站
  • 网站建设怎么搭建服务器梧州本地网站
  • 佛山哪个做网站的好天津建设工程信息网怎么报名的
  • 专注扬中网站建设无锡免费建设网站