简体   繁体   中英

How to detect Android H.264 hardware acceleration capability

A large number, though not all, of Android devices support hardware acceleration of the H.264 video codec but not the VP8/VP9 codecs. To provide a higher quality user experience, we would like to select the codec that is hardware accelerated when possible. Hence, would like runtime detection of whether the specific device has H.264 hardware acceleration support or not and based on this will set the particular codecs that is used in the SDP for session negotiation of the webRTC peerconnection. Ie, if H.264 is supported with hardware then will set that as the higher priority codec as opposed to VP8/VP9. Any thoughts on this would be greatly appreciated.

Use the MediaCodecList API to iterate over the available encoders and decoders. Encoders whose name start with OMX.google. are SW codecs - any other codec can more or less be assumed to be a HW codec. The easiest is probably to use findEncoderForFormat (and findDecoderForFormat ) and see what name this returns. If you need more detail, you can iterate through the list manually.

According to Justin Uberti's comment here , you will only get H.264 in Android WebRTC if there is an HW encoder on the device. So you can simply set WebRTC to prefer H.264 - if there is an HW encoder, HW H.264 will be used. If not, then it's VP8/VP9.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM