[FFmpeg-devel] [PATCH 2/2] avformat: add avformat_flush()
nfxjfg at googlemail.com
Mon Sep 29 20:34:44 CEST 2014
On Mon, 29 Sep 2014 20:25:47 +0200
Michael Niedermayer <michaelni at gmx.at> wrote:
> On Mon, Sep 29, 2014 at 07:41:28PM +0200, wm4 wrote:
> > Useful for Bluray and DVD, since the libraries used to read them just
> > change the byte stream under your feet on seeking.
> > Maybe there should be a AVInputFormat callback for this. But the
> > mpeg-ps (DVD) and the mpeg-ts (Bluray) demuxers don't change much
> > state during seeking - they just try to find a new packet with
> > timestamps (in read_timestamp), so I haven't found a need for this
> > yet. I don't want to add unused things.
> > I've also thought about adding a flush callback, and implementing
> > them in mpeg.c and mpegts.c by just calling ff_read_frame_flush().
> > Might be slightly better, because you can have avformat_flush() fail
> > on formats which don't support this?
> > Or maybe a flag?
> > TODO: add entry to APIchanges, bump minor version.
> > ---
> > libavformat/avformat.h | 13 +++++++++++++
> > libavformat/utils.c | 6 ++++++
> > 2 files changed, 19 insertions(+)
> > diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> > index 78054de..eaa52fa 100644
> > --- a/libavformat/avformat.h
> > +++ b/libavformat/avformat.h
> > @@ -2173,6 +2173,19 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
> > int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
> > /**
> > + * Discard all internally buffered data. This can be useful when dealing with
> > + * discontinuities in the byte stream. Generally works only with some simple
> > + * formats.
> id call them stream based or without a central header instead of
I can change that and replace "simple" with "headerless".
> > + *
> > + * This does not flush the AVIOContext (s->pb). If necessary, call
> > + * avio_flush(s->pb) before calling this function.
> > + *
> > + * @param s media file handle
> > + * @return >=0 on success, error code otherwise
> > + */
> > +int avformat_flush(AVFormatContext *s);
> i think this should document what happens with the streams
> are they flushed too so that nb_streams could decrease ...
> i guess the case where they could decrease doesnt make much sense
> as that can already be achived by closing the demuxer and reopening
> it ...
Removing the AVStreams would be not useful; keeping the streams around
is in fact this is the reason why reopening might not work, and
avformat_flush() is needed at all.
I can add something to the doxygen to explain this. Maybe: "The set of
streams, the detected duration, stream parameters and codecs do not
change when calling this function."
More information about the ffmpeg-devel