Recording 60fps video with Camera2(on Android vers

2020-06-23 09:37发布

问题:

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.

回答1:

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);