5 #include <framework/mlt.h>
9 static void transport_action( mlt_producer producer
, char *value
)
11 mlt_properties properties
= mlt_producer_properties( producer
);
12 mlt_multitrack multitrack
= mlt_properties_get_data( properties
, "multitrack", NULL
);
14 mlt_properties_set_int( properties
, "stats_off", 0 );
16 if ( strlen( value
) == 1 )
21 mlt_properties_set_int( properties
, "done", 1 );
24 mlt_producer_set_speed( producer
, 1 );
25 mlt_producer_seek( producer
, 0 );
28 mlt_producer_set_speed( producer
, -10 );
31 mlt_producer_set_speed( producer
, -5 );
34 mlt_producer_set_speed( producer
, -2 );
37 mlt_producer_set_speed( producer
, -1 );
40 mlt_producer_set_speed( producer
, 0 );
44 mlt_producer_set_speed( producer
, 1 );
47 mlt_producer_set_speed( producer
, 2 );
50 mlt_producer_set_speed( producer
, 5 );
53 mlt_producer_set_speed( producer
, 10 );
56 if ( multitrack
!= NULL
)
59 mlt_position last
= -1;
60 fprintf( stderr
, "\n" );
61 for ( i
= 0; 1; i
++ )
63 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_start
, i
);
67 fprintf( stderr
, "%d: %d\n", i
, time
);
73 if ( multitrack
!= NULL
)
75 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, 0 );
76 mlt_producer_seek( producer
, time
);
80 if ( producer
!= NULL
)
82 mlt_position position
= mlt_producer_position( producer
);
83 mlt_producer_seek( producer
, position
- ( mlt_producer_get_fps( producer
) * 60 ) );
87 if ( producer
!= NULL
)
89 mlt_position position
= mlt_producer_position( producer
);
90 mlt_producer_set_speed( producer
, 0 );
91 mlt_producer_seek( producer
, position
- 1 );
95 if ( multitrack
!= NULL
)
97 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, 1 );
98 mlt_producer_seek( producer
, time
);
102 if ( multitrack
!= NULL
)
104 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, -1 );
105 mlt_producer_seek( producer
, time
);
109 if ( producer
!= NULL
)
111 mlt_position position
= mlt_producer_position( producer
);
112 mlt_producer_set_speed( producer
, 0 );
113 mlt_producer_seek( producer
, position
+ 1 );
117 if ( producer
!= NULL
)
119 mlt_position position
= mlt_producer_position( producer
);
120 mlt_producer_seek( producer
, position
+ ( mlt_producer_get_fps( producer
) * 60 ) );
126 mlt_properties_set_int( properties
, "stats_off", 0 );
129 static mlt_consumer
create_consumer( char *id
, mlt_producer producer
)
131 char *arg
= strchr( id
, ':' );
134 mlt_consumer consumer
= mlt_factory_consumer( id
, arg
);
135 if ( consumer
!= NULL
)
137 mlt_properties properties
= mlt_consumer_properties( consumer
);
138 mlt_properties_set_data( properties
, "transport_callback", transport_action
, 0, NULL
, NULL
);
139 mlt_properties_set_data( properties
, "transport_producer", producer
, 0, NULL
, NULL
);
144 static void transport( mlt_producer producer
, mlt_consumer consumer
)
146 mlt_properties properties
= mlt_producer_properties( producer
);
150 if ( mlt_properties_get_int( properties
, "done" ) == 0 && !mlt_consumer_is_stopped( consumer
) )
152 fprintf( stderr
, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
153 fprintf( stderr
, "|1=-10| |2= -5| |3= -2| |4= -1| |5= 0| |6= 1| |7= 2| |8= 5| |9= 10|\n" );
154 fprintf( stderr
, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
156 fprintf( stderr
, "+---------------------------------------------------------------------+\n" );
157 fprintf( stderr
, "| H = back 1 minute, L = forward 1 minute |\n" );
158 fprintf( stderr
, "| h = previous frame, l = next frame |\n" );
159 fprintf( stderr
, "| g = start of clip, j = next clip, k = previous clip |\n" );
160 fprintf( stderr
, "| 0 = restart, q = quit, space = play |\n" );
161 fprintf( stderr
, "+---------------------------------------------------------------------+\n" );
163 while( mlt_properties_get_int( properties
, "done" ) == 0 && !mlt_consumer_is_stopped( consumer
) )
165 int value
= term_read( );
167 transport_action( producer
, ( char * )&value
);
169 if ( mlt_properties_get_int( properties
, "stats_off" ) == 0 )
170 fprintf( stderr
, "Current Position: %10d\r", mlt_producer_position( producer
) );
173 fprintf( stderr
, "\n" );
177 int main( int argc
, char **argv
)
180 mlt_consumer consumer
= NULL
;
181 mlt_producer inigo
= NULL
;
185 // Construct the factory
186 mlt_factory_init( NULL
);
188 // Check for serialisation switch first
189 for ( i
= 1; i
< argc
; i
++ )
191 if ( !strcmp( argv
[ i
], "-serialise" ) )
194 if ( strstr( name
, ".inigo" ) )
195 store
= fopen( name
, "w" );
199 // Get inigo producer
201 inigo
= mlt_factory_producer( "inigo", &argv
[ 1 ] );
203 if ( argc
> 1 && inigo
!= NULL
&& mlt_producer_get_length( inigo
) > 0 )
205 // Get inigo's properties
206 mlt_properties inigo_props
= mlt_producer_properties( inigo
);
208 // Get the last group
209 mlt_properties group
= mlt_properties_get_data( inigo_props
, "group", 0 );
211 // Parse the arguments
212 for ( i
= 1; i
< argc
; i
++ )
214 if ( !strcmp( argv
[ i
], "-consumer" ) )
216 consumer
= create_consumer( argv
[ ++ i
], inigo
);
217 while ( argv
[ i
+ 1 ] != NULL
&& strstr( argv
[ i
+ 1 ], "=" ) )
218 mlt_properties_parse( group
, argv
[ ++ i
] );
220 else if ( !strcmp( argv
[ i
], "-serialise" ) )
227 fprintf( store
, "%s\n", argv
[ i
] );
231 while ( argv
[ i
] != NULL
&& argv
[ i
][ 0 ] != '-' )
234 fprintf( store
, "%s\n", argv
[ i
] );
242 // If we have no consumer, default to sdl
243 if ( store
== NULL
&& consumer
== NULL
)
244 consumer
= create_consumer( "sdl", inigo
);
246 if ( consumer
!= NULL
&& store
== NULL
)
248 // Apply group settings
249 mlt_properties properties
= mlt_consumer_properties( consumer
);
250 mlt_properties_inherit( properties
, group
);
252 // Connect consumer to inigo
253 mlt_consumer_connect( consumer
, mlt_producer_service( inigo
) );
255 // Start the consumer
256 mlt_consumer_start( consumer
);
258 // Transport functionality
259 transport( inigo
, consumer
);
262 mlt_consumer_stop( consumer
);
264 else if ( store
!= NULL
)
266 fprintf( stderr
, "Project saved as %s.\n", name
);
272 fprintf( stderr
, "Usage: inigo [ -group [ name=value ]* ]\n"
273 " [ -consumer id[:arg] [ name=value ]* ]\n"
274 " [ -filter filter[:arg] [ name=value ] * ]\n"
275 " [ -attach filter[:arg] [ name=value ] * ]\n"
276 " [ -mix length [ -mixer transition ]* ]\n"
277 " [ -transition id[:arg] [ name=value ] * ]\n"
278 " [ -blank frames ]\n"
280 " [ -split relative-frame ]\n"
282 " [ -repeat times ]\n"
283 " [ producer [ name=value ] * ]+\n" );
286 // Close the consumer
287 if ( consumer
!= NULL
)
288 mlt_consumer_close( consumer
);
290 // Close the producer
292 mlt_producer_close( inigo
);
295 mlt_factory_close( );