I am trying to capture video in my app.
This was working fine on all android versions and different devices until I tried it on Nexus 9 with Android Version 5.1.1.
This is my code:
prCamera.lock();
prCamera.unlock();
prMediaRecorder.setCamera(prCamera);
prMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
prMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
prMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
prMediaRecorder.setAudioEncoder(AudioEncoder.AAC);
prMediaRecorder.setVideoEncoder(VideoEncoder.H264);
prRecordedFile = new File(mFilePath);
prMediaRecorder.setOutputFile(prRecordedFile.getPath());
prMediaRecorder.setVideoEncodingBitRate(3000000);
prMediaRecorder.setVideoSize(720, 480);
prMediaRecorder.setVideoFrameRate(cFrameRate);
prMediaRecorder.setPreviewDisplay(prSurfaceHolder.getSurface());
prMediaRecorder.prepare();
if (prRecordedFile.exists()) {
prRecordedFile.mkdirs();
if (MarkerName != null) {
try {
prMediaRecorder.start(); // EXITS HERE
} catch (Exception e) {
e.printStackTrace(); // STACK TRACE SHOWN BELOW
}
}
}
This is Log (Stack Trace):
06-24 12:42:20.099: W/System.err(10736): java.lang.RuntimeException: start failed.
06-24 12:42:20.138: W/System.err(10736): at android.media.MediaRecorder.start(Native Method)
06-24 12:42:20.206: W/System.err(10736): at uk.org.humanfocus.hfi.FFMPEGRecorderActivity.startRecording(FFMPEGRecorderActivity.java:1083)
06-24 12:42:20.260: W/System.err(10736): at uk.org.humanfocus.hfi.FFMPEGRecorderActivity.access$15(FFMPEGRecorderActivity.java:1035)
06-24 12:42:20.304: W/System.err(10736): at uk.org.humanfocus.hfi.FFMPEGRecorderActivity$5.run(FFMPEGRecorderActivity.java:1300)
06-24 12:42:20.344: W/System.err(10736): at android.os.Handler.handleCallback(Handler.java:739)
06-24 12:42:20.384: W/System.err(10736): at android.os.Handler.dispatchMessage(Handler.java:95)
06-24 12:42:20.417: W/System.err(10736): at android.os.Looper.loop(Looper.java:135)
06-24 12:42:20.467: W/System.err(10736): at android.app.ActivityThread.main(ActivityThread.java:5254)
06-24 12:42:20.504: W/System.err(10736): at java.lang.reflect.Method.invoke(Native Method)
06-24 12:42:20.547: W/System.err(10736): at java.lang.reflect.Method.invoke(Method.java:372)
06-24 12:42:20.594: W/System.err(10736): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
06-24 12:42:20.630: W/System.err(10736): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Please Remove this line and try again.