From 6856d81c6826e9698fe0154903f509d5a82917bb Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 30 Jul 2014 02:21:35 +0200 Subject: stream: hack-fix rtmp-level seeking This didn't work, because the timebase was wrong. According to the ffmpeg doxygen, if the stream index is -1 (which is what we used), the timebase is AV_TIME_BASE. But this didn't work, and it really expected the stream's timebase. Quite "surprising", since this feature (avio_seek_time) is used by rtmp only. Fixing this properly is too hard, so hack-fix our way around it. STREAM_CTRL_SEEK_TO_TIME is also used by DVD/BD, so a new STREAM_CTRL_AVSEEK is added. We simply pass-through the request verbatim. --- stream/stream_lavf.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'stream/stream_lavf.c') diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index c736ade45f..8d8ceb3f94 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -101,8 +101,7 @@ static int control(stream_t *s, int cmd, void *arg) AVIOContext *avio = s->priv; if (!avio && cmd != STREAM_CTRL_RECONNECT) return -1; - int64_t size, ts; - double pts; + int64_t size; switch(cmd) { case STREAM_CTRL_GET_SIZE: size = avio_size(avio); @@ -111,13 +110,13 @@ static int control(stream_t *s, int cmd, void *arg) return 1; } break; - case STREAM_CTRL_SEEK_TO_TIME: - pts = *(double *)arg; - ts = pts * AV_TIME_BASE; - ts = avio_seek_time(avio, -1, ts, 0); - if (ts >= 0) + case STREAM_CTRL_AVSEEK: { + struct stream_avseek *c = arg; + int64_t r = avio_seek_time(avio, c->stream_index, c->timestamp, c->flags); + if (r >= 0) return 1; break; + } case STREAM_CTRL_GET_METADATA: { *(struct mp_tags **)arg = read_icy(s); if (!*(struct mp_tags **)arg) -- cgit v1.2.3