5 Template construction is perhaps the most complex aspect of shotcuts use.
7 Tools could be developed to automate this task, but for now, no such tool
8 exists - instead we use a shell script and the MLT 'inigo' command line
9 tool to construct an empty project which dictates which tracks a project has
10 and how they can be used.
12 You could, potentially, author the westley xml manually or generate the
13 templates in C, C++, perl, ruby, tcl, java, or any other language that can
14 access the MLT API. Only the shell/inigo approach is covered in this
15 document but the principles should map to any method of westley authoring.
18 WHAT YOU NEED TO KNOW BEFORE YOU START
20 Shell scripting and Some basic knowledge of the multi track aspects of MLT
21 and inigo are pre-requisites.
23 It is vitally important to note that templates are stored in a users
24 home directory. These entries are created via the 'shotcut-templates'
25 script and this script is executed every time a user access 'New Project'
26 from the NLE or when there is no autosaved project to reload.
28 The shotcut-templates provided is meant to provide examples - typically,
29 you would create your own shotcut-templates and ensure that it is found
30 on the users PATH before the default one.
33 CREATING A CUSTOM SHOTCUT-TEMPLATES SCRIPT
35 Your custom script takes a single argument - this is the directory in
36 which you should place the templates - it may not exist at the point
37 of invocation, so you may need to create it. Typically, your first few
38 lines should look like:
42 [ "$1" == "" ] && exit
47 [ "$?" != "0" ] && exit
49 If you're regularly modifying and removing the templates available from the
50 script, then you might find it convenient to remove all the existing templates
53 rm -f "$TEMPLATES"/*.westley
55 This is optional, but be aware that the default shotcut-templates does do
58 Now we're ready to start creating templates.
61 THE FIRST TEMPLATE - SINGLE TRACK
63 The most basic template defines a single track which accepts video:
65 inigo nle_template="Single Track" nle_prefix="STR_" \
66 -track nle_label=Visual nle_type=1 \
68 -consumer westley:$TEMPLATES/SingleTrack.westley store="nle_"
72 * the nle_template property defines the label that will be shown when you access
73 New Project in the nle
74 * nle_prefix is used to define a prefix for this project type when saving a file -
75 the default location and file name for all projects saved is
76 ~/shotcut/'prefix''title'.westley. If no prefix is provided, the default is to
77 use a the nle_template to define a directory to save projects of that type.
78 * the -track introduces an audio/video track (track 0) and assigns it a label
79 and a type - the type here says that this track will accept video only (more
80 details on types below)
81 * The -blank 0 is required to ensure that the first track isn't empty - this is a
82 prerequisite for it to be serialised in inigo - it is not needed in other
83 environments of mlt use (ie: perl, ruby, c++, the c api itself, etc)
84 * The last line simply serialises the template and ensures that all properties
87 The behaviour of this template will be to:
89 1. provide a single track
90 2. reject drops of any item that is not a video clip
92 Further, it provides no 'Attributes' or 'Super' track and these panels will
93 remain inactive. It also provides no information for defining the auto transitions
94 associated to the Preview mode. Essentially, it provides the most basic playlist
97 The only feature that the NLE will provide on top of this is the obscure masking
103 The basic pattern for all templates is:
105 inigo [ template property assignment] \
106 -track [ track property assignment ] \
108 [ -track [ track property assignment ] ]*
109 [ track level filters and transitions ]
110 [ project level filters ]
111 -consumer westley:$TEMPLATES/[Template name].westley store="nle_"
114 THE SECOND TEMPLATE - AUDIO MIXING
116 Now let's assume we want to add an audio track. The audio track will mix with
117 the audio from the video track. For this to work, we need to add a second
118 track of the correct type and a 'transition' which defines how the mix should be
121 For this example, we'll assume an equal mix of audio from both tracks and we'll
122 have the audio on the lower track fade in and out for a second on the start and
123 end of each audio cut.
125 inigo nle_template="Audio Mixing" \
126 -track nle_label=Visual nle_type=1 \
128 -audio-track nle_label=Voice nle_type=16 \
129 -transition mix:0.5 always_active=1 length=25 a_track=0 b_track=1 \
130 -consumer westley:$TEMPLATES/AudioMixing.westley store="nle_"
132 This should provide us with the template described above.
134 Typically, all template level transitions are 'always_active' and have
135 a_track=0 b_track=n properties - note that not all mlt transitions are
136 candidates for use in this manner (at the time of writing, only mix and
137 composite are supported - however, these two are sufficient for many
138 types of operations).
141 THE THIRD TEMPLATE - AUTO TRANSITIONS
143 One of the features that the NLE provides are auto transitions between
144 neighbouring video cuts on the first track (note that this only applies to
147 You can activate this by providing some properties on the first track which
148 define the transition to use, the duration and other properties associated to
151 The most basic example is a fade between the cuts and is defined as follows:
153 inigo nle_template="Auto Transitions" \
154 -track nle_label=Visual nle_type=1 \
155 nle_transition=luma nle_transition_length=12 \
157 -audio-track nle_label=Voice nle_type=16 \
158 -transition mix:0.5 always_active=1 length=25 a_track=0 b_track=1 \
159 -consumer westley:$TEMPLATES/AutoTransitions.westley store="nle_"
161 Just to reiterate - this kind of processing is only applied if both
162 nle_transition and nle_transition_length are specified. Further, the
163 transition is created by holding the last frame of the outgoing frame
164 and applying the transition between that and the corresponding opening
165 frames of the incoming cut. This transition technique is used to avoid
166 relative positions of cuts on other tracks getting lost.
168 Note that all user saved and published projects enforce the 'preview'
169 mode regardless of the NLE's GUI state.
172 THE FOURTH TEMPLATE - SUPERS
174 Supers are a special case track - they don't contain audio or video - each
175 'clip' holds 1 or 2 lines of text which is sent to a (customisable) filter
176 which renders the text on the output frame in some way.
178 Note that supers are tightly coupled to track 0 - in shotcut this is
179 normally gapless and the supers are situated so they don't step outside
180 the cut on track 0 to which they belong.
182 Because of the coupling, it makes sense to place the supers on track 1 as
185 inigo nle_template="Supers" \
186 -track nle_label=Visual nle_type=1 \
187 nle_transition=luma nle_transition_length=12 \
189 -null-track nle_label=Super nle_type=8 \
190 -audio-track nle_label=Voice nle_type=16 \
191 -transition mix:0.5 always_active=1 length=25 a_track=0 b_track=2 \
192 -filter data_show:%etv.properties track=-1 \
193 -consumer westley:$TEMPLATES/AutoTransitions.westley store="nle_"
195 Supers are very sensitive to the template layout. They impose a number of
196 restrictions on templates and shotcut use in general:
198 * they must be applied to the final frame, hence the super data show must
199 use the 'wild card' track association (track=-1 above) - if you have single
200 video track, then track=0 is sufficient
202 * They (and any filters which should be rendered on the resultant frame)
203 must be rendered in the last filter(s) in the template - you can have
204 multiple data_show filters that provide the rules for rendering supers
205 and attributes, but they must be the last filters (unless you want a
206 'burnt in' filter [such as a watermark] to be applied after).
208 The super filter used here is defined in the etv.properties feed data file
209 (at runtime this is located in $prefix/share/mlt/modules/feeds/PAL).
211 More details on customising supers are found below.
214 THE FIFTH TEMPLATE - ATTRIBUTES
216 As with supers, our main concern with attributes is ensuring they get
217 handled in the correct place.
219 Unlike supers, attributes can be more flexibly placed, but with the
220 flexibility comes more decision making and care must be taken to ensure
221 the results are as required.
223 Typically, attributes, like supers, are rendered on the output frame
224 and the same rules apply as above. Note that for convenience, all the
225 ETV demo supers and attributes are defined in the same file, so all we
226 have to do is define which attributes are applied to track 0:
228 inigo nle_template="Attributes" \
229 -track nle_label=Visual nle_type=1 \
230 nle_transition=luma nle_transition_length=12 \
231 nle_attributes="location,courtesy,*exclusive,*file_shot,*special" \
233 -null-track nle_label=Super nle_type=8 \
234 -audio-track nle_label=Voice nle_type=16 \
235 -transition mix:0.5 always_active=1 length=25 a_track=0 b_track=2 \
236 -filter data_show:%etv.properties track=-1 \
237 -consumer westley:$TEMPLATES/Attributes.westley store="nle_"
239 The syntax of 'nle_attributes' is simply 'name' to dictate that it takes
240 a 'markup' argument that is passed to the rendering, or '*name' to stipulate
241 that the filter doesn't take an argument.
243 Note that these attributes belong to the output frame and by default, all
244 attributes on track 0 (along with the super) are a special case. These
245 attributes are accessible to the consumer - the consumer can 'hijack' these
246 items and render them outside of the mlt environment (for example, on dedicated
249 Attributes belonging to other tracks are locked into mlt rendering.
252 THE SIXTH TEMPLATE - DOUBLE AUDIO
254 The templates above are building up to the ETV 'Package' template. This
255 example will complete this and add a little more information regarding
256 the 'nle_type' track property.
258 As has been shown above, tracks can be tailored to accept specific types.
259 So far, we've introduced types for audio/video clips (internally known as
260 'stories'), audio only and supers. The full list is as follows:
262 STORIES = 1 All video clips are categorised as stories
263 AUDIO = 2 All inputs that have audio are categorised as audio
264 (ie: a video clip is both story and audio)
265 STILLS = 4 Inputs that have no audio are categorised as stills
266 TEXT = 8 Used to indicate the track holds supers
267 VOICE = 16 Special categorisation that indicates audio only
268 (an audio only clip is both audio and voice)
269 PROJECTS = 32 Categorisation of an injected nle project
271 Most of these are fairly self explainatory.
273 If we want to extend our first track to accept stories, stills and
274 projects, we add the values together - 1 + 4 + 32 = 37.
276 Similarly, if we want our audio tracks to accept stories with ambient
277 audio, we can can use - 16 + 2 = 18 or just 2 because of the special
280 Note that only the first track can accept a project as a project -
281 when you drop a project on to the first track, the NLE will attempt
282 to convert the entire contents of the project in to the current
283 projects template. If track 0 doesn't accept projects specifically,
284 the project will be treated as a story.
286 Just for completeness, we'll accept ambient video on the Voice track
287 and add a Music track (as per the ETV Package) and further we'll allow
288 project conversion via the first track:
290 inigo nle_template="Double Audio" \
291 -track nle_label=Visual nle_type=37 \
292 nle_transition=luma nle_transition_length=12 \
293 nle_attributes="location,courtesy,*exclusive,*file_shot,*special" \
295 -null-track nle_label=Super nle_type=8 \
296 -audio-track nle_label=Voice nle_type=2 \
297 -audio-track nle_label=Music nle_type=16 \
298 -transition mix:0.2 always_active=1 length=25 a_track=0 b_track=2 \
299 -transition mix:0.5 always_active=1 length=25 a_track=0 b_track=3 \
300 -attach data_show:%etv.properties track=-1 \
301 -consumer westley:$TEMPLATES/DoubleAudio.westley store="nle_"
306 THE SEVENTH TEMPLATE - LOCALISATION
308 The thorny issue of localisation will raise its ugly head from time to
311 Linux has 3 mechanisms for font rendering - shotcut/fltk and mlt/pango use
312 two different approaches.
314 This is an added complexity as it means we need to ensure that fonts are
315 listed in both the fc-list and xlsfonts output.
317 Taking ETV's Bengali font as an example, we need to add 4 additional
318 properties to our template:
320 inigo nle_template="Double Audio" \
321 nle_font_display=BN-TTDurga \
322 nle_font_capture=-misc-asbwlttdurga-medium-r-normal--0-0-0-0-p-0-iso8859-1 \
323 nle_font_attr_size=32 \
324 nle_font_super_size=48\
325 -track nle_label=Visual nle_type=37 \
326 nle_transition=luma nle_transition_length=12 \
327 nle_attributes="location,courtesy,*exclusive,*file_shot,*special" \
329 -null-track nle_label=Super nle_type=8 \
330 -audio-track nle_label=Voice nle_type=2 \
331 -audio-track nle_label=Music nle_type=16 \
332 -transition mix:0.2 always_active=1 length=25 a_track=0 b_track=2 \
333 -transition mix:0.5 always_active=1 length=25 a_track=0 b_track=3 \
334 -attach data_show:%etv.properties track=-1 \
335 -consumer westley:$TEMPLATES/DoubleAudio.westley store="nle_"
337 The nle_font properties dictate which fonts to use in the MLT display and
338 in the shotcut data capture and their respective sizes.
343 As mentioned above, it is possible to customise attributes and supers.
345 These fx are handled by the MLT 'feed' and 'show' mechanism.
347 Essentially, a feed is a property or collection of properties which are placed
348 on a frame (normally automatically by assigning them to the producer or the cut)
349 and a 'show' is a filter which matches the feeds up to a set of rules and
352 The feed definitions are defined in the mlt/src/modules/feeds directory.
354 The PAL/examples.properties provides the simplest definitions, for example:
357 .description=Greyscale
359 To use this with inigo, you could use the following:
361 inigo colour:blue colour:red meta.attr.greyscale=1 \
362 -filter data_show:%example.properties
364 This will cause the second colour to be treated by the greyscale effect.
366 Obviously, most of the examples in etv.properties are much more complex.
367 For example, the 'location' attribute is defined as follows:
371 .properties.markup=filter[1].producer.text
372 .properties.font=filter[1].producer.font
373 .properties.size=filter[1].producer.size
375 .properties.length[0]=composite.out
376 .composite.geometry=0,80:230x30:0;12=,:x:100
377 .composite.luma=%luma01.pgm
378 .composite.softness=.3
380 .filter[0].resource=colour:0x6c0101ff
382 .filter[1].resource=pango:
383 .filter[1].producer.text=
384 .filter[1].producer.font=Sans
385 .filter[1].producer.size=24
386 .filter[1].composite.geometry=0,0:95%x100%
387 .filter[1].composite.titles=1
388 .filter[1].composite.halign=right
389 .filter[1].composite.valign=center
391 The lines beginning with .properties dictate the names of additional
392 properties that can be accepted from the feed and how they're handled.
394 .properties.length[0] is a special case - it is handled internally.
396 In this case, the following inigo command would activate the effect:
398 inigo colour:red meta.attr.location=1 \
399 meta.attr.location.markup=Hello \
400 meta.attr.location.font=Embargo \
401 meta.attr.location.size=32 \
402 -filter data_show:%etv.properties
404 All shotcut attributes assume these 3 properties are available and they
405 are assigned to the cut - in the current implementation of shotcut, it is not
406 possible to collect different properties via the GUI and pass them though
409 The remaining properties are standard to the 'region' filter which is
410 defined in the MLT 'services.txt' document.
412 Supers are defined in a similar way, except their properties are as follows:
415 .description=Transcription
416 .properties.0=filter[1].producer.text
417 .properties.1=filter[2].producer.text
418 .properties.align=filter[1].composite.valign
419 .properties.weight=filter[1].producer.weight
420 .properties.f0=filter[1].producer.font
421 .properties.s0=filter[1].producer.size
422 .properties.f1=filter[2].producer.font
423 .properties.s1=filter[2].producer.size
425 (the remainder of definition can be found in mlt/src/modules/feeds/PAL/etv.properties).
427 These property names are very terse so a quick explaination is required:
429 0 = the text on the top
431 s0 = size of the top font
432 1 = text on the bottom
433 f1 = font of the bottom
434 s1 = size of the bottom font
435 align = vertical alignment of the top (special case - allows Single Line supers).
436 weight = specificies the weight of the top super
440 inigo colour:red meta.attr.super=1 \
441 meta.attr.super.0=Hello \
442 meta.attr.super.1=There \
443 -filter data_show:%etv.properties
445 Note that we don't need to supply all properties values to use the supers, but
446 again, the current implementation assumes the properties and their meanings.