remove no longer necessary blanks
[melted] / src / inigo / inigo.c
index bc087ba..29465db 100644 (file)
@@ -147,6 +147,20 @@ mlt_filter create_filter( mlt_field field, char *id, int track )
        return filter;
 }
 
+mlt_transition create_transition( mlt_field field, char *id, int track )
+{
+       char *arg = strchr( id, ':' );
+       if ( arg != NULL )
+               *arg ++ = '\0';
+       mlt_transition transition = mlt_factory_transition( id, arg );
+       if ( transition != NULL )
+       {
+               mlt_field_plant_transition( field, transition, track, track + 1 );
+               track_service( field, transition, ( mlt_destructor )mlt_transition_close );
+       }
+       return transition;
+}
+
 void set_properties( mlt_properties properties, char *namevalue )
 {
        mlt_properties_parse( properties, namevalue );
@@ -178,30 +192,22 @@ void transport( mlt_producer producer )
 int main( int argc, char **argv )
 {
        int i;
+       int track = 0;
        mlt_consumer consumer = NULL;
-       mlt_multitrack multitrack = NULL;
        mlt_producer producer = NULL;
-       mlt_playlist playlist = NULL;
-       mlt_field field = NULL;
+       mlt_playlist playlist = mlt_playlist_init( );
        mlt_properties group = mlt_properties_new( );
        mlt_properties properties = group;
+       mlt_field field = mlt_field_init( );
+       mlt_properties field_properties = mlt_field_properties( field );
+       mlt_multitrack multitrack = mlt_field_multitrack( field );
 
        // Construct the factory
        mlt_factory_init( getenv( "MLT_REPOSITORY" ) );
 
-       // Set up containers
-       playlist = mlt_playlist_init( );
-
-       // Construct the field
-       field = mlt_field_init( );
-
        // We need to track the number of registered filters
-       mlt_properties field_properties = mlt_field_properties( field );
        mlt_properties_set_int( field_properties, "registered", 0 );
 
-       // Get the multitrack from the field
-       multitrack = mlt_field_multitrack( field );
-
        // Parse the arguments
        for ( i = 1; i < argc; i ++ )
        {
@@ -226,13 +232,37 @@ int main( int argc, char **argv )
                }
                else if ( !strcmp( argv[ i ], "-filter" ) )
                {
-                       mlt_filter filter = create_filter( field, argv[ ++ i ], 0 );
+                       mlt_filter filter = create_filter( field, argv[ ++ i ], track );
                        if ( filter != NULL )
                        {
                                properties = mlt_filter_properties( filter );
                                mlt_properties_inherit( properties, group );
                        }
                }
+               else if ( !strcmp( argv[ i ], "-transition" ) )
+               {
+                       mlt_transition transition = create_transition( field, argv[ ++ i ], track );
+                       if ( transition != NULL )
+                       {
+                               properties = mlt_transition_properties( transition );
+                               mlt_properties_inherit( properties, group );
+                       }
+               }
+               else if ( !strcmp( argv[ i ], "-blank" ) )
+               {
+                       if ( producer != NULL )
+                               mlt_playlist_append( playlist, producer );
+                       producer = NULL;
+                       mlt_playlist_blank( playlist, atof( argv[ ++ i ] ) );
+               }
+               else if ( !strcmp( argv[ i ], "-track" ) )
+               {
+                       if ( producer != NULL )
+                               mlt_playlist_append( playlist, producer );
+                       producer = NULL;
+                       mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), track ++ );
+                       playlist = mlt_playlist_init( );
+               }
                else if ( !strstr( argv[ i ], "=" ) )
                {
                        if ( producer != NULL )
@@ -250,8 +280,13 @@ int main( int argc, char **argv )
                }
        }
 
-       // We must have a producer at this point
+       // Connect producer to playlist
        if ( producer != NULL )
+               mlt_playlist_append( playlist, producer );
+
+
+       // We must have a producer at this point
+       if ( mlt_playlist_count( playlist ) > 0 )
        {
                // If we have no consumer, default to sdl
                if ( consumer == NULL )
@@ -264,11 +299,8 @@ int main( int argc, char **argv )
                        }
                }
 
-               // Connect producer to playlist
-               mlt_playlist_append( playlist, producer );
-
                // Connect multitrack to producer
-               mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), 0 );
+               mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), track );
 
                // Connect consumer to tractor
                mlt_consumer_connect( consumer, mlt_field_service( field ) );
@@ -285,6 +317,8 @@ int main( int argc, char **argv )
                fprintf( stderr, "Usage: inigo [ -group [ name=value ]* ]\n"
                                                 "             [ -consumer id[:arg] [ name=value ]* ]\n"
                                         "             [ -filter id[:arg] [ name=value ] * ]\n"
+                                        "             [ -transition id[:arg] [ name=value ] * ]\n"
+                                                "             [ -blank time ]\n"
                                         "             [ producer [ name=value ] * ]+\n" );
        }