我有这段代码:
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的新手,我希望有人可以帮助我。感谢