Reputation: 165
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.
Upvotes: 4
Views: 11066
Reputation: 21
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.
Upvotes: 0