On Fri, 27 Jan 2017 15:09:52 +0200 (EET)
Martin Storsjö <[email protected]> wrote:

> On Fri, 27 Jan 2017, Peter Große wrote:
> 
> > The current implementation creates new segments comparing
> >
> >  pkt->pts - first_pts > total_duration  
> 
> I guess this would be more understandable written like this:
>     pkt->pts - first_pts > nb_segs * min_seg_duration
> or
>     total_duration > nb_segs * min_seg_duration

Agreed.

> > @@ -935,7 +934,7 @@ static int dash_write_packet(AVFormatContext *s,
> > AVPacket *pkt) os->max_pts = pkt->pts + pkt->duration;
> >     else
> >         os->max_pts = FFMAX(os->max_pts, pkt->pts + pkt->duration);
> > -    os->packets_written++;
> > +    os->duration_written += pkt->duration;
> >     return ff_write_chained(os->ctx, 0, pkt, s);
> > }  
> 
> This isn't the best way of achieving what you're trying to do.
> 
> Don't accumulate pkt->duration values. In general we can't really assume 
> that pkt->duration is set sensibly.
> 
> In some places we need an estimate of the duration of a packet, and in 
> those cases we fill it in using the duration of the previous packet (i.e. 
> the diff between this packets timestamp and the previous one) if we don't 
> have a definitive value available.
> 
> In those cases where we use an estimate of the duration, we make sure to 
> correct it as soon as possible when we get the real timestamps of the next 
> packet. But we shouldn't accumulate the values since that would end up 
> with accumulating the error, blowing it out of propertion at worst.

Ah ok, I see.

> To get the behaviour you want, couldn't you just change the comparison 
> like this:
> 
> -        av_compare_ts(pkt->pts - os->first_pts, st->time_base,
> -                      seg_end_duration, AV_TIME_BASE_Q) >= 0) {
> +        av_compare_ts(pkt->pts - os->start_pts, st->time_base,
> +                      c->min_seg_duration, AV_TIME_BASE_Q) >= 0) {
> 
> We already have the start timestamp of the current segment in 
> os->start_pts.

Looks like it, yes. Will change that.

Regards
Peter

Attachment: pgphKs2aV1FBg.pgp
Description: OpenPGP digital signature

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to