Search code examples
androidcameraandroid-camera

Checking Android device camera video supports at least 30fps


I need to have a function that tells whether I the phone's camera video supports at least 30fps. I'm using both camera1 and camera2 api, depending on the phone's camera2 support (or lack thereof)

I though about using this :

val manager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
val cameras = manager.cameraIdList
for (camera in cameras) {
     val cc = manager.getCameraCharacteristics(camera)
     val fpsRange = cc.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)!!
-->  Log.d("TAG", "fps : ${fpsRange.find { it.lower == 30 && it.upper == 30 }}") // is this correct?
}

but I'm not sure whether it's the right solution, I don't understand the ranges that I get and whether I chose the right CameraCharacteristics.


Solution

  • That expression will evaluate to true for a fixed 30fps frame rate (minimum frame rate=maximum frame rate=30). That will be generally supported on all Android devices, since it's required for standard video recording.