#include <framework/mlt_frame.h>
// ffmpeg Header files
-#include <ffmpeg/avformat.h>
+#include <avformat.h>
// System header files
#include <stdlib.h>
// Find default audio and video streams
find_default_streams( context, &audio_index, &video_index );
+ // Check if we're seekable (something funny about mpeg here :-/)
+ if ( strstr( file, ".mpg" ) == NULL && strstr( file, ".mpeg" ) == NULL )
+ mlt_properties_set_int( properties, "seekable", av_seek_frame( context, -1, context->start_time ) >= 0 );
+ else
+ mlt_properties_set_int( properties, "seekable", 1 );
+
// Store selected audio and video indexes on properties
mlt_properties_set_int( properties, "audio_index", audio_index );
mlt_properties_set_int( properties, "video_index", video_index );
else
{
// Set to the real timecode
- av_seek_frame( context, -1, real_timecode * 1000000.0 );
+ av_seek_frame( context, -1, context->start_time + real_timecode * 1000000.0 );
// Remove the cached info relating to the previous position
mlt_properties_set_double( properties, "current_time", real_timecode );
{
got_picture = 0;
}
+ mlt_properties_set_int( properties, "top_field_first", frame.top_field_first );
}
}
}
}
}
+
+ // Set the field order property for this frame
+ mlt_properties_set_int( frame_properties, "top_field_first",
+ mlt_properties_get_int( properties, "top_field_first" ) );
// Regardless of speed, we expect to get the next frame (cos we ain't too bright)
mlt_properties_set_position( properties, "video_expected", position + 1 );
// Get the audio_index
int index = mlt_properties_get_int( properties, "audio_index" );
+ // Get the seekable status
+ int seekable = mlt_properties_get_int( properties, "seekable" );
+
// Obtain the expected frame numer
mlt_position expected = mlt_properties_get_position( properties, "audio_expected" );
// Flag for paused (silence)
int paused = 0;
- int locked = 0;
// Lock the mutex now
avformat_lock( );
else
{
// Set to the real timecode
- av_seek_frame( context, -1, real_timecode * 1000000.0 );
+ if ( !seekable || av_seek_frame( context, -1, context->start_time + real_timecode * 1000000.0 ) != 0 )
+ paused = 1;
// Clear the usage in the audio buffer
audio_used = 0;
-
- locked = 1;
}
}
mlt_properties_set_double( properties, "discrepancy", discrepancy );
}
- if ( !ignore && discrepancy * current_pts <= ( real_timecode - 0.02 ) )
+ if ( seekable && ( !ignore && discrepancy * current_pts <= ( real_timecode - 0.02 ) ) )
ignore = 1;
}
mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples );
}
- // Regardless of speed, we expect to get the next frame (cos we ain't too bright)
- mlt_properties_set_position( properties, "audio_expected", position + 1 );
+ // Regardless of speed (other than paused), we expect to get the next frame
+ if ( !paused )
+ mlt_properties_set_position( properties, "audio_expected", position + 1 );
// Unlock the mutex now
avformat_unlock( );
mlt_frame_set_position( *frame, mlt_producer_position( this ) );
// Set the position of this producer
- mlt_properties_set_position( mlt_frame_properties( *frame ), "avformat_position", mlt_producer_get_in( this ) + mlt_producer_position( this ) );
+ mlt_properties_set_position( mlt_frame_properties( *frame ), "avformat_position", mlt_producer_position( this ) );
// Set up the video
producer_set_up_video( this, *frame );