媒體轉碼器
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
從 Android 10 (API 級別 29) 以上版本開始,MediaCodecInfo
中提供的方法可顯示編解碼器相關資訊:
isSoftwareOnly()
- 如果轉碼器只在軟體中執行,則傳回 true。軟體轉碼器無法保證轉譯效能。
isHardwareAccelerated()
- 如果編解碼器由硬體加速,則傳回 true。
isVendor()
- 如果編解碼器是由裝置供應商提供,則傳回 true;如果是由 Android 平台提供,則傳回 false。
isAlias()
MediaCodecList
可能會包含相同基礎轉碼器的其他項目,並使用替代轉碼器名稱 (別名)。如果這個項目的轉碼器是另一個轉碼器的別名,這個方法會傳回 true。
此外,MediaCodec.getCanonicalName()
會傳回透過別名建立的基礎轉碼器名稱。
效能點代表轉碼器以特定高度、寬度和畫面更新率算繪影片的能力。舉例來說,UHD_60
效能點代表以每秒 60 個影格算繪的超高畫質影片 (3840x2160 像素)。
這個方法會傳回編解碼器可轉譯或擷取的 PerformancePoint
項目清單。MediaCodecInfo.VideoCapabilities.getSupportedPerformancePoints()
您可以呼叫 PerformancePoint.covers(PerformancePoint)
,檢查特定 PerformancePoint
是否涵蓋另一個 PerformancePoint
。舉例來說,UHD_60.covers(UHD_50)
會傳回 true。
所有硬體加速轉碼器都會提供效能點數清單。
如果編解碼器連最低標準的效能點都達不到,這份清單可能會是空白。
請注意,如果裝置升級至 Android 10 (API 級別 29) 以上版本,但未更新供應商映像檔,則不會有效能點資料,因為這類資料來自供應商 HAL。在這種情況下,getSupportedPerformancePoints()
會傳回空值。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[],[],null,["Beginning 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\nPerformance 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."]]