outputBuffers returns null pointer although the frame is rendered on the screen, using MediaCodec in Android

StackOverflow https://stackoverflow.com/questions/18776776

Вопрос

I am using the MediaCodec class to decode a .mp4 video using the code given in this link.

I am able to get the rendered output on the screen, but when I try to access the outputBuffers[outIndex], I get a null pointer error. I cannot figure out how to access the frame buffer to do some processing on it.

Это было полезно?

Решение

That's the expected (albeit undocumented) behavior. You can either send the output to a ByteBuffer or to a Surface, but not both.

Some additional examples that may be of interest are available here. If you decode to a SurfaceTexture you can render the texture twice, once to a View and once to a pbuffer surface. You can either use glReadPixels to get the data and process it, or do your processing in a GLES shader.

If you extract to a ByteBuffer, you have to interpret the data yourself, which is difficult on devices that use a proprietary output format. You'll note from the buffer-to-buffer CTS tests that some devices aren't checked because the format isn't known.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top