Synchronizing QTMovieLayers

  • Howdy guys,

    I have a need to make sure multiple QTMovieLayers are in perfect sync.
    In other words, I need them to start at exactly the same time. If you
    just do a few [movieN play] in a row, they're slightly off from each
    other.

    Has anyone done this? Any suggestions? (I'd really rather not have to
    pull frames out of the movie and manually draw them myself or
    something like that.)

    --
    Seth Willits
  • On 1/2/09, Seth Willits <slists...> wrote:
    > Howdy guys,
    >
    >
    > I have a need to make sure multiple QTMovieLayers are in perfect sync.
    > In other words, I need them to start at exactly the same time. If you
    > just do a few [movieN play] in a row, they're slightly off from each
    > other.
    >
    > Has anyone done this? Any suggestions? (I'd really rather not have to
    > pull frames out of the movie and manually draw them myself or
    > something like that.)

    So are you playing different multiple movies or the same movie at
    different time indexes?
    Or are you playing the same movie in different layers and just want
    them in sync (e.g. reflection layer).

    If you are talking about the first case, I don't think there is any
    way to do this with QTMovieLayers.

    If you are talking about the second case (same movie and time), then
    as of QuickTime 7.5, you can do this. I blogged about it here and have
    sample code (doing reflection layers):
    http://playcontrol.net/ewing/jibberjabber/quicktime_75_core_animation.html

    -Eric
  • Seth,

    Synchronization is done at a lower level. You need to get the movie
    time base of the movie you want to be the master and then set the
    master time base for the movie you want to be the slave. Since this is
    done at the Movie primitive level it doesn't matter that you are using
    QTMovieLayers. This is the basic code you need:

    QTMovie *master... // initialized somewhere
    QTMovie *slave... // Initialized somewhere

    TimeBase mtb = GetMovieTimeBase([master quickTimeMovie]);
    SetTimeBaseMasterTimeBase(mtb, GetMovieTimeBase([slave
    quickTimeMovie]), nil);

    Then call play on both movies:

    [master play];
    [slave play];

    The docs for both of those time base calls are here: http://developer.apple.com/documentation/QuickTime/Reference/QTRef_MovieMan
    ager/Reference/reference.html


    As a side note, you are going to have some performance issues playing
    back two movies. You will likely need to go to using OpenGL to squeeze
    out every bit of performance. I wrote a blog post on how to composite
    a movie in a CAOpenGLLayer here: http://www.cimgf.com/2008/09/10/core-animation-tutorial-rendering-quicktime
    -movies-in-a-caopengllayer/

      . You can use this technique to composite multiple video channels at
    once.

    HTH,

    -Matt

    On Jan 2, 2009, at 3:13 PM, Seth Willits wrote:

    > Howdy guys,
    >
    >
    > I have a need to make sure multiple QTMovieLayers are in perfect
    > sync. In other words, I need them to start at exactly the same time.
    > If you just do a few [movieN play] in a row, they're slightly off
    > from each other.
    >
    > Has anyone done this? Any suggestions? (I'd really rather not have
    > to pull frames out of the movie and manually draw them myself or
    > something like that.)
    >
    > --
    > Seth Willits
    >
    >
    >
  • Thank you very much, Matt. I'll look at this today. The movies aren't
    too large and are only being played on a top end Mac Pro, so the
    performance so far is fine. Though I did think about the potential of
    having to do something myself in GL. Your post will help, if I do.

    Thanks again,

    (I'm glad the mailing lists are working again!)

    --
    Seth Willits

    On Jan 6, 2009, at 7:56 AM, Matt Long wrote:

    > Seth,
    >
    > Synchronization is done at a lower level. You need to get the movie
    > time base of the movie you want to be the master and then set the
    > master time base for the movie you want to be the slave. Since this
    > is done at the Movie primitive level it doesn't matter that you are
    > using QTMovieLayers. This is the basic code you need:
    >
    > QTMovie *master... // initialized somewhere
    > QTMovie *slave... // Initialized somewhere
    >
    > TimeBase mtb = GetMovieTimeBase([master quickTimeMovie]);
    > SetTimeBaseMasterTimeBase(mtb, GetMovieTimeBase([slave
    > quickTimeMovie]), nil);
    >
    > Then call play on both movies:
    >
    > [master play];
    > [slave play];
    >
    > The docs for both of those time base calls are here: http://developer.apple.com/documentation/QuickTime/Reference/QTRef_MovieMan
    ager/Reference/reference.html

    >
    > As a side note, you are going to have some performance issues
    > playing back two movies. You will likely need to go to using OpenGL
    > to squeeze out every bit of performance. I wrote a blog post on how
    > to composite a movie in a CAOpenGLLayer here: http://www.cimgf.com/2008/09/10/core-animation-tutorial-rendering-quicktime
    -movies-in-a-caopengllayer/

    > . You can use this technique to composite multiple video channels
    > at once.
    >
    > HTH,
    >
    > -Matt
    >
    >
    > On Jan 2, 2009, at 3:13 PM, Seth Willits wrote:
    >
    >> Howdy guys,
    >>
    >>
    >> I have a need to make sure multiple QTMovieLayers are in perfect
    >> sync. In other words, I need them to start at exactly the same
    >> time. If you just do a few [movieN play] in a row, they're slightly
    >> off from each other.
    >>
    >> Has anyone done this? Any suggestions? (I'd really rather not have
    >> to pull frames out of the movie and manually draw them myself or
    >> something like that.)
    >>
    >> --
    >> Seth Willits
    >>
    >>
    >>
previous month january 2009 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