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.)
This commit is contained in:
wm4 2013-04-21 00:21:23 +02:00
parent c768a00dfe
commit 1bae5641ab
1 changed files with 7 additions and 2 deletions

View File

@ -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. // API by default, because there are some major issues.
// Set max_ts==ts, so that demuxing starts from an earlier position in // Set max_ts==ts, so that demuxing starts from an earlier position in
// the worst case. // the worst case.
avformat_seek_file(priv->avfc, -1, INT64_MIN, int r = avformat_seek_file(priv->avfc, -1, INT64_MIN,
priv->last_pts, priv->last_pts, avsflags); 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);
}
} }
} }