// Check if we're seekable (something funny about mpeg here :-/)
if ( strcmp( file, "pipe:" ) && strncmp( file, "http://", 6 ) )
- mlt_properties_set_int( properties, "seekable", av_seek_frame( context, -1, mlt_properties_get_double( properties, "start_time" ) ) >= 0 );
+ mlt_properties_set_int( properties, "seekable", av_seek_frame( context, -1, mlt_properties_get_double( properties, "start_time" ), AVSEEK_FLAG_BACKWARD ) >= 0 );
else
av_bypass = 1;
// Fast forward - seeking is inefficient for small distances - just ignore following frames
ignore = position - expected;
}
- else if ( codec_context->has_b_frames == 0 || ( position < expected || position - expected >= 12 ) )
+ else if ( seekable && ( position < expected || position - expected >= 12 ) )
{
// Set to the real timecode
- av_seek_frame( context, -1, mlt_properties_get_double( properties, "start_time" ) + real_timecode * 1000000.0 );
+ av_seek_frame( context, -1, mlt_properties_get_double( properties, "start_time" ) + real_timecode * 1000000.0, AVSEEK_FLAG_BACKWARD );
// Remove the cached info relating to the previous position
mlt_properties_set_double( properties, "current_time", real_timecode );
{
int ret = 0;
int got_picture = 0;
+ int must_decode = 1;
+
+ // Temporary hack to improve intra frame only
+ if ( !strcmp( codec_context->codec->name, "mjpeg" ) )
+ must_decode = 0;
memset( &pkt, 0, sizeof( pkt ) );
// We only deal with video from the selected video_index
if ( ret >= 0 && pkt.stream_index == index && pkt.size > 0 )
{
+ // Determine time code of the packet
+ if ( pkt.pts != AV_NOPTS_VALUE )
+ current_time = ( double )pkt.pts / 1000000.0;
+ else
+ current_time = real_timecode;
+
// Decode the image
- ret = avcodec_decode_video( codec_context, av_frame, &got_picture, pkt.data, pkt.size );
+ if ( must_decode || current_time >= real_timecode )
+ ret = avcodec_decode_video( codec_context, av_frame, &got_picture, pkt.data, pkt.size );
if ( got_picture )
{
- if ( pkt.pts != AV_NOPTS_VALUE )
- current_time = ( double )pkt.pts / 1000000.0;
- else
- current_time = real_timecode;
-
// Handle ignore
if ( ( int )( current_time * 100 ) < ( int )( real_timecode * 100 ) - 7 )
{
}
else if ( current_time >= real_timecode )
{
- //current_time = real_timecode;
ignore = 0;
}
else if ( ignore -- )
if ( codec != NULL )
{
double source_fps = 0;
+ int norm_aspect_ratio = mlt_properties_get_int( properties, "norm_aspect_ratio" );
// XXX: We won't know the real aspect ratio until an image is decoded
// but we do need it now (to satisfy filter_resize) - take a guess based
// on pal/ntsc
- if ( codec_context->sample_aspect_ratio.num > 0 )
+ if ( !norm_aspect_ratio && codec_context->sample_aspect_ratio.num > 0 )
{
mlt_properties_set_double( properties, "aspect_ratio", av_q2d( codec_context->sample_aspect_ratio ) );
}
else if ( position < expected || position - expected >= 12 )
{
// Set to the real timecode
- if ( av_seek_frame( context, -1, mlt_properties_get_double( properties, "start_time" ) + real_timecode * 1000000.0 ) != 0 )
+ if ( av_seek_frame( context, -1, mlt_properties_get_double( properties, "start_time" ) + real_timecode * 1000000.0, AVSEEK_FLAG_BACKWARD ) != 0 )
paused = 1;
// Clear the usage in the audio buffer
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_position( this ) );
+ mlt_properties_set_position( mlt_frame_properties( *frame ), "avformat_position", mlt_producer_frame( this ) );
// Set up the video
producer_set_up_video( this, *frame );