Package quicktime.std.movies.media

Examples of quicktime.std.movies.media.VideoMedia


  public static Track addVideoTrack(Track source, Movie target)
  throws QTException
  {
    Track targetTrack = target.newTrack(source.getSize().getWidthF(),
      source.getSize().getHeightF(), 1.0f);
    @SuppressWarnings("unused")
    VideoMedia media = new VideoMedia(targetTrack,
      source.getMedia().getTimeScale(), new DataRef(new QTHandle()));
    int duration = source.getDuration();
    source.insertSegment(targetTrack, 0, duration, 0);
    return targetTrack;
  } // addVideoTrack(Track, Movie)
View Full Code Here


        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

            int kNoVolume = 0;
            int kVidTimeScale = 600;

            _videoTrack = _movie.addTrack(_frameWidth, _frameHeight, kNoVolume);
            _videoMedia = new VideoMedia(_videoTrack, kVidTimeScale);

            _videoMedia.beginEdits();

            _videoSize = new QDRect(_frameWidth, _frameHeight);
            _gw = new QDGraphics(_videoSize);
View Full Code Here

            int kNoVolume = 0;
            int kVidTimeScale = 600;

            _videoTrack = _movie.addTrack(_frameWidth, _frameHeight, kNoVolume);
            _videoMedia = new VideoMedia(_videoTrack, kVidTimeScale);

            _videoMedia.beginEdits();

            _videoSize = new QDRect(_frameWidth, _frameHeight);
            _gw = new QDGraphics(_videoSize);
View Full Code Here

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

/* 380 */     if (this.mov == null)
/* 381 */       throw new QTAppException("Can't add a Track without movie being specified");
/* 382 */     if (this.vidTrack != null)
/* 383 */       throw new QTAppException("Can't alter movie while current movie is being recorded");
/* 384 */     this.vidTrack = this.mov.addTrack(this.gwRect.getWidth(), this.gwRect.getHeight(), 0.0F);
/* 385 */     this.vidMedia = new VideoMedia(this.vidTrack, 600);
/*     */   }
View Full Code Here

/* 274 */     int i = 0;
/* 275 */     int j = 600;
/*     */
/* 277 */     Track localTrack = paramMovie.addTrack(this.imageDescription.getWidth(), this.imageDescription.getHeight(), i);
/*     */
/* 280 */     VideoMedia localVideoMedia = new VideoMedia(localTrack, j);
/*     */
/* 282 */     localVideoMedia.beginEdits();
/* 283 */     for (int k = 0; k < size(); k++) {
/* 284 */       EncodedImage localEncodedImage = getNth(k + 1);
/* 285 */       QTHandle localQTHandle = null;
/* 286 */       if ((localEncodedImage instanceof RawEncodedImage)) {
/* 287 */         localQTHandle = new QTHandle((RawEncodedImage)localEncodedImage, 0, localEncodedImage.getSize());
/*     */       }
/*     */       else
/*     */       {
/*     */         Object localObject;
/* 288 */         if ((localEncodedImage instanceof IntEncodedImage)) {
/* 289 */           localQTHandle = new QTHandle(localEncodedImage.getSize(), false);
/* 290 */           localObject = ((IntEncodedImage)localEncodedImage).getInts();
/* 291 */           localQTHandle.copyFromArray(0, (int[])localObject, 0, localObject.length);
/*     */         } else {
/* 293 */           localQTHandle = new QTHandle(localEncodedImage.getSize(), false);
/* 294 */           localObject = ((ByteEncodedImage)localEncodedImage).getBytes();
/* 295 */           localQTHandle.copyFromArray(0, (byte[])localObject, 0, localObject.length);
/*     */         }
/*     */       }
/* 297 */       localVideoMedia.addSample(localQTHandle, 0, localQTHandle.getSize(), (int)(600.0F / paramFloat), this.imageDescription, 1, 0);
/*     */
/* 304 */       if (k % 5 == 0)
/* 305 */         QTUtils.reclaimMemory();
/*     */     }
/* 307 */     localVideoMedia.endEdits();
/*     */
/* 309 */     k = 0;
/* 310 */     int m = 0;
/* 311 */     int n = 1;
/* 312 */     localTrack.insertMedia(k, m, localVideoMedia.getDuration(), n);
/* 313 */     QTUtils.reclaimMemory();
/*     */   }
View Full Code Here

TOP

Related Classes of quicktime.std.movies.media.VideoMedia

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.