Camera2 is the latest low-level Android camera package and replaces the deprecated Camera class. Camera2 provides in-depth controls for complex use cases, but requires you to manage device-specific configurations.
prop in the /system partition of your Android device, you can enable the Camera2 API functionality. First you'll need a rooted phone, and a method of editing your build. prop file. You can either use a root file explorer app (like ES Explorer) to navigate to the /system partition on your phone and open build.
camera2 API for new applications. This class was deprecated in API level 21. We recommend using the new android.
Now the question arises – how can you check if your Android device supports Camera2 API? Well, all you need to do is download a simple app called 'Camera2 API probe' from the Google Play Store and run it. The app gives detailed info about both the rear and front camera sensors of your Android phone.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With