extracting image from a video in java

2020-07-27 02:32发布

i want to know how can i extract images from a video using JMF.

1条回答
干净又极端
2楼-- · 2020-07-27 03:07
Player player = Manager.createRealizedPlayer(cdi.getLocator());
player.start();
FrameGrabbingControl frameGrabber = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");


//////////////////////////////

private Image grab() {
Buffer buf = frameGrabber.grabFrame();
// Convert frame to an buffered image so it can be processed and saved
Image img = (new BufferToImage((VideoFormat) buf.getFormat()).createImage(buf));
    return img;
}

for more info see complete example: http://www.comp.rgu.ac.uk/staff/fh/CM4062/mis/jmf/FrameGrab.html

查看更多
登录 后发表回答