Title

Saturday, 7 February 2015

MediaRecorder start failing


I get start failed: -19 when I try to run the following code, I am pretty sure I have all the elements I need to begin video capture, I have a surfaceview which I set camera preview to and below is the rest of code that is initialized in

 `@Override   public void surfaceCreated( SurfaceHolder surfaceHolder )`

I constantly get E/MediaRecorder﹕ start failed: -19 when trying to run the method that starts the recorder. Is there something else I need to add before starting the actual recorder?

 if(mRecorder == null)   mRecorder = new MediaRecorder();     try {   mRecorder.setCamera( mCamera );   mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);   mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);   mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);     //AUDIO   mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);   //VIDEO   mRecorder.setVideoSize(640, 460);   mRecorder.setVideoFrameRate( 15 );   mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);   // mRecorder.setProfile(CamcorderProfile.get(0, CamcorderProfile.QUALITY_LOW));     mRecorder.setOutputFile( createNewFile() );   mRecorder.setPreviewDisplay( mHolder.getSurface() );   mRecorder.setMaxDuration(10000); // Set max duration 60 sec. ~ 60 * 1000     } catch (Exception e) {   Log.e( getString( R.string.app_name ), "failed to open Camera" );   e.printStackTrace();   }

Then in a button click method I have mRecorder.prepare();mRecorder.start();.

Answer

No comments:

Post a Comment