Search code examples
androidvideogpuvideo-processingvideo-encoding

Use GPU in Android for video recording and playback


I have a video recording app written in Android. I was wondering if there is any ways to use the device's GPU to speed things up or make the recording (e.g. encoding part) more efficient? How about video playback (e.g. decoding parts, processing, etc.)?

Any samples or guidance would be helpful.


Solution

  • The simplest answer is to make sure your app uses one of the most common codecs and then the likelihood is that the device will support this in the HW - h.264 is probably the most common but many devices now may support h.265 in the HW also.

    The more complex answer is that your app can actually check the list of supported codecs on the device, using the MediaCodec API to get the list of coecs, and then query which ones are HW accelerated (must be API 29 or higher): https://developer.android.com/reference/android/media/MediaCodecInfo.html#isHardwareAccelerated()