[FFmpeg-devel] Problem with av_find_stream_info and possible solution(s)

Luca Abeni lucabe72
Tue Jan 27 17:13:53 CET 2009

Hi all,

currently, av_find_stream_info() tries to decode frames
until the stream parameters have been identified and the
time base is considered reliable, or until a maximum amount
of data has been read.
Some codecs, such as MJPEG (but also raw video, and all
the variable-frame-rate codecs, I think), do not set a
reliable time_base, hence the maximum amount is always
read. This is not a problem if the stream is read from a
file, but can be a problem with "timed" streams that becomes
available at a fixed rate (network streams, compressed streams
coming from a webcam, TSs coming from a dvb card, etc...)
because av_find_stream_info() ends up generating a noticeable

How is it possible to fix this problem?
I see two possibilities:
1) modify libavformat/utils.c:tb_unreliable() to consider
    reliable the time base of codecs that will never set it
    to "reliable" values (such as rawvideo, mjpeg, h.263 - I
    think - and similar)
2) add a codec capability that says that the time base of
    this codec has to be considered reliable

Now, the questions:
1) Is my analysis of the problem correct, or did I completely
    misunderstand something?
2) Am I missing a simple solution?
3) Is one of my proposed solutions acceptable?
    (I know I can make things work by using one of my proposed
    solutions, but I want to do the right thing, not a hack that
    can be due to some misunderstanding of mine... ;-)
4) Is one of my proposed solutions the correct one? If no,
    which would be the correct solution? If someone can give
    me a good hint, I'll try to implement it.


More information about the ffmpeg-devel mailing list