Package quicktime.std.movies

Examples of quicktime.std.movies.Movie


    }
   
  }

   public boolean addSelectionToMovie(String mess, MakeMedia mov, boolean includeMeta) {
    Movie mc = null;
   
    mc = setSelection(); // sets the selection in the movie
    if (mc == null) {
     System.out.println("Can't create a movie for "+movieURL+" in MovieSelection.addSelectionToMovie()");
     return false;
View Full Code Here


    }
    return true;
  }

   public Movie setSelection() {
       Movie mc = null;
    if (mc == null) {
     // fetch or create a moviecontroller for the selected movie
     MediaPresenter presenter = VideoGrok.getPresenter();
     try {
      mc = presenter.getMovieFromURL(movieURL);
     } catch (Exception e) {
      e.printStackTrace();
      mc = null;
     }
    }
    if (mc == null) {
     System.out.println("Can't create a movie reference for "+movieURL+" in MovieSelection.setSelection()");
     return mc;
    }
    try {
      int sel = (int) selection.getValue();
      int dur = (int) duration.getValue();
      if (dur == 0) dur = mc.getDuration() - sel;

      mc.setSelection(sel, dur);
    } catch (Exception e) {
     System.out.println("Could not set selection "+selection.toString()+" "+duration.toString()+" in MovieSelection.setSelection()");
    }
    return mc;
   }
View Full Code Here

   * @return result  Whether or not Phoenix is functioning correctly
   */
  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
    catch (QTException qte)
    {
      qte.printStackTrace();
    } // catch (QTException)

    // retrieve a pict at time 0 (int time on mov's QT timescale) of all
    // enabled video tracks
    try
    {
      quicktime.qd.Pict pic = mov.getPict(0);
      System.out.println("width = " + pic.getPictFrame().getWidth()
        + ", height = " + pic.getPictFrame().getHeight());
      if ((pic.getPictFrame().getWidth() < 0)
          || (pic.getPictFrame().getHeight() < 0))
      {
View Full Code Here

    // if user clicked "open" from menu
    if (source == this.menuOpen)
    {
      // open a file selector, add movie to ClipsWindow, and open movie
      Movie mov = PhoenixController.movieController.openFile();
      PhoenixController.clipsController.addClip(mov,
        PhoenixController.movieController.name);
      try
      {
        PhoenixController.movieController.showMovie(mov, "preview");
View Full Code Here

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

    // open a file chooser
    try
    {
View Full Code Here

   * @param path    Path of desired file
   * @return movie  Requested movie object
   */
  public Movie openFile(String path)
  {
    Movie local = null;

    // attempt to open the file
    try
    {
      QTFile file = new QTFile(path);
View Full Code Here

   *                   true)
   * @return result  Resized mov
   */
  public static Movie resize(Movie mov, boolean aspect, int width, int height)
  {
    Movie movie = null;
    try
    {
      // create a new copy of the movie
      movie = cloneMovie(mov);
      Track video = movie.getIndTrackType(1,
        StdQTConstants.videoMediaType,
        StdQTConstants.movieTrackMediaType);
      QDDimension dim_size = video.getSize();

      // aspect ratio before resizing.
View Full Code Here

  // Published by O'Reilly, 2005
  // pp. 166~171
  public static Movie chromaKey(Movie movFore, Movie movBack, int red,
    int green, int blue)
  {
    Movie result = null;
    QDColor key = new QDColor((float)red / 255, (float)green / 255,
      (float)blue / 255);
    try
    {
      result = new Movie();

      // add front track
      Track trackFore = movFore.getIndTrackType(1,
        StdQTConstants.visualMediaCharacteristic,
        StdQTConstants.movieTrackCharacteristic);
View Full Code Here

   * @throws QTException
   */
  public static int countFrames(Movie movie, float start, float end)
  throws QTException
  {
    Movie mov = MovieUtils.cloneMovie(movie);
    int timeScale = mov.getTimeScale();
    int begin = (int)Math.floor(start * timeScale);
    int finish = (int)Math.floor(end * timeScale);
    int count = 0;

    // get the video track from mov
    Track visualTrack = mov.getIndTrackType(1,
      StdQTConstants.visualMediaCharacteristic,
      StdQTConstants.movieTrackCharacteristic);
    mov.setTime(new TimeRecord(timeScale, (int) begin));
    Boolean go = true;
    int lastTime = 0;
    do
    {
      TimeInfo ti = visualTrack.getNextInterestingTime(
        StdQTConstants.nextTimeMediaSample, mov.getTime(), 1);

      // if looped to earlier frame or finished selected section
      if ((lastTime > ti.time) || (ti.time >= finish))
      {
        go = false;
      } // if ((lastTime > ti.time) || (ti.time >= finish))
      else
      {
        lastTime = ti.time;
        mov.setTime(new TimeRecord(mov.getTimeScale(), ti.time));
        ++count;
      } // else
    } // do
    while (go);
    return count;
View Full Code Here

    // video tracks don't need volume
    int VOLUME = 0;

    // make every frame a key (self-contained) frame
    int KEY_FRAME_RATE = frameRate;
    Movie newmovie = null;
    java.util.Random rand = new java.util.Random();
    try
    {
      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
      {
View Full Code Here

TOP

Related Classes of quicktime.std.movies.Movie

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.