4

While googling, I've got this information that if I want to enable my camera to record high frame rate video on android device, I need to put specific parameters by device vendor for calling camera APIs.

For example, by calling the methods as below, I could enable my Galaxy S6 camera app recording 120 fps constantly.

camera = Camera.open();
Camera.Parameters parms = camera.getParameters();

// for 120fps
parms.set("fast-fps-mode", 2); // 2 for 120fps
parms.setPreviewFpsRange(120000, 120000);

But the problem is no all devices(including LG, and other vendors) support 120 fps(or higher). So I need to know maximum fps in API level in real-time when run my camera app for error handling.

In my case, Camera.Parameters.getSupportedPreviewFpsRange() not worked for me. It only returns maximum 30000(meaning 30fps) even it could record at 120000(120 fps). I think it because recording at high frame rate(more than 30 fps) is strongly related with camera hardware property and that's why I need to call vendor specific APIs.

Is there a common way to get maximum fps by camera device in API level?

---------------------- EDIT ----------------------

On API21(LOLLIPOP), we could use StreamConfigurationMap to get maximum value for high speed fps recording. The usage is as below.

CameraManager manager = (CameraManager)activity.getSystemService(Context.CAMERA_SERVICE);
String cameraId = manager.getCameraIdList()[0];
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
Range<Integer>[] fpsRange = map.getHighSpeedVideoFpsRanges(); // this range intends available fps range of device's camera.
Sunggook Kim
  • 165
  • 1
  • 3
  • 10
  • Above API21(Lollipop), Camera2 API offer a method which is able to get supported fps range as below, if the device has capability REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO. Range[] ranges = map.getHighSpeedVideoFpsRanges(); – Sunggook Kim Jun 30 '16 at 07:34
  • I am not able to get fps for front camera eg. String cameraId = manager.getCameraIdList()[1]; – ashishdhiman2007 Jan 30 '17 at 08:54
  • 1
    @ashishdhiman2007 If you could not get fps from front camera, there are two possibilities that these code above not working for you. 1. Your front camera is NOT FULL_LEVEL. From Lollipop, Camera2 api categorize cameras by three levels(FULL, LEGACY, LIMITED). 2. Your front camera is FULL_LEVEL but does not support high speed fps recording. The code above is correctly working while camera(front facing or back facing) supports high speed fps recording. – Sunggook Kim Feb 01 '17 at 05:41
  • 1
    If your device is NOT FULL level or does not supports high speed fps recording, you are able to get fps ranges from this way. `Range[] fpsRange = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);` – Sunggook Kim Feb 01 '17 at 05:45
  • 2
    @SunggookKim The problem I see with the code you posted in your edit is that devices support a certain frame rate at a certain resolution. For example (120 fps @ 720p). How do you check if the fps for the given dimensions are supported? – HB. Mar 17 '20 at 04:42
  • @HB. Hello friend have you find any solution for checking given fps supported or not for given resolution? – yash khatri Aug 16 '21 at 08:31

1 Answers1

0

You can get that information via CamcoderProfile starting API-21 as follows:

for (String cameraId : manager.getCameraIdList()) {
    int id = Integer.valueOf(cameraId);
    if (CamcorderProfile.hasProfile(id, CamcorderProfile.QUALITY_HIGH_SPEED_LOW)) {
    CamcorderProfile profile = CamcorderProfile.get(id, CamcorderProfile.QUALITY_HIGH_SPEED_LOW);
    int videoFrameRate = profile.videoFrameRate;
    //...
    }
}

This will give you the lowest available profile supporting high speed capture. I doubt there are many pre-Lollipop devices out there with such hardware possibilities (if any at all), so this should get you covered.

sichevoid
  • 21
  • 1
  • Thank you @sichevoid. But this is not working for me, even I tried on my Galaxy S6 which supports 120fps recording. Which device have you tried this code on? – Sunggook Kim Jun 29 '16 at 02:31
  • @SunggookKim It works on Nexus 6P. I don't have the Galaxy S6 to try, unfortunately. I suggest you to try other CamcorderProfile.QUALITY_HIGH_SPEED_* profile variations on the S6. – sichevoid Jul 03 '16 at 17:43
  • I've tried all other CamcorderProfile which start with "QUALITY_HIGH_SPEED_", but no all were working. I think it is related with device's specification. In addition, I think, if we try this over API 21 anyway, we could use StreamConfigurationMap which I added on original post. – Sunggook Kim Jul 04 '16 at 01:23
  • Agree, that looks like a valid way to do it. – sichevoid Jul 05 '16 at 16:58