Save a Media Player Video Frame as JPEG image file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   VICTOR_DIAZ
Posted On:   Tuesday, May 28, 2002 12:11 AM

Can i Save a Video Frame from a captured video viewed in the Media Player, as a JPEG file?

Re: Save a Media Player Video Frame as JPEG image file

Posted By:   deepak_uzagare  
Posted On:   Monday, June 3, 2002 04:36 AM

Yes that is possible. The following code works for .mov file.Here fpc is frame positioning object and fgc is frame grabbing object.

import sun.awt.image.codec.JPEGImageEncoderImpl;
------
--------
int dest = fpc.skip(1);
//p is player
Component c2=p.getVisualComponent();
Canvas c1=(Canvas)c2;
Dimension size=c1.getSize();
String filename="Image1.jpg ";
int frameRate=8;
try
{
Buffer buf=fgc.grabFrame();
Format f1=buf.getFormat();
BufferToImage btoi=new BufferToImage((VideoFormat)f1);
BufferedImage image=(BufferedImage)btoi.createImage(buf);

Graphics2D g2 = image.createGraphics();
c1.paint(g2);
try{
OutputStream out = new FileOutputStream(filename);
JPEGImageEncoderImpl j = new JPEGImageEncoderImpl(out);
j.encode(image);
out.close();
//Image code found on jguru site
}catch (Exception e) {
e.printStackTrace();
}

} catch (Exception e)
{
System.out.println("Error :"+e);
}
About | Sitemap | Contact