Can not acces frame grabber
I am attempting to read an MPEG video and to grab each individual frame so that I can used pixel data within my program.
I can create a player/processor for the video. I get the format control, the frame positiong control, butNOT the frame grabbing control.
Why can I not access the frame grabbing control. How do I gain access to this control. Help...
My current source coude looks like the following:
package TestIt;
import java.io.IOException;
import java.awt.*;
import java.net.URL;
import javax.media.*;
import javax.media.control.*;
import javax.media.format.*;
import javax.media.protocol.*;
import javax.media.rtp.*;
publicclass TestItimplements ControllerListener
{
public TestIt()
{
this.processor =null;
}
publicvoid run()
{
// Define data source location
String dataLocation ="file:///D:/VideoData/clip_8.mpg";
// Create media locator
MediaLocator mediaLocator =new MediaLocator(dataLocation);
if(mediaLocator ==null)
{
System.out.println("Did not create media locator");
System.exit(0);
}
// Create data source
DataSource dataSource =null;
try
{
dataSource = Manager.createDataSource(mediaLocator);
}
catch(Exception exception)
{
System.out.println("Cannot create data source: " +
exception.getMessage());
System.exit(0);
}
// Data source characteristics
if(dataSourceinstanceof PullBufferDataSource)
{
System.out.println("Data Source Type: PullBufferDataSource");
}
elseif(dataSourceinstanceof PullDataSource)
{
System.out.println("Data Source Type: PullDataSource");
}
elseif(dataSourceinstanceof PushBufferDataSource)
{
System.out.println("Data Source Type: PushBufferDataSource");
}
elseif(dataSourceinstanceof PushDataSource)
{
System.out.println("Data Source Type: PushDataSource");
}
System.out.println("Content Type: " + dataSource.getContentType());
// Create a playert/processor
try
{
this.processor = Manager.createProcessor(dataSource);
}
catch(Exception exception)
{
System.out.println("Cannot create player/processor: " +
exception.getMessage());
}
this.processor.addControllerListener(this);
// Put player/processor in configured state
this.processor.configure();
// Put player/processor in realize state
this.processor.realize();
}
publicvoid controllerUpdate(ControllerEvent theEvent)
{
System.out.println("Received: Controller Event: " + theEvent.toString());
if(theEventinstanceof TransitionEvent)
{
System.out.println("Type: TransitionEvent");
if(theEventinstanceof ConfigureCompleteEvent)
{
System.out.println("Sub-Type: ConfigureCompleteEvent");
}
elseif(theEventinstanceof RealizeCompleteEvent)
{
System.out.println("Sub-Type: RealizeCompleteEvent");
// Some Player characteristic
System.out.println("Duration: " +
this.processor.getDuration().getSeconds());
// Get format control
this.formatControl = (FormatControl) this.processor.getControl(
"javax.media.control.FormatControl");
if(this.formatControl ==null)
{
System.out.println("Cannot get Format Control");
}
Format format = this.formatControl.getFormat();
System.out.println("Encoding: " + format.getEncoding());
if(formatinstanceof VideoFormat)
{
VideoFormat videoFormat = (VideoFormat) format;
System.out.println("Frame Rate: " +
videoFormat.getFrameRate());
System.out.println("Maximum Data Length: " +
videoFormat.getMaxDataLength());
Dimension dimension = videoFormat.getSize();
System.out.println("Width: " + dimension.getWidth());
System.out.println("Height: " + dimension.getHeight());
}
// Get frame positioning control
this.framePositioningControl =
(FramePositioningControl) this.processor.getControl(
"javax.media.control.FramePositioningControl");
if(this.framePositioningControl ==null)
{
System.out.println("Cannot get Frame Positioning Control");
}
// Get frame grabbingr control
this.frameGrabbingControl =
(FrameGrabbingControl) this.processor.getControl(
"javax.media.control.FrameGrabbingControl");
if(this.frameGrabbingControl ==null)
{
System.out.println("Cannot get Frame Grabbing Control");
}
}
}
}
// Attributes
Processor processor;
FormatControl formatControl;
FramePositioningControl framePositioningControl;
FrameGrabbingControl frameGrabbingControl;
publicstaticvoid main(String[] thArgs)
{
TestIt testIt =new TestIt();
testIt.run();
}
}

