首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xuggle和java库路径

Xuggle和java库路径
EN

Stack Overflow用户
提问于 2011-11-10 08:53:55
回答 2查看 3.2K关注 0票数 1

我正在用Java编写一个屏幕广播应用程序。我决定使用Xuggle来做这件事,然后按照xuggle上的安装说明进行操作。

我使用%XUGGLE_HOME%\bin和%XUGGLE_HOME%\lib设置了PATH环境。一切看起来都还好。我把这个应用程序作为一个RCP插件。我在"RCP-mail“模板上尝试过,插件工作正常,视频生成也是正确的。

但是,当我决定在“真实”应用程序上使用它时,插件出现了一个奇怪的错误消息:

起始捕获

2011-11-10 08:08:45,438线程-5警告com.xuggle.ferry.JNILibraryLoader -失败:库加载库:Xuggle xuggler;版本: 3:绝对路径: C:\Program (X86)\Xuggle\bin\libxuggle 3.dll;错误: java.lang.UnsatisfiedLinkError: C:\Program (X86)\Xuggle\bin\libxuggle 3.Can:无法找到依赖的库

2011-11-10 08:08:45,447线程-5警告com.xuggle.ferry.JNILibraryLoader -失败:库加载库:Xuggle xuggler;版本: 3:绝对路径: C:\Program (X86)\Xuggle\bin\libxuggle 3.dll;错误: java.lang.UnsatisfiedLinkError: C:\Program (X86)\Xuggle\bin\libxuggle 3.Can:无法找到依赖的库

2011-11-10 08:08:45,453线程-5错误com.xuggle.ferry.JNILibraryLoader -无法加载库;版本: 3;访问http://www.xuggle.com/xuggler/faq/以找到解决此问题的通用解决方案。

但这很奇怪,因为java.library.path定义得很好:

代码语言:javascript
复制
logger.info(System.getProperty("java.library.path"));

返回

代码语言:javascript
复制
Nov 10, 2011 8:08:45 AM com.gvs.tools.ui.record.video.handler.RecordHandler startRecording
INFO: C:\Program Files (x86)\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre6/bin/client;C:/Program Files (x86)/Java/jre6/bin;C:/Program Files (x86)/Java/jre6/lib/i386;C:\Program Files (x86)\Xuggle\bin;C:\Program Files (x86)\Xuggle\lib;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\JProbe 8.3\bin;C:\Program Files\TortoiseSVN\bin;D:\Work\Paul\eclipse;;.

我缺少什么来让这个应用程序的插件工作呢?此问题是由于应用程序使用其他本机库(如3D-dll )造成的吗?

下面是用来制作屏幕视频的代码:

代码语言:javascript
复制
RecordHandler.java:
    private void startRecording() {

    Logger logger = Logger.getLogger(RecordHandler.class.getName());
    logger.info(System.getProperty("java.library.path"));

    // Initialize framesQueue
    framesQueue =  new LinkedBlockingQueue<BufferedImage>();
    // Initialize the capture thread
    captureThread =  new ScreenCapturer();
    captureThread.setCaptureFramesQueue(framesQueue);
    
    // Initialize the recorder
    encoderThread = new FrameEncoder("test.mp4");
    encoderThread.setCapturedFramesQueue(framesQueue);      
    
    // Start capture
    captureThread.start();
    // wait for the Queue to be feed before encoding
    try {
        Thread.sleep(1000L);
    } catch (InterruptedException e) {
    }
    encoderThread.start();
}

ScreenCapturer.java:

代码语言:javascript
复制
    @Override
public void run() {
    // Retrieve the application main window's shell
    Display.getDefault().asyncExec(new Runnable() {
        
        @Override
        public void run() {
            appShell = Display.getCurrent().getActiveShell();
        }
    });
    
    isRunning = true;
    System.out.println("Starting Capture");
    for (numberOfFramesTaken = 0; isRunning && numberOfFramesTaken <= IVideoEncoderConfiguration.MAXIMUM_NUMBER_OF_FRAMES; numberOfFramesTaken++) {
        try {
            takeScreenShot();
            Thread.sleep(IVideoEncoderConfiguration.CAPTURE_TIME_INTERVAL_MILLIS);
        } catch (InterruptedException e) {
        }
    }
    System.out.println("Capture has ended");
    System.out.println("Number of frames taken: "
            + numberOfFramesTaken);
}

/**
 * Take a screen capture and store it in the capturedFramesQueue
 */
private void takeScreenShot() {
    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            if (appShell != null) {
                Rectangle bounds = appShell.getBounds();
                java.awt.Rectangle awtBounds =  new java.awt.Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
                final BufferedImage screenCapture =  robot.createScreenCapture(awtBounds);
                try {
                    capturedFramesQueue.put(screenCapture);
                } catch (InterruptedException e) {
                }
            }
        }
    });
}

FrameEncoder.java:

代码语言:javascript
复制
public void run() {
    isRunning = true;
    String outFile = outputdirectoryPath + outputFileName;
    // First, let's make a IMediaWriter to write the file.
    final IMediaWriter writer = ToolFactory.makeWriter(outFile);
    // Retrieve the first frame to guess video dimensions
    BufferedImage firstFrame = null;
    try {
        firstFrame = capturedFramesQueue.take();
    } catch (InterruptedException e) {
    }
    if (firstFrame == null) {
        return;
    }
    // We tell it we're going to add one video stream, with id 0,
    // at position 0, and that it will have a fixed frame rate of
    // FRAME_RATE.
    writer.addVideoStream(0, 0,
            IVideoEncoderConfiguration.FRAME_RATE,
            firstFrame.getWidth(), firstFrame.getHeight());
    
    long startTime = System.nanoTime();
    for (numberOfFramesRecorded = 0; isRunning
            && numberOfFramesRecorded <= IVideoEncoderConfiguration.MAXIMUM_NUMBER_OF_FRAMES; numberOfFramesRecorded++) {
        // Retrieve the captured frame
        try {
            final BufferedImage currentFrame = convertToType(capturedFramesQueue.take(), BufferedImage.TYPE_3BYTE_BGR);
            // encode the next frame
            writer.encodeVideo(0, currentFrame, System.nanoTime() - startTime,
                    TimeUnit.NANOSECONDS);
            // sleep, time depending of FRAME_RATE
            Thread.sleep(IVideoEncoderConfiguration.CAPTURE_TIME_INTERVAL_MILLIS);
        } catch (InterruptedException e) {
        }
    }
    // Get the remaining frame on the queue
    Collection<BufferedImage> frames = new LinkedList<BufferedImage>();
    capturedFramesQueue.drainTo(frames, IVideoEncoderConfiguration.MAXIMUM_NUMBER_OF_FRAMES - numberOfFramesRecorded);
    for (BufferedImage frame : frames) {
        BufferedImage currentFrame = convertToType(frame, BufferedImage.TYPE_3BYTE_BGR);
        writer.encodeVideo(0, currentFrame, System.nanoTime() - startTime,
                TimeUnit.NANOSECONDS);
    }
    // close the MediaWriter, write the trailer if needed
    writer.close();
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-01-21 00:27:23

我知道现在有点晚了,但问题是Xuggler要求所有的ALL都在操作系统加载路径环境中,而不仅仅是java.library.path。

这意味着所有用libavcodec.dll安装的DLL都需要在启动Java的进程的%PATH%环境变量中。

票数 2
EN

Stack Overflow用户

发布于 2013-04-06 11:14:19

原因可能是依赖jars或版本冲突不可用。

在类路径中添加以下jars对我来说很好:

-5.4.jar slf4j-api-1.6.4.jar logback-核心-1.0.jar logback-经典-1.0.jar

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8076952

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档