[FFmpeg-devel] [PATCH] Make sure AVFormatContext->start_time is initialized after the first patch

Martin Storsjö martin
Wed Jun 2 23:02:14 CEST 2010


On Wed, 2 Jun 2010, Baptiste Coudurier wrote:

> On 06/02/2010 01:50 PM, Martin Storsj? wrote:
> > On Wed, 2 Jun 2010, Baptiste Coudurier wrote:
> > 
> > > On 06/02/2010 01:17 PM, Martin Storsj? wrote:
> > > > 
> > > > Quoting Michael:
> > > > 
> > > > > The problem might be that ffserver calls av_seek_frame()
> > > > > with that the first packet demuxed might no longer correspond to the
> > > > > first packet.
> > > > > thus i think its not unreasonable if lavf doesnt set start_time to the
> > > > > first dts/pts once seeking has happened
> > > 
> > > _doesn't set_ does _not_ mean _unset_
> > > 
> > > start_time should be _set_ by av_find_stream_info _before_ the seek.
> > 
> > Actually, reading the code a bit more in detail, the code doesn't call
> > av_find_stream_info at all for inputs where iformat->name is "ffm".
> > 
> > Is there any particular reason for that?
> 
> This explains better why start_time is not set.
> 
> I think that's because there is no need to call it: all information is stored
> in the ffm file, codec time base, codec pix_fmt, so there is no need to.

Ok, makes sense.

> > Also, when reading the current ffserver code in more detail, the current
> > code that does
> > 
> >      c->cur_pts -= av_rescale_q(ist->start_time, ...)
> > 
> > ist->start_time in this case is the start time of this particular stream,
> > which could be slightly different for each stream. Shouldn't the absolute
> > to relative calculation be done using the same fixed origin for all
> > streams? That is, use c->fmt_in->start_time (which gets populated if
> > av_find_stream_info is called) or c->first_pts instead of ist->start_time?
> 
> I think you may be right, but extra checks where the values are used are
> needed, like how is cur_pts used, set, etc..

It's only set at that one place,
c->cur_pts = av_rescale_q(pkt.dts, ist->time_base, AV_TIME_BASE_Q);
and subtracted by some origin, and later used in get_packet_send_clock for 
getting the correct time for sending out that packet.

So in the light of that, cur_pts for all packets should be calculated 
against the same origin, and first_pts is a very good candidate for such 
an origin.

// Martin



More information about the ffmpeg-devel mailing list