Capurting Frames from a video file without playing it on screen

让人想犯罪 __ 提交于 2019-12-11 07:35:48

问题


I am a beginner in java programming language, Recently I have got a work to capture frames from a video file, I have also developed a program that does so, but it does that when the video is played on screen with the help of any player.

I have developed following program to do so.

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...");
            }
        }
    }
}

My sir has told to capture all frames from any specified videos without playing it on screen, Can anyone please suggest me that how can I do so.

来源:https://stackoverflow.com/questions/18073073/capurting-frames-from-a-video-file-without-playing-it-on-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!