Package quicktime.io

Examples of quicktime.io.QTFile


   */
  public static String test()
  {
    // get a standard file chooser
    Movie mov = null;
    QTFile file = null;
    try
    {
      file = QTFile.standardGetFilePreview(QTFile.kStandardQTFileTypes);
      mov = Movie.fromFile(OpenMovieFile.asRead(file));
    } // try
View Full Code Here


    Movie local = null;

    // attempt to open the file
    try
    {
      QTFile file = new QTFile(path);
      local = Movie.fromFile(OpenMovieFile.asRead(file));
      this.name = file.getName();
    } // try

    // if open fails, print error to SchemeWindow
    catch (QTException qte)
    {
View Full Code Here

   * @return movie  Requested movie object
   */
  public Movie openFile()
  {
    Movie local = null;
    QTFile file = null;

    // open a file chooser
    try
    {
      file = QTFile.standardGetFilePreview(QTFile.kStandardQTFileTypes);
      local = Movie.fromFile(OpenMovieFile.asRead(file));
      this.name = file.getName();
    } // try

    // if something goes wrong, print an error to SchemeWindow
    catch (QTException qte)
    {
View Full Code Here

   * @throws Exception
   */
  public static Pict pictFromFile(File file)
  throws Exception
  {
    return ImageUtils.pictFromFile(new QTFile(file));
  } // pictFromFile(File)
View Full Code Here

   */
  public static void saveMovie(Movie mov)
  {
    try
    {
      QTFile file = new QTFile(new File("mymovie.mov"));
      int flags = StdQTConstants.createMovieFileDeleteCurFile
      | StdQTConstants.createMovieFileDontCreateResFile
      | StdQTConstants.showUserSettingsDialog;
      mov.setProgressProc();
      mov.convertToFile(file, StdQTConstants.kQTFileTypeMovie,
View Full Code Here

    {
      int random = rand.nextInt();

      // create a new empty movie and a track
      String tempFile = "Phoenix" + java.lang.Integer.toString(random) + ".mov";
      QTFile movFile = new QTFile(new File(tempFile));
      newmovie = Movie.createMovieFile(movFile, StdQTConstants.kMoviePlayer,
        StdQTConstants.createMovieFileDeleteCurFile
        | StdQTConstants.createMovieFileDontCreateResFile);
      Track videoTrack = newmovie.addTrack(WIDTH, HEIGHT, VOLUME);

      // create media for new track
      VideoMedia videoMedia = new VideoMedia(videoTrack, timeScale);

      // get a GraphicsImporter
      GraphicsImporter gi = new GraphicsImporter(
        StdQTConstants.kQTFileTypePicture);

      // create an offscreen QDGraphics / GWorld the size of the picts
      // importer will draw into this and pass to CSequence
      QDGraphics gw = new QDGraphics(new QDRect(0, 0, WIDTH, HEIGHT));

      // set importer's GWorld
      gi.setGWorld(gw, null);
      QDRect gRect = new QDRect(0, 0, WIDTH, HEIGHT);

      // add images to media
      videoMedia.beginEdits();
      int frames = pics.length;
      int rawImageSize = QTImage.getMaxCompressionSize(gw, gRect,
        gw.getPixMap().getPixelSize(), StdQTConstants.codecLosslessQuality,
        CODEC_TYPE, CodecComponent.bestFidelityCodec);
      QTHandle imageHandle = new QTHandle(rawImageSize, true);
      imageHandle.lock();
      RawEncodedImage compressed = RawEncodedImage.fromQTHandle(imageHandle);
      CSequence seq = new CSequence(gw, gRect, gw.getPixMap().getPixelSize(),
        CODEC_TYPE, CodecComponent.bestFidelityCodec,
        StdQTConstants.codecLosslessQuality,
        StdQTConstants.codecLosslessQuality,
        KEY_FRAME_RATE, null, StdQTConstants.codecFlagUpdatePrevious);
      ImageDescription imgDesc = seq.getDescription();

      // attempt to loop through all frames, scaling to fit the first frame
      for (int x = 0; x < frames; x++)
      {
        QDRect srcRect = new QDRect(0, 0, pics[x].getPictFrame().getWidthF(),
          pics[x].getPictFrame().getHeightF());

        // add 512 byte header so the grapics importer will think that it's
        // dealing with a pict file

        byte[] newPictBytes = new byte[pics[x].getSize() + 512];
        pics[x].copyToArray(0, newPictBytes, 512, newPictBytes.length - 512);
        pics[x] = new Pict(newPictBytes);

        // export the pict
        DataRef ref = new DataRef(pics[x],
          StdQTConstants.kDataRefQTFileTypeTag, "PICT");
        gi.setDataReference(ref);

        // create matrix to represent scaling of each pict
        Matrix drawMatrix = new Matrix();
        drawMatrix.rect(srcRect, gRect);
        gi.setMatrix(drawMatrix);
        gi.draw();

        // compress frame
        CompressedFrameInfo cfInfo = seq.compressFrame(gw, gRect,
          StdQTConstants.codecFlagUpdatePrevious, compressed);

        // check to see if frame is a key frame
        boolean syncSample = (cfInfo.getSimilarity() == 0);
        int flags = syncSample ? 0 : StdQTConstants.mediaSampleNotSync;

        // add compressed frame to video media
        videoMedia.addSample(imageHandle, 0, cfInfo.getDataSize(),
          timeScale / frameRate, imgDesc, 1, flags);
      } // for

      // done adding samples to the media
      videoMedia.endEdits();

      // insert media into track
      videoTrack.insertMedia(0, 0, videoMedia.getDuration(), 1);

      // save changes made into file and add to movie
      OpenMovieFile omf = OpenMovieFile.asWrite(movFile);
      newmovie.addResource(omf, StdQTConstants.movieInDataForkResID,
        movFile.getName());
      // delete file created; prevent any thread problems by terminating
      // current thread
      try
      {
        Thread.sleep(1000);
      } // try
      catch (InterruptedException ie)
      {
        // do nothing
      } // catch (InterruptedException)
      movFile.deleteOnExit();
      omf.getFile().deleteOnExit();
    } // try
    catch (QTException qte)
    {
      qte.printStackTrace();
View Full Code Here

  public static boolean saveFrame(Pict pic, String path)
  {
    boolean saved = false;
    try
    {
      QTFile file = new QTFile(path);
      pic.writeToFile(file);
      saved = true;
    } // try
    catch (QTException qte)
    {
View Full Code Here

            _imageDrawer.setRedrawing(true);

            canv.setClient(_imageDrawer, true);

            frame.pack();
            _file = new QTFile(fileName.asFile());
            _movie = Movie.createMovieFile(_file, kMoviePlayer,
                    createMovieFileDeleteCurFile
                            | createMovieFileDontCreateResFile);

            //
View Full Code Here

            _imageDrawer.setRedrawing(true);

            canv.setClient(_imageDrawer, true);

            frame.pack();
            _file = new QTFile(fileName.asFile());
            _movie = Movie.createMovieFile(_file, kMoviePlayer,
                    createMovieFileDeleteCurFile
                            | createMovieFileDontCreateResFile);

            //
View Full Code Here

        // first try a local file using the dataPath. usually this will
        // work ok, but sometimes the dataPath is inside a jar file,
        // which is less fun, so this will crap out.
        File file = new File(parent.dataPath(filename));
        if (file.exists()) {
          movie = fromDataRef(new DataRef(new QTFile(file)));
          //init(parent, movie, ifps);
          //return;
        }
      } catch (Exception e) { }  // ignored

      // read from a folder local to the current working dir
      // called "data". presumably this might be the data folder,
      // though that should be caught above, if such a folder exists.
      /*
      if (movie == null) {
        try {
          File file = new File("data", filename);
          if (file.exists()) {
            movie = fromDataRef(new DataRef(new QTFile(file)));
            init(parent, movie, ifps);
            return;
          }
        } catch (QTException e2) { }
      }
      */

      // read from a file just hanging out in the local folder.
      // this might happen when the video library is used with some
      // other application, or the person enters a full path name
      if (movie == null) {
        try {
          File file = new File(filename);
          if (file.exists()) {
            movie = fromDataRef(new DataRef(new QTFile(file)));
            //init(parent, movie, ifps);
            //return;
          }
        } catch (QTException e1) { }
      }
View Full Code Here

TOP

Related Classes of quicktime.io.QTFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.