12

I'm trying to record videos using the front facing camera, following is the code snippet, I'm setting the setVideoFrameRate to 29, but the recorded video is having the fps between 7.5 and 8. I need the video fps of the vidio recorded 29.

      recorder.setPreviewDisplay(holder.getSurface()); 
      recorder.setOnInfoListener(this); 
      recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
      recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); 
      recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
      recorder.setVideoFrameRate(29);
      recorder.setVideoSize(640,480);
      recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); 
      recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); 
      recorder.setOutputFile("/sdcard/recordvideooutput.mp4"); 
      recorder.setMaxDuration(16*1000);
apaderno
  • 28,547
  • 16
  • 75
  • 90
user566502
  • 121
  • 3
  • 1
    according to developer guide, it is written that the Actual frame rate will vary according to lighting conditions. Also this method will set the maximum frame rate if your device is having auto frame rate. Please check – Naved Nov 17 '11 at 03:28
  • hi Naded, thanks for the answer. You are right.. The fps is better when there is good light, it is recording at 14-15 fps. When I compare it with the native camera applcation, in the same lighting conditions, the native camera is recording at 29 fps but the my program is recording at 14 fps. Just wondering how the native camera is recording at better fps and whether we achive the same programmatically. Thanks again. – user566502 Nov 24 '11 at 05:56
  • How are you benchmarking the frame rate of the video? If you're trying to do it in your java code by monitoring the preview, see the following: http://stackoverflow.com/questions/8676046/why-fps-is-not-same-as-original-camera-app/8685028#8685028 – John O'Connor Jan 17 '12 at 14:36
  • The native camera may be driving the camera at a lower resolution. Have you tried that? Get the available preview sizes and try running at the smallest size. – aardvarkk Feb 06 '12 at 17:11

2 Answers2

2

i was facing the same problem but finally got the solution Video record using front camera

nvavadiya
  • 127
  • 11
0

This piece of code is not valid.

recorder.SetOutputFormat()

This piece of code is:

recorder.SetOutFormat()

From Android Developers Website: "Sets the frame rate of the video to be captured. Must be called after setVideoSource(). Call this after setOutFormat() but before prepare()."

EGHDK
  • 17,818
  • 45
  • 129
  • 204