JavaCV使用FFmpeg捕获帧

前端之家收集整理的这篇文章主要介绍了JavaCV使用FFmpeg捕获帧前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了一个从视频中捕获帧的类.捕获帧时,它将保存为图片.当视频是.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项目中!

猜你在找的Java相关文章