为什么我的Xuggle视频转换器无法正常工作

时间:2013-05-22 09:02:14

标签: java image video xuggler

我有这段代码:

import com.xuggle.mediatool.IMediaWriter;
import com.xuggle.mediatool.ToolFactory;
import com.xuggle.xuggler.ICodec;

public class ImageToVideo implements Runnable {

    private static Dimension dimension;
    private final IMediaWriter writer;
    long startTime;
    LoadFrame loadframe;

    public ImageToVideo(int framespersecond, LoadFrame loadframe) {
        this.loadframe = loadframe;
        writer = ToolFactory.makeWriter(Project.getInstance().getFileURLStr() + Project.getInstance().getProjectName() + ".mp4");
        dimension = Toolkit.getDefaultToolkit().getScreenSize();
        writer.addVideoStream(0, 0, ICodec.ID.CODEC_ID_MPEG4, dimension.width / 2, dimension.height / 2);
        startTime = System.nanoTime();
    }

    @Override
    public void run() {
        Project project = Project.getInstance();
        for (int index = 0; index <= project.getTimeLineImageCount(); index++) {
            loadframe.updateProgress(index/project.getTimeLineImageCount());
            ImageIcon imgtoencode = (ImageIcon)project.getNextTimeLineImage();
            BufferedImage imgtoencodebuf = (BufferedImage)imgtoencode.getImage();
            writer.encodeVideo(0, imgtoencodebuf, System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
        }
        project.setWalkIndexes();
        writer.close();
    }

}

我应该将图像列表转换为视频。但是当我尝试运行它时,我收到了这个错误:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at com.xuggle.ferry.JNIMemoryManager.<init>(JNIMemoryManager.java:861)
    at com.xuggle.ferry.JNIMemoryManager.<clinit>(JNIMemoryManager.java:860)
    at com.xuggle.mediatool.MediaWriter.<clinit>(MediaWriter.java:119)
    at com.xuggle.mediatool.ToolFactory.makeWriter(ToolFactory.java:149)
    at Operations.ImageToVideo.<init>(ImageToVideo.java:31)
    at GUI.MainScreen.actionPerformed(MainScreen.java:501)

等。我从互联网上的一个例子中得到了代码:http://examples.javacodegeeks.com/desktop-java/xuggler/create-video-from-image-frames-with-xuggler/

我是Xuggle的新手,我希望有人可以帮助我。感谢

1 个答案:

答案 0 :(得分:1)

你错过了sl4j如果没有那个

从这里下载库--> http://www.slf4j.org/download.html并将jar添加到项目库(类路径