5

我创建了一个从视频中捕获帧的类。当它捕获一帧时,它会保存为图片。当视频为 .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)

有谁知道是什么问题?

提前致谢

4

1 回答 1

3

在网上搜索了一段时间后,我得出了以下解决方案:

第 1 步:https://code.google.com/p/javacv/downloads/list下载 .zip 文件“javacv-0.6-cppjars.zip 并解压缩。

第 2 步:将“ffmpeg-20130915-git-7ac6c63-windows-x86_64.jar”文件添加到您的 Java 项目中!

于 2013-12-02T12:44:54.697 回答