RuntimeException:不允许操作,无法编写预告片。使用IMediaWriter时

时间:2014-03-22 15:29:39

标签: java xuggle

使用Xuggle中的IMediaWriter.close();时出错 相关代码Main Class

 protected IMediaWriter WRITER = ToolFactory.makeWriter(OUTPUT_FILE);
 protected static final String OUTPUT_FILE = "C:/Users/Ryan.D/Desktop/fileTest.mp4";
 protected void stopThreads() {
    textField.setBackground(Color.RED);
    capture = false;
    try {
        thread.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    WRITER.addVideoStream(0, 0, ICodec.ID.CODEC_ID_MPEG4, SCREEN_BOUNDS.width / 2, SCREEN_BOUNDS.height / 2);
    long startTime = System.nanoTime();
    for (int index = 0; index < (FRAME_TIME * images.size()) * FRAME_RATE; index++) {
        BufferedImage converted = convert(images.get(index), BufferedImage.TYPE_3BYTE_BGR);
        WRITER.encodeVideo(0, converted, System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
        try {
            Thread.sleep((long) (1000 / FRAME_RATE));
        } catch (InterruptedException e) {
            // e.printStackTrace();
        }
    }
    WRITER.flush();
    WRITER.close();
}

Error

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: error Operation not permitted, failed to write trailer to C:/Users/Ryan.D/Desktop/fileTest.mp4

我不确定为什么会发生这种情况,我一直在寻找解决方案,但大多数其他解决方案与音频有关,而我的只是视频。

感谢
莱恩。

0 个答案:

没有答案