When you call ProcessCameraProvider.bindToLifecycle(), it will return a Camera object to you. From that Camera object, you can get a CameraInfo, which is used for querying available frame rate ranges, and a CameraControl, which can be used to set the frame rate.
Currently, CameraX only has APIs for querying and setting frame rate via the Camera2 Interop APIs.
From CameraInfo, you can query the frame rate ranges supported by the device:
val camera2Info = Camera2CameraInfo.from(camera.cameraInfo)
val supportedFpsRanges = camera2Info.getCameraCharacteristic(
CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
)
From
CameraControl, you can set the frame rate range on the camera:
val fpsRange: Range<Int> = ... // Choose from "supportedFpsRanges" above
val camera2Control = Camera2CameraControl.from(camera.cameraControl)
camera2Control.setCaptureRequestOptions(
CaptureRequestOptions.Builder()
.setCaptureRequestOption(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange)
.build()
)