Package quicktime.std.movies

Examples of quicktime.std.movies.Track


    boolean hasAudio = false;
    boolean hasVideo = false;
   
    for (int i = 1; i <= m.getTrackCount(); ++i)
    {
      final Track track = m.getTrack(i);
      final Media media = track.getMedia();
      final MediaHandler mediaHandler = media.getHandler();
      // MediaHandler can be instanceof both AudioMediaHandler and VisualMediaHandler, for example MPEGMediaHandler.
      if (mediaHandler instanceof AudioMediaHandler)
      {
        hasAudio = true;
View Full Code Here


  {
    TimeInfo time = null;
    try
    {
      // get the video track from the movie
      Track visualTrack = mov.getIndTrackType(1,
        StdQTConstants.visualMediaCharacteristic,
        StdQTConstants.movieTrackCharacteristic);

      // if no visual track, make something up to avoid exceptions
      if (visualTrack == null)
      {
        return 10;
      } // if (visualTrack == null)
      mov.setTime(new TimeRecord(mov.getTimeScale(), 0));

      // get the distance to the next interesting time
      time = visualTrack.getNextInterestingTime(
        StdQTConstants.nextTimeMediaSample, mov.getTime(), 1);
    } // try
    catch (QTException qte)
    {
      qte.printStackTrace();
View Full Code Here

   * @throws QTException
   */
  public static Track addAudioTrack(Track source, Movie target)
  throws QTException
  {
    Track targetTrack = target.newTrack(0f, 0f, 20);
    @SuppressWarnings("unused")
    SoundMedia media = new SoundMedia(targetTrack,
      source.getMedia().getTimeScale(), new DataRef(new QTHandle()));
    source.insertSegment(targetTrack, 0, source.getDuration(), 0);
    return targetTrack;
View Full Code Here

    temp = null;
    tempF = null;
    QDRect textBox = new QDRect(0, 0, TEXT_TRACK_WIDTH, TEXT_TRACK_HEIGHT);

    // add text track
    Track textTrack;
    try
    {
      textTrack = movie.addTrack(TEXT_TRACK_WIDTH, TEXT_TRACK_HEIGHT, 0);
      Media textMedia = new TextMedia(textTrack, movie.getTimeScale());
      TextMediaHandler handler = (TextMediaHandler)textMedia.getHandler();
      textMedia.beginEdits();
      byte[] msgBytes = text.getBytes();
      QTPointer msgPoint = new QTPointer(msgBytes);
      handler.addTextSample(msgPoint, QDFont.getFNum(fontName), fontSize, style,
        new QDColor(fgColor[0] / 255f, fgColor[1] / 255f, fgColor[2] / 255f),
        new QDColor(bgColor[0] / 255f, bgColor[1] / 255f, bgColor[2] / 255f),
        QDConstants.teJustLeft, textBox, dfFlag, QDFont.getFNum(fontName), 0, 0,
        QDColor.white, Math.round(duration * movie.getTimeScale()));
      textMedia.endEdits();
      textTrack.insertMedia(Math.round(start * movie.getTimeScale()), 0,
        textMedia.getDuration(), 1);

      // position the text track to (x, y)
      Matrix mat = new Matrix();
      mat.rect(new QDRect(0, 0, TEXT_TRACK_WIDTH, TEXT_TRACK_HEIGHT),
        new QDRect(x, y, TEXT_TRACK_WIDTH, TEXT_TRACK_HEIGHT));
      textTrack.setMatrix(mat);
    } // try
    catch (Exception e)
    {
      e.printStackTrace();
    } // catch (Exception)
View Full Code Here

   * @throws QTException
   */
  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();
View Full Code Here

    // first record at 0 hrs, 0 min, 0 sec, 0 frames
    TimeCodeTime tcTime = new TimeCodeTime (0, 0, 0, 0);

    // create time code track and media
    Track tcTrack = movie.addTrack (width, height, 0);
    TimeCodeMedia tcMedia = new TimeCodeMedia (tcTrack, timescale);
    TimeCoder timeCoder = tcMedia.getTimeCodeHandler();

    int style = 0;
    if (fontOptions.equalsIgnoreCase("plain"))
    {
      style = QDConstants.normal;
    } // if (fontOptions.equalsIgnoreCase("plain"))
    else if (fontOptions.equalsIgnoreCase("bold"))
    {
      style = QDConstants.bold;
    } // else if (fontOptions.equalsIgnoreCase("bold"))
    else if (fontOptions.equalsIgnoreCase("italic"))
    {
      style = QDConstants.italic;
    } // else if (fontOptions.equalsIgnoreCase("italic"))
    else if (fontOptions.equalsIgnoreCase("bolditalic"))
    {
      style = QDConstants.bold | QDConstants.italic;
    } // else if (fontOptions.equalsIgnoreCase("bolditalic"))
    else if (fontOptions.equalsIgnoreCase("underline"))
    {
      style = QDConstants.underlined;
    } // else if (fontOptions.equalsIgnoreCase("underline"))
    else if (fontOptions.equalsIgnoreCase("boldunderline"))
    {
      style = QDConstants.underlined | QDConstants.bold;
    } // else if (fontOptions.equalsIgnoreCase("boldunderline"))
    else if (fontOptions.equalsIgnoreCase("italicunderline"))
    {
      style = QDConstants.underlined | QDConstants.italic;
    } // else if (fontOptions.equalsIgnoreCase("italicunderline"))
    else if (fontOptions.equalsIgnoreCase("bolditalicunderline"))
    {
      style = QDConstants.underlined| QDConstants.italic | QDConstants.bold;
    } // else if (fontOptions.equalsIgnoreCase("bolditalicunderline"))

    // turn on time code display, set colors
    timeCoder.setFlags(timeCoder.getFlags() | StdQTConstants.tcdfShowTimeCode,
      StdQTConstants.tcdfShowTimeCode);
    TCTextOptions tcTextOptions = timeCoder.getDisplayOptions();
    tcTextOptions.setTXSize(fontSize);
    tcTextOptions.setTXFace(style);
    tcTextOptions.setTXFont(QDFont.getFNum(fontName));
    tcTextOptions.setForeColor(new QDColor(fgColor[0] / 255f, fgColor[1] / 255f,
      fgColor[2] / 255f));

    // if transparency is indicated, set background color to a special value
    if (bgColor[0] == -1)
    {
      tcTextOptions.setBackColor(new QDColor(0.1f, 0.7f, 0.43f));
    } // if (bgColor[0] == -1)
    else
    {
      tcTextOptions.setBackColor(new QDColor(bgColor[0] / 255f,
        bgColor[1] / 255f, bgColor[2] / 255f));
    } // else
    timeCoder.setDisplayOptions(tcTextOptions);

    // set up a sample as a 4-byte array in a QTHandle
    int frameNumber = timeCoder.toFrameNumber(tcTime, tcDef);
    int frameNums[] = new int[1];

    // BOOK ERRATA: this is buggy on Windows for time codes other
    // than 00:00:00;00.  You need to adjust for endianness, as
    // seen in the revised (uncommented) line.
    // frameNums[0] = frameNumber;
    frameNums[0] = EndianOrder.flipNativeToBigEndian32(frameNumber);
    QTHandle frameNumHandle = new QTHandle (4, false);
    frameNumHandle.copyFromArray(0, frameNums, 0, 1);

    // create a time code description (sample to be added)
    TimeCodeDescription tcDesc = new TimeCodeDescription();
    tcDesc.setTimeCodeDef (tcDef);

    // add the sample to the TimeCodeMedia
    tcMedia.beginEdits();
    tcMedia.addSample(frameNumHandle, 0, frameNumHandle.getSize(),
      movie.getDuration(), tcDesc, 1, 0);
    tcMedia.endEdits();

    // insert media into track
    tcTrack.insertMedia(0, 0, tcMedia.getDuration(), 1);

    // set a transparent-background GrahpicsMode
    QDRect moveFrom = new QDRect(0, 0, width, height);
    QDRect moveTo = new QDRect(x, y, width, height);
    Matrix matrix = new Matrix();
    matrix.rect(moveFrom, moveTo);
    tcTrack.setMatrix (matrix);

    // if transparency is indicated, make the special value the transparent
    // color
    if (bgColor[0] == -1)
    {
View Full Code Here

      // insert the movies to new movie files, in order to resize without
      // affecting originals
      mov1.insertSegment(movie1, 0, mov1.getDuration(), 0);
      mov2.insertSegment(movie2, 0, mov2.getDuration(), 0);
      Track track1 = movie1.getIndTrackType(1,
        StdQTConstants.videoMediaType,
        StdQTConstants.movieTrackMediaType);
      Track track2 = movie2.getIndTrackType(1,
        StdQTConstants.videoMediaType,
        StdQTConstants.movieTrackMediaType);
      Matrix matrix1 = track1.getMatrix();
      Matrix matrix2 = track2.getMatrix();

      // translate tracks based on size
      if (box1.equals(box2))
      {
        // do nothing - no resizing needed
      } // if (box1.equals(box2))
      else if ((height1 >= height2) && (width1 >= width2))
      {
        c = (width1 - width2) / 2;
        d = (height1 - height2) / 2;
      } // else if ((height1 >= height2) && (width1 >= width2))
      else if ((height2 >= height1) && (width2 >= width1))
      {
        a = (width2 - width1) / 2;
        b = (height2 - height1) / 2;
      } // else if ((height2 >= height1) && (width2 >= width1))
      else if ((height1 >= height2) && (width2 >= width1))
      {
        a = (width2 - width1) / 2;
        d = (height1 - height2) / 2;
      } // else if ((height1 >= height2) && (width2 >= width1))
      else if ((height2 >= height1) && (width1 >= width2))
      {
        b = (height2 - height1) / 2;
        c = (width1 - width2) / 2;
      } // else if ((height2 >= height1) && (width1 >= width2))

      // modify matrices based on changes made in the if-clause above
      matrix1.translate(a, b);
      matrix2.translate(c, d);

      // set tracks to changed matrices
      track1.setMatrix(matrix1);
      track2.setMatrix(matrix2);

      // add the two movies with translated video tracks to the returned
      // composite
      movie2.insertSegment(composite, 0, movie2.getDuration(), 0);
      movie1.insertSegment(composite, 0, movie1.getDuration(), 0);
View Full Code Here

    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.
      float originalaspect = (dim_size.getWidthF() / dim_size.getHeightF());

      //  aspect with new dimensions
      float changedaspect = ((float) width / (float) height);

      // scaling factor to adjust aspect ratios
      float scale = changedaspect * (1 / originalaspect);

      // get track matrix to preserve other scaling changes
      Matrix stretch = video.getMatrix();
      QDRect oldsize = new QDRect(0, 0, dim_size.getWidthF(),
        dim_size.getHeightF());
      QDRect newsize;

      // determine whether the aspect ratio needs to be checked/maintained
      if (aspect)
      {
        if (originalaspect != changedaspect)
        {
          height = (int) (height * scale);
        } // if (originalaspect != changedaspect)
      } // if (aspect)
      newsize = new QDRect(0, 0, width, height);
      stretch.map(oldsize, newsize);
      video.setMatrix(stretch);
    } // try
    catch (QTException qte)
    {
      qte.printStackTrace();
    } // catch (QTException)
View Full Code Here

    try
    {
      result = new Movie();

      // add front track
      Track trackFore = movFore.getIndTrackType(1,
        StdQTConstants.visualMediaCharacteristic,
        StdQTConstants.movieTrackCharacteristic);
      trackFore = MovieUtils.addVideoTrack(trackFore, result);

      // add back track
      Track trackBack = movBack.getIndTrackType(1,
        StdQTConstants.visualMediaCharacteristic,
        StdQTConstants.movieTrackCharacteristic);
      trackBack = MovieUtils.addVideoTrack(trackBack, result);

      // make sure both tracks have their actual size
      Matrix matrix1 = new Matrix();
      QDRect from1 = new QDRect(0, 0, trackFore.getSize().getWidth(),
        trackFore.getSize().getHeight());
      QDRect to1 = new QDRect(0, 0,
        movFore.getDisplayBoundsRgn().getBounds().getWidth(),
        movFore.getDisplayBoundsRgn().getBounds().getHeight());
      matrix1.map(from1, to1);
      Matrix matrix2 = new Matrix();
      QDRect from2 = new QDRect(0, 0, trackBack.getSize().getWidth(),
        trackBack.getSize().getHeight());
      QDRect to2 = new QDRect(0, 0,
        movBack.getDisplayBoundsRgn().getBounds().getWidth(),
        movBack.getDisplayBoundsRgn().getBounds().getHeight());
      matrix2.map(from2, to2);

      GraphicsMode graph = new GraphicsMode(QDConstants.transparent, key);

      // make pixels with key color transparent, so back movie shows through
      VisualMediaHandler handlerFore =
        (VisualMediaHandler)trackFore.getMedia().getHandler();
      handlerFore.setGraphicsMode(graph);
      trackBack.setMatrix(matrix2);
      trackFore.setMatrix(matrix1);
      trackFore.setLayer(-1);
    } // try
    catch (QTException qte)
    {
View Full Code Here

    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))
      {
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.