【问题标题】:Capurting Frames from a video file without playing it on screen从视频文件中捕获帧而不在屏幕上播放
【发布时间】: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...");
            }
        }
    }
}

我的先生已经告诉我要从任何指定的视频中捕获所有帧而不在屏幕上播放,任何人都可以建议我如何做到这一点。

【问题讨论】:

  • 您需要加载视频文件并使用可让您访问帧的解码器。看看Xuggler能不能帮到你。
  • @c.s.,是否可以不使用任何第三方 API?。
  • 另一个选项是JMF。如果您正在谈论阅读视频并自己解码,那肯定是可能的。虽然无痛,但我对此表示怀疑。所以我不推荐它

标签: java video-capture video-processing


【解决方案1】:

好吧,您可以简单地使用 OpenCV。这是一个例子。

https://www.tutorialspoint.com/opencv/opencv_using_camera.htm

您可以在 VideoCapture 类中使用任何视频代替摄像头:

VideoCapture capture = new VideoCapture(0);

代替上面那行代码,你可以使用

VideoCapture capture = new VideoCapture("/location/of/video/");

我希望这就是你要找的。​​p>

【讨论】:

    猜你喜欢
    • 2012-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 2016-05-07
    • 2023-04-09
    • 2016-02-14
    相关资源
    最近更新 更多