1

I'm am capturing a video from the Android camera. However, I would like to set the frame rate to 1 frame per second.

If I add the setVideoFrameRate(1), then the video cannot be recorded properly. If I don't set this value, recording works correctly.

This is my code...

mediaRecorder = new MediaRecorder();
mediaRecorder.setCamera(camera);                
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

mediaRecorder.setOutputFile(GetOutputMediaFileDir(VIDEO_TYPE,intVideoIndex));
mediaRecorder.setVideoSize(640,480);

mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
//  mediaRecorder.setCaptureRate(1);
mediaRecorder.setVideoFrameRate(1);
mediaRecorder.setMaxDuration(10000);
mediaRecorder.setOnInfoListener(this);
mediaRecorder.setPreviewDisplay(surfaceView.getHolder().getSurface());

mediaRecorder.prepare();
mediaRecorder.start();

Basically I need to reduce the size of video since I have to send it on a phone which may be using 3G network. The longest video will be 1 minute so it will take a long time to send the video.

Could someone please help me with this problem.

wattostudios
  • 8,666
  • 13
  • 43
  • 57
Iam619
  • 795
  • 2
  • 12
  • 28
  • That's going to be really choppy video. Those early silent films that look "choppy" had 14-24 fps. I think the human brain will see anything less than 10 fps as single image instances. – Roddy of the Frozen Peas Jun 28 '12 at 16:38
  • 1
    Setting the video to default at the lowest possible quality just because the user may only be on 3G is a terrible approach. What about the people on Wifi? What about the ones that want an HD video and don't care about the wait? If you're really concerned about upload time, you should ask your users what quality they want and warn them if there's potentially an incredible wait (which even on 3G for a 1 minute video isn't that bad), instead of forcing them to do something because the connection MIGHT be slow. – Cruceo Jun 28 '12 at 16:44
  • Actually the video to be sent is a combination of several images, which are really needed on the server side..so I want to set the frame rate to be as low as 1 fps and reduce the size. However it is not doable right? – Iam619 Jun 28 '12 at 20:25

2 Answers2

3

frame rate 5 is supported in many devices.you can use getSupportedPreviewFpsRange() for finding supported frame rate.

check this : http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getSupportedPreviewFpsRange()

Amrendra
  • 2,019
  • 2
  • 18
  • 36
0

20 - 24 frames per second is the absolute minimum for a video to maintain any sort of quality. 1 Frame per second is not supported because it would be more of a slideshow. Also, the sound associated with the video would not be able to sync correctly.

Jack Satriano
  • 1,999
  • 1
  • 13
  • 17
  • Thanks a lot for your reply. Actually I'm capture several images continuously instead of capturing a video. So I want to set the frame rate to be 1 fps. The audio is separated from video so it's ok to not sync correctly. So it is not possible to set the frame rate to be 1 fps right? I'm wondering that we can still use the method setVideoFrameRate() android provide, but maybe there is a minimum value that a user can set to the device... – Iam619 Jun 28 '12 at 20:20
  • I recommend you use a `Camera` object and the `takePicture` method in a loop: http://developer.android.com/reference/android/hardware/Camera.html Hit the green check if you got what you needed! – Jack Satriano Jun 28 '12 at 20:36
  • If I do takePicture in a loop then can I merge these images into one mp4 video file? I searched around since I think it's a good idea, but haven't found out something. I will hit the green check don't worry:) – Iam619 Jun 28 '12 at 20:53
  • You may find what you need here: http://stackoverflow.com/questions/8170523/create-video-from-images – Jack Satriano Jun 28 '12 at 20:58
  • Thanks! Seems that I need to deal with the NDK now to solve the problem. Hope I can get Libav work. – Iam619 Jun 28 '12 at 21:04