feat: add custom fps range

This commit is contained in:
cnwxu3ea 2024-07-31 00:36:04 +08:00
parent b35feb64ad
commit 69d6af9b58

View file

@ -477,7 +477,8 @@ public class Camera2Session {
}
if (recordingVideo) {
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<Integer>(30, 60));
Range<Integer> targetFpsRange = selectOptimalFpsRange();
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, targetFpsRange);
captureRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD);
isStabilizationAvailable(captureRequestBuilder);
@ -505,6 +506,22 @@ public class Camera2Session {
}
}
private Range<Integer> selectOptimalFpsRange() {
Range<Integer>[] fpsRange = cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
Range<Integer> optimalRange = new Range<>(30, 30);
assert fpsRange != null;
for (Range<Integer> range : fpsRange) {
if (range.getLower() <= 30 && range.getUpper() >= 30) {
optimalRange = range;
break;
}
}
FileLog.d("Camera2Session selected FPS range: " + optimalRange);
return optimalRange;
}
private void isStabilizationAvailable(CaptureRequest.Builder builder) {
if (setModeIfAvailable(
CameraCharacteristics.LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,