2 * melt.c -- MLT command line utility
3 * Copyright (C) 2002-2011 Ushodaya Enterprises Limited
4 * Authors: Charles Yates <charles.yates@pandora.be>
5 * Dan Dennedy <dan@dennedy.org>
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.
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.
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.
33 #include <framework/mlt.h>
35 #if defined(__DARWIN__) || defined(WIN32)
41 static void transport_action( mlt_producer producer, char *value )
43 mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
44 mlt_multitrack multitrack = mlt_properties_get_data( properties, "multitrack", NULL );
45 mlt_consumer consumer = mlt_properties_get_data( properties, "transport_consumer", NULL );
46 mlt_properties jack = mlt_properties_get_data( MLT_CONSUMER_PROPERTIES( consumer ), "jack_filter", NULL );
47 mlt_position position = mlt_producer_position( producer );
49 mlt_properties_set_int( properties, "stats_off", 1 );
51 if ( strlen( value ) == 1 )
57 mlt_properties_set_int( properties, "done", 1 );
58 mlt_events_fire( jack, "jack-stop", NULL );
62 mlt_producer_set_speed( producer, 1 );
63 mlt_producer_seek( producer, position );
64 mlt_consumer_purge( consumer );
65 mlt_events_fire( jack, "jack-seek", &position, NULL );
68 mlt_producer_set_speed( producer, -10 );
71 mlt_producer_set_speed( producer, -5 );
74 mlt_producer_set_speed( producer, -2 );
77 mlt_producer_set_speed( producer, -1 );
80 mlt_producer_set_speed( producer, 0 );
81 mlt_consumer_purge( consumer );
82 mlt_events_fire( jack, "jack-stop", NULL );
86 if ( !jack || mlt_producer_get_speed( producer ) != 0 )
87 mlt_producer_set_speed( producer, 1 );
88 mlt_consumer_purge( consumer );
89 mlt_events_fire( jack, "jack-start", NULL );
92 mlt_producer_set_speed( producer, 2 );
95 mlt_producer_set_speed( producer, 5 );
98 mlt_producer_set_speed( producer, 10 );
101 if ( multitrack != NULL )
104 mlt_position last = -1;
105 fprintf( stderr, "\n" );
106 for ( i = 0; 1; i ++ )
108 position = mlt_multitrack_clip( multitrack, mlt_whence_relative_start, i );
109 if ( position == last )
112 fprintf( stderr, "%d: %d\n", i, (int)position );
118 if ( multitrack != NULL )
120 position = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 0 );
121 mlt_producer_seek( producer, position );
122 mlt_consumer_purge( consumer );
123 mlt_events_fire( jack, "jack-seek", &position, NULL );
127 if ( producer != NULL )
129 position -= mlt_producer_get_fps( producer ) * 60;
130 mlt_consumer_purge( consumer );
131 mlt_producer_seek( producer, position );
132 mlt_events_fire( jack, "jack-seek", &position, NULL );
136 if ( producer != NULL )
139 mlt_producer_set_speed( producer, 0 );
140 mlt_consumer_purge( consumer );
141 mlt_producer_seek( producer, position );
142 mlt_events_fire( jack, "jack-stop", NULL );
143 mlt_events_fire( jack, "jack-seek", &position, NULL );
147 if ( multitrack != NULL )
149 position = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 );
150 mlt_consumer_purge( consumer );
151 mlt_producer_seek( producer, position );
152 mlt_events_fire( jack, "jack-seek", &position, NULL );
156 if ( multitrack != NULL )
158 position = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, -1 );
159 mlt_consumer_purge( consumer );
160 mlt_producer_seek( producer, position );
161 mlt_events_fire( jack, "jack-seek", &position, NULL );
165 if ( producer != NULL )
168 mlt_consumer_purge( consumer );
169 if ( mlt_producer_get_speed( producer ) != 0 )
171 mlt_producer_set_speed( producer, 0 );
172 mlt_events_fire( jack, "jack-stop", NULL );
176 mlt_producer_seek( producer, position );
177 mlt_events_fire( jack, "jack-seek", &position, NULL );
182 if ( producer != NULL )
184 position += mlt_producer_get_fps( producer ) * 60;
185 mlt_consumer_purge( consumer );
186 mlt_producer_seek( producer, position );
187 mlt_events_fire( jack, "jack-seek", &position, NULL );
192 mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "refresh", 1 );
195 mlt_properties_set_int( properties, "stats_off", 0 );
198 static void on_jack_started( mlt_properties owner, mlt_consumer consumer, mlt_position *position )
200 mlt_producer producer = mlt_properties_get_data( MLT_CONSUMER_PROPERTIES(consumer), "transport_producer", NULL );
203 if ( mlt_producer_get_speed( producer ) != 0 )
205 mlt_properties jack = mlt_properties_get_data( MLT_CONSUMER_PROPERTIES( consumer ), "jack_filter", NULL );
206 mlt_events_fire( jack, "jack-stop", NULL );
210 mlt_producer_set_speed( producer, 1 );
211 mlt_consumer_purge( consumer );
212 mlt_producer_seek( producer, *position );
213 mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "refresh", 1 );
218 static void on_jack_stopped( mlt_properties owner, mlt_consumer consumer, mlt_position *position )
220 mlt_producer producer = mlt_properties_get_data( MLT_CONSUMER_PROPERTIES(consumer), "transport_producer", NULL );
223 mlt_producer_set_speed( producer, 0 );
224 mlt_consumer_purge( consumer );
225 mlt_producer_seek( producer, *position );
226 mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "refresh", 1 );
230 static void setup_jack_transport( mlt_consumer consumer, mlt_profile profile )
232 mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
233 mlt_filter jack = mlt_factory_filter( profile, "jackrack", NULL );
234 mlt_properties jack_properties = MLT_FILTER_PROPERTIES(jack);
236 mlt_service_attach( MLT_CONSUMER_SERVICE(consumer), jack );
237 mlt_properties_set_int( properties, "audio_off", 1 );
238 mlt_properties_set_data( properties, "jack_filter", jack, 0, (mlt_destructor) mlt_filter_close, NULL );
239 // mlt_properties_set( jack_properties, "out_1", "system:playback_1" );
240 // mlt_properties_set( jack_properties, "out_2", "system:playback_2" );
241 mlt_events_listen( jack_properties, consumer, "jack-started", (mlt_listener) on_jack_started );
242 mlt_events_listen( jack_properties, consumer, "jack-stopped", (mlt_listener) on_jack_stopped );
245 static mlt_consumer create_consumer( mlt_profile profile, char *id )
247 char *myid = id ? strdup( id ) : NULL;
248 char *arg = myid ? strchr( myid, ':' ) : NULL;
251 mlt_consumer consumer = mlt_factory_consumer( profile, myid, arg );
252 if ( consumer != NULL )
254 mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
255 mlt_properties_set_data( properties, "transport_callback", transport_action, 0, NULL, NULL );
262 static void load_consumer( mlt_consumer *consumer, mlt_profile profile, int argc, char **argv )
265 for ( i = 1; i < argc; i ++ )
267 if ( !strcmp( argv[ i ], "-consumer" ) )
270 mlt_consumer_close( *consumer );
271 *consumer = create_consumer( profile, argv[ ++ i ] );
274 mlt_properties properties = MLT_CONSUMER_PROPERTIES( *consumer );
275 while ( argv[ i + 1 ] != NULL && strstr( argv[ i + 1 ], "=" ) )
276 mlt_properties_parse( properties, argv[ ++ i ] );
282 #if defined(__DARWIN__) || defined(WIN32)
284 static void event_handling( mlt_producer producer, mlt_consumer consumer )
288 while ( SDL_PollEvent( &event ) )
293 mlt_properties_set_int( MLT_PRODUCER_PROPERTIES( consumer ), "done", 1 );
297 if ( event.key.keysym.unicode < 0x80 && event.key.keysym.unicode > 0 )
299 char keyboard[ 2 ] = { event.key.keysym.unicode, 0 };
300 transport_action( producer, keyboard );
309 static void transport( mlt_producer producer, mlt_consumer consumer )
311 mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
312 int silent = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "silent" );
313 int progress = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "progress" );
314 struct timespec tm = { 0, 40000 };
315 int total_length = mlt_producer_get_length( producer );
316 int last_position = 0;
318 if ( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) )
320 if ( !silent && !progress )
324 fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
325 fprintf( stderr, "|1=-10| |2= -5| |3= -2| |4= -1| |5= 0| |6= 1| |7= 2| |8= 5| |9= 10|\n" );
326 fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
328 fprintf( stderr, "+---------------------------------------------------------------------+\n" );
329 fprintf( stderr, "| H = back 1 minute, L = forward 1 minute |\n" );
330 fprintf( stderr, "| h = previous frame, l = next frame |\n" );
331 fprintf( stderr, "| g = start of clip, j = next clip, k = previous clip |\n" );
332 fprintf( stderr, "| 0 = restart, q = quit, space = play |\n" );
333 fprintf( stderr, "+---------------------------------------------------------------------+\n" );
336 while( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) )
338 int value = ( silent || progress )? -1 : term_read( );
342 char string[ 2 ] = { value, 0 };
343 transport_action( producer, string );
346 #if defined(__DARWIN__) || defined(WIN32)
347 event_handling( producer, consumer );
350 if ( !silent && mlt_properties_get_int( properties, "stats_off" ) == 0 )
354 int current_position = mlt_producer_position( producer );
355 if ( current_position > last_position )
357 fprintf( stderr, "Current Frame: %10d, percentage: %10d\r",
358 current_position, 100 * current_position / total_length );
359 last_position = current_position;
364 fprintf( stderr, "Current Position: %10d\r", (int)mlt_consumer_position( consumer ) );
368 if ( silent || progress )
369 nanosleep( &tm, NULL );
373 fprintf( stderr, "\n" );
377 static void show_usage( char *program_name )
380 "Usage: %s [options] [producer [name=value]* ]+\n"
382 " -attach filter[:arg] [name=value]* Attach a filter to the output\n"
383 " -attach-cut filter[:arg] [name=value]* Attach a filter to a cut\n"
384 " -attach-track filter[:arg] [name=value]* Attach a filter to a track\n"
385 " -attach-clip filter[:arg] [name=value]* Attach a filter to a producer\n"
386 " -audio-track | -hide-video Add an audio-only track\n"
387 " -blank frames Add blank silence to a track\n"
388 " -consumer id[:arg] [name=value]* Set the consumer (sink)\n"
389 " -debug Set the logging level to debug\n"
390 " -filter filter[:arg] [name=value]* Add a filter to the current track\n"
391 " -group [name=value]* Apply properties repeatedly\n"
392 " -help Show this message\n"
393 " -jack Enable JACK transport synchronization\n"
394 " -join clips Join multiple clips into one cut\n"
395 " -mix length Add a mix between the last two cuts\n"
396 " -mixer transition Add a transition to the mix\n"
397 " -null-track | -hide-track Add a hidden track\n"
398 " -profile name Set the processing settings\n"
399 " -progress Display progress along with position\n"
400 " -remove Remove the most recent cut\n"
401 " -repeat times Repeat the last cut\n"
402 " -query List all of the registered services\n"
403 " -query \"consumers\" | \"consumer\"=id List consumers or show info about one\n"
404 " -query \"filters\" | \"filter\"=id List filters or show info about one\n"
405 " -query \"producers\" | \"producer\"=id List producers or show info about one\n"
406 " -query \"transitions\" | \"transition\"=id List transitions, show info about one\n"
407 " -query \"profiles\" | \"profile\"=id List profiles, show info about one\n"
408 " -query \"presets\" | \"preset\"=id List presets, show info about one\n"
409 " -query \"formats\" List audio/video formats\n"
410 " -query \"audio_codecs\" List audio codecs\n"
411 " -query \"video_codecs\" List video codecs\n"
412 " -serialise [filename] Write the commands to a text file\n"
413 " -silent Do not display position/transport\n"
414 " -split relative-frame Split the last cut into two cuts\n"
415 " -swap Rearrange the last two cuts\n"
416 " -track Add a track\n"
417 " -transition id[:arg] [name=value]* Add a transition\n"
418 " -verbose Set the logging level to verbose\n"
419 " -version Show the version and copyright\n"
420 " -video-track | -hide-audio Add a video-only track\n"
421 "For more help: <http://www.mltframework.org/>\n",
422 basename( program_name ) );
425 static void query_metadata( mlt_repository repo, mlt_service_type type, const char *typestr, char *id )
427 mlt_properties metadata = mlt_repository_metadata( repo, type, id );
430 char *s = mlt_properties_serialise_yaml( metadata );
431 fprintf( stdout, "%s", s );
436 fprintf( stdout, "# No metadata for %s \"%s\"\n", typestr, id );
440 static void query_services( mlt_repository repo, mlt_service_type type )
442 mlt_properties services = NULL;
443 const char *typestr = NULL;
447 services = mlt_repository_consumers( repo );
448 typestr = "consumers";
451 services = mlt_repository_filters( repo );
455 services = mlt_repository_producers( repo );
456 typestr = "producers";
458 case transition_type:
459 services = mlt_repository_transitions( repo );
460 typestr = "transitions";
465 fprintf( stdout, "---\n%s:\n", typestr );
469 for ( j = 0; j < mlt_properties_count( services ); j++ )
470 fprintf( stdout, " - %s\n", mlt_properties_get_name( services, j ) );
472 fprintf( stdout, "...\n" );
475 static void query_profiles()
477 mlt_properties profiles = mlt_profile_list();
478 fprintf( stdout, "---\nprofiles:\n" );
482 for ( j = 0; j < mlt_properties_count( profiles ); j++ )
483 fprintf( stdout, " - %s\n", mlt_properties_get_name( profiles, j ) );
485 fprintf( stdout, "...\n" );
486 mlt_properties_close( profiles );
489 static void query_profile( const char *id )
491 mlt_properties profiles = mlt_profile_list();
492 mlt_properties profile = mlt_properties_get_data( profiles, id, NULL );
495 char *s = mlt_properties_serialise_yaml( profile );
496 fprintf( stdout, "%s", s );
501 fprintf( stdout, "# No metadata for profile \"%s\"\n", id );
503 mlt_properties_close( profiles );
506 static void query_presets()
508 mlt_properties presets = mlt_repository_presets();
509 fprintf( stdout, "---\npresets:\n" );
513 for ( j = 0; j < mlt_properties_count( presets ); j++ )
514 fprintf( stdout, " - %s\n", mlt_properties_get_name( presets, j ) );
516 fprintf( stdout, "...\n" );
517 mlt_properties_close( presets );
520 static void query_preset( const char *id )
522 mlt_properties presets = mlt_repository_presets();
523 mlt_properties preset = mlt_properties_get_data( presets, id, NULL );
526 char *s = mlt_properties_serialise_yaml( preset );
527 fprintf( stdout, "%s", s );
532 fprintf( stdout, "# No metadata for preset \"%s\"\n", id );
534 mlt_properties_close( presets );
537 static void query_formats( )
539 mlt_consumer consumer = mlt_factory_consumer( NULL, "avformat", NULL );
542 mlt_properties_set( MLT_CONSUMER_PROPERTIES(consumer), "f", "list" );
543 mlt_consumer_start( consumer );
544 mlt_consumer_close( consumer );
548 fprintf( stdout, "# No formats - failed to load avformat consumer\n" );
552 static void query_acodecs( )
554 mlt_consumer consumer = mlt_factory_consumer( NULL, "avformat", NULL );
557 mlt_properties_set( MLT_CONSUMER_PROPERTIES(consumer), "acodec", "list" );
558 mlt_consumer_start( consumer );
559 mlt_consumer_close( consumer );
563 fprintf( stdout, "# No audio codecs - failed to load avformat consumer\n" );
567 static void query_vcodecs( )
569 mlt_consumer consumer = mlt_factory_consumer( NULL, "avformat", NULL );
572 mlt_properties_set( MLT_CONSUMER_PROPERTIES(consumer), "vcodec", "list" );
573 mlt_consumer_start( consumer );
574 mlt_consumer_close( consumer );
578 fprintf( stdout, "# No video codecs - failed to load avformat consumer\n" );
582 static void on_fatal_error( mlt_properties owner, mlt_consumer consumer )
584 mlt_consumer_stop( consumer );
585 exit( EXIT_FAILURE );
588 int main( int argc, char **argv )
591 mlt_consumer consumer = NULL;
592 mlt_producer melt = NULL;
595 mlt_profile profile = NULL;
598 mlt_profile backup_profile;
600 // Construct the factory
601 mlt_repository repo = mlt_factory_init( NULL );
607 for ( i = 1; i < argc; i ++ )
609 // Check for serialisation switch
610 if ( !strcmp( argv[ i ], "-serialise" ) )
613 if ( name != NULL && strstr( name, ".melt" ) )
614 store = fopen( name, "w" );
617 if ( name == NULL || name[0] == '-' )
622 // Look for the profile option
623 else if ( !strcmp( argv[ i ], "-profile" ) )
625 const char *pname = argv[ ++ i ];
626 if ( pname && pname[0] != '-' )
627 profile = mlt_profile_init( pname );
629 else if ( !strcmp( argv[ i ], "-progress" ) )
633 // Look for the query option
634 else if ( !strcmp( argv[ i ], "-query" ) )
636 const char *pname = argv[ ++ i ];
637 if ( pname && pname[0] != '-' )
639 if ( !strcmp( pname, "consumers" ) || !strcmp( pname, "consumer" ) )
640 query_services( repo, consumer_type );
641 else if ( !strcmp( pname, "filters" ) || !strcmp( pname, "filter" ) )
642 query_services( repo, filter_type );
643 else if ( !strcmp( pname, "producers" ) || !strcmp( pname, "producer" ) )
644 query_services( repo, producer_type );
645 else if ( !strcmp( pname, "transitions" ) || !strcmp( pname, "transition" ) )
646 query_services( repo, transition_type );
647 else if ( !strcmp( pname, "profiles" ) || !strcmp( pname, "profile" ) )
649 else if ( !strcmp( pname, "presets" ) || !strcmp( pname, "preset" ) )
651 else if ( !strncmp( pname, "format", 6 ) )
653 else if ( !strncmp( pname, "acodec", 6 ) || !strcmp( pname, "audio_codecs" ) )
655 else if ( !strncmp( pname, "vcodec", 6 ) || !strcmp( pname, "video_codecs" ) )
658 else if ( !strncmp( pname, "consumer=", 9 ) )
659 query_metadata( repo, consumer_type, "consumer", strchr( pname, '=' ) + 1 );
660 else if ( !strncmp( pname, "filter=", 7 ) )
661 query_metadata( repo, filter_type, "filter", strchr( pname, '=' ) + 1 );
662 else if ( !strncmp( pname, "producer=", 9 ) )
663 query_metadata( repo, producer_type, "producer", strchr( pname, '=' ) + 1 );
664 else if ( !strncmp( pname, "transition=", 11 ) )
665 query_metadata( repo, transition_type, "transition", strchr( pname, '=' ) + 1 );
666 else if ( !strncmp( pname, "profile=", 8 ) )
667 query_profile( strchr( pname, '=' ) + 1 );
668 else if ( !strncmp( pname, "preset=", 7 ) )
669 query_preset( strchr( pname, '=' ) + 1 );
676 query_services( repo, consumer_type );
677 query_services( repo, filter_type );
678 query_services( repo, producer_type );
679 query_services( repo, transition_type );
680 fprintf( stdout, "# You can query the metadata for a specific service using:\n"
681 "# -query <type>=<identifer>\n"
682 "# where <type> is one of: consumer, filter, producer, or transition.\n" );
686 else if ( !strcmp( argv[ i ], "-silent" ) )
690 else if ( !strcmp( argv[ i ], "-verbose" ) )
692 mlt_log_set_level( MLT_LOG_VERBOSE );
694 else if ( !strcmp( argv[ i ], "-version" ) || !strcmp( argv[ i ], "--version" ) )
696 fprintf( stdout, "MLT %s " VERSION "\n"
697 "Copyright (C) 2002-2011 Ushodaya Enterprises Limited\n"
698 "<http://www.mltframework.org/>\n"
699 "This is free software; see the source for copying conditions. There is NO\n"
700 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
701 basename( argv[0] ) );
704 else if ( !strcmp( argv[ i ], "-debug" ) )
706 mlt_log_set_level( MLT_LOG_DEBUG );
709 if ( !is_silent && !isatty( STDIN_FILENO ) )
712 // Create profile if not set explicitly
713 if ( getenv( "MLT_PROFILE" ) )
714 profile = mlt_profile_init( NULL );
715 if ( profile == NULL )
716 profile = mlt_profile_init( NULL );
718 profile->is_explicit = 1;
720 // Look for the consumer option to load profile settings from consumer properties
721 backup_profile = mlt_profile_clone( profile );
722 load_consumer( &consumer, profile, argc, argv );
724 // If the consumer changed the profile, then it is explicit.
725 if ( backup_profile && !profile->is_explicit && (
726 profile->width != backup_profile->width ||
727 profile->height != backup_profile->height ||
728 profile->sample_aspect_num != backup_profile->sample_aspect_num ||
729 profile->sample_aspect_den != backup_profile->sample_aspect_den ||
730 profile->frame_rate_den != backup_profile->frame_rate_den ||
731 profile->frame_rate_num != backup_profile->frame_rate_num ||
732 profile->colorspace != backup_profile->colorspace ) )
733 profile->is_explicit = 1;
734 mlt_profile_close( backup_profile );
738 melt = mlt_factory_producer( profile, "melt", &argv[ 1 ] );
742 // Generate an automatic profile if needed.
743 if ( ! profile->is_explicit )
745 mlt_profile_from_producer( profile, melt );
746 mlt_producer_close( melt );
747 melt = mlt_factory_producer( profile, "melt", &argv[ 1 ] );
750 // Reload the consumer with the fully qualified profile.
751 // The producer or auto-profile could have changed the profile.
752 load_consumer( &consumer, profile, argc, argv );
754 // If we have no consumer, default to sdl
755 if ( store == NULL && consumer == NULL )
756 consumer = create_consumer( profile, NULL );
759 // Set transport properties on consumer and produder
760 if ( consumer != NULL && melt != NULL )
762 mlt_properties_set_data( MLT_CONSUMER_PROPERTIES( consumer ), "transport_producer", melt, 0, NULL, NULL );
763 mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( melt ), "transport_consumer", consumer, 0, NULL, NULL );
765 mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "progress", is_progress );
767 mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "silent", is_silent );
770 if ( argc > 1 && melt != NULL && mlt_producer_get_length( melt ) > 0 )
772 // Parse the arguments
773 for ( i = 1; i < argc; i ++ )
775 if ( !strcmp( argv[ i ], "-jack" ) )
777 setup_jack_transport( consumer, profile );
779 else if ( !strcmp( argv[ i ], "-serialise" ) )
781 if ( store != stdout )
787 fprintf( store, "%s\n", argv[ i ] );
791 while ( argv[ i ] != NULL && argv[ i ][ 0 ] != '-' )
794 fprintf( store, "%s\n", argv[ i ] );
802 if ( consumer != NULL && store == NULL )
804 // Get melt's properties
805 mlt_properties melt_props = MLT_PRODUCER_PROPERTIES( melt );
807 // Get the last group
808 mlt_properties group = mlt_properties_get_data( melt_props, "group", 0 );
810 // Apply group settings
811 mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
812 mlt_properties_inherit( properties, group );
814 // Connect consumer to melt
815 mlt_consumer_connect( consumer, MLT_PRODUCER_SERVICE( melt ) );
817 // Start the consumer
818 mlt_events_listen( properties, consumer, "consumer-fatal-error", ( mlt_listener )on_fatal_error );
819 if ( mlt_consumer_start( consumer ) == 0 )
821 // Transport functionality
822 transport( melt, consumer );
825 mlt_consumer_stop( consumer );
828 else if ( store != NULL && store != stdout && name != NULL )
830 fprintf( stderr, "Project saved as %s.\n", name );
836 show_usage( argv[0] );
839 // Close the producer
841 mlt_producer_close( melt );
843 // Close the consumer
844 if ( consumer != NULL )
845 mlt_consumer_close( consumer );
848 mlt_profile_close( profile );
852 mlt_factory_close( );