Package quicktime.std.movies

Examples of quicktime.std.movies.Track


      int timeScale = mov.getTimeScale();
      int begin = (int)Math.floor(start * timeScale);
      int finish = (int)Math.floor(end * timeScale);

      // 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
      {
        if (Thread.interrupted())
        {
          throw new SchemeException(new Pair(), null, null);
        } // if (Thread.interrupted())
        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))
        {
View Full Code Here


      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());
View Full Code Here

   * @param mov     Movie to get audio track from
   * @return audio  Audio track in mov
   */
  public static Track getAudioTrack(Movie mov)
  {
    Track audio = null;
    try
    {
      Movie movie = cloneMovie(mov);
      audio = movie.getIndTrackType(1, StdQTConstants.soundMediaType,
        StdQTConstants.movieTrackMediaType);
View Full Code Here

    Movie newMov = null;
    try
    {
      // make a copy of mov
      newMov = cloneMovie(mov);
      Track newAudio;

      // use addEmptyTrack to make sure it has SoundMedia characteristics
      newAudio = newMov.addEmptyTrack(audio, new DataRef(new QTHandle()));
      audio.insertSegment(newAudio, 0, audio.getDuration(),
        (int)(start * newMov.getTimeScale()));
 
View Full Code Here

    Movie newMov = null;
    try
    {
      // make a copy of mov
      newMov = cloneMovie(mov);
      Track newAudio;
      newAudio = newMov.addEmptyTrack(audio, new DataRef(new QTHandle()));

      // use addEmptyTrack to make sure it has Sound Media characteristics
      audio.insertSegment(newAudio, 0, (int) (duration
          * audio.getMovie().getTimeScale()),
 
View Full Code Here

      {
        if (Thread.interrupted())
        {
          throw new SchemeException(new Pair(), null, null);
        } // if (Thread.interrupted())
        Track video = mov.getIndTrackType(1, StdQTConstants.videoMediaType,
          StdQTConstants.movieTrackMediaType);
        Track newTrack = MovieUtils.addVideoTrack(video, temp);
        Matrix mat = new Matrix();
        QDRect from = mov.getBounds();
        QDRect to = null;
        int height = from.getHeight();
        int width = from.getWidth();
        int x = 0;
        int y = 0;
        if ((direction == 0) || (direction == 2))
        {
          height = Math.round(from.getHeight() * (float)1.0f/(i+1));
          y = j * height;
        } // if ((direction == 0) || (direction == 2))
        else if ((direction == 1) || (direction == 3))
        {
          width = Math.round(from.getWidth() * (float)1.0f/(i+1));
          x = j * width;
        } // else if ((direction == 1) || (direction == 3))
        to = new QDRect(x, y, width, height);
        mat.rect(from, to);
        newTrack.setMatrix(mat);
        newTrack.setLayer(-1);
      } // for
      result.add(temp);
    } // for
    return result;
  } // squishMovies(Vector<Movie>, int)
View Full Code Here

  {
    try
    {
      Movie video = glueMovies(squishMovies(cutMovie(mov, cycle), direction),
        cycle);
      Track sound = mov.getIndTrackType(1,
        StdQTConstants.audioMediaCharacteristic,
        StdQTConstants.movieTrackCharacteristic);
      MovieUtils.addAudioTrack(sound, video);
      return video;
    } // try
View Full Code Here

        result.add(thisCycle[l]);
      } // for
      Pict[] res = new Pict[0];

      // copy the audio into the new movie
      Track sound = mov.getIndTrackType(1,
        StdQTConstants.audioMediaCharacteristic,
        StdQTConstants.movieTrackCharacteristic);
      Movie video = MovieUtils.compileFrames(result.toArray(res),
        (int)MovieUtils.countFrames(mov, 0, 1), mov.getTimeScale());
      if (sound != null)
View Full Code Here

      int timeScale = mov.getTimeScale();
      int begin = (int)Math.floor(start * timeScale);
      int finish = (int)Math.floor(end * timeScale);
      Pict oldPic = mov.getPict(begin);
      this.cache = chopFrame(oldPic);
      Track visualTrack = mov.getIndTrackType(1,
        StdQTConstants.visualMediaCharacteristic,
        StdQTConstants.movieTrackCharacteristic);
      mov.setTime(new TimeRecord(timeScale, (int) begin));
      Boolean go = true;
      int lastTime = 0;
      while (go)
      {
        // user terminated execution
        if (Thread.interrupted())
        {
          throw new SchemeException(new Pair(), null, null);
        } // if (Thread.interrupted())

        // find the next frame
        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))
        {
View Full Code Here

      int finish = (int)Math.floor(end * timeScale);
      Pict oldPic = mov.getPict(begin);
      this.cache = chopFrame(oldPic);

      // get the first visual 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;
      while (go)
      {
        // user terminated execution
        if (Thread.interrupted())
        {
          throw new SchemeException(new Pair(), null, null);
        } // if (Thread.interrupted())

        // find next frame
        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))
        {
View Full Code Here

TOP

Related Classes of quicktime.std.movies.Track

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.