错误com.xuggle.ferry.JNILibraryLoader - 无法加载库:xuggle-xuggler;版本:3; [英] ERROR com.xuggle.ferry.JNILibraryLoader - Could not load library: xuggle-xuggler; version: 3;

查看:164
本文介绍了错误com.xuggle.ferry.JNILibraryLoader - 无法加载库:xuggle-xuggler;版本:3;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从 Xuggler教程:帧捕获和视频创建的代码frames-capture-video.html / comment-page-1 /#comment-4336rel =nofollow>此链接,我在项目中添加了所有 .jar 文件运行此代码需要,但是,当我运行此代码时,我收到错误:



这是我的代码:

  package xug; 

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.xuggle.mediatool.IMediaReader;
import com.xuggle.mediatool.MediaListenerAdapter;
import com.xuggle.mediatool.ToolFactory;
import com.xuggle.mediatool.event.IVideoPictureEvent;
import com.xuggle.xuggler.Global;

公共类VideoThumbnailsExample {

public static final double SECONDS_BETWEEN_FRAMES = 10;
private static final String inputFilename =e:/low_light.mp4;
private static final String outputFilePrefix =e:/ Frames / processedImages;
//视频流索引,用于确保我们从一个和
//显示来自媒体容器的一个视频流。
private static int mVideoStreamIndex = -1;
//最后一帧写入的时间
private static long mLastPtsWrite = Global.NO_PTS;
public static final long MICRO_SECONDS_BETWEEN_FRAMES =
(long)(Global.DEFAULT_PTS_PER_SECOND * SECONDS_BETWEEN_FRAMES);

public static void main(String [] args){

IMediaReader mediaReader = ToolFactory.makeReader(inputFilename);

//规定我们希望在BGR 24位色彩空间中创建BufferedImages
mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);

mediaReader.addListener(new ImageSnapListener());

//读出媒体文件的内容和
//调度事件到附加的监听器
while(mediaReader.readPacket()== null);

}

私有静态类ImageSnapListener扩展MediaListenerAdapter {

public void onVideoPicture(IVideoPictureEvent event){

if(

if( event.getStreamIndex()!= mVideoStreamIndex){
//如果所选的视频流id尚未设置,请继续
//选择此幸运视频流
if(mVideoStreamIndex == -1){
mVideoStreamIndex = event.getStreamIndex();
} //无需显示此视频流中的帧
else {
return;
}
}

//如果未初始化,返回日期mLastPtsWrite获取第一帧
if(mLastPtsWrite == Global.NO_PTS){
mLastPtsWrite = event.getTimeStamp() - MICRO_SECONDS_BETWEEN_FRAMES;
}

//如果是时候写下一帧
if(event.getTimeStamp() - mLastPtsWrite
> = MICRO_SECONDS_BETWEEN_FRAMES){

String outputFilename = dumpImageToFile(event.getImage());

//表示写入的文件
double seconds =((double)event.getTimeStamp())
/ Global.DEFAULT_PTS_PER_SECOND;
System.out.printf(
经过时间%6.3f秒写道:%s \ n,
秒,outputFilename);

//更新上次写入时间
mLastPtsWrite + = MICRO_SECONDS_BETWEEN_FRAMES;
}

}

private String dumpImageToFile(BufferedImage image){
try {
String outputFilename = outputFilePrefix
+ System .currentTimeMillis()+。png;
ImageIO.write(image,png,new File(outputFilename));
返回outputFilename;
} catch(IOException e){
e.printStackTrace();
返回null;
}
}
}
}

和我收到了以下错误。

  [main]错误com.xuggle.ferry.JNILibraryLoader  - 无法加载库:xuggle-xuggler;版本:3;访问http://www.xuggle.com/xuggler/faq/以查找此问题的常见解决方案
java.lang.UnsatisfiedLinkError:java.library.path中的no xuggle-xuggler
at java.lang .ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at com.xuggle.ferry.JNILibraryLoader.loadLibrary0(JNILibraryLoader.java:265)
at com.xuggle.ferry.JNILibraryLoader.loadLibrary(JNILibraryLoader.java:168)
at com.xuggle。 xuggler.XugglerJNI。< clinit>(XugglerJNI.java:19)
at com.xuggle.xuggler.Global。< clinit>(Global.java:238)
at xug.VideoThumbnailsExample。< clinit>(VideoThumbnailsExample.java:28)
线程main中的异常Java结果:1



<请解释为什么 Class-Loader 无法加载 .jar 文件。

解决方案

你遇到的问题ave是无法找到Xuggle使用的本机库。我怀疑你的类路径中存在冲突。



如果所有的罐子你的意思是下载页面中的罐子,你不应该下载所有的他们。在 Xuggler下载页面上,它说您要么下载 xuggle-xuggler .jar 包含所有操作系统的本机库,或者您选择特定的体系结构。



尝试运行您链接到的示例,我已完成以下操作:




  • 已下载 xuggle-xuggler.jar (v.5.2)。我没有使用maven,所以根据下载页面的内容,我打开了 Xuggle POM文件使用特定版本检查并获取依赖项。

  • 使用谷歌的一些帮助,这些依赖是: slf4j-1.6.4 commons -cli 1.1 logback 1.0 ,(包含两个所需的罐子, xuggle-utils 1.20 junit 你可以忽略它。

    下载后你可以在zip文件里找到5个罐子( slf4j- api-1.6.4.jar,commons-cli-1.1.jar,logback-core-1.0.0.jar,logback-classic-1.0.0.jar,xuggle-utils-1.20.688.jar )在POM文件中描述的是 xuggle-xuggler.jar 的依赖关系。

  • 在您喜欢的IDE中创建一个项目(我使用Eclipse)将这6个jar文件导入到您的项目中,你就可以了。



按照上述步骤,我能够在Windows机器上成功运行您的测试程序。



我希望有所帮助。 / p>

I have recently downloaded a code for, Xuggler Tutorial: Frames Capture and Video Creation from this link, I have added all the .jar files in my project which are required to run this code but, When I am running this code then I am getting Error:

Here is my code:

package xug;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.xuggle.mediatool.IMediaReader;
import com.xuggle.mediatool.MediaListenerAdapter;
import com.xuggle.mediatool.ToolFactory;
import com.xuggle.mediatool.event.IVideoPictureEvent;
import com.xuggle.xuggler.Global;

public class VideoThumbnailsExample {

    public static final double SECONDS_BETWEEN_FRAMES = 10;
    private static final String inputFilename = "e:/low_light.mp4";
    private static final String outputFilePrefix = "e:/Frames/processedImages";
    // The video stream index, used to ensure we display frames from one and
    // only one video stream from the media container.
    private static int mVideoStreamIndex = -1;
    // Time of last frame write
    private static long mLastPtsWrite = Global.NO_PTS;
    public static final long MICRO_SECONDS_BETWEEN_FRAMES =
            (long) (Global.DEFAULT_PTS_PER_SECOND * SECONDS_BETWEEN_FRAMES);

    public static void main(String[] args) {

        IMediaReader mediaReader = ToolFactory.makeReader(inputFilename);

        // stipulate that we want BufferedImages created in BGR 24bit color space
        mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);

        mediaReader.addListener(new ImageSnapListener());

        // read out the contents of the media file and
        // dispatch events to the attached listener
        while (mediaReader.readPacket() == null) ;

    }

    private static class ImageSnapListener extends MediaListenerAdapter {

        public void onVideoPicture(IVideoPictureEvent event) {

            if (event.getStreamIndex() != mVideoStreamIndex) {
                // if the selected video stream id is not yet set, go ahead an
                // select this lucky video stream
                if (mVideoStreamIndex == -1) {
                    mVideoStreamIndex = event.getStreamIndex();
                } // no need to show frames from this video stream
                else {
                    return;
                }
            }

            // if uninitialized, back date mLastPtsWrite to get the very first frame
            if (mLastPtsWrite == Global.NO_PTS) {
                mLastPtsWrite = event.getTimeStamp() - MICRO_SECONDS_BETWEEN_FRAMES;
            }

            // if it's time to write the next frame
            if (event.getTimeStamp() - mLastPtsWrite
                    >= MICRO_SECONDS_BETWEEN_FRAMES) {

                String outputFilename = dumpImageToFile(event.getImage());

                // indicate file written
                double seconds = ((double) event.getTimeStamp())
                        / Global.DEFAULT_PTS_PER_SECOND;
                System.out.printf(
                        "at elapsed time of %6.3f seconds wrote: %s\n",
                        seconds, outputFilename);

                // update last write time
                mLastPtsWrite += MICRO_SECONDS_BETWEEN_FRAMES;
            }

        }

        private String dumpImageToFile(BufferedImage image) {
            try {
                String outputFilename = outputFilePrefix
                        + System.currentTimeMillis() + ".png";
                ImageIO.write(image, "png", new File(outputFilename));
                return outputFilename;
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    }
}

and I am getting following error in this.

[main] ERROR com.xuggle.ferry.JNILibraryLoader - Could not load library: xuggle-xuggler; version: 3; Visit http://www.xuggle.com/xuggler/faq/ to find common solutions to this problem
java.lang.UnsatisfiedLinkError: no xuggle-xuggler in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
    at java.lang.Runtime.loadLibrary0(Runtime.java:845)
    at java.lang.System.loadLibrary(System.java:1084)
    at com.xuggle.ferry.JNILibraryLoader.loadLibrary0(JNILibraryLoader.java:265)
    at com.xuggle.ferry.JNILibraryLoader.loadLibrary(JNILibraryLoader.java:168)
    at com.xuggle.xuggler.XugglerJNI.<clinit>(XugglerJNI.java:19)
    at com.xuggle.xuggler.Global.<clinit>(Global.java:238)
    at xug.VideoThumbnailsExample.<clinit>(VideoThumbnailsExample.java:28)
Exception in thread "main" Java Result: 1

Please explain why Class-Loader is unable to load the .jar file.

解决方案

The problem you have is that the native libraries that Xuggle uses cannot be found. I suspect that there is a conflict in your classpath.

If by "all the jars" you mean the jars in the download page, you are not supposed to download all of them. At the Xuggler downloads page it says that either you download the xuggle‑xuggler.jar that contains the native libraries for all operating systems or you choose a specific architecture.

On an attempt to run the example you link to, I have done the following:

  • Downloaded xuggle‑xuggler.jar (v.5.2). I didn't use maven, so as per the instrunctions at the download page I opened the Xuggle POM file to check and get the dependencies using the specific versions.
  • Using a little help from google those dependencies are: slf4j-1.6.4, commons-cli 1.1, logback 1.0, (contains two of the required jars), xuggle-utils 1.20 and junit which you can ignore.
    After downloading you can find inside the zip files the 5 jars (slf4j-api-1.6.4.jar, commons-cli-1.1.jar, logback-core-1.0.0.jar, logback-classic-1.0.0.jar, xuggle-utils-1.20.688.jar) described in the POM file that are the dependencies of the xuggle‑xuggler.jar.
  • Create a project in your favourite IDE (I use Eclipse) import those 6 jar files to your project and you are good to go.

Following the procedure above I was able to run your test program succesfully in a Windows machine.

I hope that helps.

这篇关于错误com.xuggle.ferry.JNILibraryLoader - 无法加载库:xuggle-xuggler;版本:3;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆