I meet a problem when i try to output a h.264 video with android MediaCodec. I get frame data from onPreviewFrame ,then i feed it to MediaCodec,and draw the frame on GLSurfaceView using OpenGL. it works correctly on some device and OS version such as Samsung s5 with 5.0 system ,Samsung note4 with 5.1 system and some android 4.4 devices.
But when i tried to run this app on other devices such as Samsung s6 with android 6.0 , Samsung note5 with android 6.0 and a 5.0 device,there's something wrong.Image i draw on GLSurfaceViewis correct and normal,but i got the wrong video which seems have no color or have wrong color.
I tried to find the answer and i finally realize that it may caused by the difference of the color format accepted by MediaCodec.In my program,I assumed that mediaCodec can accept YUV420SP,so i convert nv21 i420SemiPlanar and feed it to MediaCodec.i guess color format of mediaCodec is the key to solve problem, but is it true? Why mediaCodec on difference device and os version have such big difference?
Anybody meet the same problem?
What can i do to avoid this problem?