Search code examples
mlt

(MLT Framework) How does a <tractor> decide which frame to use from which <track>, taking <transition>s into account?


I can't get my head around really understanding why MLT, taken the following example, uses video frames from track #1 (middle track) instead of from track #0 with track #2 composed onto it. Any explanation?

Let's assume a simple MLT setup, along the lines of:

<mlt>
  ... <!-- some producers here -->
  <tractor>
    <multitrack>
      <track producer="playlist1"/>
      <track producer="playlist2"/>
      <track producer="playlist3"/>
    </multitrack>
    <transition id="transition1">
      <property name="a_track">0</property>
      <property name="b_track">2</property>
      <property name="mlt_service">composite</property>
    </transition>
  </tractor>
</mlt>

Now let's also assume that all three playlists have video clips starting with the same in and out points. That is, all three clips overlap each other.

Without any transition, if I'm correct, I understand the tractor to work such that it takes always the "topmost" video frame from track #2, that is, from "playlist3".

But with "transition1" in place, the tractor takes the frames from track #1, aka "playlist2". Remember that all three playlists have the same in and out points, so they overlap in time.

Can someone explain to my why the tractor now "produces" video frames from track #1 instead of from the composition of track #2 onto track #0?

I would have expected either the latter or from track #2 otherwise, but a quick check using Kdenlive shows that only video frames from track #2 are taken. Why?


Solution

  • As I've learned now, using a transition basically "consumes" the top/B track for the duration of the transition. And this does in fact make sense, albeit it makes MLT slightly counter-intuitive. With the "consumer rule" in mind, my example above works as follows:

    1. tracks 0, 1, 2 are present.
    2. transition1 consumes track 2.
    3. tracks 0 and 1 are left.
    4. track 1 is now the topmost track which does produce frames.