Gagan
Gagan

Reputation: 1497

Can I force a Codec to decode H264 data to a particular ColorFormat (from the ColorFormats it supports)?

On Android 4.1 and above, I am using MediaCodec framework to decode H264 data. I see the codec instance that I'm using (via createDecoderByType) supports multiple color-formats. However, it always gives the output in the 1st-indexed color-format (from its supported list).

Is there a way to force the decoder to give out decoded data in a particular color-format from the ColorFormats it supports? I know the developer docs does mention that the key KEY_COLOR_FORMAT can only be set for encoders, but then help me understand what is the rational of having multiple supported color-formats for decoders?

Upvotes: 0

Views: 774

Answers (1)

fadden
fadden

Reputation: 52353

No, there is currently no way to specify the color format for the decoder output.

This is especially annoying on devices that use undocumented proprietary buffer layouts.

Directing the output to a Surface results in more consistent and portable behavior, but as of API 19 there's still no convenient way to get at the pixel data (ImageReader doesn't work with MediaCodec output formats, glReadPixels() can be slow and works in RGB, etc). If you can do what you need with OpenGL shaders then things work pretty well (see e.g. the effects in "show + capture camera").

Upvotes: 2

Related Questions