媒体编解码器
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从 Android 10(API 级别 29)及更高版本开始,MediaCodecInfo
中有一些方法可以显示有关编解码器的更多信息:
isSoftwareOnly()
- 如果编解码器仅在软件中运行,则返回 true。软件编解码器并不能保证渲染性能。
isHardwareAccelerated()
- 如果编解码器由硬件加速,则返回 true。
isVendor()
- 如果编解码器由设备供应商提供,则返回 true;如果由 Android 平台提供,则返回 false。
isAlias()
MediaCodecList
可能针对使用备用编解码器名称(别名)的同一底层编解码器包含额外的条目。如果此条目中的编解码器是另一个编解码器的别名,则此方法会返回 true。
此外,MediaCodec.getCanonicalName()
会针对通过别名创建的编解码器返回底层编解码器名称。
“性能点”表示编解码器以特定高度、宽度和帧速率渲染视频的能力。例如,UHD_60
性能点表示以每秒 60 帧的速度渲染超高清视频(3840x2160 像素)。
方法 MediaCodecInfo.VideoCapabilities.getSupportedPerformancePoints()
会返回编解码器可以呈现或捕获的 PerformancePoint
条目列表。
您可以通过调用 PerformancePoint.covers(PerformancePoint)
检查给定的 PerformancePoint
是否覆盖另一个 PerformancePoint
。例如,UHD_60.covers(UHD_50)
会返回 true。
我们为所有硬件加速的编解码器都提供了性能点列表。
如果编解码器连标准性能点的最低值都不能满足,则此列表可能为空。
请注意,已升级到 Android 10(API 级别 29)及更高版本但未更新供应商映像的设备是没有性能点数据的,因为此数据来自供应商 HAL。在这种情况下,getSupportedPerformancePoints()
会返回 null。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Media codecs\n\nBeginning with Android 10 (API level 29) and higher, there are methods in\n[`MediaCodecInfo`](/reference/android/media/MediaCodecInfo) that\nreveal more information about a codec:\n\n[`isSoftwareOnly()`](/reference/android/media/MediaCodecInfo#isSoftwareOnly)\n: Returns true if the codec runs in software only. Software codecs make no\n guarantees about rendering performance.\n\n[`isHardwareAccelerated()`](/reference/android/media/MediaCodecInfo#isHardwareAccelerated)\n: Returns true if a codec is accelerated by hardware.\n\n[`isVendor()`](/reference/android/media/MediaCodecInfo#isVendor)\n: Returns true if the codec is provided by the device vendor or false if provided\n by the Android platform.\n\n[`isAlias()`](/reference/android/media/MediaCodecInfo#isAlias)\n: `MediaCodecList` may contain additional entries for the same underlying codec\n using an alternate codec name/s (alias/es). This method returns true if the\n codec in this entry is an alias for another codec.\n\nIn addition,\n[`MediaCodec.getCanonicalName()`](/reference/android/media/MediaCodecInfo#getCanonicalName)\nreturns the underlying codec name for codecs created via an alias.\n\n#### Performance Points\n\nA *performance point* represents a codec's ability to render video at a specific\nheight, width and frame rate. For example, the `UHD_60` performance point\nrepresents Ultra High Definition video (3840x2160 pixels) rendered at 60 frames\nper second.\n\nThe method\n[`MediaCodecInfo.VideoCapabilities.getSupportedPerformancePoints()`](/reference/android/media/MediaCodecInfo.VideoCapabilities#getSupportedPerformancePoints())\nreturns a list of\n[`PerformancePoint`](/reference/android/media/MediaCodecInfo.VideoCapabilities.PerformancePoint)\nentries that the codec can render or capture.\n\nYou can check whether a given `PerformancePoint` covers another by calling\n[`PerformancePoint.covers(PerformancePoint)`](/reference/android/media/MediaCodecInfo.VideoCapabilities.PerformancePoint#covers(android.media.MediaCodecInfo.VideoCapabilities.PerformancePoint)).\nFor example, `UHD_60.covers(UHD_50)` returns true.\n\nA list of performance points is provided for all hardware-accelerated codecs.\nThis could be an empty list if the codec does not meet even the lowest standard\nperformance point.\n\nNote that devices which have been upgraded to Android 10 (API level 29) and higher without\nupdating the vendor image will not have performance point data, because this\ndata comes from the vendor HAL. In this case, `getSupportedPerformancePoints()`\nreturns null."]]