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 if ( strlen( value
) == 1 )
19 mlt_properties_set_int( properties
, "done", 1 );
22 mlt_producer_set_speed( producer
, 1 );
23 mlt_producer_seek( producer
, 0 );
26 mlt_producer_set_speed( producer
, -10 );
29 mlt_producer_set_speed( producer
, -5 );
32 mlt_producer_set_speed( producer
, -2 );
35 mlt_producer_set_speed( producer
, -1 );
38 mlt_producer_set_speed( producer
, 0 );
42 mlt_producer_set_speed( producer
, 1 );
45 mlt_producer_set_speed( producer
, 2 );
48 mlt_producer_set_speed( producer
, 5 );
51 mlt_producer_set_speed( producer
, 10 );
54 if ( multitrack
!= NULL
)
57 mlt_position last
= -1;
58 for ( i
= 0; 1; i
++ )
60 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_start
, i
);
64 fprintf( stderr
, "%d: %lld\n", i
, time
);
66 fprintf( stderr
, "Current Position: %lld\n", mlt_producer_position( producer
) );
71 if ( multitrack
!= NULL
)
73 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, 0 );
74 mlt_producer_seek( producer
, time
);
78 if ( producer
!= NULL
)
80 mlt_position position
= mlt_producer_position( producer
);
81 mlt_producer_seek( producer
, position
- ( mlt_producer_get_fps( producer
) * 60 ) );
85 if ( producer
!= NULL
)
87 mlt_position position
= mlt_producer_position( producer
);
88 mlt_producer_set_speed( producer
, 0 );
89 mlt_producer_seek( producer
, position
- 1 );
93 if ( multitrack
!= NULL
)
95 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, 1 );
96 mlt_producer_seek( producer
, time
);
100 if ( multitrack
!= NULL
)
102 mlt_position time
= mlt_multitrack_clip( multitrack
, mlt_whence_relative_current
, -1 );
103 mlt_producer_seek( producer
, time
);
107 if ( producer
!= NULL
)
109 mlt_position position
= mlt_producer_position( producer
);
110 mlt_producer_set_speed( producer
, 0 );
111 mlt_producer_seek( producer
, position
+ 1 );
115 if ( producer
!= NULL
)
117 mlt_position position
= mlt_producer_position( producer
);
118 mlt_producer_seek( producer
, position
+ ( mlt_producer_get_fps( producer
) * 60 ) );
125 static mlt_consumer
create_consumer( char *id
, mlt_producer producer
)
127 char *arg
= strchr( id
, ':' );
130 mlt_consumer consumer
= mlt_factory_consumer( id
, arg
);
131 if ( consumer
!= NULL
)
133 mlt_properties properties
= mlt_consumer_properties( consumer
);
134 mlt_properties_set_data( properties
, "transport_callback", transport_action
, 0, NULL
, NULL
);
135 mlt_properties_set_data( properties
, "transport_producer", producer
, 0, NULL
, NULL
);
140 static void transport( mlt_producer producer
)
142 mlt_properties properties
= mlt_producer_properties( producer
);
146 fprintf( stderr
, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
147 fprintf( stderr
, "|1=-10| |2= -5| |3= -2| |4= -1| |5= 0| |6= 1| |7= 2| |8= 5| |9= 10|\n" );
148 fprintf( stderr
, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" );
150 fprintf( stderr
, "+---------------------------------------------------------------------+\n" );
151 fprintf( stderr
, "| H = back 1 minute, L = forward 1 minute |\n" );
152 fprintf( stderr
, "| h = previous frame, l = next frame |\n" );
153 fprintf( stderr
, "| g = start of clip, j = next clip, k = previous clip |\n" );
154 fprintf( stderr
, "| 0 = restart, q = quit, space = play |\n" );
155 fprintf( stderr
, "+---------------------------------------------------------------------+\n" );
157 while( mlt_properties_get_int( properties
, "done" ) == 0 )
159 int value
= term_read( );
161 transport_action( producer
, ( char * )&value
);
165 int main( int argc
, char **argv
)
168 mlt_consumer consumer
= NULL
;
169 mlt_producer inigo
= NULL
;
173 // Construct the factory
174 mlt_factory_init( getenv( "MLT_REPOSITORY" ) );
176 for ( i
= 1; i
< argc
; i
++ )
178 if ( !strcmp( argv
[ i
], "-serialise" ) )
181 if ( strstr( name
, ".inigo" ) )
182 store
= fopen( name
, "w" );
186 // Get inigo producer
187 inigo
= mlt_factory_producer( "inigo", &argv
[ 1 ] );
189 if ( argc
> 1 && inigo
!= NULL
&& mlt_producer_get_length( inigo
) > 0 )
191 // Get inigo's properties
192 mlt_properties inigo_props
= mlt_producer_properties( inigo
);
194 // Get the field service from inigo
195 mlt_field field
= mlt_properties_get_data( inigo_props
, "field", 0 );
197 // Get the last group
198 mlt_properties group
= mlt_properties_get_data( inigo_props
, "group", 0 );
200 // Parse the arguments
201 for ( i
= 1; i
< argc
; i
++ )
203 if ( !strcmp( argv
[ i
], "-consumer" ) )
205 consumer
= create_consumer( argv
[ ++ i
], inigo
);
206 while ( argv
[ i
+ 1 ] != NULL
&& strstr( argv
[ i
+ 1 ], "=" ) )
207 mlt_properties_parse( group
, argv
[ ++ i
] );
209 else if ( !strcmp( argv
[ i
], "-serialise" ) )
216 fprintf( store
, "%s\n", argv
[ i
] );
220 while ( argv
[ i
] != NULL
&& argv
[ i
][ 0 ] != '-' )
223 fprintf( store
, "%s\n", argv
[ i
] );
231 // If we have no consumer, default to sdl
232 if ( store
== NULL
&& consumer
== NULL
)
233 consumer
= create_consumer( "sdl", inigo
);
235 if ( consumer
!= NULL
&& store
== NULL
)
237 // Apply group settings
238 mlt_properties properties
= mlt_consumer_properties( consumer
);
239 mlt_properties_inherit( properties
, group
);
241 // Connect consumer to tractor
242 mlt_consumer_connect( consumer
, mlt_field_service( field
) );
244 // Start the consumer
245 mlt_consumer_start( consumer
);
247 // Transport functionality
251 mlt_consumer_stop( consumer
);
253 else if ( store
!= NULL
)
255 fprintf( stderr
, "Project saved as %s.\n", name
);
261 fprintf( stderr
, "Usage: inigo [ -group [ name=value ]* ]\n"
262 " [ -consumer id[:arg] [ name=value ]* ]\n"
263 " [ -filter id[:arg] [ name=value ] * ]\n"
264 " [ -transition id[:arg] [ name=value ] * ]\n"
265 " [ -blank frames ]\n"
267 " [ producer [ name=value ] * ]+\n" );
270 // Close the consumer
271 if ( consumer
!= NULL
)
272 mlt_consumer_close( consumer
);
274 // Close the producer
276 mlt_producer_close( inigo
);
279 mlt_factory_close( );