android mediarecorder error (MediaRecorder start failed : -19)

余生长醉 提交于 2019-12-11 06:46:26

问题


When I try to make the camera recorder in my program I get this error:

E/MediaRecorder﹕ start failed: -19

code is

try {
    final SurfaceView sv = (SurfaceView) findViewById(R.id.srvView);
    MediaRecorder mrec = new MediaRecorder();
    mrec.setCamera(camera);

    mrec.setAudioSource(MediaRecorder.AudioSource.MIC);
    mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    mrec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mrec.setVideoFrameRate(10);
    mrec.setVideoSize(480, 320);
    mrec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    mrec.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);

    mrec.setPreviewDisplay(mSh.getSurface());
    mrec.setOutputFile("/mnt/sdcard/pro/andsend.avi");
    mrec.prepare();
    mrec.start();
} catch(Exception e)
{
    e.printStackTrace();
}

I try to change the sequence and change the set size, Frame Rate etc...

But, I can't find the problem.

What's the problem?


回答1:


see my answer : android-mediarecorder-start-failed-19

error code -19 comes about when there is a problem with the size of the video as set by MediaRecorder#setVideoSize()




回答2:


 mrec.setOutputFile("/mnt/sdcard/pro/andsend.avi");

are you sure that this folder exist? Also edit this line to

mrec.setOutputFile(Environment.getExternalStorageDirectory() + "/pro/andsend.avi");


来源:https://stackoverflow.com/questions/30303975/android-mediarecorder-error-mediarecorder-start-failed-19

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!