extracting image from a video in java

2020-07-27 02:35发布

问题:

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

回答1:

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