我在我的项目中使用了 javacv 来处理 avi。视频显示速度比正常快,我想获得 fps 来设置视频的速度。但是grabber.getFrameRate()返回0,与grabber.getLengthInFrames()和grabber.getSampleRate()一样,谁能告诉我为什么?下面的代码片段:
FrameGrabber grabber = new OpenCVFrameGrabber("sample.avi");
double fps=grabber.getFrameRate();
System.out.println(fps);
//int n=grabber.getLengthInFrames();
//int f=grabber.getSampleRate();
CvMemStorage storage = CvMemStorage.create();
grabber.start();
grabbedImage = grabber.grab();
while (frame.isVisible() && (grabbedImage = grabber.grab()) != null)
{
BufferedImage bfimg = grabbedImage.getBufferedImage();
frame.showImage(bfimg);
frame.waitKey((int)(1000/fps));
cvClearMemStorage(storage);
}
grabber.stop();