Binu
Binu

Reputation: 91

How to limit preview fps range in android for camera?

Is it possible to limit fps range in android camera.. tried to change the values in .setPreviewFpsRange()... but frame rate are not changed.. it comes continuously 30 frames per second

Upvotes: 6

Views: 11774

Answers (2)

BurningThumb
BurningThumb

Reputation: 31

I set the preview frame rate to the lowest rate possible with this code, but you could set it to the highest rate possible by using l_last instead of l_first in the List index (mCamera is a member variable that references the Camera and is set elsewhere in the code).

Camera.Parameters l_params = mCamera.getParameters();

List<int[]> frameRates = l_params.getSupportedPreviewFpsRange();
int l_first = 0;
int l_last = frameRates.size() - 1;
int minFps = (frameRates.get(l_first))[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
int maxFps = (frameRates.get(l_first))[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
l_params.setPreviewFpsRange(minFps, maxFps);

mCamera.setParameters(l_params);

Upvotes: 0

yushulx
yushulx

Reputation: 12160

You can use public List<int[]> getSupportedPreviewFpsRange () to check what FPS range supported by your device. Here is mine:

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

so if I want to change the fps to 15, I can setPreviewFpsRange(15000,15000).

Upvotes: 5

Related Questions