The Return of the Blue Q
Subject:   Having trouble with frame grabbing (code from another article)
Date:   2004-07-21 09:02:10
From:   johnmangum

I was trying out the code grabbing a frame from a movie in your article here.

But I'm having trouble getting a good jpeg file from a movie. Here's the code:;
QTFile qtFile = new QTFile("/Users/josh/kelley20.mp4");

OpenMovieFile movieFile = OpenMovieFile.asRead(qtFile);
Movie movie = Movie.fromFile(movieFile);
int j = 0;
int step = (movie.getDuration() - movie.getTime())/5;
for (int i = movie.getTime(); i < movie.getDuration(); i += step) {
Pict pict = movie.getPict(i); // frame number
File f = new File("/Users/josh/quicktime/test" + j +".jpeg");


It almost works. There is a file saved and I can open it in safari and it's the right picture. Unfortunately it won't open in camino ("this jpeg contains errors") or preview. It's not really a jpeg though. Graphics Converter says its file format is "QuickTime Importer (QuickDraw)".

Any idea how i can convert this into a jpeg? I've tried using GraphicsImporter,on the file like this:

GraphicsImporter gi = new GraphicsImporter(qtFile); // get a cantFindHandler error here
GraphicsImporterDrawer myDrawer = new GraphicsImporterDrawer
QTImageProducer qtProducer = new QTImageProducer (myDrawer,
Image image = Toolkit.getDefaultToolkit().createImage(qtProducer);

but I get the "Unsupported on Mac OS X and Java 1.4 and higher" error on the GraphicsImporterDrawer line. I'm using 10.2, could that be a problem? (I think i've updated quicktime java properly).

Could i use ibm's toolkit for this?

Thanks for your help and great articles, J.

1 to 1 of 1
1 to 1 of 1