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