[FFmpeg-devel] [PATCH] lavf/utils: update stream duration only if it is not set or 0

Michael Niedermayer michael at niedermayer.cc
Tue Jul 4 13:31:59 EEST 2017


On Mon, Jul 03, 2017 at 02:02:24PM +0200, Matthieu Bouron wrote:
> ---
> 
> The following patch makes lavf/utils only update stream duration only if it is
> not set or 0 in fill_all_stream_timings (which is called by
> avformat_find_stream_info).
> 
> In the context of mov demuxing, the patch makes the last packet duration the
> same as the one declared in the stts table for example (ie: we trust what the
> demuxer reports).
> 
> The patch passes fate, however it might not be valid but I would like to
> understand what is the purpose / use-case of the update_stream_timing /
> fill_all_stream_timings functions which are not too well documented.

I think these functions were mostly for filling in values that
have not been set otherwise
as in stream timings <-> file timings, that way demuxers can just
export what is stored in a file and teh rest is set from that


> 
> Thanks.
> 
> ---
>  libavformat/utils.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 38d247c6cd..00adf026e6 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2654,7 +2654,8 @@ static void fill_all_stream_timings(AVFormatContext *ic)
>              if (ic->start_time != AV_NOPTS_VALUE)
>                  st->start_time = av_rescale_q(ic->start_time, AV_TIME_BASE_Q,
>                                                st->time_base);
> -            if (ic->duration != AV_NOPTS_VALUE)
> +            if (ic->duration != AV_NOPTS_VALUE &&
> +                (st->duration == 0 || st->duration == AV_NOPTS_VALUE))
>                  st->duration = av_rescale_q(ic->duration, AV_TIME_BASE_Q,
>                                              st->time_base);
>          }

can a inconsistency occur from setting start_time and duration from
different sources ?



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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170704/59a8006b/attachment.sig>


More information about the ffmpeg-devel mailing list