mlt_profile mlt_profile_load_string( const char *string ) { mlt_properties properties = mlt_properties_new(); mlt_profile profile = NULL; if ( properties ) { const char *p = string; while ( p ) { if ( strcmp( p, "" ) && p[ 0 ] != '#' ) mlt_properties_parse( properties, p ); p = strchr( p, '\n' ); if ( p ) p++; } profile = mlt_profile_load_properties( properties ); mlt_properties_close( properties ); } return profile; }
static void load_consumer( mlt_consumer *consumer, mlt_profile profile, int argc, char **argv ) { int i; int multi = 0; int qglsl = 0; for ( i = 1; i < argc; i ++ ) { // See if we need multi consumer. multi += !strcmp( argv[i], "-consumer" ); // Seee if we need the qglsl variant of multi consumer. if ( !strncmp( argv[i], "glsl.", 5 ) || !strncmp( argv[i], "movit.", 6 ) ) qglsl = 1; } // Disable qglsl if xgl is being used! for ( i = 1; qglsl && i < argc; i ++ ) if ( !strcmp( argv[i], "xgl" ) ) qglsl = 0; if ( multi > 1 || qglsl ) { // If there is more than one -consumer use the 'multi' consumer. int k = 0; char key[20]; if ( *consumer ) mlt_consumer_close( *consumer ); *consumer = create_consumer( profile, ( qglsl? "qglsl" : "multi" ) ); mlt_properties properties = MLT_CONSUMER_PROPERTIES( *consumer ); for ( i = 1; i < argc; i ++ ) { if ( !strcmp( argv[ i ], "-consumer" ) && argv[ i + 1 ]) { // Create a properties object for each sub-consumer mlt_properties new_props = mlt_properties_new(); snprintf( key, sizeof(key), "%d", k++ ); mlt_properties_set_data( properties, key, new_props, 0, (mlt_destructor) mlt_properties_close, NULL ); if ( strchr( argv[i + 1], ':' ) ) { char *temp = strdup( argv[++i] ); char *service = temp; char *target = strchr( temp, ':' ); *target++ = 0; mlt_properties_set( new_props, "mlt_service", service ); mlt_properties_set( new_props, "target", target ); } else { mlt_properties_set( new_props, "mlt_service", argv[ ++i ] ); } while ( argv[ i + 1 ] && strchr( argv[ i + 1 ], '=' ) ) mlt_properties_parse( new_props, argv[ ++ i ] ); } } } else for ( i = 1; i < argc; i ++ ) { if ( !strcmp( argv[ i ], "-consumer" ) ) { if ( *consumer ) mlt_consumer_close( *consumer ); *consumer = create_consumer( profile, argv[ ++ i ] ); if ( *consumer ) { mlt_properties properties = MLT_CONSUMER_PROPERTIES( *consumer ); while ( argv[ i + 1 ] != NULL && strchr( argv[ i + 1 ], '=' ) ) mlt_properties_parse( properties, argv[ ++ i ] ); } } } }
void set_properties( mlt_service service, char *namevalue ) { mlt_properties properties = mlt_service_properties( service ); mlt_properties_parse( properties, namevalue ); }
int inigo( int argc, char **argv ) { int i; mlt_consumer consumer = NULL; mlt_producer melt = NULL; FILE *store = NULL; char *name = NULL; mlt_profile profile = NULL; int is_progress = 0; int is_silent = 0; // Construct the factory mlt_repository repo = mlt_factory_init( NULL ); for ( i = 1; i < argc; i ++ ) { // fprintf(stderr, "argv[%d] = %s\n", i, argv[i]); // Check for serialisation switch if ( !strcmp( argv[ i ], "-serialise" ) ) { name = argv[ ++ i ]; if ( name != NULL && strstr( name, ".melt" ) ) store = fopen( name, "w" ); else { if ( name == NULL || name[0] == '-' ) store = stdout; name = NULL; } } // Look for the profile option else if ( !strcmp( argv[ i ], "-profile" ) ) { const char *pname = argv[ ++ i ]; if ( pname && pname[0] != '-' ) profile = mlt_profile_init( pname ); } else if ( !strcmp( argv[ i ], "-progress" ) ) { is_progress = 1; } // Look for the query option else if ( !strcmp( argv[ i ], "-query" ) ) { const char *pname = argv[ ++ i ]; if ( pname && pname[0] != '-' ) { if ( !strcmp( pname, "consumers" ) || !strcmp( pname, "consumer" ) ) query_services( repo, consumer_type ); else if ( !strcmp( pname, "filters" ) || !strcmp( pname, "filter" ) ) query_services( repo, filter_type ); else if ( !strcmp( pname, "producers" ) || !strcmp( pname, "producer" ) ) query_services( repo, producer_type ); else if ( !strcmp( pname, "transitions" ) || !strcmp( pname, "transition" ) ) query_services( repo, transition_type ); else if ( !strncmp( pname, "consumer=", 9 ) ) query_metadata( repo, consumer_type, "consumer", strchr( pname, '=' ) + 1 ); else if ( !strncmp( pname, "filter=", 7 ) ) query_metadata( repo, filter_type, "filter", strchr( pname, '=' ) + 1 ); else if ( !strncmp( pname, "producer=", 9 ) ) query_metadata( repo, producer_type, "producer", strchr( pname, '=' ) + 1 ); else if ( !strncmp( pname, "transition=", 11 ) ) query_metadata( repo, transition_type, "transition", strchr( pname, '=' ) + 1 ); else goto query_all; } else { query_all: query_services( repo, consumer_type ); query_services( repo, filter_type ); query_services( repo, producer_type ); query_services( repo, transition_type ); fprintf( stderr, "# You can query the metadata for a specific service using:\n" "# -query <type>=<identifer>\n" "# where <type> is one of: consumer, filter, producer, or transition.\n" ); } goto exit_factory; } else if ( !strcmp( argv[ i ], "-silent" ) ) { is_silent = 1; } else if ( !strcmp( argv[ i ], "-verbose" ) ) { mlt_log_set_level( MLT_LOG_VERBOSE ); } else if ( !strcmp( argv[ i ], "-version" ) || !strcmp( argv[ i ], "--version" ) ) { fprintf( stderr, "MLT %s 0.5\n" "Copyright (C) 2002-2009 Ushodaya Enterprises Limited\n" "<http://www.mltframework.org/>\n" "This is free software; see the source for copying conditions. There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", basename( argv[0] ) ); goto exit_factory; } else if ( !strcmp( argv[ i ], "-debug" ) ) { mlt_log_set_level( MLT_LOG_DEBUG ); } } // Create profile if not set explicitly if ( profile == NULL ) profile = mlt_profile_init( NULL ); // Look for the consumer option for ( i = 1; i < argc; i ++ ) { if ( !strcmp( argv[ i ], "-consumer" ) ) { consumer = create_consumer( profile, argv[ ++ i ] ); if ( consumer ) { mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer ); while ( argv[ i + 1 ] != NULL && strstr( argv[ i + 1 ], "=" ) ) mlt_properties_parse( properties, argv[ ++ i ] ); } } } // If we have no consumer, default to sdl if ( store == NULL && consumer == NULL ) consumer = create_consumer( profile, NULL ); // Get melt producer if ( argc > 1 ) melt = mlt_factory_producer( profile, "melt", &argv[ 1 ] ); // Set transport properties on consumer and produder if ( consumer != NULL && melt != NULL ) { mlt_properties_set_data( MLT_CONSUMER_PROPERTIES( consumer ), "transport_producer", melt, 0, NULL, NULL ); mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( melt ), "transport_consumer", consumer, 0, NULL, NULL ); if ( is_progress ) mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "progress", is_progress ); if ( is_silent ) mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "silent", is_silent ); } if ( argc > 1 && melt != NULL && mlt_producer_get_length( melt ) > 0 ) { // Parse the arguments for ( i = 1; i < argc; i ++ ) { if ( !strcmp( argv[ i ], "-serialise" ) ) { if ( store != stdout ) i ++; } else { if ( store != NULL ) fprintf( store, "%s\n", argv[ i ] ); i ++; while ( argv[ i ] != NULL && argv[ i ][ 0 ] != '-' ) { if ( store != NULL ) fprintf( store, "%s\n", argv[ i ] ); i += 1; } i --; } } if ( consumer != NULL && store == NULL ) { // Get melt's properties mlt_properties melt_props = MLT_PRODUCER_PROPERTIES( melt ); // Get the last group mlt_properties group = mlt_properties_get_data( melt_props, "group", 0 ); // Apply group settings mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer ); mlt_properties_inherit( properties, group ); // Connect consumer to melt mlt_consumer_connect( consumer, MLT_PRODUCER_SERVICE( melt ) ); // Start the consumer mlt_consumer_start( consumer ); // Transport functionality transport( melt, consumer ); // Stop the consumer mlt_consumer_stop( consumer ); } else if ( store != NULL && store != stdout && name != NULL ) { fprintf( stderr, "Project saved as %s.\n", name ); fclose( store ); } } else { fprintf( stderr, "Usage: %s [options] [producer [name=value]* ]+\n" "Options:\n" " -attach filter[:arg] [name=value]* Attach a filter to the output\n" " -attach-cut filter[:arg] [name=value]* Attach a filter to a cut\n" " -attach-track filter[:arg] [name=value]* Attach a filter to a track\n" " -attach-clip filter[:arg] [name=value]* Attach a filter to a producer\n" " -audio-track | -hide-video Add an audio-only track\n" " -blank frames Add blank silence to a track\n" " -consumer id[:arg] [name=value]* Set the consumer (sink)\n" " -debug Set the logging level to debug\n" " -filter filter[:arg] [name=value]* Add a filter to the current track\n" " -group [name=value]* Apply properties repeatedly\n" " -help Show this message\n" " -join clips Join multiple clips into one cut\n" " -mix length Add a mix between the last two cuts\n" " -mixer transition Add a transition to the mix\n" " -null-track | -hide-track Add a hidden track\n" " -profile name Set the processing settings\n" " -progress Display progress along with position\n" " -remove Remove the most recent cut\n" " -repeat times Repeat the last cut\n" " -query List all of the registered services\n" " -query \"consumers\" | \"consumer\"=id List consumers or show info about one\n" " -query \"filters\" | \"filter\"=id List filters or show info about one\n" " -query \"producers\" | \"producer\"=id List producers or show info about one\n" " -query \"transitions\" | \"transition\"=id List transitions, show info about one\n" " -serialise [filename] Write the commands to a text file\n" " -silent Do not display position/transport\n" " -split relative-frame Split the last cut into two cuts\n" " -swap Rearrange the last two cuts\n" " -track Add a track\n" " -transition id[:arg] [name=value]* Add a transition\n" " -verbose Set the logging level to verbose\n" " -version Show the version and copyright\n" " -video-track | -hide-audio Add a video-only track\n" "For more help: <http://www.mltframework.org/>\n", basename( argv[0] ) ); } // Close the producer if ( melt != NULL ) mlt_producer_close( melt ); // Close the consumer if ( consumer != NULL ) mlt_consumer_close( consumer ); // Close the factory mlt_profile_close( profile ); exit_factory: mlt_factory_close( ); return 0; }
static void load_consumer( mlt_consumer *consumer, mlt_profile profile, int argc, char **argv ) { int i; int multi = 0; for ( i = 1; i < argc; i ++ ) multi += !strcmp( argv[ i ], "-consumer" ); if ( multi > 1 ) { // If there is more than one -consumer use the 'multi' consumer. int k = 0; char key[20]; if ( *consumer ) mlt_consumer_close( *consumer ); *consumer = create_consumer( profile, "multi" ); mlt_properties properties = MLT_CONSUMER_PROPERTIES( *consumer ); for ( i = 1; i < argc; i ++ ) { if ( !strcmp( argv[ i ], "-consumer" ) && argv[ i + 1 ]) { // Create a properties object for each sub-consumer mlt_properties new_props = mlt_properties_new(); snprintf( key, sizeof(key), "%d", k++ ); mlt_properties_set_data( properties, key, new_props, 0, (mlt_destructor) mlt_properties_close, NULL ); if ( strchr( argv[i + 1], ':' ) ) { char *temp = strdup( argv[++i] ); char *service = temp; char *target = strchr( temp, ':' ); *target++ = 0; mlt_properties_set( new_props, "mlt_service", service ); mlt_properties_set( new_props, "target", target ); } else { mlt_properties_set( new_props, "mlt_service", argv[ ++i ] ); } while ( argv[ i + 1 ] && strchr( argv[ i + 1 ], '=' ) ) mlt_properties_parse( new_props, argv[ ++ i ] ); } } } else for ( i = 1; i < argc; i ++ ) { if ( !strcmp( argv[ i ], "-consumer" ) ) { if ( *consumer ) mlt_consumer_close( *consumer ); *consumer = create_consumer( profile, argv[ ++ i ] ); if ( *consumer ) { mlt_properties properties = MLT_CONSUMER_PROPERTIES( *consumer ); while ( argv[ i + 1 ] != NULL && strchr( argv[ i + 1 ], '=' ) ) mlt_properties_parse( properties, argv[ ++ i ] ); } } } }