diff options
author | wm4 <wm4@nowhere> | 2013-04-21 00:21:23 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-04-21 00:21:23 +0200 |
commit | 1bae5641ab21c0f15572dc016a8deef2a32d15b5 (patch) | |
tree | c886404f47927c3b30a24cf757bd18a4d4023360 /demux | |
parent | c768a00dfe669b9406f9baba9c027cb1c9a19d6c (diff) | |
download | mpv-1bae5641ab21c0f15572dc016a8deef2a32d15b5.tar.bz2 mpv-1bae5641ab21c0f15572dc016a8deef2a32d15b5.tar.xz |
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.)
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux_lavf.c | 9 |
1 files changed, 7 insertions, 2 deletions
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); + } } } |