summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-08 13:12:46 +0100
committerwm4 <wm4@nowhere>2012-12-11 00:36:42 +0100
commitb3fb7c2cade9d70a4ca05821c87f68e941da6237 (patch)
tree192974248bd908e6b807d5fbf070174e48470d30 /demux/demux.c
parent7288834a4c2945729f5a261cba2c007683754b7b (diff)
downloadmpv-b3fb7c2cade9d70a4ca05821c87f68e941da6237.tar.bz2
mpv-b3fb7c2cade9d70a4ca05821c87f68e941da6237.tar.xz
core: improve seeking in external files
This affects streams loaded with -subfile and -audiofile. They could get out of sync when they were deselected, and the main file was seeked. Add code to seek external files when they are selected (see init_demux_stream()). Use avformat_seek_file() under certain circumstances. Both av_seek_frame() ("old" API) and avformat_seek_file() ("new" API) seem to be broken with some formats. At least the vobsub demuxer doesn't implement the old API (and the old API doesn't fallback to the new API), while the fallback from new API to old API gives bad results. For example, seeking forward with small step sizes seems to fail with the new API (tested with Matroska by trying to seek 1 second forward relative to priv->last_pts). Since only subtitle demuxers implement the new API anyway, checking whether iformat->read_seek2 is set to test whether the old API is not supported gives best results. This is a hack at best, but makes things work. Remove backwards seeking on seek failure. This was annoying, and only was there to compensate for obscure corner cases (see 1ad332). In particular, files with completely broken seeking that used to skip back to the start on every seek request may now terminate playback.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 82159057d8..f765b2ae87 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1077,6 +1077,10 @@ int demux_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay,
mp_tmsg(MSGT_SEEK, MSGL_WARN, "Cannot seek in this file.\n");
return 0;
}
+
+ if (rel_seek_secs == MP_NOPTS_VALUE && (flags & SEEK_ABSOLUTE))
+ return 0;
+
// clear demux buffers:
demux_flush(demuxer);
demuxer->video->eof = 0;