媒体录制器启动失败使用Android的东西

时间:2017-10-23 21:13:25

标签: android android-camera2 android-things

嗨,每当我尝试在Android中设置并启动视频录制时,我都会收到以下错误。

这是错误:

java.lang.RuntimeException: start failed.
    at android.media.MediaRecorder.start(Native Method)
    at com.jr.survailancedropboxcam.VideoCameraRecorder.setMediaOutputSurface(VideoCameraRecorder.kt:88)
    at com.jr.survailancedropboxcam.VideoCameraRecorder.access$setMediaOutputSurface(VideoCameraRecorder.kt:26)
    at com.jr.survailancedropboxcam.VideoCameraRecorder$cameraStateCalback$1.onOpened(VideoCameraRecorder.kt:46)
    at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

这是我的代码:

 mediaRecorder = MediaRecorder()
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA)
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT)
    mediaRecorder.setOutputFile(context.filesDir.absolutePath + "/"+System.currentTimeMillis())
    mediaRecorder.prepare()
    mediaRecorder.start()

    var outputCaptures = ArrayList<Surface>()
    outputCaptures.add(mediaRecorder.surface)

    return outputCaptures
当我尝试调用mediaRecorder.start

时发生

崩溃

0 个答案:

没有答案