public static void main(String args[]) {
    try {
      QTSession.open();
      GroupDrawing frame = new GroupDrawing("QT in Java");

      frame.pack();
      frame.show();
      frame.toFront();
    } catch (Exception e) {
      e.printStackTrace();
      QTSession.close();
    }
  }
  public void init() {
    try {
      if (QTSession.isInitialized() == false) QTSession.open();
      // set up a QTComponent which will disply its content
      // at its original size of smaller and centered in the space given
      // to the QTComponent when the applet is layed out
      setLayout(new BorderLayout());
      QTFile qtf = new QTFile(getCodeBase().getFile() + getParameter("file"));
      OpenMovieFile fis = OpenMovieFile.asRead(qtf);
      mov = Movie.fromFile(fis);
      qtc = QTFactory.makeQTComponent(mov);

    } catch (QTException qtE) {
      throw new RuntimeException(qtE.getMessage());
    }
  }
Example #3
0
  public void dispose() {
    if (readyForFrames) finish();

    try {
      QTSession.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
    public void run() {

      try {

        QTSession.open();
        while (!isClosing()) {
          Thread.sleep(taskingDelay);
          sg.idleMore();
          sg.update(null);
        }

      } catch (InterruptedException ex) {

      } catch (Exception ex) {
        if (observer != null && !isClosing())
          observer.onError(QTCaptureStream.this, new CaptureException(ex));
      } finally {
        QTSession.close();
        setClosed();
      }
    }
  private void initSequenceGrabber() throws QTException {
    if (sequenceGrabberInitialized) return;
    QTSession.open();

    sg = new SequenceGrabber();

    vc = new SGVideoChannel(sg);
    // cameraImageSize = new QDRect(320, 240);
    if (overrideVideoFormat != null)
      cameraImageSize = new QDRect(overrideVideoFormat.getWidth(), overrideVideoFormat.getHeight());
    else {
      cameraImageSize = vc.getSrcVideoBounds();
      logger.info(
          "Camera image size reported as: "
              + cameraImageSize.getWidth()
              + "x"
              + cameraImageSize.getHeight());

      // this is a workaround found at
      // http://rsb.info.nih.gov/ij/plugins/download/QuickTime_Capture.java
      // and other places for the isight, which gives the wrong resolution.
      // TODO: find a better way of identifying the isight.
      Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
      if (cameraImageSize.getHeight() > screen.height - 40) // iSight camera claims to 1600x1200!
      {
        logger.warning(
            "Camera image size reported as: "
                + cameraImageSize.getWidth()
                + "x"
                + cameraImageSize.getHeight()
                + "; resizing to 640x480");
        cameraImageSize.resize(640, 480);
      }
    }
    // On PPC (big endian) we use: k32ARGBPixelFormat
    // On Intel we use: k32ABGRPixelFormat
    // fails on PPC with DepthErrInvalid: k32ABGRPixelFormat, k32BGRAPixelFormat, k32RGBAPixelFormat
    gWorld =
        new QDGraphics(
            bigEndian ? QDConstants.k32ARGBPixelFormat : QDConstants.k32ABGRPixelFormat,
            cameraImageSize); // set a specific pixel format so we can predictably convert to
                              // buffered image below.
    sg.setGWorld(gWorld, null);
    vc.setBounds(cameraImageSize);
    vc.setUsage(quicktime.std.StdQTConstants.seqGrabRecord);
    vc.setFrameRate(0);
    myCodec = quicktime.std.StdQTConstants.kComponentVideoCodecType;
    vc.setCompressorType(myCodec);
    sequenceGrabberInitialized = true;
  }
  private void disposeSequenceGrabber() throws QTException {
    if (!sequenceGrabberInitialized) return;
    try {
      if (vc != null) vc.disposeQTObject();

      if (sg != null) {
        sg.stop();
        sg.disposeQTObject();
      }

      QTSession.close();
    } finally {
      sequenceGrabberInitialized = false;
    }
  }
Example #7
0
  /**
   * Create a movie with the specified width, height, filename, frame rate, codec type and quality,
   * and key frame rate.
   */
  public MovieMaker(
      PApplet p,
      int _w,
      int _h,
      String _filename,
      int _rate,
      int _codecType,
      int _codecQuality,
      int _keyFrameRate) {
    parent = p;

    width = _w;
    height = _h;
    rate = _rate;

    try {
      QTSession.open();
    } catch (QTException e1) {
      e1.printStackTrace();
    }

    try {
      ImageDescription imgD = null;
      if (quicktime.util.EndianOrder.isNativeLittleEndian()) {
        imgD = new ImageDescription(QDConstants.k32BGRAPixelFormat);
      } else {
        imgD = new ImageDescription(QDGraphics.kDefaultPixelFormat);
      }
      imgD.setWidth(width);
      imgD.setHeight(height);
      gw = new QDGraphics(imgD, 0);

    } catch (QTException e) {
      e.printStackTrace();
    }
    codecType = _codecType;
    codecQuality = _codecQuality;
    keyFrameRate = _keyFrameRate;
    initMovie(_filename);

    parent.registerDispose(this);
  }
 public void destroy() {
   QTSession.close();
 }