Following is th code which helps in capturing the video but the problem is with the frame rate as i have already defined framerate to 30 frames per sec still. When record a video using front camera its gives an output of 8 frames per sec and with back camera it give max 15 to 18 frames
private void startRecording() {
if(mrec != null){
mrec.reset();
}
mCamera.unlock();
mrec.setCamera(mCamera);
mrec.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
mrec.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mrec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mrec.setVideoSize(640, 480);
mrec.setVideoEncodingBitRate(3000000);
mrec.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mrec.setVideoEncoder(MediaRecorder.VideoEncoder.H264);// MPEG_4_SP
File dir = new File(SdCardPath + Directory);
if (!dir.exists()) {
if (dir.mkdir()) {
Log.v(STORAGE_SERVICE, "Created directory");
} else {
Log.v(STORAGE_SERVICE, "Failed to create Directory");
}
}
FullFilePath = SdCardPath + Directory + RecordFileName;
mrec.setOutputFile(FullFilePath);
mrec.setVideoFrameRate(30);
mrec.setPreviewDisplay(surfaceHolder.getSurface());
try {
mrec.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
mrec.start();
}
According to android documentation
may not work as you are expecting it to work. If your device cannot give you 30 frames per second, then there will be some internal clipping, and the frame rate will be set to the maximum frame rate that the device supports.
Also, in practise, I have observed, that even for legitimate values, the setVideoFrameRate() call is not reliable, and the actual frame rate may differ from the value that you pass to this function.