所以问题只有在我第二次尝试录制时才会出现。这意味着我第一次运行 MediaCodecs 和 Muxer 时,大部分时间一切正常。但现在我希望应用程序更稳定。
帮助找出没有被拆除并正确设置的内容。
基本上在第二次运行时,一切设置都很好,但是当“Renderer.drawFrame”调用时GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
出现错误:I/Adreno﹕ Native window GetBuffer failed
当GLES20.glFlush();
被称为错误是:I/Adreno﹕ Failed to acquire a surface
eglSwapBuffers: EGL error: 0x300d
当我尝试交换缓冲区时,它总是先于。所以有些东西从第一次运行就没有得到清理。
清理代码:
public void releaseCapture(){
if (audioCodec != null){
audioCodec.stop();
audioCodec = null;
}
if (videoCodec != null){
videoCodec.stop();
videoCodec = null;
}
if (mediaMux != null){
mediaMux.release();
mediaMux = null;
}
if ( releaseAll ) {
releaseAll = false;
//releaseSurfaceTexture();
mEGLWrapper.destroySurface();
}
}
MyMediaCodec.stop()
public void stop(){
if (codec == null) return;
if (!isAudioCodec) {
videoCodecInputSurface.release();
}
codecPrimed=false;
codec.stop();
codec.release();
codec = null;
codecManager.stopMuxer(isAudioCodec);
}
MyMediaMuxer.stop()
public void stopMuxer(boolean isAudio){
if (mediaMux == null) return;
if (isAudio){
audioActive = false;
} else {
videoActive = false;
}
if (!(audioActive||videoActive)){
Log.d(TAG, "Stopping Muxer now. audio frame count = " + audioFrameCount +
"; video frame count = " + videoFrameCount);
videoHandler.postDelayed(new Runnable(){
@Override
public void run() {
if (mediaMux!=null) mediaMux.stop();
// set up for next run
releaseCapture();
}
},frame_delay);
}
}
mEGLWrapper.destroySurface();
public void destroySurface(){
EGL14.eglDestroySurface(mEGLDisplay,mEGLSurface);
checkEglError("eglDestroySurace");
}
错误日志
05-05 17:51:43.072 27756-27913/com.harmonicprocesses.penelopefree
E/OMXMaster﹕ A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
05-05 17:51:43.085 27756-27918/com.harmonicprocesses.penelopefree I/OMXClient﹕ Using client-side OMX mux.
05-05 17:51:43.470 27756-27756/com.harmonicprocesses.penelopefree D/penny.cam.MyMediaCodec﹕ Camera profile: Frame Rate = 30; Bit Rate = 42000000
05-05 17:51:43.470 27756-27756/com.harmonicprocesses.penelopefree D/penny.cam.MyMediaCodec﹕ ; Heighth = 2160; Width = 3840
05-05 17:51:43.472 27756-27918/com.harmonicprocesses.penelopefree E/ACodec﹕ [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -1010
05-05 17:51:43.474 27756-27918/com.harmonicprocesses.penelopefree W/ACodec﹕ do not know color format 0x7fa30c04 = 2141391876
05-05 17:51:43.475 27756-27918/com.harmonicprocesses.penelopefree W/ACodec﹕ do not know color format 0x7f000789 = 2130708361
05-05 17:51:43.478 27756-27918/com.harmonicprocesses.penelopefree I/ACodec﹕ setupVideoEncoder succeeded
05-05 17:51:43.478 27756-27918/com.harmonicprocesses.penelopefree W/ACodec﹕ do not know color format 0x7f000789 = 2130708361
05-05 17:52:57.317 27756-27784/com.harmonicprocesses.penelopefree I/Adreno﹕ Native window GetBuffer failed
05-05 17:55:41.518 27756-27784/com.harmonicprocesses.penelopefree I/Adreno﹕ Failed to acquire a surface
05-05 17:56:24.246 27756-27791/com.harmonicprocesses.penelopefree V/com.hpp.MyMediaMux﹕ Trying to write data before muxer started, isAudioSample = true
05-05 18:04:55.189 27756-27784/com.harmonicprocesses.penelopefree D/io.hpp.MyGLSurfaceView18﹕ eglSwapBuffers: EGL error: 0x300d
05-05 18:04:55.189 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ java.lang.Exception
05-05 18:04:55.189 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.hpp.openGL.MyEGLWrapper.checkEglError(MyEGLWrapper.java:443)
05-05 18:04:55.190 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.hpp.openGL.MyEGLWrapper.swapBuffers(MyEGLWrapper.java:314)
05-05 18:04:55.190 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.harmonicprocesses.penelopefree.camera.CaptureManager.drawFrame(CaptureManager.java:478)
05-05 18:04:55.190 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.harmonicprocesses.penelopefree.camera.CaptureManager.drawFrameOnInputSurface(CaptureManager.java:463)
05-05 18:04:55.190 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.harmonicprocesses.penelopefree.camera.CaptureManager.videoCaptureLoop(CaptureManager.java:335)
05-05 18:04:55.190 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at com.harmonicprocesses.penelopefree.camera.CaptureManager$5.run(CaptureManager.java:318)
05-05 18:04:55.190 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
05-05 18:04:55.190 27756-27784/com.harmonicprocesses.penelopefree W/System.err﹕ at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)