Preambule: This may sound like a very specific question, but this is actually a go / no go to build an API
16+ Android
application using MediaCodec
that is compatible with most phone.
I have an application with a h.264
MediaCodec
that receives data from a buffer - and not a surface since I'm doing a lot of manipulations on the image. When creating the Encoder
, I iterate through the list of possible encoders from the phone to make sure I'm using a proprietary encoder if any. This part is not a problem.
The problem is that each encoder has its color format preference. This may lead to color format conversion before encoding. In my proof-of-concept, for example, I included method to convert to NV12
, NV21
and YV12
, along with following very strict rules, like placing the start of some planes / interleaved plane at a precise offset in the buffer, etc. Just being able to make an encoded video look good may be a long story.
So, if I was certain that there is a standard in what Android h.264
MediaCodec
Encoders are accepting, then that would limit a lot the amount of customization I have to do to get my API 16 MediaCodec proof-of-concept working on all devices.
[EDIT]
Oh. I just saw that it's impossible to create an input surface before Android 18. I will have to rely on detecting proprietary codecs and color formats for each case, random crashes, slow FPS, etc. Bwe... With a bit of chance, in 2017 or 2018, there will be enough devices with relevant API features to write a decent app using MediaCodec.