我创建了一个从视频捕获帧的类。捕获帧时,将其另存为图片。视频为.avi时,应用程序正常运行。格式为.avi时。
public static void main(String[] args) {
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("C:/Users/Ioanna/Desktop/video1.avi");
try {
IplImage img;
//Start grabber to capture video
grabber.start();
//grab video frame to IplImage
img = grabber.grab();
if (img != null) {
//save video frame as a picture
cvSaveImage("capture.jpg", img);
}
}catch (Exception e) {
}
}
错误是
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.googlecode.javacv.FFmpegFrameGrabber.<init>(FFmpegFrameGrabber.java:106)
at Video.main(Video.java:75)
Caused by: java.lang.IllegalStateException: Can't overwrite cause with java.lang.UnsatisfiedLinkError: no avcodec in java.library.path
at java.lang.Throwable.initCause(Throwable.java:457)
at com.googlecode.javacpp.Loader.load(Loader.java:581)
at com.googlecode.javacpp.Loader.load(Loader.java:532)
at com.googlecode.javacv.cpp.avcodec.<clinit>(avcodec.java:39)
... 2 more
Caused by: java.lang.UnsatisfiedLinkError: no jniavcodec in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1837)
有人知道是什么问题吗?
提前致谢
最佳答案
在网上搜索了一段时间后,我得出以下解决方案:
步骤1:从以下位置下载.zip文件“ javacv-0.6-cppjars.zip”
https://code.google.com/p/javacv/downloads/list并将其解压缩。
步骤2:将“ ffmpeg-20130915-git-7ac6c63-windows-x86_64.jar”文件添加到您的Java项目中!