[FFmpeg-devel] [PATCH] RTMP seek support

Michael Niedermayer michaelni
Thu Apr 1 17:37:08 CEST 2010


On Wed, Mar 31, 2010 at 05:24:49PM -0700, Howard Chu wrote:
> Howard Chu wrote:
>> Michael Niedermayer wrote:
>>> On Tue, Mar 30, 2010 at 06:42:50PM -0700, Howard Chu wrote:
>>>>> Note that the did_rseek flag wouldn't even be needed if the rest of 
>>>>> flvdec
>>>>> always read from the start of a frame, instead of reading from the end 
>>>>> of
>>>>> the previous frame, as it currently does.
>>
>>> putting the url_fskip() inside the loop at the end seems cleaner to me
>>>
>>> also the url_fskip() movement could be a seperate patch
>>
>> OK, patch separated, url_fskip() moved to inside the loop.
>
> The rest of the patch.
>
> >> removial is planed but the new API might be changed if we find the need
> >> to change it still ...
>
> It seems to me that one thing that ought to be changed is that rescaling 
> the timestamp should still be done by the caller, not in read_seek2. Right 
> now each implementation of read_seek2() has to duplicate this code.

if rescaling is done outside then exact seeking becomes impossible
because rescaling implicates rounding


>
> -- 
>   -- Howard Chu
>   CTO, Symas Corp.           http://www.symas.com
>   Director, Highland Sun     http://highlandsun.com/hyc/
>   Chief Architect, OpenLDAP  http://www.openldap.org/project/

> Index: libavformat/flvdec.c
> ===================================================================
> --- libavformat/flvdec.c	(revision 22713)
> +++ libavformat/flvdec.c	(working copy)
> @@ -442,6 +442,38 @@
>      return ret;
>  }
>  
> +static int flv_read_seek(AVFormatContext *s, int stream_index,
> +    int64_t ts, int flags)
> +{
> +    return av_url_read_fseek(s->pb, stream_index, ts, flags);
> +}
> +
> +static int flv_read_seek2(AVFormatContext *s, int stream_index,
> +    int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
> +{
> +    int ret = AVERROR_NOTSUPP;
> +
> +    if (url_is_streamed(s->pb)) {
> +        if (stream_index < 0) {
> +            AVStream *st;
> +
> +            stream_index = av_find_default_stream_index(s);
> +            if (stream_index < 0)
> +                return -1;
> +
> +            st = s->streams[stream_index];
> +            // timestamp for default must be expressed in AV_TIME_BASE units
> +            ts = av_rescale(ts, st->time_base.den,
> +                                AV_TIME_BASE * (int64_t)st->time_base.num);
> +        }
> +        ret = av_url_read_fseek(s->pb, stream_index, ts, flags);
> +    }
> +
> +    if (ret == AVERROR_NOTSUPP)
> +        ret = av_seek_frame(s, stream_index, ts, flags | (ts - min_ts > (uint64_t)(max_ts - ts) ? AVSEEK_FLAG_BACKWARD : 0));
> +    return ret;
> +}

now i see what you meant by that this will need to be changed again
either way this does not implement the new API correctly
also you mix AVERROR_NOTSUPP with AVERROR(ENOSYS)

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100401/213ba9f7/attachment.pgp>



More information about the ffmpeg-devel mailing list