5

in my Android app, I observed that the video recorded from the front camera is being recorded with 7-10 fps while the back camera does the job fine, the native camera app does record video from front cam at 29fps.

I use the following function to set the frame rate

 myRecorder.setVideoFrameRate(30);

but somehow it records it at 8fps. what is the problem? Also the lighting conditions seem to improve it to 15fps, but I want it to be atleast >25fps how can I achieve this? Can we use NDK for this purpose?

Arif Nadeem
  • 8,524
  • 7
  • 47
  • 78

2 Answers2

2

I'm exploring the same problem. Because the MediaRecorder already has a native implementation, using the NDK doesn't seem to be a promising approach to increasing the frames per second. Improving the buffering with setPreviewCallbackWithBuffer as shown in the code at http://www.androidadb.com/source/cellbots-read-only/experimental/android/ioio/samples/ShootOnSight/src/com/cellbots/ioioshoot/CameraView.java.html seems promising but I first would like to get a better understanding of the many camera parameters and how they affect frame rate.

As you surely know, there is a wide range of Android devices with a wide range of camera capabilities. To see the capabilities of your particular front and back cameras, you can use the following code (e.g., setting mCameraId to 0 for rear facing and to 1 for front facing).

    Camera mCamera = Camera.open(mCameraId);
    Camera.Parameters cp = mCamera.getParameters();
    Log.d(TAG, "camera parameters: " + cp.flatten());

For example, here are the camera parameters dumped by my Nexus S (running OS 4.0.4).

NEXUS-S FRONT FACING CAMERA PARAMETERS:
06-16 15:14:16.909: D/SENSORS_PLUS(24583): camera parameters:
picture-size-values=640x480;
preview-fps-range=7500,30000;
min-exposure-compensation=-4;
vertical-view-angle=39.4;
horizontal-view-angle=51.2;
whitebalance=auto;
jpeg-thumbnail-height=120;
jpeg-quality=100;
preview-format-values=yuv420sp,yuv420p;
rotation=0;
jpeg-thumbnail-quality=100;
focus-mode=fixed;
preview-format=yuv420sp;
preview-size=640x480;
focal-length=0.9;
video-frame-format=yuv420p;
picture-format-values=jpeg;
max-exposure-compensation=4;
exposure-compensation=0;
preview-frame-rate-values=15;
exposure-compensation-step=0.5;
preview-frame-rate=15;
effect-values=none,mono,negative,sepia;
focus-mode-values=fixed;
picture-size=640x480;
effect=none;
jpeg-thumbnail-width=160;
whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;
picture-format=jpeg;
focus-distances=0.20,0.25,Infinity;
preview-fps-range-values=(7500,30000);
jpeg-thumbnail-size-values=160x120,0x0;
preview-size-values=640x480,320x240,176x144

NEXUS-S REAR FACING CAMERA PARAMETERS:
06-16 15:46:55.315: D/SENSORS_PLUS(24732): camera parameters:
picture-size-values=2560x1920,2048x1536,1600x1200,1280x960,640x480;
preview-fps-range=15000,30000;
min-exposure-compensation=-4;
vertical-view-angle=39.4;
horizontal-view-angle=51.2;
whitebalance=auto;
jpeg-thumbnail-height=240;
scene-mode=auto;
jpeg-quality=100;
preview-format-values=yuv420sp,yuv420p;
rotation=0;
jpeg-thumbnail-quality=100;
focus-mode=auto;
preview-format=yuv420sp;
preview-size=720x480;
focal-length=3.43;
video-frame-format=yuv420p;
picture-format-values=jpeg;
max-exposure-compensation=4;
flash-mode-values=on,off,auto,torch;
exposure-compensation=0;
preview-frame-rate-values=30;
exposure-compensation-step=0.5;
preview-frame-rate=30;
flash-mode=off;
effect-values=none,mono,negative,sepia;
focus-mode-values=auto,infinity,macro;
picture-size=2560x1920;
effect=none;
jpeg-thumbnail-width=320;
whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;
scene-mode-values=auto,portrait,landscape,night,beach,snow,sunset,fireworks,sports,party,candlelight;
picture-format=jpeg;
focus-distances=0.10,1.20,Infinity;
preview-fps-range-values=(15000,30000);
jpeg-thumbnail-size-values=320x240,0x0;
preview-size-values=720x480,640x480,352x288,176x144

gregS
  • 2,580
  • 5
  • 28
  • 33
  • this is nice and self explanatory, but how do I increase the frame rate? Did you try cellbots code? I doubt if it works. Perhaps a little control over the camera parameters should have been provided by the Google Android team. – Arif Nadeem Jun 19 '12 at 05:34
  • I should have summarized that long answer. In short, I'm just starting to look at increasing frame rate but I'm quite sure that NDK is not the best path for that. It seems to me that the camera parameters are the low hanging fruit that should be tried first. An example of setting the camera parameters is at http://developer.android.com/guide/topics/media/camera.html#using-features – gregS Jun 21 '12 at 23:51
1

Following setting works for some mobile for 30 FPS.

    Camera.Parameters parms = camera.getParameters();
    parms.setRecordingHint(true);
    camera.setParameters(parms);
MMHossain
  • 326
  • 3
  • 12