First attempt at a composite clean up
[melted] / src / modules / inigo / producer_inigo.c
index 212aea8..593cc19 100644 (file)
@@ -129,6 +129,7 @@ mlt_producer producer_inigo_init( char **argv )
        mlt_field field = mlt_tractor_field( tractor );
        mlt_properties field_properties = mlt_field_properties( field );
        mlt_multitrack multitrack = mlt_tractor_multitrack( tractor );
+       char *title = NULL;
 
        // We need to track the number of registered filters
        mlt_properties_set_int( field_properties, "registered", 0 );
@@ -157,10 +158,57 @@ mlt_producer producer_inigo_init( char **argv )
                                mlt_properties_inherit( properties, group );
                        }
                }
+               else if ( !strcmp( argv[ i ], "-repeat" ) )
+               {
+                       int repeat = atoi( argv[ ++ i ] );
+                       if ( producer != NULL && !mlt_producer_is_cut( producer ) )
+                               mlt_playlist_append( playlist, producer );
+                       producer = NULL;
+                       if ( mlt_playlist_count( playlist ) > 0 )
+                       {
+                               mlt_playlist_clip_info info;
+                               mlt_playlist_repeat_clip( playlist, mlt_playlist_count( playlist ) - 1, repeat );
+                               mlt_playlist_get_clip_info( playlist, &info, mlt_playlist_count( playlist ) - 1 );
+                               producer = info.cut;
+                               properties = mlt_producer_properties( producer );
+                       }
+               }
+               else if ( !strcmp( argv[ i ], "-split" ) )
+               {
+                       int split = atoi( argv[ ++ i ] );
+                       if ( producer != NULL && !mlt_producer_is_cut( producer ) )
+                               mlt_playlist_append( playlist, producer );
+                       producer = NULL;
+                       if ( mlt_playlist_count( playlist ) > 0 )
+                       {
+                               mlt_playlist_clip_info info;
+                               mlt_playlist_get_clip_info( playlist, &info, mlt_playlist_count( playlist ) - 1 );
+                               split = split < 0 ? info.frame_out + split : split;
+                               mlt_playlist_split( playlist, mlt_playlist_count( playlist ) - 1, split );
+                               mlt_playlist_get_clip_info( playlist, &info, mlt_playlist_count( playlist ) - 1 );
+                               producer = info.cut;
+                               properties = mlt_producer_properties( producer );
+                       }
+               }
+               else if ( !strcmp( argv[ i ], "-join" ) )
+               {
+                       int clips = atoi( argv[ ++ i ] );
+                       if ( producer != NULL && !mlt_producer_is_cut( producer ) )
+                               mlt_playlist_append( playlist, producer );
+                       producer = NULL;
+                       if ( mlt_playlist_count( playlist ) > 0 )
+                       {
+                               mlt_playlist_clip_info info;
+                               mlt_playlist_join( playlist, mlt_playlist_count( playlist ) - clips - 1, clips, 0 );
+                               mlt_playlist_get_clip_info( playlist, &info, mlt_playlist_count( playlist ) - 1 );
+                               producer = info.cut;
+                               properties = mlt_producer_properties( producer );
+                       }
+               }
                else if ( !strcmp( argv[ i ], "-mix" ) )
                {
                        int length = atoi( argv[ ++ i ] );
-                       if ( producer != NULL )
+                       if ( producer != NULL && !mlt_producer_is_cut( producer ) )
                                mlt_playlist_append( playlist, producer );
                        producer = NULL;
                        if ( mlt_playlist_count( playlist ) >= 2 )
@@ -169,9 +217,9 @@ mlt_producer producer_inigo_init( char **argv )
                                {
                                        mlt_playlist_clip_info info;
                                        mlt_playlist_get_clip_info( playlist, &info, mlt_playlist_count( playlist ) - 1 );
-                                       if ( mlt_properties_get_int( ( mlt_properties )info.producer, "mlt_mix" ) == 0 )
+                                       if ( mlt_properties_get_data( ( mlt_properties )info.producer, "mlt_mix", NULL ) == NULL )
                                                mlt_playlist_get_clip_info( playlist, &info, mlt_playlist_count( playlist ) - 2 );
-                                       mix = ( mlt_tractor )info.producer;
+                                       mix = ( mlt_tractor )mlt_properties_get_data( ( mlt_properties )info.producer, "mlt_mix", NULL );
                                }
                                else
                                {
@@ -230,7 +278,7 @@ mlt_producer producer_inigo_init( char **argv )
                }
                else if ( !strcmp( argv[ i ], "-blank" ) )
                {
-                       if ( producer != NULL )
+                       if ( producer != NULL && !mlt_producer_is_cut( producer ) )
                                mlt_playlist_append( playlist, producer );
                        producer = NULL;
                        mlt_playlist_blank( playlist, atof( argv[ ++ i ] ) );
@@ -240,7 +288,7 @@ mlt_producer producer_inigo_init( char **argv )
                                  !strcmp( argv[ i ], "-hide-video" ) ||
                                  !strcmp( argv[ i ], "-hide-audio" ) )
                {
-                       if ( producer != NULL )
+                       if ( producer != NULL && !mlt_producer_is_cut( producer ) )
                                mlt_playlist_append( playlist, producer );
                        producer = NULL;
                        mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), track ++ );
@@ -263,8 +311,10 @@ mlt_producer producer_inigo_init( char **argv )
                }
                else if ( argv[ i ][ 0 ] != '-' )
                {
-                       if ( producer != NULL )
+                       if ( producer != NULL && !mlt_producer_is_cut( producer ) )
                                mlt_playlist_append( playlist, producer );
+                       if ( title == NULL )
+                               title = argv[ i ];
                        producer = create_producer( field, argv[ i ] );
                        if ( producer != NULL )
                        {
@@ -287,7 +337,7 @@ mlt_producer producer_inigo_init( char **argv )
        }
 
        // Connect last producer to playlist
-       if ( producer != NULL )
+       if ( producer != NULL && !mlt_producer_is_cut( producer ) )
                mlt_playlist_append( playlist, producer );
 
        // Track the last playlist too
@@ -303,6 +353,8 @@ mlt_producer producer_inigo_init( char **argv )
        mlt_properties_set_position( props, "length", mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) + 1 );
        mlt_producer_set_in_and_out( prod, 0, mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) );
        mlt_properties_set_double( props, "fps", mlt_producer_get_fps( mlt_multitrack_producer( multitrack ) ) );
+       if ( title != NULL )
+               mlt_properties_set( props, "title", strchr( title, '/' ) ? strrchr( title, '/' ) + 1 : title );
 
        return prod;
 }