javacv icon indicating copy to clipboard operation
javacv copied to clipboard

JVM crash error

Open jetamie opened this issue 1 year ago • 6 comments

Pseudocode

public class Demo {
   private final static OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();
    public static void main(String[] args) throws Exception {
                      FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("test.mp4")
                      grabber.start();
                      Frame img = null;
                      while((img = grabber.grabImage()) !=null ) {
                          Mat mat = converter.convert(img);
                          //todo do something
                      }
     }
}

description

It worked very well at first, and I would repeat this logic over and over again, and immediately after a while, the JVM crashed, and here is the screenshot

screenshots

jetamie avatar Jul 24 '23 13:07 jetamie

Please call grabber.stop() at the end.

saudet avatar Jul 24 '23 13:07 saudet

Please call grabber.stop() at the end.

Sorry, I didn't write completely above, I used grabber.restart()

jetamie avatar Jul 31 '23 11:07 jetamie

Please call grabber.stop() at the end.

Do I need to reinitialize the ToMat object?

jetamie avatar Jul 31 '23 12:07 jetamie

restart() might not always work. Try not to use it see if it works.

saudet avatar Jul 31 '23 14:07 saudet

restart() might not always work. Try not to use it see if it works.

I need to read video frames in a loop, similar to FFmpeg's --loop parameter function

jetamie avatar Aug 02 '23 05:08 jetamie

Creating multiple instances of FFmpegFrameGrabber should do what you need.

saudet avatar Aug 18 '23 11:08 saudet