Search code examples
androidopengl-esandroid-mediacodecmuxer

MediaCodecMuxer encode video too slow


I am using MediaCodec Muxer to encode videos,but the process is too slow. Sometimes 60 seconds video, the encode process takes more than 90 seconds. The encode plan comes from ExtractDecodeEditEncodeMuxTest(BigFlake) and I interpret this example into jni layer. I don't know whether it is because of the using of reflection in my code to call java api that leads to encode video very slow or the swap process between GLDisplay and MediaCodec inputSurface causes this problem? I use eglCreateWindowSurface to create GLSurface, I wonder if I can use eglCreatePbufferSurface to create off-screen surface that may speed up the encode process? Can any one give some advice ? thanks!


Solution

  • I speed up by encoding audio and video in different thread and speed up audio encoding by enlarge audio writing buffer.