Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording 60fps video with Camera2(on Android version 21) API

I'm trying to record a video at 60(or more)fps rate on Camera2(android.hardware.camera2) APIs.

Finally, I succeeded recording at 120fps using CameraConstrainedHighSpeedCaptureSession. But it is only targeted at >=120fps use case not for 60fps.

Even I tried to record at 60fps using normal capture session(CameraCaptureSession), it only supports <=30fps. I could figure it out through this code below.

Range<Integer>[] fpsRanges = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);

I don't know how I could record at 60fps with Camera2 APIs.

Any idea would be most welcome.

Thanks.

like image 914
Sunggook Kim Avatar asked Nov 20 '22 02:11

Sunggook Kim


1 Answers

You must create a ConstrainedHighSpeedCaptureSession from CameraDevice and instantiate a new session as you possibly did with a normal capture session.

Also you need to set the next values to your Builder:

myPreviewRequestBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
myPreviewRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CaptureRequest.CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO);
myPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<Integer>(frameRate, frameRate));

After, generate a CaptureRequestList with your builder:

 myHighSpeedRequestList = ((CameraConstrainedHighSpeedCaptureSession) cameraCaptureSession).createHighSpeedRequestList(myPreviewRequestBuilder.build());

and use it in your capture Session to generate the CaptureSession:

mCaptureSession.setRepeatingBurst(myHighSpeedRequestList,
                                  YourHighSpeedVideoCaptureCallback,
                                  YourBackgroundHandler);
like image 82
Francisco Durdin Garcia Avatar answered Dec 04 '22 00:12

Francisco Durdin Garcia