Mediarecorder start failed -19

后端 未结 5 1207
醉梦人生
醉梦人生 2020-12-18 10:37

I am getting this error when running start() for mediarecorder.

06-28 18:46:22.570: E/MediaRecorder(9540): start failed: -19
06-28 18:46:22.570: W/System.err         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-18 11:09

    This code worked for me (found here)

    mCamera.unlock(); // maybe not for your activity flow
    
    //1st. Initial state
    mProfile = CamcorderProfile.get( CamcorderProfile.QUALITY_HIGH );
    mMediaRecorder = new MediaRecorder();
    mMediaRecorder.setCamera( mCamera );
    
    //2nd. Initialized state
    mMediaRecorder.setAudioSource( MediaRecorder.AudioSource.CAMCORDER );
    mMediaRecorder.setVideoSource( MediaRecorder.VideoSource.CAMERA );
    
    //3rd. config
    mMediaRecorder.setOutputFormat( mProfile.fileFormat );
    mMediaRecorder.setAudioEncoder( mProfile.audioCodec );
    mMediaRecorder.setVideoEncoder( mProfile.videoCodec );
    mMediaRecorder.setOutputFile( "/sdcard/FBVideo.3gp" );
    mMediaRecorder.setVideoSize( mProfile.videoFrameWidth, mProfile.videoFrameHeight );
    mMediaRecorder.setVideoFrameRate( mProfile.videoFrameRate );
    mMediaRecorder.setVideoEncodingBitRate( mProfile.videoBitRate );
    mMediaRecorder.setAudioEncodingBitRate( mProfile.audioBitRate );
    mMediaRecorder.setAudioChannels( mProfile.audioChannels );
    mMediaRecorder.setAudioSamplingRate( mProfile.audioSampleRate );
    mMediaRecorder.setPreviewDisplay( mHolder.getSurface() );
    
    try {
        mMediaRecorder.prepare();
        mMediaRecorder.start();
    } catch ( IllegalStateException e ) {
        e.printStackTrace();
    } catch ( IOException e ) {
        e.printStackTrace();
    }
    

提交回复
热议问题