natario1/CameraView

Maybe create a new callback for capturing runtime errors?

EzequielAdrianM opened this issue · 0 comments

Hello Natario1

I am getting this crash here:

Fatal Exception: java.lang.RuntimeException: java.io.FileNotFoundException: /storage/emulated/0/Movies/appname/VID_20230517_205355.mp4: open failed: ENOENT (No such file or directory)
       at com.otaliastudios.cameraview.video.encoding.MediaEncoderEngine.<init>(MediaEncoderEngine.java:139)
       at com.otaliastudios.cameraview.video.SnapshotVideoRecorder.onRendererFrame(SnapshotVideoRecorder.java:261)
       at com.otaliastudios.cameraview.preview.GlCameraPreview$Renderer.onDrawFrame(GlCameraPreview.java:236)
       at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1553)
       at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)

After Reviewing your MediaEncoderEngine.java (139) I can see that your library does in fact catch the exception:

        try {
            mMediaMuxer = new MediaMuxer(file.toString(),
                    MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

But this Throw RuntimeException is still unable to being handled by the application code implementing the library. I think exception should be thrown by a new CameraListener callback like, for example: onVideoRecordingError(Exception e) {} I hope this will help prevent making the app crash.