Android Question Camera2 CamEx2 CONTROL_AE_TARGET_FPS_RANGE setting

Charlie Burnham

Licensed User
This pertains to video capture mode only. In order to set CONTROL_AE_TARGET_FPS_RANGE using CamEx2, I apparently need to convert my 2-integer array (7,15) into an android.util.range object. I can put integers and booleans directly into the builder from CamEx2, but I get a cast error with all attempts to make a range key and set the camera with it. All examples I could find involve some java code, which is hard for me to follow. Basically, I want to extend CamEx2 to have something like this:

Public Sub setAE_FPS_Range (FPS_Range As JavaObject) 'javaobject here would an integer android.util.range type, which I don't know how to make
End Sub

As an aside, the PreviewCaptureRequest log reports this camera's fps range as [30, 30] which results in a fixed output fps of 30, regardless of the fps setting in MediaRecorder. It may be that this particular camera (motoG7 Power, front, Android 9) cannot go below 30fps, but I need to try a lower range setting to find out. At 30fps, this camera is permanently underexposed in video mode..


Charlie Burnham

Licensed User
Caution, this is probably device-specific:

Brightness problem solved by writing a null to the CONTROL_AE_TARGET_FPS_RANGE in both maps. Apparently this wiped out the default 30,30 fps manufacturer's default constraint and allowed the camera to drop down to 24 fps (as seen in output mp4 properties). This, in turn, allows various CONTROL_AE_EXPOSURE_COMPENSATION values to take effect. The FPS_RANGE no longer appears as a key so I don't know for sure what is this value inside the camera--if any.

On my device, it turned out that to obtain the same level of brightness, I needed to use 1 for the front and 6 for the rear camera. Curiously, on this device, on both the native camera app and CameraMX app, both cameras appearunderexposed for video recording and there is no way to change it.

I never did solve the problem of obtaining an acceptable android.util.range object for FPS_RANGE, although I imagine this would be trivial in java. My solution avoided java after several attempts to get java to return my android.util.range to B4A. Generally the errors were "Cannot cast java array to android.util.range" and similar. The idea was to hard code a range of 7,15 or 15,30 and stick that into both maps. I noticed that all code examples avoided this approach by selecting an android.util.range object as supplied by the device and putting that into the map, which is surely best practice for compatibility. In my case, I will be using only one specific device so I can just code for that.