summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/options.rst10
-rw-r--r--demux/demux_raw.c4
2 files changed, 13 insertions, 1 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index f49b5f4f46..6aa3466d0d 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -479,6 +479,16 @@ Playback Control
framestep commands are transposed. Backstepping will perform very
expensive work to step forward by 1 frame.
+ - Backward playback in wav files does not work properly (and possibly
+ similar formats, typically raw audio formats used through libavformat).
+ This is because libavformat does not align seeks on the packet sizes it
+ uses. (The packet sizes are arbitrary and chosen by libavformat
+ internally. Seeks on the other hand are sample-exact, which leads to
+ overlapping packets if the backward playback state machine seeks back.
+ This is very complex to work around, so it doesn't attempt to.)
+ A workaround is to remux to a format like mkv, which enforces packet
+ boundaries. Making mpv cache the entire file in memory also works.
+
Tuning:
- Remove all ``--vf``/``--af`` filters you have set. Disable deinterlacing.
diff --git a/demux/demux_raw.c b/demux/demux_raw.c
index 2b47ebfedf..7469d80c5e 100644
--- a/demux/demux_raw.c
+++ b/demux/demux_raw.c
@@ -301,7 +301,9 @@ static void raw_seek(demuxer_t *demuxer, double seek_pts, int flags)
stream_t *s = demuxer->stream;
int64_t end = 0;
stream_control(s, STREAM_CTRL_GET_SIZE, &end);
- int64_t pos = seek_pts * p->frame_rate * p->frame_size;
+ int64_t frame_nr = seek_pts * p->frame_rate;
+ frame_nr = frame_nr - (frame_nr % p->read_frames);
+ int64_t pos = frame_nr * p->frame_size;
if (flags & SEEK_FACTOR)
pos = end * seek_pts;
if (pos < 0)