Iam trying to develop an android based camera application which requires recording videos on live camera preview with overlay images. Is there any way on android using which we can record videos with overlay images without using any third party library .
Currently iam using an additional Surfaceview as an overlay on live camera screen and MediaRecorder class for recording videos.Here is my code :
recorder = new MediaRecorder();
recorder.setCamera(mCam);
String filename="";
String path="";
path= Environment.getExternalStorageDirectory().getAbsolutePath().toString();
Date date=new Date();
filename="/rec"+date.toString().replace(" ", "_").replace(":", "_")+".mp4";
File file=new File(path,filename);
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoSize(mPreviewSize.width, mPreviewSize.height);
recorder.setVideoEncodingBitRate(10000000);
recorder.setVideoFrameRate(30);
try {
recorder.prepare();
} catch (IllegalStateException e) {
releaseMediaRecorder();
return false;
} catch (IOException e) {
releaseMediaRecorder();
return false;
}
The above code crashes the application during the start of recording process. Is there any other way in OpenGL ES 2.0 apart from MediaRecorder for recording videos with overlay.
Please advice.