javacv
javacv copied to clipboard
JVM crash error
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
Please call grabber.stop() at the end.
Please call grabber.stop() at the end.
Sorry, I didn't write completely above, I used grabber.restart()
Please call grabber.stop() at the end.
Do I need to reinitialize the ToMat
object?
restart() might not always work. Try not to use it see if it works.
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
Creating multiple instances of FFmpegFrameGrabber should do what you need.