int64_t time_image = 0;
// Get the first frame
- gettimeofday( &ante, NULL );
frame = mlt_consumer_get_frame( this );
- time_frame = time_difference( &ante );
// Get the image of the first frame
mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 );
mlt_properties_set_int( mlt_frame_properties( frame ), "rendered", 1 );
- time_image = time_difference( &ante );
+
+ // Get the starting time (can ignore the times above)
+ gettimeofday( &ante, NULL );
// Continue to read ahead
while ( this->ahead )
count ++;
// Get the image
- if ( ( time_frame + time_image + time_wait ) / count < 40000 )
+ if ( ( time_frame + time_image ) / count < ( 40000 - ( time_wait / count ) ) )
{
// Get the image, mark as rendered and time it
mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 );
mlt_properties_set_int( mlt_frame_properties( frame ), "rendered", 1 );
time_image += time_difference( &ante );
}
- else
- {
- // This is wrong, but it avoids slower machines getting starved
- // It is, after all, impossible to go back in time :-/
- time_image -= ( time_image / count / 8 );
- }
}
// Remove the last frame
// Allocate a single PAL frame for encoding
uint8_t *dv_frame = malloc( frame_size_625_50 );
+ // Frame and size
+ mlt_frame frame = NULL;
+ int size = 0;
+
// Loop while running
while( mlt_properties_get_int( properties, "running" ) )
{
// Get the frame
- mlt_frame frame = mlt_consumer_rt_frame( this );
+ frame = mlt_consumer_rt_frame( this );
// Check that we have a frame to work with
if ( frame != NULL )
if ( libdv_get_encoder( this, frame ) != NULL )
{
// Encode the image
- int size = video( this, dv_frame, frame );
+ size = video( this, dv_frame, frame );
// Encode the audio
if ( size > 0 )