O
Oracle3001
Hi All,
I have copied the following code straight out of a text book, but it doesn't
seem to compile and I have been banging my head against a brick wall trying
to see why not for ages. I am a newbie to JMF, so I'm sure this is something
really stupid. This program is designed to grab a single frame, and I would
be extremely grateful for any help,
Cheers,
Adam
import java.awt.*;
import javax.media.*;
import java.awt.Image;
import javax.media.control.TrackControl;
import javax.media.Format;
import javax.media.format.*;
import javax.media.util.BufferToImage;
public class FrameGrab {
public static void main (String[] args) {
int desiredFrame = 500 ;
String url = "file://c:\\1a.avi" ;
//If the incorrect parameters were given
//display the correct usage of the function
//Create a media locator
//MediaLocator ml;
//if ((ml = new MediaLocator(url)) == null)
//{
// System.err.println("Cannot build media locator from: " + url);
// System.exit(0);
//}
Player player = Manager.createRealizedPlayer(new MediaLocator(url)) ;
FramePositioningControl positioner =
player.getControl("javax.media.control.FramePosiitioningControl") ;
if (positioner == null)
return ;
FrameGrabbingControl grabber =
Player.getControl("javax.media.control.FrameGrabbingControl") ;
if (grabber == null)
return ;
player.prefetch() ;
positioner.seek(desiredFrame) ;
Buffer inTheBuff = grabber.grabFrame() ;
Format videoFormat = inTheBuff.getFormat() ;
BufferToImage converter = new BufferToImage(videoFormat) ;
Image captured = converter.createImage(inTheBuff) ;
}
}
I have copied the following code straight out of a text book, but it doesn't
seem to compile and I have been banging my head against a brick wall trying
to see why not for ages. I am a newbie to JMF, so I'm sure this is something
really stupid. This program is designed to grab a single frame, and I would
be extremely grateful for any help,
Cheers,
Adam
import java.awt.*;
import javax.media.*;
import java.awt.Image;
import javax.media.control.TrackControl;
import javax.media.Format;
import javax.media.format.*;
import javax.media.util.BufferToImage;
public class FrameGrab {
public static void main (String[] args) {
int desiredFrame = 500 ;
String url = "file://c:\\1a.avi" ;
//If the incorrect parameters were given
//display the correct usage of the function
//Create a media locator
//MediaLocator ml;
//if ((ml = new MediaLocator(url)) == null)
//{
// System.err.println("Cannot build media locator from: " + url);
// System.exit(0);
//}
Player player = Manager.createRealizedPlayer(new MediaLocator(url)) ;
FramePositioningControl positioner =
player.getControl("javax.media.control.FramePosiitioningControl") ;
if (positioner == null)
return ;
FrameGrabbingControl grabber =
Player.getControl("javax.media.control.FrameGrabbingControl") ;
if (grabber == null)
return ;
player.prefetch() ;
positioner.seek(desiredFrame) ;
Buffer inTheBuff = grabber.grabFrame() ;
Format videoFormat = inTheBuff.getFormat() ;
BufferToImage converter = new BufferToImage(videoFormat) ;
Image captured = converter.createImage(inTheBuff) ;
}
}