]> git.sesse.net Git - mlt/blob - src/melt/melt.c
Add an automatic profile feature to melt.
[mlt] / src / melt / melt.c
1 /*
2  * melt.c -- MLT command line utility
3  * Copyright (C) 2002-2010 Ushodaya Enterprises Limited
4  * Authors: Charles Yates <charles.yates@pandora.be>
5  *          Dan Dennedy <dan@dennedy.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef _GNU_SOURCE
23 #define _GNU_SOURCE
24 #endif
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sched.h>
29 #include <libgen.h>
30 #include <limits.h>
31
32 #include <framework/mlt.h>
33
34 #ifdef __DARWIN__
35 #include <SDL.h>
36 #endif
37
38 #include "io.h"
39
40 static void transport_action( mlt_producer producer, char *value )
41 {
42         mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
43         mlt_multitrack multitrack = mlt_properties_get_data( properties, "multitrack", NULL );
44         mlt_consumer consumer = mlt_properties_get_data( properties, "transport_consumer", NULL );
45
46         mlt_properties_set_int( properties, "stats_off", 1 );
47
48         if ( strlen( value ) == 1 )
49         {
50                 switch( value[ 0 ] )
51                 {
52                         case 'q':
53                                 mlt_properties_set_int( properties, "done", 1 );
54                                 break;
55                         case '0':
56                                 mlt_producer_set_speed( producer, 1 );
57                                 mlt_producer_seek( producer, 0 );
58                                 break;
59                         case '1':
60                                 mlt_producer_set_speed( producer, -10 );
61                                 break;
62                         case '2':
63                                 mlt_producer_set_speed( producer, -5 );
64                                 break;
65                         case '3':
66                                 mlt_producer_set_speed( producer, -2 );
67                                 break;
68                         case '4':
69                                 mlt_producer_set_speed( producer, -1 );
70                                 break;
71                         case '5':
72                                 mlt_producer_set_speed( producer, 0 );
73                                 break;
74                         case '6':
75                         case ' ':
76                                 mlt_producer_set_speed( producer, 1 );
77                                 break;
78                         case '7':
79                                 mlt_producer_set_speed( producer, 2 );
80                                 break;
81                         case '8':
82                                 mlt_producer_set_speed( producer, 5 );
83                                 break;
84                         case '9':
85                                 mlt_producer_set_speed( producer, 10 );
86                                 break;
87                         case 'd':
88                                 if ( multitrack != NULL )
89                                 {
90                                         int i = 0;
91                                         mlt_position last = -1;
92                                         fprintf( stderr, "\n" );
93                                         for ( i = 0; 1; i ++ )
94                                         {
95                                                 mlt_position time = mlt_multitrack_clip( multitrack, mlt_whence_relative_start, i );
96                                                 if ( time == last )
97                                                         break;
98                                                 last = time;
99                                                 fprintf( stderr, "%d: %d\n", i, (int)time );
100                                         }
101                                 }
102                                 break;
103
104                         case 'g':
105                                 if ( multitrack != NULL )
106                                 {
107                                         mlt_position time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 0 );
108                                         mlt_producer_seek( producer, time );
109                                 }
110                                 break;
111                         case 'H':
112                                 if ( producer != NULL )
113                                 {
114                                         mlt_position position = mlt_producer_position( producer );
115                                         mlt_producer_seek( producer, position - ( mlt_producer_get_fps( producer ) * 60 ) );
116                                 }
117                                 break;
118                         case 'h':
119                                 if ( producer != NULL )
120                                 {
121                                         mlt_position position = mlt_producer_position( producer );
122                                         mlt_producer_set_speed( producer, 0 );
123                                         mlt_producer_seek( producer, position - 1 );
124                                 }
125                                 break;
126                         case 'j':
127                                 if ( multitrack != NULL )
128                                 {
129                                         mlt_position time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 );
130                                         mlt_producer_seek( producer, time );
131                                 }
132                                 break;
133                         case 'k':
134                                 if ( multitrack != NULL )
135                                 {
136                                         mlt_position time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, -1 );
137                                         mlt_producer_seek( producer, time );
138                                 }
139                                 break;
140                         case 'l':
141                                 if ( producer != NULL )
142                                 {
143                                         mlt_position position = mlt_producer_position( producer );
144                                         if ( mlt_producer_get_speed( producer ) != 0 )
145                                                 mlt_producer_set_speed( producer, 0 );
146                                         else
147                                                 mlt_producer_seek( producer, position + 1 );
148                                 }
149                                 break;
150                         case 'L':
151                                 if ( producer != NULL )
152                                 {
153                                         mlt_position position = mlt_producer_position( producer );
154                                         mlt_producer_seek( producer, position + ( mlt_producer_get_fps( producer ) * 60 ) );
155                                 }
156                                 break;
157                 }
158
159                 mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "refresh", 1 );
160         }
161
162         mlt_properties_set_int( properties, "stats_off", 0 );
163 }
164
165 static mlt_consumer create_consumer( mlt_profile profile, char *id )
166 {
167         char *myid = id ? strdup( id ) : NULL;
168         char *arg = myid ? strchr( myid, ':' ) : NULL;
169         if ( arg != NULL )
170                 *arg ++ = '\0';
171         mlt_consumer consumer = mlt_factory_consumer( profile, myid, arg );
172         if ( consumer != NULL )
173         {
174                 mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
175                 mlt_properties_set_data( properties, "transport_callback", transport_action, 0, NULL, NULL );
176         }
177         if ( myid )
178                 free( myid );
179         return consumer;
180 }
181
182 #ifdef __DARWIN__
183
184 static void event_handling( mlt_producer producer, mlt_consumer consumer )
185 {
186         SDL_Event event;
187
188         while ( SDL_PollEvent( &event ) )
189         {
190                 switch( event.type )
191                 {
192                         case SDL_QUIT:
193                                 mlt_properties_set_int( MLT_PRODUCER_PROPERTIES( consumer ), "done", 1 );
194                                 break;
195
196                         case SDL_KEYDOWN:
197                                 if ( event.key.keysym.unicode < 0x80 && event.key.keysym.unicode > 0 )
198                                 {
199                                         char keyboard[ 2 ] = { event.key.keysym.unicode, 0 };
200                                         transport_action( producer, keyboard );
201                                 }
202                                 break;
203                 }
204         }
205 }
206
207 #endif
208
209 static void transport( mlt_producer producer, mlt_consumer consumer )
210 {
211         mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
212         int silent = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "silent" );
213         int progress = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "progress" );
214         struct timespec tm = { 0, 40000 };
215         int total_length = mlt_producer_get_length( producer );
216         int last_position = 0;
217
218         if ( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) )
219         {
220                 if ( !silent && !progress )
221                 {
222                         term_init( );
223
224                         fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
225                         fprintf( stderr, "|1=-10| |2= -5| |3= -2| |4= -1| |5=  0| |6=  1| |7=  2| |8=  5| |9= 10|\n" );
226                         fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
227
228                         fprintf( stderr, "+---------------------------------------------------------------------+\n" );
229                         fprintf( stderr, "|               H = back 1 minute,  L = forward 1 minute              |\n" );
230                         fprintf( stderr, "|                 h = previous frame,  l = next frame                 |\n" );
231                         fprintf( stderr, "|           g = start of clip, j = next clip, k = previous clip       |\n" );
232                         fprintf( stderr, "|                0 = restart, q = quit, space = play                  |\n" );
233                         fprintf( stderr, "+---------------------------------------------------------------------+\n" );
234                 }
235
236                 while( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) )
237                 {
238                         int value = ( silent || progress )? -1 : term_read( );
239
240                         if ( value != -1 )
241                         {
242                                 char string[ 2 ] = { value, 0 };
243                                 transport_action( producer, string );
244                         }
245
246 #ifdef __DARWIN__
247                         event_handling( producer, consumer );
248 #endif
249
250                         if ( !silent && mlt_properties_get_int( properties, "stats_off" ) == 0 )
251                         {
252                                 if ( progress )
253                                 {
254                                         int current_position = mlt_producer_position( producer );
255                                         if ( current_position > last_position )
256                                         {
257                                                 fprintf( stderr, "Current Frame: %10d, percentage: %10d\r",
258                                                         current_position, 100 * current_position / total_length );
259                                                 last_position = current_position;
260                                         }
261                                 }
262                                 else
263                                 {
264                                         fprintf( stderr, "Current Position: %10d\r", (int)mlt_producer_position( producer ) );
265                                 }
266                         }
267
268                         if ( silent || progress )
269                                 nanosleep( &tm, NULL );
270                 }
271
272                 if ( !silent )
273                         fprintf( stderr, "\n" );
274         }
275 }
276
277 static void guess_profile( mlt_producer melt, mlt_profile profile )
278 {
279         mlt_frame fr = NULL;
280         uint8_t *buffer;
281         mlt_image_format fmt = mlt_image_yuv422;
282         mlt_properties p;
283         int w, h;
284
285         if ( ! mlt_service_get_frame( MLT_PRODUCER_SERVICE(melt), &fr, 0 ) && fr )
286         {
287                 if ( ! mlt_frame_get_image( fr, &buffer, &fmt, &w, &h, 0 ) )
288                 {
289                         // Some source properties are not exposed until after the first get_image call.
290                         mlt_frame_close( fr );
291                         mlt_service_get_frame( MLT_PRODUCER_SERVICE(melt), &fr, 0 );
292                         p = MLT_FRAME_PROPERTIES( fr );
293                         if ( mlt_properties_get_int( p, "meta.media.width" ) )
294                         {
295                                 profile->width = mlt_properties_get_int( p, "meta.media.width" );
296                                 profile->height = mlt_properties_get_int( p, "meta.media.height" );
297                                 profile->progressive = mlt_properties_get_int( p, "meta.media.progressive" );
298                                 profile->frame_rate_num = mlt_properties_get_int( p, "meta.media.frame_rate_num" );
299                                 profile->frame_rate_den = mlt_properties_get_int( p, "meta.media.frame_rate_den" );
300                                 profile->sample_aspect_num = mlt_properties_get_int( p, "meta.media.sample_aspect_num" );
301                                 profile->sample_aspect_den = mlt_properties_get_int( p, "meta.media.sample_aspect_den" );
302                                 profile->display_aspect_num = (int) ( (double) profile->sample_aspect_num * profile->width / profile->sample_aspect_den + 0.5 );
303                                 profile->display_aspect_den = profile->height;
304                         }
305                 }
306         }
307         mlt_frame_close( fr );
308         mlt_producer_seek( melt, 0 );
309 }
310
311 static void query_metadata( mlt_repository repo, mlt_service_type type, const char *typestr, char *id )
312 {
313         mlt_properties metadata = mlt_repository_metadata( repo, type, id );
314         if ( metadata )
315         {
316                 char *s = mlt_properties_serialise_yaml( metadata );
317                 fprintf( stderr, "%s", s );
318                 free( s );
319         }
320         else
321         {
322                 fprintf( stderr, "# No metadata for %s \"%s\"\n", typestr, id );
323         }
324 }
325
326 static void query_services( mlt_repository repo, mlt_service_type type )
327 {
328         mlt_properties services = NULL;
329         const char *typestr = NULL;
330         switch ( type )
331         {
332                 case consumer_type:
333                         services = mlt_repository_consumers( repo );
334                         typestr = "consumers";
335                         break;
336                 case filter_type:
337                         services = mlt_repository_filters( repo );
338                         typestr = "filters";
339                         break;
340                 case producer_type:
341                         services = mlt_repository_producers( repo );
342                         typestr = "producers";
343                         break;
344                 case transition_type:
345                         services = mlt_repository_transitions( repo );
346                         typestr = "transitions";
347                         break;
348                 default:
349                         return;
350         }
351         fprintf( stderr, "---\n%s:\n", typestr );
352         if ( services )
353         {
354                 int j;
355                 for ( j = 0; j < mlt_properties_count( services ); j++ )
356                         fprintf( stderr, "  - %s\n", mlt_properties_get_name( services, j ) );
357         }
358         fprintf( stderr, "...\n" );
359 }
360
361 int main( int argc, char **argv )
362 {
363         int i;
364         mlt_consumer consumer = NULL;
365         mlt_producer melt = NULL;
366         FILE *store = NULL;
367         char *name = NULL;
368         mlt_profile profile = NULL;
369         mlt_profile backup_profile = NULL;
370         int is_progress = 0;
371         int is_silent = 0;
372         int is_profile_explicit = 0;
373
374         // Construct the factory
375         mlt_repository repo = mlt_factory_init( NULL );
376
377         for ( i = 1; i < argc; i ++ )
378         {
379                 // Check for serialisation switch
380                 if ( !strcmp( argv[ i ], "-serialise" ) )
381                 {
382                         name = argv[ ++ i ];
383                         if ( name != NULL && strstr( name, ".melt" ) )
384                                 store = fopen( name, "w" );
385                         else
386                         {
387                                 if ( name == NULL || name[0] == '-' )
388                                         store = stdout;
389                                 name = NULL;
390                         }
391                 }
392                 // Look for the profile option
393                 else if ( !strcmp( argv[ i ], "-profile" ) )
394                 {
395                         const char *pname = argv[ ++ i ];
396                         if ( pname && pname[0] != '-' )
397                                 profile = mlt_profile_init( pname );
398                 }
399                 else if ( !strcmp( argv[ i ], "-progress" ) )
400                 {
401                         is_progress = 1;
402                 }
403                 // Look for the query option
404                 else if ( !strcmp( argv[ i ], "-query" ) )
405                 {
406                         const char *pname = argv[ ++ i ];
407                         if ( pname && pname[0] != '-' )
408                         {
409                                 if ( !strcmp( pname, "consumers" ) || !strcmp( pname, "consumer" ) )
410                                         query_services( repo, consumer_type );
411                                 else if ( !strcmp( pname, "filters" ) || !strcmp( pname, "filter" ) )
412                                         query_services( repo, filter_type );
413                                 else if ( !strcmp( pname, "producers" ) || !strcmp( pname, "producer" ) )
414                                         query_services( repo, producer_type );
415                                 else if ( !strcmp( pname, "transitions" ) || !strcmp( pname, "transition" ) )
416                                         query_services( repo, transition_type );
417                                 
418                                 else if ( !strncmp( pname, "consumer=", 9 ) )
419                                         query_metadata( repo, consumer_type, "consumer", strchr( pname, '=' ) + 1 );
420                                 else if ( !strncmp( pname, "filter=", 7 ) )
421                                         query_metadata( repo, filter_type, "filter", strchr( pname, '=' ) + 1 );
422                                 else if ( !strncmp( pname, "producer=", 9 ) )
423                                         query_metadata( repo, producer_type, "producer", strchr( pname, '=' ) + 1 );
424                                 else if ( !strncmp( pname, "transition=", 11 ) )
425                                         query_metadata( repo, transition_type, "transition", strchr( pname, '=' ) + 1 );
426                                 else
427                                         goto query_all;
428                         }
429                         else
430                         {
431 query_all:
432                                 query_services( repo, consumer_type );
433                                 query_services( repo, filter_type );
434                                 query_services( repo, producer_type );
435                                 query_services( repo, transition_type );
436                                 fprintf( stderr, "# You can query the metadata for a specific service using:\n"
437                                         "# -query <type>=<identifer>\n"
438                                         "# where <type> is one of: consumer, filter, producer, or transition.\n" );
439                         }
440                         goto exit_factory;
441                 }
442                 else if ( !strcmp( argv[ i ], "-silent" ) )
443                 {
444                         is_silent = 1;
445                 }
446                 else if ( !strcmp( argv[ i ], "-verbose" ) )
447                 {
448                         mlt_log_set_level( MLT_LOG_VERBOSE );
449                 }
450                 else if ( !strcmp( argv[ i ], "-version" ) || !strcmp( argv[ i ], "--version" ) )
451                 {
452                         fprintf( stderr, "MLT %s " VERSION "\n"
453                                 "Copyright (C) 2002-2010 Ushodaya Enterprises Limited\n"
454                                 "<http://www.mltframework.org/>\n"
455                                 "This is free software; see the source for copying conditions.  There is NO\n"
456                                 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
457                                 basename( argv[0] ) );
458                         goto exit_factory;
459                 }
460                 else if ( !strcmp( argv[ i ], "-debug" ) )
461                 {
462                         mlt_log_set_level( MLT_LOG_DEBUG );
463                 }
464         }
465
466         // Create profile if not set explicitly
467         if ( profile == NULL )
468                 profile = mlt_profile_init( NULL );
469         else
470                 is_profile_explicit = 1;
471
472         // Look for the consumer option to load profile settings from consumer properties
473         for ( i = 1; i < argc; i ++ )
474         {
475                 if ( !strcmp( argv[ i ], "-consumer" ) )
476                 {
477                         consumer = create_consumer( profile, argv[ ++ i ] );
478                         if ( consumer )
479                         {
480                                 mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
481                                 while ( argv[ i + 1 ] != NULL && strstr( argv[ i + 1 ], "=" ) )
482                                         mlt_properties_parse( properties, argv[ ++ i ] );
483                         }
484                 }
485         }
486
487         // Make backup of profile for determining if we need to use 'consumer' producer.
488         backup_profile = mlt_profile_init( NULL );
489         memcpy( backup_profile, profile, sizeof( struct mlt_profile_s ) );
490         backup_profile->description = strdup( "" );
491
492         // Get melt producer
493         if ( argc > 1 )
494                 melt = mlt_factory_producer( profile, "melt", &argv[ 1 ] );
495
496         if ( melt )
497         {
498                 // If the producer changed the profile then do not try to guess it.
499                 if ( profile->width != backup_profile->width ||
500                      profile->height != backup_profile->height ||
501                      profile->sample_aspect_num != backup_profile->sample_aspect_num ||
502                      profile->sample_aspect_den != backup_profile->sample_aspect_den )
503                 {
504                         if ( is_profile_explicit )
505                         {
506                                 // We need to use the 'consumer' producer.
507                                 mlt_producer_close( melt );
508                                 mlt_profile_close( profile );
509                                 profile = backup_profile;
510                                 backup_profile = NULL;
511                                 if ( profile->description )
512                                         free( profile->description );
513                                 // This is a hack to signal create_producer() in producer_melt.c.
514                                 profile->description = strdup( "consumer:" );
515                                 melt = mlt_factory_producer( profile, "melt", &argv[ 1 ] );
516                         }
517                 }
518                 else if ( ! is_profile_explicit )
519                 {
520                         guess_profile( melt, profile );
521                 }
522
523                 // Reload the consumer with the fully qualified profile
524                 for ( i = 1; i < argc; i ++ )
525                 {
526                         if ( !strcmp( argv[ i ], "-consumer" ) )
527                         {
528                                 if ( consumer )
529                                         mlt_consumer_close( consumer );
530                                 consumer = create_consumer( profile, argv[ ++ i ] );
531                                 if ( consumer )
532                                 {
533                                         mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
534                                         while ( argv[ i + 1 ] != NULL && strstr( argv[ i + 1 ], "=" ) )
535                                                 mlt_properties_parse( properties, argv[ ++ i ] );
536                                 }
537                         }
538                 }
539
540                 // If we have no consumer, default to sdl
541                 if ( store == NULL && consumer == NULL )
542                         consumer = create_consumer( profile, NULL );
543         }
544         
545         // Set transport properties on consumer and produder
546         if ( consumer != NULL && melt != NULL )
547         {
548                 mlt_properties_set_data( MLT_CONSUMER_PROPERTIES( consumer ), "transport_producer", melt, 0, NULL, NULL );
549                 mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( melt ), "transport_consumer", consumer, 0, NULL, NULL );
550                 if ( is_progress )
551                         mlt_properties_set_int(  MLT_CONSUMER_PROPERTIES( consumer ), "progress", is_progress );
552                 if ( is_silent )
553                         mlt_properties_set_int(  MLT_CONSUMER_PROPERTIES( consumer ), "silent", is_silent );
554         }
555
556         if ( argc > 1 && melt != NULL && mlt_producer_get_length( melt ) > 0 )
557         {
558                 // Parse the arguments
559                 for ( i = 1; i < argc; i ++ )
560                 {
561                         if ( !strcmp( argv[ i ], "-serialise" ) )
562                         {
563                                 if ( store != stdout )
564                                         i ++;
565                         }
566                         else
567                         {
568                                 if ( store != NULL )
569                                         fprintf( store, "%s\n", argv[ i ] );
570
571                                 i ++;
572
573                                 while ( argv[ i ] != NULL && argv[ i ][ 0 ] != '-' )
574                                 {
575                                         if ( store != NULL )
576                                                 fprintf( store, "%s\n", argv[ i ] );
577                                         i += 1;
578                                 }
579
580                                 i --;
581                         }
582                 }
583
584                 if ( consumer != NULL && store == NULL )
585                 {
586                         // Get melt's properties
587                         mlt_properties melt_props = MLT_PRODUCER_PROPERTIES( melt );
588         
589                         // Get the last group
590                         mlt_properties group = mlt_properties_get_data( melt_props, "group", 0 );
591         
592                         // Apply group settings
593                         mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
594                         mlt_properties_inherit( properties, group );
595
596                         // Connect consumer to melt
597                         mlt_consumer_connect( consumer, MLT_PRODUCER_SERVICE( melt ) );
598
599                         // Start the consumer
600                         mlt_consumer_start( consumer );
601
602                         // Transport functionality
603                         transport( melt, consumer );
604
605                         // Stop the consumer
606                         mlt_consumer_stop( consumer );
607                 }
608                 else if ( store != NULL && store != stdout && name != NULL )
609                 {
610                         fprintf( stderr, "Project saved as %s.\n", name );
611                         fclose( store );
612                 }
613         }
614         else
615         {
616                 fprintf( stderr,
617 "Usage: %s [options] [producer [name=value]* ]+\n"
618 "Options:\n"
619 "  -attach filter[:arg] [name=value]*       Attach a filter to the output\n"
620 "  -attach-cut filter[:arg] [name=value]*   Attach a filter to a cut\n"
621 "  -attach-track filter[:arg] [name=value]* Attach a filter to a track\n"
622 "  -attach-clip filter[:arg] [name=value]*  Attach a filter to a producer\n"
623 "  -audio-track | -hide-video               Add an audio-only track\n"
624 "  -blank frames                            Add blank silence to a track\n"
625 "  -consumer id[:arg] [name=value]*         Set the consumer (sink)\n"
626 "  -debug                                   Set the logging level to debug\n"
627 "  -filter filter[:arg] [name=value]*       Add a filter to the current track\n"
628 "  -group [name=value]*                     Apply properties repeatedly\n"
629 "  -help                                    Show this message\n"
630 "  -join clips                              Join multiple clips into one cut\n"
631 "  -mix length                              Add a mix between the last two cuts\n"
632 "  -mixer transition                        Add a transition to the mix\n"
633 "  -null-track | -hide-track                Add a hidden track\n"
634 "  -profile name                            Set the processing settings\n"
635 "  -progress                                Display progress along with position\n"
636 "  -remove                                  Remove the most recent cut\n"
637 "  -repeat times                            Repeat the last cut\n"
638 "  -query                                   List all of the registered services\n"
639 "  -query \"consumers\" | \"consumer\"=id       List consumers or show info about one\n"
640 "  -query \"filters\" | \"filter\"=id           List filters or show info about one\n"
641 "  -query \"producers\" | \"producer\"=id       List producers or show info about one\n"
642 "  -query \"transitions\" | \"transition\"=id   List transitions, show info about one\n"
643 "  -serialise [filename]                    Write the commands to a text file\n"
644 "  -silent                                  Do not display position/transport\n"
645 "  -split relative-frame                    Split the last cut into two cuts\n"
646 "  -swap                                    Rearrange the last two cuts\n"
647 "  -track                                   Add a track\n"
648 "  -transition id[:arg] [name=value]*       Add a transition\n"
649 "  -verbose                                 Set the logging level to verbose\n"
650 "  -version                                 Show the version and copyright\n"
651 "  -video-track | -hide-audio               Add a video-only track\n"
652 "For more help: <http://www.mltframework.org/>\n",
653                 basename( argv[0] ) );
654         }
655
656         // Close the producer
657         if ( melt != NULL )
658                 mlt_producer_close( melt );
659
660         // Close the consumer
661         if ( consumer != NULL )
662                 mlt_consumer_close( consumer );
663
664         // Close the factory
665         mlt_profile_close( profile );
666         mlt_profile_close( backup_profile );
667
668 exit_factory:
669                 
670         mlt_factory_close( );
671
672         return 0;
673 }