我正在尝试运行代码,但此错误显示出来。我在windows上使用Netbeans,jdk-9,javacv 1.3.2,opencv 3.1.0-1.2。有什么可以解决这个问题?
主要代码的一部分:
public void start() {
frameGrabber = new FFmpegFrameGrabber("video=Webcam C170");
frameGrabber.setFormat("dshow");
frameGrabber.setImageWidth(1280);
frameGrabber.setImageHeight(720);
logger.debug("Starting frame grabber");
try {
frameGrabber.start(); //line 72
logger.debug("Started frame grabber with image width-height : {}-{}", frameGrabber.getImageWidth(), frameGrabber.getImageHeight());
} catch (FrameGrabber.Exception e) {
logger.error("Error when initializing the frame grabber", e);
throw new RuntimeException("Unable to start the FrameGrabber", e);
}
SwingUtilities.invokeLater(() -> {
window.setVisible(true);
});
process();
logger.debug("Stopped frame grabbing.");
}
错误:
Caused by: org.bytedeco.javacv.FrameGrabber$Exception: avformat_open_input() error -5: Could not open input "video=Webcam C170". (Has setFormat() been called?)
at org.bytedeco.javacv.FFmpegFrameGrabber.startUnsafe(FFmpegFrameGrabber.java:535)
at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:465)
at org.imesha.examples.javacv.JavaCVExample.start(JavaCVExample.java:72)
答案 0 :(得分:0)
您是否尝试将filename作为构造函数参数传递,但是使用扩展名?基于源文件,FFmpegFrameGrabber有3个构造函数,其中一个选项是传递一个名为filename的String,它主要是指一个文件名+它的扩展名,如" yourfile.mpeg"