From 1bae5641ab21c0f15572dc016a8deef2a32d15b5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 21 Apr 2013 00:21:23 +0200 Subject: demux_lavf: fix subtitle seeking before start of the file When trying to seek before the start of the file, which usually happens when using the arrow keys to seek to the start of the file, external libavformat demuxed subtitles will be invisible. This is because seeking in the external subtitle file fails, so the subtitle demuxer is left in a random state. This is actually similar to the normal seeking path, which has some fallback code to handle this situation. Add such code to the subtitle seeking path too. (Normally, all demuxer support av_seek_frame(), except subtitles, which support avformat_seek_file() only. The latter was meant to be the "new" seeking API, but this never really took off, and using it normally seems to cause worse seeking behavior. Or maybe we just use it incorrectly, nobody really knows.) --- demux/demux_lavf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'demux/demux_lavf.c') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 968e9e60c8..8a8b003680 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -701,8 +701,13 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, // 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); + int r = avformat_seek_file(priv->avfc, -1, INT64_MIN, + priv->last_pts, priv->last_pts, avsflags); + // Similar issue as in the normal seeking codepath. + if (r < 0) { + avformat_seek_file(priv->avfc, -1, INT64_MIN, + priv->last_pts, INT64_MAX, avsflags); + } } } -- cgit v1.2.3