示例#1
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);
  }
示例#2
0
 // A simple add function to just add whatever is in the parent window
 public void addFrame() {
   // http://dev.processing.org/bugs/show_bug.cgi?id=692
   parent.flush();
   parent.loadPixels();
   addFrame(parent.pixels, parent.width, parent.height);
 }
示例#3
0
  private void initMovie(String filename) {
    try {
      String path = parent.savePath(filename);
      movFile = new QTFile(new File(path));
      movie =
          Movie.createMovieFile(
              movFile, StdQTConstants.kMoviePlayer, StdQTConstants.createMovieFileDeleteCurFile);
      int timeScale = TIME_SCALE; // 100 units per second
      videoTrack = movie.addTrack(width, height, 0);
      videoMedia = new VideoMedia(videoTrack, timeScale);
      videoMedia.beginEdits();
      bounds = new QDRect(0, 0, width, height);
      int rawImageSize =
          QTImage.getMaxCompressionSize(
              gw,
              bounds,
              gw.getPixMap().getPixelSize(),
              codecQuality,
              codecType,
              CodecComponent.anyCodec);
      imageHandle = new QTHandle(rawImageSize, true);
      imageHandle.lock();
      compressedImage = RawEncodedImage.fromQTHandle(imageHandle);
      seq =
          new CSequence(
              gw,
              bounds,
              gw.getPixMap().getPixelSize(),
              codecType,
              CodecComponent.bestFidelityCodec,
              codecQuality,
              codecQuality,
              keyFrameRate,
              null,
              0);
      imgDesc = seq.getDescription();
      readyForFrames = true;

    } catch (QTException e) {
      if (e.errorCode() == Errors.noCodecErr) {
        if (imageHandle == null) {
          // This means QTImage.getMaxCompressionSize() failed
          System.err.println(
              "The specified codec is not supported, "
                  + "please ensure that the parameters are valid, "
                  + "and in the correct order.");
        } else {
          // If it's a -8961 error, quietly do it the other way
          // (this happens when RAW is specified)
          temporalSupported = false;
          readyForFrames = true;
        }

      } else if (e.errorCode() == Errors.fBsyErr) {
        System.err.println("The movie file already exists.  " + "Please delete it first.");

      } else {
        e.printStackTrace();
      }
    }
  }