[FFmpeg-devel] [PATCH] flv duration

Michael Niedermayer michaelni
Sun Apr 4 14:14:34 CEST 2010


On Sun, Apr 04, 2010 at 04:24:54AM -0700, Howard Chu wrote:
> elupus wrote:
>> On Sat, 03 Apr 2010 18:41:24 -0700, Howard Chu wrote:
>>
>>> Howard Chu wrote:
>>>> Michael Niedermayer wrote:
>>>>> On Thu, Apr 01, 2010 at 02:28:11AM -0700, Howard Chu wrote:
>>>>>> When playing an FLV, you always see this message:
>>>>>>
>>>>>> [flv @ 0x120cea0]Estimating duration from bitrate, this may be 
>>>>>> inaccurate
>>>>>>
>>>>>> even if the FLV metadata provides the duration. I'd been ignoring this 
>>>>>> for
>>>>>> the most part, but after someone else mentioned it on irc I decided to 
>>>>>> take
>>>>>> a look. The FLV demux sets the AVFormatContext->duration based on the
>>>>>> metadata, but the av_has_duration() function wants to see it set in 
>>>>>> one of
>>>>>> the AVStreams. It looks to me like it does no harm one way or the 
>>>>>> other,
>>>>>> but I wrote this patch just to shut up that diagnostic.
>>>>
>>>>> you dont need to set s->duration
>>>>
>>>> OK. Works fine, make test passes.
>>>
>>> Spoke too soon. Not setting s->duration breaks XBMC.
>>
>> In what way? lavf should have populated that from the stream duration
>> anyway.
>
> I don't know why, but it didn't, it was zero. And since by default XBMC 
> uses percentage-based seeks, all of my seek requests were turned into seeks 
> to zero. Restoring the line to set s->duration made it all work fine.
>
> I have to admit I wasn't really interested in digging to see why it wasn't 
> set by something else in lavf. I'm content knowing that this code was in 
> there originally, and things were working. My first patch preserved the 
> existing behavior, so I'm going to stick with it. This code base is just 
> too rife with unintended consequences, and there was no good reason to 
> remove that line in the first place.

The good reason was the API, but its unpopular to read the docs
   /** Decoding: duration of the stream, in AV_TIME_BASE fractional
       seconds. NEVER set this value directly: it is deduced from the
       AVStream values.  */
    int64_t duration;

maybe the (internal after all) API should be changed and demuxers should
set the AVFormatContext duration if thats the only thing they know. That
does seem to make sense but it requires that api text to be changed,
ill do that.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

> ... defining _GNU_SOURCE...
For the love of all that is holy, and some that is not, don't do that.
-- Luca & Mans
-------------- 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/20100404/a060ff76/attachment.pgp>



More information about the ffmpeg-devel mailing list