diff mbox

[FFmpeg-devel,1/1] libavformat/mov.c: use calculated dts offset when seeking in streams

Message ID 20171026163256.19604-1-pegro@friiks.de
State Superseded
Headers show

Commit Message

Peter Gro├če Oct. 26, 2017, 4:32 p.m. UTC
From: Jonas Licht <jonas.licht@fem.tu-ilmenau.de>

Subtract the calculated dts offset from the requested timestamp before
seeking. This fixes an error "Error while filtering: Operation not
permitted" observed with a short file which contains only one key frame
and starts with negative timestamps.

Then, av_index_search_timestamp() returns a valid negative timestamp,
but mov_seek_stream bails out with AVERROR_INVALIDDATA.

Fixes ticket #6139.

Signed-off-by: Jonas Licht <jonas.licht@fem.tu-ilmenau.de>
---
 libavformat/mov.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a5177e8f91..029d6a152d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6918,10 +6918,12 @@  static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t timestamp
 static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
 {
     MOVStreamContext *sc = st->priv_data;
-    int sample, time_sample;
+    int sample, time_sample, ret;
     unsigned int i;
 
-    int ret = mov_seek_fragment(s, st, timestamp);
+    timestamp -= sc->time_offset;
+
+    ret = mov_seek_fragment(s, st, timestamp);
     if (ret < 0)
         return ret;