summaryrefslogtreecommitdiffstats
path: root/demux/demux_lavf.c
diff options
context:
space:
mode:
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r--demux/demux_lavf.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index c1c15f345a..42b687dc20 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -886,9 +886,17 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs,
priv->last_pts += rel_seek_secs * priv->avfc->duration;
} else
priv->last_pts += rel_seek_secs * AV_TIME_BASE;
- if (av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags) < 0) {
- avsflags ^= AVSEEK_FLAG_BACKWARD;
+
+ if (!priv->avfc->iformat->read_seek2) {
+ // Normal seeking.
av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags);
+ } else {
+ // av_seek_frame() won't work. Use "new" seeking API. We don't use this
+ // API by default, because there are some major issues.
+ // Set max_ts==ts, so that demuxing starts from an earlier position in
+ // the worst case.
+ avformat_seek_file(priv->avfc, -1, INT64_MIN,
+ priv->last_pts, priv->last_pts, avsflags);
}
}