0

How to achieve (video recording and capture frames in real time) simultaneously using camerax?

What I tried till now. I tried to bind camera preview, videoCapture and imageAnalysis use cases together but got this exception, java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 0. May be attempting to bind too many use cases.
at androidx.camera.camera2.impl.Camera2DeviceSurfaceManager.getSuggestedResolutions.

So What approaches I did

1- bind only videoCapture and imageAnalysis use cases and for preview I used an imageView and set image to it retrieved from imageAnalysis, which was indeed not so efficient approach so.
2- I tried binding only preview and imageAnalysis use cases, and for recording i used screen recording, but we must have permission for that, so this approach is at least priority.
3- I got this library implementation "com.priyankvasa.android:cameraview-ex:3.5.5-alpha" which is promising me what i seek but not working on 3 out of 5 devices i tested.

Could it not be achieved using camera-x?

That's all.
Help me out.

  • Can you provide more information and what you've tried so far? – Kryten Jul 13 '20 at 21:58
  • Depending on the camera hardware type, there is a limit on how many concurrent streams can be used. So yeah lower end devices can't have preview + analysis + video, at least not until video is officially supported by CameraX. If you want to read more about it, see: https://developer.android.com/reference/android/hardware/camera2/CameraDevice The workaround I would suggest at this point, is not using preview. Instead, show the buffer from ImageAnalysis as preview. You will have to convert the YUV image to bitmap first. This is inefficient on many levels, but a viable workaround for now. – Xi 张熹 Jul 19 '20 at 17:44

0 Answers0