i want to get the frames of the video file. file type is .avi. how to do it?
i want to get the frames of the video file. file type is .avi. how to do it?
Try to play the video file using player, get Video Control from it and use getSnapshot() method to capture frames.
thanks,
~Amitabh
thanks im2amit,
but i dont want to use snapshot(). anyone can suggest any other way?
If you dont want to use getSnapshot() then a more complex way will be to exlpore and find (pure java) decoder for .avi and fetch the frames from the actual bytes read from the avi file and create Image for each frame.
thanks,
~Amitabh
I tried to use getSnapshot(). The code is as below:
playerVideo = Manager.createPlayer(PATH);
playerVideo.realize();
control = (VideoControl)playerVideo.getControl("VideoControl");
playerVideo.start();
raw = control.getSnapshot("encoding=bmp");
where PATH is string of location where the video file is stored. the last line of the code tries to get the frame of the video. However, there's error when the last line is executed. Im not sure what's the error.
Anyone can tell me did i code the coding for getting video frame right?
Thanks
Put a try catch and see what exception is thrown, try putting a small sleep b4 catpuring the frame and try default encoding.
You VC is not visible:
try
thanks,PHP Code:javax.microedition.lcdui.Canvas canvas;
:
try {
Player p = Manager.createPlayer("http://abc.mpg");
p.realize();
VideoControl vc;
if ((vc = (VideoControl)p.getControl("VideoControl")) != null)
vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, canvas));
vc.setVisible(true);
p.start();
// sleep for sometime
raw = vc.getSnapshot(null); // if null is give it defaults to PNG
} catch (MediaException pe) {
} catch (IOException ioe) {
}
~Amitabh