setPreviewFpsRange not working despite values being within getPreviewFpsRange's range
Asked Answered
A

2

4

This simple code:

Camera.Parameters params = currentCamera.getParameters();
params.setPreviewFpsRange( 10000, 15000 );
currentCamera.setParameters( params );

does not work on my Nexus 4 (or my Motorola Atrix), despite the allowed values being between in the allowed range of 5000 to 120000.

When I try to use any min or max values different than 5000 and 120000, respectively, I get:

setPreviewFpsRange(const android::QCameraParameters&): error: FPS range 
value not supported

which is silly. Also, I tried this code on my older Motorola Atrix (which shows a valid fps range to be between 10000 and 30000) and it also doesn't work. Anything that can be done?

From my searching on the topic I have found that a) there is very little material on the topic anywhere, and b) it may be the case that this functionality is simply unsupported by some platforms. It's a bit strange that Google's current flagship phone, the Nexus 4, doesn't support it, though...

Apprehensible answered 21/4, 2013 at 5:33 Comment(0)
A
19

Ahah! So as part of my search for answers I checked the operation of my Nexus 10 with my app. It turns out that the values that the getSupportedFpsRange function returns are ranges representing exact duples that may be input into setPreviewFpsRange and any other duples are unsupported (as far as I can tell, anyway.)

I discovered this because the Nexus 10 returns multiple duples from getSupportedFpsRange. I've duplicated the three devices' getSupportedFpsRange return values here.

Examples of supported range values

LG Nexus 4:

preview-fps-range-values=(5000,120000);

Motorola Atrix:

preview-fps-range-values=(10000,30000);

Samsung Nexus 10:

preview-fps-range-values=(15000,15000),(24000,24000),(25000,25000),(15000,30000),(30000,30000);

Conclusion

We cannot do

params.setPreviewFpsRange( 29000, 29000 );

to force the preview to be at 29fps unless the device already specifically supports that duple.

Of course, the original reason I was investigating this functionality was in the hopes of replicating the Nexus 4's silky smooth camera preview in my own app. This would seem to prove conclusively that, on the Nexus 4 at least, setPreviewFpsRange won't help with that.

Time to continue searching. (:

Apprehensible answered 22/4, 2013 at 2:2 Comment(3)
It would seem the Sony Xperia is much the same in this regard.Peripeteia
That is what the documentation says, at least these days: The minimum and maximum preview fps must be one of the elements from getSupportedPreviewFpsRange()Prentice
even if you do params.setPreviewFpsRange(15000, 15000); on a Samsung which is a supported "duple", it is not guaranteed that you will have a fps of 15000. The setPreviewFpsRange is not programmed to force the fps, which is by the way a ridiculous limitation from googleWynn
M
-2

I found that if getSupportedPreviewFpsRange list has only one pair of supported values like (2000, 35000) which is 2fp to 35fps then it will accept any values between that range.

If list containt more pairs then you need to use one of them

List<int[]> fpsRange = param.getSupportedPreviewFpsRange();

if (fpsRange.size() == 1) {
    //fpsRange.get(0)[0] < CAMERA_PREVIEW_FPS < fpsRange.get(0)[1]
    param.setPreviewFpsRange(CAMERA_PREVIEW_FPS, CAMERA_PREVIEW_FPS);
} else {
    //pick first from list to limit framerate or last to maximize framerate
    param.setPreviewFpsRange(fpsRange.get(0)[0], fpsRange.get(0)[1]);
}
Minetta answered 9/7, 2015 at 11:19 Comment(1)
That may work on some devices, but it's not generally true: for example, ASUS Zenpad 10 (ZD300CL) reports only a single fps range (4000 - 50000), but trying to set fps range of (30000 - 30000) results in "failed to set parameters" exception. So, probably, the best way is to try to force a desired framerate, catch an exception, then apply first fps range,Scutiform

© 2022 - 2024 — McMap. All rights reserved.