当前位置: 首页 > 面试题库 >

Android MediaRecording错误启动失败-19 runTimeException

孙永嘉
2023-03-14
问题内容

我的媒体录制出现问题。我正在尝试使用前置摄像头进行记录。这给我一个错误(但预览正常)。每当我使用后置摄像头时,一切正常,我觉得这很奇怪。可能是什么问题,可能是解决方案?我的代码和错误如下所示。

编辑。使用VGA前置摄像头录制似乎不起作用。这怎么可能?虽然可以使用HTC camera应用程序进行录制。

预先感谢您。

protected void startRecording() throws Exception 
{
    mrec = new MediaRecorder();
    mCamera.unlock();

    mrec.setCamera(mCamera);


    mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    mrec.setAudioSource(MediaRecorder.AudioSource.MIC);

    mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
    //mrec.setPreviewDisplay(surfaceHolder.getSurface());

    File picDirectory = new File(Environment.getExternalStorageDirectory() +"/TrouwApp");
    picDirectory.mkdirs();

    File mediaStorageDir = new File(Environment.getExternalStorageDirectory() +"/TrouwApp", "Videos");

    // Create the storage directory if it does not exist
    if (! mediaStorageDir.exists()){
        if (! mediaStorageDir.mkdirs()){
            Log.d("MyCameraApp", "failed to create directory");
        }
    }

    mrec.setOutputFile( mediaStorageDir.getPath() + File.separator  + date + "_" + videonr+ ".3gp");

    mrec.prepare();
    mrec.start();//line 136

    Log.d(TAG, "Recording started!!");
}

行添加到清单:

<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

错误日志:

 08-25 23:25:25.332:V / MediaRecorderJNI(4989):设置
08-25 23:25:25.362:V / MediaRecorder(4989):构造函数
08-25 23:25:25.402:V / MediaRecorder(4989):doCleanUp
08-25 23:25:25.402:V / MediaRecorder(4989):setListener
08-25 23:25:25.402:V / MediaRecorderJNI(4989):setMediaRecorder E:mr = mr
08-25 23:25:25.402:V / MediaRecorderJNI(4989):setMediaRecorder X
08-25 23:25:25.402:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.402:V / MediaRecorderJNI(4989):JNIMediaRecorderListener :: setCamera
08-25 23:25:25.402:V / MediaRecorder(4989):setCamera(0x16c2290,0x1c08dc8)
08-25 23:25:25.402:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.402:V / MediaRecorderJNI(4989):setVideoSource(1)
08-25 23:25:25.402:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.402:V / MediaRecorder(4989):setVideoSource(1)
08-25 23:25:25.402:V / MediaRecorder(4989):由于媒体记录器尚未初始化,请调用init()
08-25 23:25:25.402:V / MediaRecorder(4989):初始化
08-25 23:25:25.412:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.412:V / MediaRecorderJNI(4989):setAudioSource(1)
08-25 23:25:25.412:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.412:V / MediaRecorder(4989):setAudioSource(1)
08-25 23:25:25.412:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.502:V / MediaRecorderJNI(4989):setOutputFormat(2)
08-25 23:25:25.502:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.502:V / MediaRecorder(4989):setOutputFormat(2)
08-25 23:25:25.502:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.502:V / MediaRecorderJNI(4989):setVideoFrameRate(30)
08-25 23:25:25.502:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.502:V / MediaRecorder(4989):setVideoFrameRate(30)
08-25 23:25:25.502:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.502:V / MediaRecorderJNI(4989):setVideoSize(1920,1088)
08-25 23:25:25.502:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.502:V / MediaRecorder(4989):setVideoSize(1920,1088)
08-25 23:25:25.502:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.502:V / MediaRecorderJNI(4989):setParameter()
08-25 23:25:25.502:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.502:V / MediaRecorder(4989):setParameters(视频参数编码比特率= 12000000)
08-25 23:25:25.512:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.512:V / MediaRecorderJNI(4989):setVideoEncoder(2)
08-25 23:25:25.512:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.512:V / MediaRecorder(4989):setVideoEncoder(2)
08-25 23:25:25.512:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.512:V / MediaRecorderJNI(4989):setParameter()
08-25 23:25:25.512:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.512:V / MediaRecorder(4989):setParameters(音频参数编码比特率= 96000)
08-25 23:25:25.512:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.512:V / MediaRecorderJNI(4989):setParameter()
08-25 23:25:25.512:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.512:V / MediaRecorder(4989):setParameters(音频参数通道数= 1)
08-25 23:25:25.512:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.512:V / MediaRecorderJNI(4989):setParameter()
08-25 23:25:25.512:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.512:V / MediaRecorder(4989):setParameters(音频参数采样率= 48000)
08-25 23:25:25.512:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.512:V / MediaRecorderJNI(4989):setAudioEncoder(3)
08-25 23:25:25.512:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.512:V / MediaRecorder(4989):setAudioEncoder(3)
08-25 23:25:25.512:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.542:V / MediaRecorderJNI(4989):setOutputFile
08-25 23:25:25.542:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.542:V / MediaRecorder(4989):setOutputFile(60,0,0)
08-25 23:25:25.542:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.542:V / MediaRecorderJNI(4989):准备
08-25 23:25:25.542:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.542:V / MediaRecorder(4989):准备
08-25 23:25:25.542:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.542:V / MediaRecorderJNI(4989):开始
08-25 23:25:25.552:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:25.552:V / MediaRecorder(4989):开始
08-25 23:25:25.562:E / MediaRecorder(4989):启动失败:-19
08-25 23:25:25.562:V / MediaRecorderJNI(4989):process_media_recorder_call
08-25 23:25:25.562:E / MediaRecorder(4989):启动失败
08-25 23:25:25.562:E / MediaRecorder(4989):尝试删除损坏的文件:/mnt/sdcard/TrouwApp/Videos/25-8-2013_0.3gp
08-25 23:25:25.562:D / videoActivity(4989):错误启动失败。
08-25 23:25:25.562:D / videoActivity(4989):错误java.lang.RuntimeException:启动失败。
08-25 23:25:25.562:D / videoActivity(4989):错误java.lang.RuntimeException:启动失败。
08-25 23:25:25.562:V / MediaRecorderJNI(4989):发布
08-25 23:25:25.562:V / MediaRecorderJNI(4989):setMediaRecorder E:mr = null
08-25 23:25:25.562:V / MediaRecorderJNI(4989):setMediaRecorder X
08-25 23:25:25.562:V / MediaRecorder(4989):setListener
08-25 23:25:25.562:V / MediaRecorder(4989):发布
08-25 23:25:25.562:V / MediaRecorder(4989):析构函数
08-25 23:25:25.562:D / videoActivity(4989):开始记录错误
08-25 23:25:25.562:W / System.err(4989):java.lang.RuntimeException:启动失败。
08-25 23:25:25.572:W / System.err(4989):位于android.media.MediaRecorder._start(本机方法)
08-25 23:25:25.572:W / System.err(4989):位于android.media.MediaRecorder.start(MediaRecorder.java:712)
08-25 23:25:25.572:W / System.err(4989):在com.example.trouwapp.VideoActivity.startRecording(VideoActivity.java:136)
08-25 23:25:25.572:W / System.err(4989):在com.example.trouwapp.VideoActivity.onClick(VideoActivity.java:246)
08-25 23:25:25.572:W / System.err(4989):在android.view.View.performClick(View.java:3549)
08-25 23:25:25.572:W / System.err(4989):在android.view.View $ PerformClick.run(View.java:14393)
08-25 23:25:25.582:W / System.err(4989):位于android.os.Handler.handleCallback(Handler.java:605)
08-25 23:25:25.582:W / System.err(4989):在android.os.Handler.dispatchMessage(Handler.java:92)
08-25 23:25:25.582:W / System.err(4989):位于android.os.Looper.loop(Looper.java:154)
08-25 23:25:25.582:W / System.err(4989):位于android.app.ActivityThread.main(ActivityThread.java:4945)
08-25 23:25:25.582:W / System.err(4989):at java.lang.reflect.Method.invokeNative(本机方法)
08-25 23:25:25.582:W / System.err(4989):at java.lang.reflect.Method.invoke(Method.java:511)
08-25 23:25:25.582:W / System.err(4989):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:784)
08-25 23:25:25.582:W / System.err(4989):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-25 23:25:25.592:W / System.err(4989):在dalvik.system.NativeStart.main(本机方法)
08-25 23:25:55.582:V / MediaRecorderJNI(4989):native_reset
08-25 23:25:55.582:V / MediaRecorderJNI(4989):getMediaRecorder E
08-25 23:25:55.582:V / MediaRecorderJNI(4989):发布
08-25 23:25:55.582:V / MediaRecorderJNI(4989):setMediaRecorder E:mr = null
08-25 23:25:55.582:V / MediaRecorderJNI(4989):setMediaRecorder X
08-25 23:25:56.002:D / AndroidRuntime(4989):关闭VM
08-25 23:25:56.002:W / dalvikvm(4989):threadid = 1:线程以未捕获的异常退出(group = 0x40ac8228)

问题答案:

找到了解决方案。由于我使用的是前置摄像头,因此我需要从前置摄像头获取摄像机配置文件。我做到了这一点:

mrec.setProfile(CamcorderProfile.get(1, CamcorderProfile.QUALITY_HIGH));

代替这个:

mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));


 类似资料:
  • 错误:无法启动连接:错误:WebSocket无法连接。在服务器上找不到连接,endpoint可能不是信号器endpoint,服务器上不存在连接ID,或者存在阻止WebSocket的代理。如果有多台服务器,请检查是否启用了粘性会话。 WebSocketTransport.js:49WebSocket连接到“ws://xxxxxx/生产/网络服务/集线器/spreadhub”失败: Angular.t

  • 我正在使用NetBeans 8.0.2(也在最新的夜间版本中尝试过),并试图在端口8084上启动TomEE Plume服务器(也在不同的端口上尝试过)。服务器启动和工作正常,但NetBeans认为它没有启动,在大约2分钟的等待(“等待Tomcat”)后,抛出一个错误窗口“Tomcat失败启动”或类似的东西。 有些问题与我的问题相似,不同的是我完全没有错误,只有“Tomcat失败启动”窗口,所以我甚

  • 我正在试验一个随附的新功能。NETCoreSDK2.2,据说它可以将性能提高400%左右。 令人印象深刻,所以我在我的ABP(ASP.NET样板文件)项目中试用了它 我在我的文件 不幸的是,我不认为这个版本的ABP框架是兼容的,因为项目根本无法运行并抛出:(最终) HTTP错误500.30-ANCM进程内启动失败 在web中设置后,我检查了日志。配置并重试-但没有条目。 是否有人成功地针对asp运

  • 我正在尝试部署一个简单的应用程序,没什么大不了的,但我总是收到这个错误。 错误R10(启动超时)- 即使Heroku在60秒前就完成了部署。我也在服务器上设置了process.env.PORT。我在Heroku上有几个应用程序,所以我很熟悉部署。 我事先制作了服务器捆绑文件(src/build/bundle.js)和客户端捆绑文件(src/dist/bundle.js),并将所有内容推送到Hero

  • 我正在开发一个应用程序来录制视频。 我在Nexus 4和Sony Ericsson mini pro上运行良好的应用程序中得到了这段代码,但当我在其他设备上测试时,比如Archos 80G9和Jiayu G3ST时,应用程序给出了以下错误 “MediaRecorder启动失败-19” 我试过: 在之前放置但这会给我一个错误。 在development.android.com中放置默认的Camera