Search code examples
javaandroidh.264android-mediacodec

Does Android MediaCodec support RGBA encoding?


I have a set of Bitmap, need to be encoded into h264 video, Bitmap converted to RGBA byte [] sent to MediaCodec, but the exception: java.nio.BufferOverflowException

 I would like to know if Android MediaCodec supports RBGA encoding?

Does anyone know how to fix this?

Or another workaround to achieve encoding to H.264?

Thank you!


Solution

  • You can load them into an openGL es texture and render to the encoder's input surface. (maybe this will help: https://github.com/google/grafika)

    Another option is to convert to the color format that the encoder support. (using libyuv for example)