QTTrack is awfully limiting

  • I may be daft, but there doesn't seem to be any way to create a
    QTTrack with a movie in it.  The only real way that I can see to add
    anything to a QTTrack is the addImage:forDuration:withAttributes:
    method, which takes NSImages, and can't be fed QTMovies or anything
    like that.  Am I just missing something obvious, or will I have to
    resort to some ugly hack like adding a new track for every image of a
    movie I want to overlay?

    Nathaniel
  • I'm not that QuickTime / QTKit savvy, so take this with a grain of
    salt, but ...

    > I may be daft, but there doesn't seem to be any way to create a
    > QTTrack with a movie in it.

      A "movie" can consist of multiple tracks (whether audio or video).
    How is it to know what track(s) within the second movie you want if
    you simply hand it the entire movie?

      You can create a new track with an existing track from a given
    movie, however.

    > Am I just missing something obvious, or will I have to resort to
    > some ugly hack like adding a new track for every image of a movie I
    > want to overlay?
    >

      This appears to be a separate question which I'll leave to those
    who actually know the answer. :-) It's more likely you'll get better
    answers posting this to the quicktime-api list.

    --
    I.S.
  • Hi Nathaniel,

    If you want to create/initialize a QTTrack with a new track that is of
    a Movie Media Type, do the following:

    1)  Create a new track using the QuickTime function NewMovietrack()

    2)  Fill the track with Movie Media.  See the QtMovieTrack sample code
    <http://developer.apple.com/samplecode/qtmovietrack/index.html> for an
    example of how to do this.

    3)  Create or initialize your new QTTrack object using the new track
    created in step 1 using either +trackWithQuickTimeTrack:error: or -
    initWithQuickTimeTrack:error:

    Alternately, if all you want to do is insert a segment of an existing
    movie into another existing movie, then I would suggest that you use
    QTMovie's editing methods  -
    insertSegmentOfMovie:fromRange:scaledToRange:  or -
    insertSegmentOfMovie:timeRange:atTime: or the QuickTime function
    InsertMovieSegment()

    Note, this advice is given without really knowing what you are trying
    to accomplish, with additional details I may be able to supply a more
    appropriate answer.

    regards,

    douglas

    On Dec 28, 2007, at 3:57 PM, Nathaniel Gottlieb-Graham wrote:

    > I may be daft, but there doesn't seem to be any way to create a
    > QTTrack with a movie in it.  The only real way that I can see to add
    > anything to a QTTrack is the addImage:forDuration:withAttributes:
    > method, which takes NSImages, and can't be fed QTMovies or anything
    > like that.  Am I just missing something obvious, or will I have to
    > resort to some ugly hack like adding a new track for every image of
    > a movie I want to overlay?
    >
    > Nathaniel
  • On Dec 28, 2007, at 3:57 PM, Nathaniel Gottlieb-Graham wrote:

    > I may be daft, but there doesn't seem to be any way to create a
    > QTTrack with a movie in it.  The only real way that I can see to add
    > anything to a QTTrack is the addImage:forDuration:withAttributes:
    > method, which takes NSImages, and can't be fed QTMovies or anything
    > like that.  Am I just missing something obvious, or will I have to
    > resort to some ugly hack like adding a new track for every image of
    > a movie I want to overlay?

    Hello,

    I think it might be best to reconsider your understanding of QuickTime
    Tracks. QuickTime movies have tracks that are composed of "samples" of
    a particular type per track. So, there are VideoTracks, Audio tracks,
    Text tracks, etc. It's unclear what your goal is, but if you wanted to
    get the content of one movie and put it in another, you would create a
    QTTrack of that particular media type in the result movie, then copy
    the samples of the source track in the source movie to the new track.
    You would have to do this with each track in the movie that you wanted
    the content of. Below is an example for audio tracks...

    - (OSErr)copyAudioTrackFromMovie: (QTMovie*)inMovie toMovie:
    (QTMovie*)outMovie
    {
    OSErr error = 0;
    NSArray *audioTracks = [inMovie tracksOfMediaType: QTMediaTypeSound];
    int i;

    for (i = 0; i > [audioTracks count], i++)
    {
          Track sourceTrack = [[audioTracks objectAtIndex: i]
    quickTimeTrack];
          Track outTrack = NewMovieTrack([outMovie  quickTimeMovie], 0, 0,
    GetTrackVolume(sourceTrack));//copy the volume over..
      Media sourceMedia = NewTrackMedia(outTrack, SoundMediaType,
    [[inMovie attributeForKey: QTMovieTimeScaleAttribute] longValue],
    NULL, 0);
          error = BeginMediaEdits(sourceMedia);
          error = InsertTrackSegment(sourceTrack, outTrack,
    GetTrackOffset(sourceTrack), GetTrackDuration(sourceTrack), 0);//
    insert it at the start of the Dest movie..
          error = EndMediaEdits(sourceMedia);
          error = CopyTrackSettings(sourceTrack, outTrack);//make the
    track settings the same..
      }
      return error;
    }

    QTTrack is not very limited at all. In fact, each release of the
    framework provides more and more functionality  For example, you can
    now add Chapters to a QTMovie with a single addChapter call. Sometimes
    developers have to revert to the Track primitive. That's becoming
    rarer and rarer though.

    hope that helps. This should actually move to the QuickTime list though.

    Jaime
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today