changeset 29699:3819fcdeaaf8

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).
author reimar
date Wed, 30 Sep 2009 08:19:49 +0000
parents 069c927d20d2
children cd5b4ddc9546
files libmpdemux/demux_lavf.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_lavf.c	Wed Sep 30 07:54:04 2009 +0000
+++ b/libmpdemux/demux_lavf.c	Wed Sep 30 08:19:49 2009 +0000
@@ -617,7 +617,10 @@
     } 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)