Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do hardware h.264 video encoding on android platform

I'm trying to do hardware h.264 video encoding platform, I've learned that "MediaCodec" seems support hardware video decoding, but does it support hardware video encoding?

Some search results from google suggest I should consider search for different solutions for different chips according to user's Android device, does this mean I should go to each chip provider's website to search for different solution?

Thanks for any advice

like image 582
Zhiqiang Li Avatar asked Apr 27 '16 10:04

Zhiqiang Li


People also ask

What video codecs are supported on Android devices?

Device implementations must support dynamic video resolution and frame rate switching through the standard Android APIs within the same stream for all VP8, VP9, H.264, and H.265 codecs in real time and up to the maximum resolution supported by each codec on the device.

Do I need a video encoder and decoder for Android media framework?

The decoder is required, the encoder is recommended. The decoder is optional. The table below lists the Android media framework video encoding profiles and parameters recommended for playback using the H.264 Baseline Profile codec. The same recommendations apply to the Main Profile codec, which is only available in Android 6.0 and later.

Why use hardware encoding for video communication?

This is why we wanted to use hardware encoding for video communication, where possible because it reduces the load on the processor and consumes less battery power, which is essential for legacy devices. Also, H.264 hardware encoding is supported on lots of devices, in contrast to VP8 mentioned above.

Why is my hardware encoding not working on my Android device?

It’s apparent from the names of topics from discuss-webrtc, which are devoted to hardware encoding on Android, that something would be bound to go wrong. In most cases, the errors appear during the codec configuration stage.


1 Answers

The MediaCodec class also supports video encoding. The MediaCodec class was explicitly designed for multi device hardware accelerated media processing so that the same code runs on every device (from experience i can tell you it won't)

Good readings about this topic: http://developer.android.com/reference/android/media/MediaCodec.html http://bigflake.com/mediacodec/

Remember, MediaCodec min-sdk version is 16 (i recommend to target api 18 e.g. usage of surface / MediaMuxer class), so if you're targeting devices with api < 16 MediaCodec won't do. If you wan't to target these devices you'll have to use lib stagefright and OpenMax wich i do not recomend

like image 197
chris Avatar answered Oct 17 '22 01:10

chris