gpt4 book ai didi

使用 MediaRecorder#stop 时出现 java.lang.RuntimeException : stop failed.

转载 作者:太空宇宙 更新时间:2023-11-04 12:38:45 50 4
gpt4 key购买 nike

这是我的full code ,这里是my project ,当我在 #onCreate 中使用 MediaRecorder#stop 时,它会引发

java.lang.RuntimeException: stop failed.
at android.media.MediaRecorder.stop(Native Method)
at ro.rotry.TestMr.onCreate(TestMr.java:39)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

那么如何解决呢?

最佳答案

而不是这个:

    mr.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mr.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mr.setVideoSize(1920, 1080);
mr.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

尝试使用摄像机配置文件:

        try {

camera.unlock();

recorder.setPreviewDisplay(holder.getSurface());
recorder.setCamera(camera);

recorder.setOrientationHint(cameraRotationDegree);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
recorder.setVideoEncodingBitRate(5000000);
recorder.setOutputFile(getFilesDir() + "/try.mp4");
recorder.prepare();
Thread.sleep(1000);
recorder.start();

}catch (IOException e) {
e.printStackTrace();
}

关于使用 MediaRecorder#stop 时出现 java.lang.RuntimeException : stop failed.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37044964/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com