RecordVideo:. lang。RuntimeException:开始失败了

时间:2022-12-15 18:53:26

I have a problem with video reocrding on nexus s with android 4.1.2.

我对nexus s和android 4.1.2的视频重放有异议。

 private static final String OUTPUT_FILE="/storage/sdcard0/uatestvideo1.mp4";

Android Manifest:

Android清单:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.STORAGE" />
<uses-feature android:name="android.hardware.camra"/>

onCreate: In oncreate I have: ...

onCreate:在onCreate中,我有:……

final SurfaceHolder holder =    videoView.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

...

private void beginRecording(SurfaceHolder holder) throws Exception{

        if(recorder!=null){
            recorder.stop();
            recorder.release();
            recorder=null;
        }
        File outFile = new File(OUTPUT_FILE);
        if(outFile.exists()){
            outFile.delete();
        }

        try{
            recorder = new MediaRecorder();
            recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
            recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            recorder.setVideoSize(320, 240);
            recorder.setVideoFrameRate(15);
            recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            recorder.setMaxDuration(200000);
            recorder.setPreviewDisplay(holder.getSurface());
            recorder.setOutputFile(OUTPUT_FILE);
            recorder.prepare();
                recorder.start();
        }catch(Exception e){
            Log.e(TAG, e.toString());
            e.printStackTrace();
        }

    }


}

ERRORS:

错误:

11-25 10:46:07.723: E/MediaRecorder(15354): start failed: -19
11-25 10:46:07.727: E/RecordVideo(15354): java.lang.RuntimeException: start failed.
11-25 10:46:07.727: D/Blad w rekorder(15354): java.lang.RuntimeException: start failed.
11-25 10:46:07.727: W/System.err(15354): java.lang.RuntimeException: start failed.
11-25 10:46:07.727: W/System.err(15354):    at android.media.MediaRecorder.start(Native Method)
11-25 10:46:07.727: W/System.err(15354):    at com.plym.andr.UsVideoRecorder.beginRecording(UsVideoRecorder.java:198)
11-25 10:46:07.727: W/System.err(15354):    at com.plym.andr.UsVideoRecorder.access$2(UsVideoRecorder.java:168)
11-25 10:46:07.727: W/System.err(15354):    at com.plym.andr.UsVideoRecorder$1.onClick(UsVideoRecorder.java:76)
11-25 10:46:07.727: W/System.err(15354):    at android.view.View.performClick(View.java:4084)
11-25 10:46:07.727: W/System.err(15354):    at android.view.View$PerformClick.run(View.java:16966)
11-25 10:46:07.731: W/System.err(15354):    at android.os.Handler.handleCallback(Handler.java:615)
11-25 10:46:07.731: W/System.err(15354):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-25 10:46:07.731: W/System.err(15354):    at android.os.Looper.loop(Looper.java:137)
11-25 10:46:07.731: W/System.err(15354):    at android.app.ActivityThread.main(ActivityThread.java:4745)
11-25 10:46:07.731: W/System.err(15354):    at java.lang.reflect.Method.invokeNative(Native Method)
11-25 10:46:07.731: W/System.err(15354):    at java.lang.reflect.Method.invoke(Method.java:511)
11-25 10:46:07.731: W/System.err(15354):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-25 10:46:07.731: W/System.err(15354):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-25 10:46:07.731: W/System.err(15354):    at dalvik.system.NativeStart.main(Native Method)

1 个解决方案

#1


2  

-19 is the error for NO_INIT. Which would mean your recorder is not properly initialized.

-19是NO_INIT的错误。这意味着您的记录器没有正确初始化。

Check this link for a similar question.

检查这个链接找到一个类似的问题。

#1


2  

-19 is the error for NO_INIT. Which would mean your recorder is not properly initialized.

-19是NO_INIT的错误。这意味着您的记录器没有正确初始化。

Check this link for a similar question.

检查这个链接找到一个类似的问题。