用Java中的图像制作视频文件?

问题描述:

我制造了一个具有50自动延迟的机器人,然后执行此操作.

I make a robot that has an auto delay of 50 then do this.

for(int a=0;a<1000;a++;)
{
    Rectangle screenRect= new Rectangle(300,400);
    al.add(r.createScreenCapture(screenRect));
}
File outputfile = new File(output,"Test.mp4");
AWTSequenceEncoder enc = 
AWTSequenceEncoder.createSequenceEncoder(outputfile,20);
for (BufferedImage bi : al)
    enc.encodeImage(bi);
enc.finish();`

输出是我的桌面的路径.这些是我得到的错误:

output is the path to my desktop. These are the errors I have gotten:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.jcodec.containers.mp4.muxer.MP4Muxer.addTrack(MP4Muxer.java:91)
    at org.jcodec.containers.mp4.muxer.MP4Muxer.addTrack(MP4Muxer.java:87)
    at org.jcodec.containers.mp4.muxer.MP4Muxer.addVideoTrack(MP4Muxer.java:196)
    at org.jcodec.api.transcode.SinkImpl.outputVideoPacket(SinkImpl.java:69)
    at org.jcodec.api.transcode.SinkImpl.outputVideoFrame(SinkImpl.java:223)
    at org.jcodec.api.SequenceEncoder.encodeNativeFrame(SequenceEncoder.java:101)
    at org.jcodec.api.awt.AWTSequenceEncoder.encodeImage(AWTSequenceEncoder.java:49)
    at Test.main(Test.java:47)
    Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find symbol
        symbol:   class Nullable
        location: package javax.annotation
             at org.jcodec.common.Preconditions.<clinit>(Preconditions.java:17)
             ... 8 more

Uncompilable source code - cannot find symbol
        symbol:   class Nullable
        location: package javax.annotation

编译器找不到 javax.annotation.Nullable .您正在使用 Jcodec ,它依赖于您似乎未包含的 Javax.annotation API .您可以在此处找到它.

The compiler can't find javax.annotation.Nullable. You are using Jcodec, which depends on the Javax.annotation API, which you don't seem to have included. You can find it here.

但是,您应该考虑使用 Maven 构建项目,这将为您解决此类依赖性.如果隐藏了其他依赖项,我不会感到惊讶.

However, you should consider building your project with Maven, which will take care of such dependencies for you. I wouldn't be surprised if there are further dependencies hidden.