[FFmpeg-devel] [PATCH V1 5/5] lavf/utils: add duration estimate method trace

mypopy at gmail.com mypopy at gmail.com
Sun Sep 29 03:59:03 EEST 2019


On Sat, Sep 28, 2019 at 11:29 PM Michael Niedermayer
<michael at niedermayer.cc> wrote:
>
> On Sat, Sep 28, 2019 at 08:23:57PM +0800, Jun Zhao wrote:
> > From: Jun Zhao <barryjzhao at tencent.com>
> >
> > add duration estimate method trace, it's can help to some duration
> > issue trace or debug.
>
> theres some english grammer issue here
>
Will fix, thx
>
> >
> > Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
> > ---
> >  libavformat/utils.c |   16 +++++++++++++++-
> >  1 files changed, 15 insertions(+), 1 deletions(-)
> >
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index c0ccd8c..8620c6f 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -2977,6 +2977,16 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
> >      {
> >          int i;
> >          AVStream av_unused *st;
> > +        const char *duration_method;
>
> > +        struct duration_mode {
> > +            enum AVDurationEstimationMethod mode;
> > +            const char *name; ///< short name for the duration estimation method
> > +        };
> > +        struct duration_mode duration_modes[] = {
> > +            { AVFMT_DURATION_FROM_PTS,    "pts"       },
> > +            { AVFMT_DURATION_FROM_STREAM, "stream"    },
> > +            { AVFMT_DURATION_FROM_BITRATE,"bit rate"  },
> > +        };
>
> This maybe could be in a seperate function
>
Will split as a seperate function
>
> >          for (i = 0; i < ic->nb_streams; i++) {
> >              st = ic->streams[i];
> >              if (st->time_base.den)
> > @@ -2984,10 +2994,14 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
> >                         (double) st->start_time * av_q2d(st->time_base),
> >                         (double) st->duration   * av_q2d(st->time_base));
> >          }
> > +        for (i = 0; i < FF_ARRAY_ELEMS(duration_modes); i++)
> > +            if (ic->duration_estimation_method == duration_modes[i].mode)
> > +                duration_method = duration_modes[i].name;
> >          av_log(ic, AV_LOG_TRACE,
> > -                "format: start_time: %0.3f duration: %0.3f bitrate=%"PRId64" kb/s\n",
> > +                "format: start_time: %0.3f duration: %0.3f (estimate from %s) bitrate=%"PRId64" kb/s\n",
> >                  (double) ic->start_time / AV_TIME_BASE,
> >                  (double) ic->duration   / AV_TIME_BASE,
> > +                duration_method,
> >                  (int64_t)ic->bit_rate / 1000);
> >      }
>
> rest LGTM
>
> thx
>
> [...]
>
> --


More information about the ffmpeg-devel mailing list