2016-07-25

Inside Kdenlive Projects: Bin Clips

From the perspective of MLT, Kdenlive's bin clips are nothing more producers. However, there is more to Kdenlive's bin clips than MLT thinks...

A Big Thank You ... goes to Kdenlive developer Jean-Baptiste Mardelle. He kindly and thoroughly answered my questions about the different producer identifiers when, for the life of me, I simply couldn't figure out their different purposes.

From the user perspective we've got clips in the Kdenlive project bin. But from the perspective of MLT: how are these Kdenlive clips represented? The simple answer is that there's an MLT producer for every and each Kdenlive project bin clip.

But the correct answer is that there may be multiple producers for the same project bin clip:
  • master (clip) producers,
  • track-wise (clip) producers,
  • muted (clip) producers,
  • slowmotion (clip) producers.

Master (Bin) Clips/Producers


Producers representing the individual bin clips are also termed master producers or master clips. Kdenlive will show only these in its project bin. In addition, only master clips have the additional property with the (bin) folder id this clip is contained in.

The identifier form for master clips is simply a cardinal number, starting with 1. This is also denoted here as simply id="#". Be careful with other forms of identifiers, as certain identifier prefixes and postfixes signal special meaning, as we'll see later.

As we've seen in the project bin post, each master bin clip can optionally reference a Kdenlive project bin folder. This is achieved using a <property> with a name="kdenlive:folderid". For example, the following Kdenlive project XML snippet shows a master bin clip with id="42" that is contained in a bin folder with "5".
<mlt>
  <producer id="42">
    <property name="kdenlive:folderid">5</property>
  </producer>
</mlt>
Note: in order to add a clip to a Kdenlive project outside Kdenlive, you'll have to add a master <producer> with a suitable id="#" and some basic parameters to the project. When loading the project, Kdenlive will automatically fill in many of the other parameters, such as a source hash, et cetera.

Track-wise Bin Clip Producers (Audio)


Next come producers with identifiers in the form of id="#_playlist#". They are needed to work around a limitation in MLT, where placing the same producer onto two tracks and mixing track audio causes severe audio distortion. Fortunately, this only affects audio, but not video.

So Kdenlive creates a separate track-wise producer for each master producer which has audio. For video-only producers, there is no need to create additional track-wise producers. The playlist # corresponds with the identifier of the particular track playlist.

Kdenlive is smart enough to create track-wise producers only for those tracks where they are needed. In addition, track-wise producers are never shown in the project bin, as there's already the master producer shown.

Muted Producers (Video)


Muted video-only producers derived from master producers are identified by an id="#_video". As there is no video compositing issue as with audio mixing, there is no need for track-wiser video-only producers. Thus, whenever the user either mutes a particular clip in the timeline or splits audio from a video clip, Kdenlive creates such a hidden video-only producer.

Of coure, Kdenlive never shows these producers in the project bin, as there's already the master producer shown.

Slowmotion/Speed Producers


At the user interface level, the slowmotion/speed effect is considered to be a Kdenlive effect. However, internally it is a so-called slowmotion producer using MLT's new timewarp service. Slowmotion producers are easily identified by their unique identifiers: they are in the form of id="slowmotion:#:#:#". The three parameters denoted here by #'s are to be interpreted as follows:
      1. the id of the master producer, that is, the id of the bin clip.
      2. the clip speed, where 1 represents 100% speed, that is, original speed.
      3. the third parameter is not used anymore with recent Kdenlive versions that work with the new MLT timewarp effect instead of the older Kdenlive speed effect (which is based on the generic producer speed parameter instead). It is now always set to 1 (that is, show every frame). For older projects basing on Kdenlive's speed effect, this third parmeter represents the strobe parameter.