[Libav-user] How to know if lavf guessed the duration from the bitrate or not?

Michael Bradshaw mbradshaw at sorensonmedia.com
Wed Jun 13 17:58:49 CEST 2012

On Tue, Jun 12, 2012 at 8:12 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Tue, Jun 12, 2012 at 11:44:03AM -0600, Michael Bradshaw wrote:
>> avformat_find_stream_info() attempts to find the file's and streams'
>> durations, but it will guess them based on the bitrate if it can't
>> determine the actual duration. This guess can be useful, but I need to
>> be able to know if the AVFormatContext's or AVStream's duration was a
>> guess   based on the bitrate or not, so I know how much I should trust
>> this duration.
>> Is there a way to know this?
> One could parse the av_log() output other then that, i dont think
> theres a way thats not quite fragile currently.
> One thing that could be done is extending the API with  a flag that
> specifies the expected accuracy of the duration field

I think the flag would be nice. Would it be added to both
AVFormatContext and AVStream, or just one of them? I think
AVFormatContext may be sufficient, and would be the simplest (as
AVStream has no flags member). Perhaps 3 flags can be added:


and estimate_timings() can set the proper flag according to what
method it uses. Your thoughts? I can submit a patch today (if you
don't beat me to it).



More information about the Libav-user mailing list