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

时间:2018-01-18 14:27:26

标签: java jcodec

我制造了一个自动延迟为50的机器人,然后这样做。

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();`

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

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

1 个答案:

答案 0 :(得分:1)

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

编译器无法找到 javax.annotation.Nullable 。您正在使用 Jcodec ,这取决于您似乎没有包含的 Javax.annotation API 。你可以找到它here

但是,您应该考虑使用Maven构建项目,这将为您处理此类依赖项。如果隐藏了更多依赖项,我不会感到惊讶。