在Android上访问高fps相机 [英] Access high fps camera on Android

查看:108
本文介绍了在Android上访问高fps相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有些正式支持高fps录制的手机,例如Galaxy S5和S6.我都尝试过,两者都可以使用默认的相机应用程序录制高fps的视频(60甚至120 fps).(或者在使用Gear VR的直通相机"功能的S6上.)但是:当您通过标准Android API查询相机的功能时(在4.4和5.0的S5和5.1的S6上都尝试过)在所有情况下,camera2 API)均以30 fps报告为最高可用速率.这是否意味着这些电话使用私有的专有API来访问高fps功能,并且没有标准的方法来访问更高的fps?这是制造商的缺点(可能会随着将来的软件版本或手机而改变)还是我只是缺少一些东西?我什至不需要慢动作,只需高帧率的摄像头即可实时使用,因此60 fps就足够了.

我尝试在旧相机API中查询相机fps的示例;

  List< Camera.Size>一个= camera.getParameters().getSupportedPreviewSizes();List< int []>b = camera.getParameters().getSupportedPreviewFpsRange();int [] c =新的int [2];camera.getParameters().getPreviewFpsRange(c); 

camera2 API中相同:

  CameraManager管理器=(CameraManager)getSystemService(Context.CAMERA_SERVICE);String []摄影机= manager.getCameraIdList();对于(字符串相机:相机){CameraCharacteristics cc = manager.getCameraCharacteristics(camera);范围< Integer> [] fpsRange = cc.get(cc.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);} 

我只得到范围:[15,15],[24,24],[10,30],[15,30],[30,30](旧相机API的范围甚至更少).

在camera2 API中,我找到了一些用于访问高fps摄像机记录的方法:

There are phones with official support for high fps recording, like the Galaxy S5 and S6. I tried both, with both you can record high fps videos (60 or even 120 fps) with the default camera app. (Or on the S6 using Gear VR's "Passthrough Camera" function.) BUT: when you query the camera's capabilities through the standard Android APIs (tried it on both S5 on 4.4 and 5.0 and S6 on 5.1, tried both the old and the new camera2 APIs) in all cases, 30 fps is reported as the highest available. Does this mean that these phones use private proprietary APIs to access high fps capabilities and there's no standard way to access higher fps? Is this the shortcoming of the manufacturer (which might change with future software versions or phones) or am I just missing something? I don't even need slow motion, just high frame rate camera for real-time usage, so 60 fps would be sufficient.

Sample I tried for querying camera fps in the old camera API;

List<Camera.Size> a = camera.getParameters().getSupportedPreviewSizes();
List<int[]> b = camera.getParameters().getSupportedPreviewFpsRange();
int[] c = new int[2];
camera.getParameters().getPreviewFpsRange(c);

Same in camera2 API:

CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
String[] cameras = manager.getCameraIdList();
for(String camera : cameras) {
    CameraCharacteristics cc = manager.getCameraCharacteristics(camera);
    Range<Integer>[] fpsRange = cc.get(cc.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
}

I only get ranges: [15, 15], [24, 24], [10, 30], [15, 30], [30, 30] (even less ranges with the old camera API).

In camera2 API I found some methods for accessing high fps camera recording: createConstrainedHighSpeedCaptureSession(). But it defines high speed video recording as "frame rate >=120fps", so I shouldn't even need it for 60 fps. Anyway I queried this capability, but it seems it's not supported on the S6. The code I tried:

CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
String[] cameras = manager.getCameraIdList();
for(String camera : cameras) {
    CameraCharacteristics cc = manager.getCameraCharacteristics(camera);
    CameraCharacteristics.Key<int[]> aa = cc.REQUEST_AVAILABLE_CAPABILITIES;
    for (int i = 0; i < cc.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES).length; i++) {
            Log.e(TAG, "Capability: " + cc.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES)[i]);
    }
}

It says it only support capabilities 0, 1, 2, 3, 5, 6. REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO would be 9.

At this point I've pretty much ran out if ideas suspecting these capabilities truly aren't available through standard APIs on these phones. Any help is appreciated.

I know the question is pretty similar/related to this: Capture high fps videos using new Camera API But my question is more general, not specific to neither the old nor the new camera API, or specific devices. I'm also curious what supported fps other new flagship devices report through the standard APIs as I could only test it on 3 devices.

解决方案

After many discussions I had with Samsung developer support I can assure you the following:

60 FPS was never officially supported by Samsung. It was definitely available on S9, S10, S20 (regular) but they have a bug on the S20 & S21 Snapdragon/USA version - it still works like a charm on the Exynos/worldwide version - if needed I have screen recording from both. I have reported it to Samsung and waiting for answers.

You can use the high speed capturing but it is designed only for 120 FPS or 240 FPS. currently their S21 series and the S20 Plus & Ultra Snapdragon/USA version declare and approve that the 120/240 is available - but it does not work. all ok with the Exynos/worldwide version.

If you ask yourself - how come the high speed return also ranges of [30:120] and [60:120] - those ranges are designed for the preview mode and if you use it for the recording - you can will get FPS of 30 until 120 - depends on the amount of light you got. For example : in one recording you will get 90 FPS, and in the other 120 FPS. you can only promise a stable 120 FPS if you use the [120:120] and you will not get [60:60] or [90:90] if you use the high speed session - only 120 or 240.

You can follow all of my discussions with them on my Facebook page: https://www.facebook.com/Background-video-recorder-Ultimate-121145775953677 You are welcome to share my posts or to contact their support and complain.

这篇关于在Android上访问高fps相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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