我试图使用 Jcodec 将一组图像转换为视频,在 youtube 上看到一个运行正常的视频。我做了他们展示的一切。但是代码不起作用。请帮忙。我正在发布视频、我的代码和错误的链接。
视频链接:https ://www.youtube.com/watch?v=NYhnqE3E4CI
爪哇代码:
package imagetovideoencoder;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.jcodec.api.awt.AWTSequenceEncoder;
import org.jcodec.api.SequenceEncoder;
import org.jcodec.common.io.NIOUtils;
import org.jcodec.common.io.SeekableByteChannel;
import org.jcodec.scale.AWTUtil;
import org.jcodec.common.*;
/**
*
* @author dell
*/
public class ImagetoVideoEncoder {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
AWTSequenceEncoder enc = AWTSequenceEncoder.createSequenceEncoder(new File("C:\\Users\\dell\\Desktop\\Downloads from seenium\\test.mp4"));
enc.getEncoder().setKeyInterval(25);
int framestoEncode = 100;
for(int i=1;i<=framestoEncode/2;++i)
{
BufferedImage image = ImageIO.read(new File("C:/Users/dell/Desktop/Downloads from seenium/0f1f4905877e9a5e92b069c966059cce.jpg"));
enc.encodeImage(image);
}
for(int i=1;i<=framestoEncode/2;++i)
{
BufferedImage image = ImageIO.read(new File("C:/Users/dell/Desktop/Downloads from seenium/54cae4238a5cf_-_american-muscle-facts-05-0312-xln.jpg"));
enc.encodeImage(image);
}
enc.finish();
}
}
错误:运行:
线程“主”java.lang.NoSuchMethodError 中的异常:org.jcodec.api.SequenceEncoder.(Lorg/jcodec/common/io/SeekableByteChannel;)V at org.jcodec.api.awt.AWTSequenceEncoder.(AWTSequenceEncoder.java:27 ) 在 org.jcodec.api.awt.AWTSequenceEncoder.createSequenceEncoder(AWTSequenceEncoder.java:23) 在 imagetovideoencoder.ImagetoVideoEncoder.main(ImagetoVideoEncoder.java:30) C:\Users\dell\AppData\Local\NetBeans\Cache\8.2\ executor-snippets\run.xml:53:Java 返回:1 BUILD FAILED(总时间:9 秒)