I am using Android development (SDK 2.2) and I would like to make a video recording with mediaRecorder and, at the same time, do some process on each preview fr
if you are using os 2.2 or higher then use this method your prepare failed and other exception will removed
public boolean startRecording() {
try {
camera.unlock();
mediaRecorder = new MediaRecorder();
mediaRecorder.setCamera(camera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile
.get(CamcorderProfile.QUALITY_HIGH));
File tempFile = new File(getOutputMediaFile(MEDIA_TYPE_VIDEO)
.toString());
mediaRecorder.setOutputFile(tempFile.getPath());
mediaRecorder.setVideoFrameRate(videoFramesPerSecond);
mediaRecorder.setVideoSize(surfaceView.getWidth(),
surfaceView.getHeight());
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.setMaxFileSize(maxFileSizeInBytes);
mediaRecorder.prepare();
mediaRecorder.start();
return true;
} catch (IllegalStateException e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
return false;
} catch (IOException e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
return false;
}
}