From 1ad332f8a57dd8a0b6c94a512738910e6866ca97 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 30 Sep 2009 08:19:49 +0000 Subject: [PATCH] lavf: if seeking in the desired direction failed, also try in the opposite one, otherwise we might end up at some random position (where lavf last ended up while trying to build the index). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29741 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_lavf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 3ac0b6d489..4bff317b9b 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -617,7 +617,10 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, float audio } else { priv->last_pts += rel_seek_secs * AV_TIME_BASE; } - av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags); + if (av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags) < 0) { + avsflags ^= AVSEEK_FLAG_BACKWARD; + av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags); + } } static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)