Reputation: 1568
The approach I've tried to implement is shown below.
It saves the file and the audio is fine, but the video is all greenish lines.
What am I doing wrong?
camera.unlock();
mediaRecorder = new MediaRecorder();
mediaRecorder.setCamera(camera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mediaRecorder.setOutputFile("/sdcard/"+ videoName + ".mp4");
mediaRecorder.setVideoSize(240, 240);
mediaRecorder.setVideoFrameRate(24);
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
//mediaRecorder.setMaxDuration(10000);
//mediaRecorder.setMaxFileSize(10000000);
mediaRecorder.prepare();
mediaRecorder.start();
Upvotes: 1
Views: 1303
Reputation: 1568
Found my answer at: Problem with Video recording after auto focus in Android
camera.stopPreview();
camera.unlock();
//etc
This fixed it.
Upvotes: 2