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

Michael Niedermayer michaelni
Tue Jan 27 20:07:34 CET 2009

On Tue, Jan 27, 2009 at 05:13:53PM +0100, Luca Abeni wrote:
> 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
> delay.
> 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)

we cant do that, this will break framerate detection for these codecs
in some cases

> 2) add a codec capability that says that the time base of
>     this codec has to be considered reliable

there is nothing codec specific.
As you already noted yourself its a file vs. network issue

I think the most obvious thing is the simple question if the user
app wants the guessed frame rate or not.
ffplay does not give a damn about it and ffmpeg in some cases
should not need it either but for some cases like avi output
it is essential to have some "reasonable minimal" timebase and not
Adding a flag to enable/disable it should be easy ...

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- 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/20090127/af04b0e2/attachment.pgp>

More information about the ffmpeg-devel mailing list