I am trying to create an Android VCR and I have prepared my code that should work, but I constantly get the error message start failed: -19
.
Here is my code:
public boolean startRecording() { try { camera.unlock(); mediaRecorder = new MediaRecorder(); mediaRecorder.setOnErrorListener(new MediaRecorder.OnErrorListener() { @Override public void onError(MediaRecorder mr, int what, int extra) { Log.i(TAG, "Error"); } }); mediaRecorder.setCamera(camera); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); Log.i(TAG, "a"); mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263); Log.i(TAG, "b"); mediaRecorder.setMaxDuration(maxDurationInMs); // set to 20000 String uniqueOutFile = OUTPUT_FILE + System.currentTimeMillis() + ".3gp"; File outFile = new File(uniqueOutFile); if (outFile.exists()) { outFile.delete(); } mediaRecorder.setOutputFile(uniqueOutFile); mediaRecorder.setVideoFrameRate(videoFramesPerSecond); // set to 20 mediaRecorder.setVideoSize(sView.getWidth(), sView.getHeight()); Log.i(TAG, "c"); mediaRecorder.setPreviewDisplay(holder.getSurface()); mediaRecorder.setMaxFileSize(maxFileSizeInBytes); // set to 50000 mediaRecorder.prepare(); Log.i(TAG, "d"); mediaRecorder.start(); Log.i(TAG, "e"); return true; } catch (IllegalStateException e) { Log.i(TAG, "f"); Log.e(TAG, e.getMessage()); e.printStackTrace(); camera.lock(); return false; } catch (IOException e) { Log.i(TAG, "g"); Log.e(TAG, e.getMessage()); e.printStackTrace(); camera.lock(); return false; } catch (RuntimeException e) { Log.i(TAG, "h"); Log.e(TAG, e.getMessage()); camera.lock(); return false; } }
All debug logs (from "a" to "d") are printed in the log, so it seems that all the steps to mediaRecorder.prepare()
done correctly. Then it catches a RuntimeException
with the message start failed: -19
. There is a similar question , but this does not solve my problem.
Is there any other reason to get such an error?
source share