]> git.sesse.net Git - mlt/blob - docs/melt.txt
Add -query profile to melt.
[mlt] / docs / melt.txt
1 Melt Documentation
2
3 Copyright (C) 2004-2009 Ushodaya Enterprised Limited
4 Author: Charles Yates <charles.yates@pandora.be>
5 Author: Dan Dennedy <dan@dennedy.org>
6 Last Revision: 2011-04-03
7
8
9 MELT
10 -----
11
12 Preamble:
13
14         Melt was developed as a test tool for the MLT framework. It can be thought
15         of as a powerful, if somewhat obscure, multitrack command line oriented 
16         video editor.
17
18         The following details the usage of the tool and as a result, provides a lot 
19         of insight into the workings of the MLT framework.
20
21
22 Usage:
23
24     melt [options] [producer [name=value]* ]+
25     Options:
26       -attach filter[:arg] [name=value]*       Attach a filter to the output
27       -attach-cut filter[:arg] [name=value]*   Attach a filter to a cut
28       -attach-track filter[:arg] [name=value]* Attach a filter to a track
29       -attach-clip filter[:arg] [name=value]*  Attach a filter to a producer
30       -audio-track | -hide-video               Add an audio-only track
31       -blank frames                            Add blank silence to a track
32       -consumer id[:arg] [name=value]*         Set the consumer (sink)
33       -debug                                   Set the logging level to debug
34       -filter filter[:arg] [name=value]*       Add a filter to the current track
35       -group [name=value]*                     Apply properties repeatedly
36       -help                                    Show this message
37       -join clips                              Join multiple clips into one cut
38       -mix length                              Add a mix between the last two cuts
39       -mixer transition                        Add a transition to the mix
40       -null-track | -hide-track                Add a hidden track
41       -profile name                            Set the processing settings
42       -progress                                Display progress along with the position
43       -remove                                  Remove the most recent cut
44       -repeat times                            Repeat the last cut
45       -query                                   List all of the registered services
46       -query "consumers" | "consumer"=id       List consumers or show info about one
47       -query "filters" | "filter"=id           List filters or show info about one
48       -query "producers" | "producer"=id       List producers or show info about one
49       -query "transitions" | "transition"=id   List transitions or show info about one
50       -query "profile" | "profile"=id          List profiles or show info about one
51       -serialise [filename]                    Write the commands to a text file
52       -silent                                  Do not display position/transport help
53       -split relative-frame                    Split the last cut into two cuts
54       -swap                                    Rearrange the last two cuts
55       -track                                   Add a track
56       -transition id[:arg] [name=value]*       Add a transition
57       -verbose                                 Set the logging level to verbose
58       -version                                 Show the version and copyright message
59       -video-track | -hide-audio               Add a video-only track
60
61
62 General rules:
63
64         1. Order is incredibly important;
65
66         2. Error checking on command line parsing is weak;
67
68         3. Please refer to services.txt for details on services available;
69
70         4. The MLT framework, from which melt has inherited its naming convention,
71         is very mlt-centric. Producers produce MLT frame objects and consumers 
72         consume MLT frame objects.  The distinction is important - a DV producer 
73         does not produce DV, it produces MLT frames from a DV source, and similarly
74         a DV consumer does not consume DV, it consumes MLT frames and produces DV
75         frames.
76
77
78 Terminology:
79
80         'Producers' typically refer to files but may also indicate devices (such as
81         dv1394 input or video4linux). Hence, the more generic term is used [the more 
82         generic usage is out of scope for now...].
83
84         'Filters' are frame modifiers - they always guarantee that for every frame 
85         they receive, they output *precisely* one frame.  Never more, never less, 
86         ever. Nothing says that a filter cannot generate frames though
87         
88         'Transitions' collect frames from two tracks (a and b) and output 1 
89         modified frame on their 'a track', and 1 unmodified frame on their 'b track'.
90         Never more, never less, ever.
91         
92         'Consumers' collect frames from a producer, do something with them and
93         destroy them.
94         
95         Collectively, these are known as 'services'. 
96         
97         All services have 'properties' associated to them. These are typically
98         defaulted or evaluated and may be overriden on a case by case basis.
99         
100         All services except consumers obey in and out properties.
101         
102         Consumers have no say in the flow of frames [though they may give the
103         illusion that they do]. They get frames from a connected producer, use them, 
104         destroy them and get more.
105
106
107 Basics:
108
109         To play a file with the default SDL PAL consumer, usage is:
110         
111         $ melt file
112
113         Note that 'file' can be anything that melt has a known 'producer' mapping 
114         for (so this can be anything from .dv to .txt).
115
116         You can also specify the producer directly, for example:
117
118         $ melt avformat:file.mpeg
119
120         Would force the direct use of avformat for loading the file.
121
122
123 Properties:
124
125         Properties can be assigned to the producer by adding additional name=value
126         pairs after the producer:
127         
128         $ melt file in=50 out=100 something="something else"
129         
130         Note that while some properties have meaning to all producers (for example:
131         in, out and length are guaranteed to be valid for all, though typically, 
132         length is determined automatically), the validity of others are dependent on 
133         the producer - however, properties will always be assigned and silently 
134         ignored if they won't be used.
135
136
137 Multiple Files:
138
139         Multiple files of different types can be used:
140         
141         $ melt a.dv b.mpg c.png
142         
143         Properties can be assigned to each file:
144         
145         $ melt a.dv in=50 out=100 b.mpg out=500 c.png out=500
146
147         MLT will take care of 'normalising' the output of a producer to ensure
148         that the consumer gets what it needs. So, in the case above, the mlt
149         framework will ensure that images are rescaled and audio resampled to meet
150         the requirements of your configuration (which, by default, will be PAL).
151         See 'Appendix A: Normalisation Rules' below.
152
153
154 Filters:
155
156         Filters are frame modifiers - they can change the contents of the audio or
157         the images associated to a frame.
158
159         $ melt a.dv -filter greyscale
160
161         As with producers, properties may be specified on filters too.
162         
163         Again, in and out properties are common to all, so to apply a filter to a
164         range of frames, you would use something like:
165         
166         $ melt a.dv -filter greyscale in=0 out=50
167         
168         Again, filters have their own set of rules about properties and will
169         silently ignore properties that do not apply.
170
171
172 Groups:
173
174         The -group switch is provided to force default properties on the following
175         'services'. For example:
176         
177         $ melt -group in=0 out=49 clip*
178         
179         would play the first 50 frames of all clips that match the wild card
180         pattern.
181         
182         Note that the last -group settings also apply to the following filters, 
183         transitions and consumers, so:
184         
185         $ melt -group in=0 out=49 clip* -filter greyscale
186         
187         is *probably not* what you want (ie: the greyscale filter would only be 
188         applied to the first 50 frames).
189         
190         To shed the group properties, you can use any empty group:
191         
192         $ melt -group in=0 out=49 clip* -group -filter greyscale
193
194
195 Attached Filters:
196
197         As described above, the -filter switch applies filters to an entire track. To
198         localise filters to a specific clip on a track, you have to know information
199         about the lengths of the clip and all clips leading up to it. In practise, 
200         this is horrifically impractical, especially at a command line level (and not
201         even that practical from a programing point of view...).
202
203         The -attach family of switches simplify things enormously. By default, -attach
204         will attach a filter to the last service created, so:
205
206         $ melt clip1.dv clip2.dv -attach greyscale clip3.dv
207
208         would only apply the filter to clip2.dv. You can further narrow down the area of
209         the effect by specifying in/out points on the attached filter.
210
211         This might seem simple so far, but there is a catch... consider the following:
212
213         $ melt clip1.dv -attach watermark:+hello.txt -attach invert
214
215         The second attached filter is actually attached to the watermark. You might 
216         think, yay, nice (and it is :-)), but, it might not be what you want. For example
217         you might want to attach both to clip1.dv. To do that, you can use:
218
219         $ melt clip1.dv -attach-cut watermark:+hello.txt -attach-cut invert
220
221         As you shall see below, there are still another couple of gotchas associated to 
222         -attach, and even another variant :-).
223
224
225 Mixes:
226
227         The -mix switch provides the simplest means to introduce transitions between
228         adjacent clips.
229
230         For example:
231
232         $ melt clip1.dv clip2.dv -mix 25 -mixer luma -mixer mix:-1
233
234         would provide both an audio and video transition between clip1 and clip2.
235
236         This functionality supercedes the enforced use of the -track and -transition
237         switches from earlier versions of melt and makes life a lot easier :-).
238
239         These can be used in combination, so you can for example do a fade from black
240         and to black using the following:
241
242         $ melt colour:black out=24 clip1.dv -mix 25 -mixer luma \
243                 colour:black out=24 -mix 25 -mixer luma 
244         
245         while this may not be immediately obvious, consider what's happening as the 
246         command line is being parsed from left to right:
247
248         Input:                  Track
249         ----------------------- -----------------------------------------------------
250         colour:black out=24     [black]
251         clip1.dv                [black][clip1.dv]
252         -mix 25                 [black+clip1.dv][clip1.dv]
253         -mixer luma             [luma:black+clip1.dv][clip1.dv]
254         colour:black out=24     [luma:black+clip1.dv][clip1.dv][black]
255         -mix 25                 [luma:black+clip1.dv][clip1.dv][clip1.dv+black]
256         -mixer luma             [luma:black+clip1.dv][clip1.dv][luma:clip1.dv+black]
257
258         Obviously, the clip1.dv instances refer to different parts of the clip, but 
259         hopefully that will demonstrate what happens as we construct the track.
260
261         You will find more details on the mix in the framework.txt.
262
263
264 Mix and Attach:
265
266         As noted, -attach normally applies to the last created service - so, you can 
267         attach a filter to the transition region using:
268
269         $ melt clip1.dv clip2.dv -mix 25 -mixer luma -attach watermark:+Transition.txt
270
271         Again, nice, but take care - if you want the attached filter to be associated
272         to the region following the transition, use -attach-cut instead.
273
274
275 Splits, Joins, Removes and Swaps:
276
277         COMPLEX - needs simplification....
278
279
280 Introducing Tracks and Blanks:
281
282         So far, all of the examples have shown the definition of a single
283         playlist, or more accurately, track.
284
285         When multiple tracks exist, the consumer will receive a frame
286         from the 'highest numbered' track that is generating a non-blank
287         frame.
288         
289         It is best to visualise a track arrangement, so we'll start with
290         an example:
291         
292         $ melt a.dv -track b.dv in=0 out=49
293         
294         This can be visualised as follows:
295         
296         +------------------+
297         |a                 |
298         +-------+----------+
299         |b      |
300         +-------+
301
302         Playout will show the first 50 frames of b and the 51st frame shown will be
303         the 51st frame of a.
304
305         This rule also applies to audio only producers on the second track, for
306         example, the following would show the video from the a track, but the audio
307         would come from the second track:
308
309         $ melt a.dv -track b.mp3 in=0 out=49
310
311         To have the 51st frame be the first frame of b, we can use the -blank switch:
312         
313         $ melt a.dv out=49 -track -blank 49 b.dv
314         
315         Which we can visualise as:
316         
317         +-------+
318         |a      |
319         +-------+-------------------+
320                 |b                  |
321                 +-------------------+
322         
323         Now playout will continue as though a and b clips are on the
324         same track (which on its own, is about as useful as reversing the 
325         process of slicing bread).
326
327
328 Transitions:
329
330         Where tracks become useful is in the placing of transitions.
331         
332         Here we need tracks to overlap, so a useful multitrack
333         definition could be given as:
334         
335         $ melt a.dv out=49 \
336                 -track \
337                 -blank 24 b.dv \
338                 -transition luma in=25 out=49 a_track=0 b_track=1
339         
340         Now we're cooking - our visualisation would be something like:
341         
342         +-------+
343         |a      |
344         +---+---+--------------+
345             |b                 |
346             +------------------+
347         
348         Playout will now show the first 25 frames of a and then a fade
349         transition for 25 frames between a and b, and will finally
350         playout the remainder of b.
351
352
353 Reversing a Transition:
354
355         When we visualise a track definition, we also see situations
356         like:
357         
358         +-------+              +----------+
359         |a1     |              |a2        |
360         +---+---+--------------+----+-----+
361             |b                      |
362             +-----------------------+
363         
364         In this case, we have two transitions, a1 to b and b to a2. 
365         
366         In this scenario, we define a command line as follows:
367         
368         $ melt a.dv out=49 -blank 49 a2.dv \
369                 -track \
370                 -blank 24 b.dv out=99 \
371                 -transition luma in=25 out=49 a_track=0 b_track=1 \
372                 -transition luma in=100 out=124 reverse=1 a_track=0 b_track=1
373
374
375 Serialisation:
376
377         Melt has a built in serialisation mechanism - you can build up
378         your command, test it via any consumer and then add a -serialise
379         file.melt switch to save it.
380         
381         The saved file can be subsequently used as a clip by melt or other
382         MLT applications. Take care though - paths to files are saved as
383         provided on the command line....
384
385         A more expressive serialisation can be obtained with the xml consumer
386         - this will provide an xml document which can be used freely in melt and
387         other MLT applications.
388
389         See mlt-xml.txt for more information.
390
391
392 Missing Features:
393
394         Some filters/transitions should be applied on the output frame regardless
395         of which track it comes from - for example, you might have a 3rd text 
396         track or a watermark which you want composited on every frame, and of 
397         course, there's the obscure filter.... 
398         
399         melt only supports this in two invocations - as a simple example:
400
401         $ melt a.dv -track -blank 100 b.dv -consumer xml:basic.mlt
402         $ melt basic.mlt -filter watermark:watermark.png
403