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. --- demux/demux_lavf.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'demux') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 9a44e9ac35..41263ceabf 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -183,11 +183,14 @@ static int64_t mp_read_seek(void *opaque, int stream_idx, int64_t ts, int flags) { struct demuxer *demuxer = opaque; struct stream *stream = demuxer->stream; - struct lavf_priv *priv = demuxer->priv; - AVStream *st = priv->avfc->streams[stream_idx]; - double pts = (double)ts * st->time_base.num / st->time_base.den; - int ret = stream_control(stream, STREAM_CTRL_SEEK_TO_TIME, &pts); + struct stream_avseek cmd = { + .stream_index = stream_idx, + .timestamp = ts, + .flags = flags, + }; + + int ret = stream_control(stream, STREAM_CTRL_AVSEEK, &cmd); return ret < 1 ? AVERROR(ENOSYS) : 0; } -- cgit v1.2.3