6 Westley is the MLT projects XML serialisation/deserialisation format -
7 as such, it closely mirrors the internal structure of the MLT API.
9 If you just want to go straight to the DTD, then see
10 mlt/src/modules/westley.dtd, which gets installed at
11 $(prefix)/share/mlt/modules/westley.dtd. Currently, the westley parser is
17 A westley document is essentially a list of 'producers' - a producer is
18 an mlt object which generates mlt frames (images and associated audio
21 There are 3 types of producer:
23 * Basic Producers - these are typically file or device oriented feeds;
24 * Playlists - these are arrangements of multiple producers;
25 * Multitracks - these are the fx encapsulators.
27 In the mlt model, producers are created and attached to 'consumers' -
28 consumers are software playback components (such as SDL), or wrappers for
29 hardware drivers (such as bluefish) or even the westley serialising
30 consumer itself (the latter doesn't receive frames - it merely
31 interrogates the connected producer for its configuration).
33 Although westley was defined as a serialisation mechanism for instantiated
34 MLT components, this document will concentrate on the hand authoring of
40 As shall become apparent through the remainder of this document, the basic
41 tenet of westley authoring is to organise the document in the following
44 1) create producer elements for each unique media clip in the project;
45 2) create playlists for each track;
46 3) create a multitrack and specify filters and transitions;
47 4) adding global filters.
49 While other uses of westley exist, the approach taken here is to maximise
50 efficiency for complex projects.
55 The simplest westley document is:
58 <producer id="producer0">
59 <property name="resource">clip1.dv</property>
63 The westley wrapping is of course superfluous here - loading this document
64 with MLT is identical to loading the clip directly.
66 Of course, you can specify additional properties. For example, consider an
67 MPEG file with multiple soundtracks - you could define a westley document to
68 ensure that the second audio track is loaded:
71 <producer id="producer0">
72 <property name="resource">clip1.mpeg</property>
73 <property name="audio_track">1</property>
77 NB: This relies on the mpeg being handled by the avformat producer, rather
78 than the mcmpeg one. See services.txt for more details.
80 A more useful example comes with the pango producer for a text producer.
82 TODO: pango example...
86 1) It is better not to specify in/out points when defining basic producers
87 as these can be specified in the playlists. The reasoning is that in/out
88 restricts the amount of the clip available, and could lead to the same clip
89 being loaded multiple times if you need different regions of the clip
91 2) A westley can be specified as a resource, so westleys can naturally
92 encapsulate other westleys.
97 Playlists provide a 'collection' structure for producers. These can be used
98 to define 'tracks' in the multitrack approach, or simple playlists for
99 sequential, single track playout.
101 As an example, the following defines two basic producers and a playlist with 3
105 <producer id="producer0">
106 <property name="resource">clip1.dv</property>
108 <producer id="producer1">
109 <property name="resource">clip2.dv</property>
111 <playlist id="playlist0">
112 <entry producer="producer0" in="0" out="2999"/>
113 <entry producer="producer1" in="0" out="999"/>
114 <entry producer="producer0" in="3000" out="6999"/>
118 Here we see how the playlist defines the in/out points of the basic
123 1) All in/out points are absolute frame positions relative to the producer
124 being appended to the playlist;
125 2) Westley documents are currently authored for a specific normalisation;
126 3) The last 'producer' in the document is the default for play out;
127 4) Playlists can reference the same producer multiple times. In/out regions
128 do not need to be contiguous - duplication and skipping is acceptable.
131 Interlude - Introducing Multitracks:
133 So far we've defined basic producers and playlists/tracks - the tractor is
134 the element that allows us to arrange our tracks and specify filters and
135 transitions. Similarly to a playlist, a tractor is a container.
137 Note that MLT doesn't see a filter or a transition as a producer in the
138 normal sense - filters and transitions are passive when it comes to seeking.
139 Internally, seeks are carried out on the producers. This is an important
140 point - MLT does not follow a traditional graph oriented model.
142 Visualising an MLT tractor and it's interaction with the consumer will
145 +----------------------------------------------+
147 | +----------+ +-+ +-+ +-+ +-+ |
148 | |multitrack| |f| |f| |t| |t| |
149 | | +------+ | |i| |i| |r| |r| |
150 | | |track0|-|--->|l|- ->|l|- ->|a|--->|a|\ |
151 | | +------+ | |t| |t| |n| |n| \ |
152 | | | |e| |e| |s| |s| \ |
153 | | +------+ | |r| |r| |i| |i| \ | +--------+
154 | | |track1|-|- ->|0|--->|1|--->|t|--->|t|-----|--->|consumer|
155 | | +------+ | | | | | |i| |i| / | +--------+
156 | | | | | | | |o| |o| / | ^
157 | | +------+ | | | | | |n| |n| / | |
158 | | |track2|-|- ->| |- ->| |--->|0|- ->|1|/ | |
159 | | +------+ | | | | | | | | | | |
160 | +----------+ +-+ +-+ +-+ +-+ | |
161 +----------------------------------------------+ |
165 |APPLICATION|--------------------------------------------+
168 Internally, all frames from all tracks pass through all the filters and
169 transitions - these are told which tracks to deal and which regions of the
172 Note that the application communicates with the producer - it can alter
173 playback speed, position, or even which producer is connected to which
176 The consumer receives the first non-blank frame (see below). It has no say
177 in the order in which gets them (the sdl consumer when used with inigo might
178 appear to be an exception - it isn't - it simply has a route back to the
179 application to allow the application to interpret key presses).
181 Whether this is better or worse than a traditional graph approach is a moot
182 point. The author of this document likes it anyway :-).
187 To create a multitrack westley, we can use two playlists and introduce a
188 tractor. For the purposes of demonstration, I'll add a filter here too:
191 <producer id="producer0">
192 <property name="resource">clip1.dv</property>
194 <producer id="producer1">
195 <property name="resource">clip2.dv</property>
197 <playlist id="playlist0">
198 <entry producer="producer0" in="0" out="2999"/>
199 <blank length="1000"/>
200 <entry producer="producer0" in="3000" out="6999"/>
201 <playlist id="playlist1">
202 <blank length="3000"/>
203 <entry producer="producer1" in="0" out="999"/>
205 <tractor id="tractor0">
207 <track producer="playlist0"/>
208 <track producer="playlist1"/>
211 <property name="track">0</property>
212 <property name="mlt_service">greyscale</property>
217 Here we see that blank frames are inserted into the first playlist and a
218 blank is provided at the beginning of the second - this can be visualised in
219 the traditional timeline widget as follows:
221 +-------+ +-------------+
223 +-------+---+-------------+
227 Adding the filter on the top track, gives us:
229 +-------+ +-------------+
231 +-------+---+-------------+
233 --------+---+-------------+
237 Note that it's only applied to the visible parts of the top track.
239 The requirement to apply a filter to the output, as opposed to a specific
240 track leads us to the final item in the Rules section above. As an example,
241 let's assume we wish to watermark all output, then we could use the
245 <producer id="producer0">
246 <property name="resource">clip1.dv</property>
248 <producer id="producer1">
249 <property name="resource">clip2.dv</property>
251 <playlist id="playlist0">
252 <entry producer="producer0" in="0" out="2999"/>
253 <blank length="1000"/>
254 <entry producer="producer0" in="3000" out="6999"/>
255 <playlist id="playlist1">
256 <blank length="3000"/>
257 <entry producer="producer1" in="0" out="999"/>
259 <tractor id="tractor0">
261 <track producer="playlist0"/>
262 <track producer="playlist1"/>
265 <property name="track">0</property>
266 <property name="mlt_service">greyscale</property>
269 <tractor id="tractor1">
271 <track producer="tractor0"/>
274 <property name="mlt_service">watermark</property>
275 <property name="resource">watermark1.png</property>
280 Here we employ another tractor and we define a single track (being the
281 tractor we previously defined) and apply a watermarking filter there.
283 This is simply provided as an example - the watermarking functionality could
284 be better handled at the playout stage itself (ie: as a filter automatically
285 placed between all producers and the consumer).
287 Tracks act like "layers" in an image processing program like the GIMP. The
288 bottom-most track takes highest priority and higher layers are overlays
289 and do not appear unless there are gaps in the lower layers or unless
290 a transition is applied that merges the tracks on the specifed region.
291 Practically speaking, for A/B video editing it does not mean too much,
292 and it will work as expected; however, as a general rule apply any CGI
293 (graphic overlays with pixbuf or titles with pango) on tracks higher than
294 your video tracks. Also, this means that any audio-only tracks that are
295 lower than your video tracks will play rather than the audio from the video
296 clip. Remember, nothing is affected like mixing or compositing until one
297 applies a transition or appropriate filter.
300 <producer id="producer0">
301 <property name="resource">clip1.dv</property>
303 <playlist id="playlist0">
304 <entry producer="producer0"/>
306 <producer id="producer1">
307 <property name="resource">clip2.mpeg</property>
309 <playlist id="playlist1">
311 <entry producer="producer1"/>
313 <tractor id="tractor0" in="0" out="315">
314 <multitrack id="multitrack0">
315 <track producer="playlist0"/>
316 <track producer="playlist1"/>
318 <transition id="transition0" in="50" out="74">
319 <property name="a_track">0</property>
320 <property name="b_track">1</property>
321 <property name="mlt_service">luma</property>
323 <transition id="transition1" in="50" out="74">
324 <property name="a_track">0</property>
325 <property name="b_track">1</property>
326 <property name="mlt_service">mix</property>
327 <property name="start">0.0</property>
328 <property name="end">1.0</property>
333 A "luma" transition is a video wipe processor that takes a greyscale bitmap
334 for the wipe definition. When one does not specify a bitmap, luma performs
335 a dissolve. The "mix" transition does an audio mix, but it interpolates
336 between the gain scaling factors between the start and end properties -
337 in this example, from 0.0 (none of track B) to 1.0 (all of track B).
338 Because the bottom track starts out with a gap specified using the <blank>
339 element, the upper track appears during the blank segment. See the demos and
340 services.txt to get an idea of the capabilities of the included transitions.
344 The information presented above is considered the MLT Westley "normal"
345 form. This is the output generated by the westley consumer, for example,
346 when used with inigo. It is the output generated when you use the
347 "Westley to File" consumer in the demo script, which beginners will find
348 most useful for learning to use westley XML. This section describes
349 alternative forms the westley producer accepts.
351 First of all, the normal form is more of a linear format with producers
352 and playlists defined prior to their usage in a multitrack. Westley
353 also accepts a hierarchical format with producers as children of tracks
354 or playlist entries and with playlists as children of tracks:
363 <property name="resource">clip1.dv</property>
372 Obviously, this example is meant to demonstrate hierarchy and not effective
373 use of playlist or multitrack!
375 Secondly, as part of error handling, westley is forgiving if you fail to
376 supply <tractor>, <track>, and <entry> where one can be understood. This
377 affords an abbreviated syntax that is less verbose and perhaps less
378 intimidating for a human to read and understand. One can simplify the
385 <property name="resource">clip1.dv</property>
391 Yes, filters and transitions can be added to the above example after the
392 closing multitrack tag (</multitrack>) because it is still enclosed within
393 the westley body tags.
395 If you specify in and out on a producer and it has been enclosed within
396 an <entry> or <playlist>, then the edit points apply to the playlist
397 entry and not to the producer itself. This facilitates re-use of media:
400 <producer id="clip1" in="25" out="78">
401 <property name="resource">clip1.dv</property>
403 <entry producer="clip1" in="119" out="347"/>
406 In the above example, the producer attribute of the entry element is
407 a reference to the preceding producer. All references must follow the
408 definition. The edit points supplied on the producer above will not affect
409 the entry that references it below because westley knows the clip is a
410 playlist entry and optimises this situation. The advantage is that one
411 does not need to determine every clip to be included ahead of time
412 and specify them outside the context of the mutlitrack timeline.
414 This form of authoring will be easier for many to visualise as a non-linear
415 editor's timeline. Here is a more complex example:
420 <producer id="foo" in="100" out="149">
421 <property name="resource">clip2.mpeg</property>
424 <entry producer="foo" in="10" out="59"/>
428 <producer id="bar" in="100" out="199">
429 <property name="resource">clip3.mpeg</property>
431 <entry out="99" producer="bar"/>
434 <filter mlt_service="greyscale" track="0"/>
435 <transition mlt_service="luma" in="25" out="49" a_track="0" b_track="1"/>
436 <transition mlt_service="luma" in="75" out="99" a_track="0" b_track="1">
437 <property name="reverse" value="1"/>
441 Did you notice something different in the last example? Properties can be
442 expressed using XML attributes on the element as well. However, only
443 non-service-specific properties are supported in this way. For example,
444 "mlt_service" is available to any producer, filter, or transition. However,
445 "resource" is actually service-specific. Notice the syntax of the last
446 property, on the last transition. Westley accepts property values using
447 the "value" attribute as well as using element text.
449 We have seen a few different ways of expressing property values. There are
450 a couple more for properties that can accept XML data. For example, the
451 GDK pixbuf producer with librsvg can handle embedded SVG, and the Pango
452 producer can handle embedded Pango markup. You can enclose the embedded XML
453 using a CDATA section:
455 <property name="resource"><![CDATA[ <svg>...</svg> ]]></property>
457 Please ensure the opening CDATA tag immediately follows the opening
458 property tag and that the section closing tag immediately precedes the
459 closing property tag.
461 However, westley can also accept inline embedded XML:
463 <property name="resource">
468 Currently, there is no namespace handling so a conflict will occur only on
469 any embedded XML that contains an element named "property" because
470 westley collects embedded XML until it reaches a closing property tag.
473 Entities and Parameterisation:
475 The westley producer parser supports XML entities. An example:
477 <?xml version="1.0"?>
479 <!ENTITY msg "Hello world!">
482 <producer id="producer0">
483 <property name="mlt_service">pango</property>
484 <property name="text">&msg;</property>
488 If you are embedding another XML document into a property value not using
489 a CNODE section, then any DOCTYPE section must be relocated before any of
490 the xml elements to be well-formed. See demo/dvg.westley for an example.
492 Entities can be used to parameterise westley! Using the above example, the
493 entity declared serves as the default value for &msg;. The entity content
494 can be overridden from the resource property supplied to the westley
495 producer. The syntax is the familiar, url-encoded query string used with
496 HTTP, e.g.: file?name=value&name=value...
498 There are a couple of rules of usage. The Miracle LOAD command and inigo
499 command line tool require you to preface the URL with "westley:" because
500 the query string destroys the filename extension matching peformed by
501 Fezzik. Also, inigo looks for '=' to tokenise property settings. Therefore,
502 one uses ':' between name and value instead of '='. Finally, since inigo
503 is run from the shell, one must enclose the URL within single quotes to
504 prevent shell filename expansion, or similar.
506 Needless to say, the ability to parameterise westley XML compositions is
507 an extremely powerful tool. An example for you to play with is available in
508 demo/entity.westley. Try overriding the name from inigo:
509 inigo 'westley:entity.westley?name:Charlie'
511 Technically, the entity declaration is not needed in the head of the XML
512 document if you always supply the parameter. However, you run the risk
513 of unpredictable behviour without one. Therefore, it is safest and a best
514 practice to always supply an entity declaration. It is improves the
515 readability as one does not need to search for the entity references to
516 see what parameters are available.
521 If one finds the above hierarchical, abbreviated format intuitive,
522 start with a simple template and fill and extend as needed:
527 ...add a playlist for each track...
529 ...add filters and transitions...
532 By using a playlist for each track, it is easier to iteratively add new
533 clips and blank regions as you develop the project. You will not have to
534 use <track> or later add <playlist> when necessary.
536 A more advanced template that allows sequencing multitracks is:
542 ...add a playlist for each track...
544 ...add filters and transitions...
551 ...add a playlist for each track...
553 ...add filters and transitions...
557 If you end up making a collection of templates for various situations, then
558 consider using XML Entities to make the template more effective by moving
559 anything that should parameterised into an entity.
561 If you want to have a silent, black background for audio and video fades,
562 then make the top track simply <producer mlt_service="colour"/>. Then,
563 use composite and volume effects. See the "Fade from/to black/silence"
564 demo for an example (demo/mlt_fade_black).
566 If you apply the reverse=1 property to a transition like "luma," then
567 be careful because it also inherently swaps the roles of A and B tracks.
568 Therefore, you need to might need to swap the a_track and b_track values
569 if it did not turn out the way you expected. See the "Clock in and out"
570 for an example (demo/mlt_clock_in_and_out).