Women in Technology

Hear us Roar



Article:
  The Return of the Blue Q
Subject:   Having trouble with frame grabbing (code from another article)
Date:   2004-09-25 11:03:30
From:   invalidname
Response to: Having trouble with frame grabbing (code from another article)

The book is coming in December - working through tech review now. The grab-a-movie-frame trick with the GraphicsImporter and the 512-byte pseudo-header is spelled out with code (from the book) in a message I posted to the quicktime-java mailing list:


http://lists.apple.com/archives/quicktime-java/2004/Jul/msg00032.html


-Chris

Full Threads Newest First

Showing messages 1 through 2 of 2.

  • Having trouble with frame grabbing (code from another article)
    2005-01-23 13:26:16  johnmangum [View]

    By the way I figured out a fairly clean way to to this. Excuse the Pr.tln functions, just my way of doing System.out.println.


    static public ArrayList makeFrames(String movieFilename, int numFrames, String prepend,
    String directory) {
    ArrayList resultFiles = new ArrayList();

    try {
    QTSession.open();
    QTFile qtFile = new QTFile(movieFilename);

    OpenMovieFile movieFile = OpenMovieFile.asRead(qtFile);
    Movie movie = Movie.fromFile(movieFile);
    int duration = movie.getDuration() - movie.getTime();
    int j = 0;
    int step = (duration + numFrames*2)/numFrames;
    step = (int) (step * .95);
    Pict pict = null;
    QTFile f = null;
    for (int i = movie.getTime() + (int)(duration * .05); i < movie.getDuration(); i += step) {
    j++;

    pict = movie.getPict(i); // frame number
    Pr.tln("size: " +pict.getSize() +", i: " +i);
    Pr.tln(pict.getPictFrame());
    String fullFileName = directory +File.separator+ prepend +j +".jpeg";

    f = new QTFile(fullFileName);
    resultFiles.add(f.getName());
    GraphicsExporter graphicsExporter = new GraphicsExporter(StdQTConstants.kQTFileTypeJPEG);
    graphicsExporter.setCompressionQuality(StdQTConstants.codecNormalQuality);
    graphicsExporter.setOutputFile(f);
    graphicsExporter.setInputPicture(pict);
    graphicsExporter.doExport();

    }
    QTSession.close();

    } catch (Exception e) {
    throw (new RuntimeException(e));
    } finally {
    QTSession.close();
    }

    return resultFiles;
    }

  • Having trouble with frame grabbing (code from another article)
    2005-01-23 13:27:32  johnmangum [View]

    By the way I figured out a fairly clean way to to this. Excuse the Pr.tln functions, just my way of doing System.out.println.


    static public ArrayList makeFrames(String movieFilename, int numFrames, String prepend,
    String directory) {
    ArrayList resultFiles = new ArrayList();

    try {
    QTSession.open();
    QTFile qtFile = new QTFile(movieFilename);

    OpenMovieFile movieFile = OpenMovieFile.asRead(qtFile);
    Movie movie = Movie.fromFile(movieFile);
    int duration = movie.getDuration() - movie.getTime();
    int j = 0;
    int step = (duration + numFrames*2)/numFrames;
    step = (int) (step * .95);
    Pict pict = null;
    QTFile f = null;
    for (int i = movie.getTime() + (int)(duration * .05); i < movie.getDuration(); i += step) {
    j++;

    pict = movie.getPict(i); // frame number
    Pr.tln("size: " +pict.getSize() +", i: " +i);
    Pr.tln(pict.getPictFrame());
    String fullFileName = directory +File.separator+ prepend +j +".jpeg";

    f = new QTFile(fullFileName);
    resultFiles.add(f.getName());
    GraphicsExporter graphicsExporter = new GraphicsExporter(StdQTConstants.kQTFileTypeJPEG);
    graphicsExporter.setCompressionQuality(StdQTConstants.codecNormalQuality);
    graphicsExporter.setOutputFile(f);
    graphicsExporter.setInputPicture(pict);
    graphicsExporter.doExport();

    }
    QTSession.close();

    } catch (Exception e) {
    throw (new RuntimeException(e));
    } finally {
    QTSession.close();
    }

    return resultFiles;
    }