From 7d91581a9beeda493919b3cb50ec89e192e86392 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Wed, 17 Jun 2009 22:44:28 +0200 Subject: [PATCH] avformat: better seperation between time and byte seek operations. It seems that avformat does not recover from a byteseek when it does not know a duration for the file. It continiously spits out data with pts values of AV_NOPTS_VALUE after the seek. Tested with mxf_original_NOB_format.mxf --- modules/demux/avformat/demux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c index 16a9cb0471..9bf5684922 100644 --- a/modules/demux/avformat/demux.c +++ b/modules/demux/avformat/demux.c @@ -535,7 +535,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) case DEMUX_SET_POSITION: f = (double) va_arg( args, double ); - i64 = stream_Tell( p_demux->s ); if( p_sys->i_pcr > 0 ) { i64 = p_sys->ic->duration * f; @@ -550,12 +549,16 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) (av_seek_frame( p_sys->ic, -1, i64, 0 ) < 0) ) { int64_t i_size = stream_Size( p_demux->s ); + i64 = (i_size * f); msg_Warn( p_demux, "DEMUX_SET_BYTE_POSITION: %"PRId64, i64 ); - if( av_seek_frame( p_sys->ic, -1, (i_size * f), AVSEEK_FLAG_BYTE ) < 0 ) + if( av_seek_frame( p_sys->ic, -1, i64, AVSEEK_FLAG_BYTE ) < 0 ) return VLC_EGENERIC; } - UpdateSeekPoint( p_demux, i64 ); + else + { + UpdateSeekPoint( p_demux, i64 ); + } p_sys->i_pcr = -1; /* Invalidate time display */ } return VLC_SUCCESS; -- 2.39.2