chenzhihui28/VideoRecorderAndCompressor

摄像头初始化失败

yuekong opened this issue · 7 comments

摄像头初始化失败

有看到报错日志吗

06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: java.io.FileNotFoundException: /mnt/sdcard/videokit/in.mp4: open failed: ENOENT (No such file or directory)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at libcore.io.IoBridge.open(IoBridge.java:409)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at java.io.FileOutputStream.(FileOutputStream.java:95)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at java.io.FileOutputStream.(FileOutputStream.java:145)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at java.io.FileOutputStream.(FileOutputStream.java:134)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at android.media.MediaRecorder.prepare(MediaRecorder.java:718)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at com.czh.testmpeg.videorecord.CameraActivity.prepareMediaRecorder(CameraActivity.java:490)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at com.czh.testmpeg.videorecord.CameraActivity.access$1200(CameraActivity.java:62)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at com.czh.testmpeg.videorecord.CameraActivity$7.onClick(CameraActivity.java:405)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at android.view.View.performClick(View.java:4438)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at android.view.View$PerformClick.run(View.java:18439)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at android.os.Handler.handleCallback(Handler.java:733)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at android.os.Looper.loop(Looper.java:136)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5241)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at java.lang.reflect.Method.invoke(Method.java:515)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:818)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at dalvik.system.NativeStart.main(Native Method)
06-23 09:09:32.413 6405-6405/com.czh.testmpeg W/System.err: Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
06-23 09:09:32.413 6405-6405/com.czh.testmpeg W/System.err: at libcore.io.Posix.open(Native Method)
06-23 09:09:32.413 6405-6405/com.czh.testmpeg W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
06-23 09:09:32.413 6405-6405/com.czh.testmpeg W/System.err: at libcore.io.IoBridge.open(IoBridge.java:393)
06-23 09:09:32.413 6405-6405/com.czh.testmpeg W/System.err: ... 18 more

 at com.czh.testmpeg.videorecord.CameraActivity.prepareMediaRecorder(CameraActivity.java:490)

06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at com.czh.testmpeg.videorecord.CameraActivity.access$1200(CameraActivity.java:62)
06-23 09:09:32.403 6405-6405/com.czh.testmpeg W/System.err: at com.czh.testmpeg.videorecord.CameraActivity$7.onClick(CameraActivity.java:405)

换一下路径录制视频文件的路径

换了还是一样报错

确认文件夹创建了,不能越级,比如先创建xx 再创建xx/zz
RandomAccessFile file = new RandomAccessFile(mPath, "rws"); 这里会报找不到文件异常,
尤其5.0以上的机型

权限,限制了api>23