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

梦想的初衷 提交于 2019-12-09 13:49:39

问题


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


来源:https://stackoverflow.com/questions/37985383/recording-60fps-video-with-camera2on-android-version-21-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!