Frame Grab Prob in JMF

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) ;

}

}
 
S

Skippy

FramePositioningControl positioner =
player.getControl("javax.media.control.FramePosiitioningControl") ;

"Posiitioning" ???

When you debug your code, try to print stuff to the console to see what's
happening:

~~~ change this code:

if (positioner == null)
return ;

~~~ for example to:

if (positioner == null)
{
System.out.println("positioner == null");

return ;
}

good luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,592
Members
45,103
Latest member
VinaykumarnNevatia
Top