question to JMF FrameGrabbing

hi @all,

i want to write a program which grab EVRY frame in a Stream i used the frame grabbin contol for it, an go always 1 step forward, but when i grab the frame i grabs many times the fitst frame than many times the 30 frame and so on. in the api stands following:

"If the Player or Renderer is in the Started state, the exact frame returned is not well-defined. "

I think thats my problem because the current media time goes on with the right steps.

How can i gurantee that the renderer is in the correct state, or can i

somehow else solve the problem.

I would be real thankful for your help.

[640 byte] By [helpless0815a] at [2007-10-2 22:39:24]
# 1
Hi,could nobody help me i am lealy at a dead end, pleeeeeeease ;-).
helpless0815a at 2007-7-14 1:56:43 > top of Java-index,Security,Cryptography...
# 2
If you post your source code here maybe we can find out what is wrong. Without it we can't guess...
axelinux@hotmail.coma at 2007-7-14 1:56:43 > top of Java-index,Security,Cryptography...
# 3

Hi, thanks for your reply, the source is the follow:

public class VideoToFrameSequenceConverter extends javax.swing.JPanel implements ControllerListener, java.lang.Runnable {

private Player player;

private javax.media.control.FrameGrabbingControl grabber;

private javax.media.control.FramePositioningControl posCon;

private javax.media.util.BufferToImage bti;

private javax.media.Buffer buffer;

private int framePosition = 0;

private boolean firstTime = true;

private boolean endReached = false;

private java.lang.Thread thread;

private double endTimeSeconds;

public VideoToFrameSequenceConverter(java.lang.String source) {

Manager.setHint(Manager.PLUGIN_PLAYER, new Boolean(true));

try {

player = Manager.createPlayer(new URL("file:///" + source));

}

catch (javax.media.NoPlayerException e) {

e.printStackTrace();

}

catch (java.io.IOException e) {

e.printStackTrace();

}

player.addControllerListener(this);

player.realize();

player.prefetch();

thread = new java.lang.Thread(this);

}

public void stopConversionThread() {

try {

thread.interrupt();

thread.join();

}

catch (java.lang.InterruptedException e) {

}

}

public void run() {

java.awt.image.BufferedImage picture;

while (!endReached) {

if (posCon != null && grabber != null) {

if (player.getMediaTime().getSeconds() <= endTimeSeconds) {

buffer = grabber.grabFrame();

if (buffer != null) {

bti = new javax.media.util.BufferToImage( (javax.media.format.VideoFormat) buffer.getFormat());

picture = (java.awt.image.BufferedImage) bti.createImage(buffer);

framePosition++;

java.io.File f = new java.io.File("c:/test/frame" + framePosition +".jpg");

try {

javax.imageio.ImageIO.write(picture, "jpeg", f);

}

catch (java.lang.Exception e) {

}

System.out.println("Skiped: " + posCon.skip(1));

}

}

else {

endReached = true;

stopConversionThread();

}

}

}

}

public void controllerUpdate(ControllerEvent event) {

if (event instanceof javax.media.PrefetchCompleteEvent) {

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

grabber = (javax.media.control.FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");

endTimeSeconds = player.getDuration().getSeconds();

if (firstTime) {

thread.start();

firstTime = false;

}

}

}

}

I start the process from the main program with VideoToFrameSequenceConverter p = new VideoToFrameSequenceConverter ("test.mpg");

helpless0815a at 2007-7-14 1:56:43 > top of Java-index,Security,Cryptography...
# 4
Hi @ all,could somebody look at the sorce Code, because i had not found the bug till now.thx
helpless0815a at 2007-7-14 1:56:43 > top of Java-index,Security,Cryptography...