使用Camera2(在Android 21版上)API录制60fps的视频 [英] Recording 60fps video with Camera2(on Android version 21) API

查看:399
本文介绍了使用Camera2(在Android 21版上)API录制60fps的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Camera2(android.hardware.camera2)API上以60(或更高)fps的速率录制视频.

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

最后,我成功使用 CameraConstrainedHighSpeedCaptureSession 以120fps的速度录制.但这仅针对> = 120fps用例,而不是60fps.

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

即使我尝试使用正常的捕获会话以60fps进行录制( CameraCaptureSession ),则仅支持< = 30fps.我可以通过下面的代码找出答案.

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

我不知道如何使用Camera2 API以60fps的速度录制.

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

任何想法都将受到欢迎.

Any idea would be most welcome.

谢谢.

推荐答案

您必须从CameraDevice创建一个ConstrainedHighSpeedCaptureSession并实例化一个新会话,就像对普通捕获会话所做的那样.

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

另外,您需要为Builder设置下一个值:

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

之后,使用您的构建器生成一个CaptureRequestList:

After, generate a CaptureRequestList with your builder:

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

并在您的捕获会话中使用它来生成CaptureSession:

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

mCaptureSession.setRepeatingBurst(myHighSpeedRequestList,
                                  YourHighSpeedVideoCaptureCallback,
                                  YourBackgroundHandler);

这篇关于使用Camera2(在Android 21版上)API录制60fps的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆