【发布时间】:2013-08-06 06:27:52
【问题描述】:
我是java编程语言的初学者,最近我有一个从视频文件中捕获帧的工作,我也开发了一个程序,但是它在帮助下在屏幕上播放视频时会这样做任何玩家的。
我为此开发了以下程序。
public class Beginning implements Runnable {
private Thread thread;
private static long counter = 0;
private final int FRAME_CAPTURE_RATE = 124;
private Robot robot;
public Beginning() throws Exception {
robot = new Robot();
thread = new Thread(this);
thread.start();
}
public static void main(String[] args) throws Exception {
Beginning beginning = new Beginning();
}
public void run() {
for (;;) {
try {
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage bufferedImage = robot.createScreenCapture(screenRect);
ImageIO.write(bufferedImage, "png", new File("D:\\CapturedFrame\\toolImage" + counter + ".png"));
counter++;
thread.sleep(FRAME_CAPTURE_RATE);
} catch (Exception e) {
System.err.println("Something fishy is going on...");
}
}
}
}
我的先生已经告诉我要从任何指定的视频中捕获所有帧而不在屏幕上播放,任何人都可以建议我如何做到这一点。
【问题讨论】:
标签: java video-capture video-processing