I have been trying camera2 API. I have downloaded code from

https://developer.android.com/samples/Camera2Video/index.html to learn about how it works. It works fine till I stop recording. When I stop recording it runs following code.

private void stopRecordingVideo() {

// UI

mIsRecordingVideo = false;

mBtn_Video.setText(R.string.record);

// Stop recording

try {

mMediaRecorder.stop();

mMediaRecorder.reset();

}

catch (Exception e) {

e.printStackTrace();

}

Activity activity = getActivity();

if (null != activity) {

System.out.println("file " + getVideoFile(activity));

Toast.makeText(activity, "Video saved: " + getVideoFile(activity),

Toast.LENGTH_SHORT).show();

}

startPreview();

at mMediaRecorder.stop(); it throw following error

01-12 16:24:23.115 2161-2200/com.cameratwoapi E/Surface﹕ queueBuffer: error queuing buffer to SurfaceTexture, -19

01-12 16:24:23.135 2161-2200/com.cameratwoapi E/EGL_emulation﹕ tid 2200: swapBuffers(285): error 0x3003 (EGL_BAD_ALLOC)

01-12 16:24:23.197 2161-2200/com.cameratwoapi E/CameraDeviceGLThread-0﹕ Received exception on GL render thread:

java.lang.IllegalStateException: swapBuffers: EGL error: 0x3003

at android.hardware.camera2.legacy.SurfaceTextureRenderer.checkEglError(SurfaceTextureRenderer.java:487)

at android.hardware.camera2.legacy.SurfaceTextureRenderer.swapBuffers(SurfaceTextureRenderer.java:480)

at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:681)

at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:103)

at android.os.Handler.dispatchMessage(Handler.java:98)

at android.os.Looper.loop(Looper.java:135)

at android.os.HandlerThread.run(HandlerThread.java:61)

Any Idea what I am doing wrong. I spent few hours but couldn't find any solution.

Edit - I am using geneymotion emulator. The path I am using

file /storage/emulated/0/Android/data/com.gold.cameratwoapi/files/video.mp4

Thanks

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐