录制来自JFrame的视频

时间:2016-04-05 09:22:24

标签: java video jframe

我有一个可以产生长运行时输出的JFrame应用程序。我想知道我是否可以录制它并生成一个具有高帧率的视频或帧/图像,以便以后将它们转换为视频?

1 个答案:

答案 0 :(得分:0)

您可以像这样生成JFrame内容的图像:

public static void main(String[] a) throws Exception {

    final JFrame frame = new JFrame("My Frame");
    frame.getContentPane().setBackground(Color.CYAN);
    frame.setSize(400, 400);
    frame.setVisible(true);

    final BufferedImage image = new BufferedImage(frame.getWidth(),
            frame.getHeight(), BufferedImage.TYPE_INT_ARGB);
    frame.paint(image.getGraphics());
    File outputfile = new File("C:/Temp/frame.png");
    ImageIO.write(image, "png", outputfile);
}

然后使用任何可用的软件转换器来构建视频。