[FFmpeg-devel] [PATCH v4 0/3] Add option to log timing

ffmpegagent ffmpegagent at gmail.com
Fri Feb 7 08:27:23 EET 2025


This pathcset adds two logging flags: 'timing' and 'datetiming'.

Usage:

ffmpeg -loglevel +timing

or

ffmpeg -loglevel +datetiming

Update V1

 * Fix merge conflicts

Update V2

 * Rebased

Update V3

 * Fix print timing on exit (as reported by Michael Niedermayer)

softworkz (3):
  avutil/log: support logging of date and timing information
  fftools/opt_common: add timing and datetiming log flags
  doc/fftools-common-opts: document log timing flags

 doc/APIchanges               |  3 +++
 doc/fftools-common-opts.texi |  4 ++++
 fftools/ffmpeg.c             |  1 +
 fftools/opt_common.c         | 12 ++++++++++++
 libavutil/log.c              | 32 +++++++++++++++++++++++++++++---
 libavutil/log.h              | 10 ++++++++++
 libavutil/version.h          |  2 +-
 7 files changed, 60 insertions(+), 4 deletions(-)


base-commit: 4ba9ae7742a6f8a29d6486e25ff5709a075edb5b
Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-37%2Fsoftworkz%2Fsubmit_logtiming-v4
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-37/softworkz/submit_logtiming-v4
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/37

Range-diff vs v3:

 1:  13a7dc164b ! 1:  2871595d3b avutil/log: support logging of date and timing information
     @@ libavutil/log.c: static const char *item_name(void *obj, const AVClass *cls)
           return (cls->item_name ? cls->item_name : av_default_item_name)(obj);
       }
       
     -+static void format_date_now(AVBPrint* timeBuf, int include_date)
     ++static void format_date_now(AVBPrint* bp_time, int include_date)
      +{
      +    struct tm *ptm, tmbuf;
      +    const int64_t time_us = av_gettime();
     @@ libavutil/log.c: static const char *item_name(void *obj, const AVClass *cls)
      +    ptm                   = localtime_r(&time_s, &tmbuf);
      +    if (ptm) {
      +        if (include_date)
     -+            av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm);
     ++            av_bprint_strftime(bp_time, "%Y-%m-%d ", ptm);
      +
     -+        av_bprint_strftime(timeBuf, "%H:%M:%S", ptm);
     -+        av_bprintf(timeBuf, ".%03d ", millisec);
     ++        av_bprint_strftime(bp_time, "%H:%M:%S", ptm);
     ++        av_bprintf(bp_time, ".%03d ", millisec);
      +    }
      +}
      +
 2:  6c435fc02d ! 2:  aed251e1f5 fftools/opt_common: add timing and datetiming log flags
     @@ fftools/opt_common.c: int opt_loglevel(void *optctx, const char *opt, const char
                   } else {
                       flags |= AV_LOG_PRINT_LEVEL;
                   }
     -+        } else if (av_strstart(token, "timing", &arg)) {
     ++        } else if (av_strstart(token, "time", &arg)) {
      +            if (cmd == '-') {
      +                flags &= ~AV_LOG_PRINT_TIME;
      +            } else {
      +                flags |= AV_LOG_PRINT_TIME;
      +            }
     -+        } else if (av_strstart(token, "datetiming", &arg)) {
     ++        } else if (av_strstart(token, "datetime", &arg)) {
      +            if (cmd == '-') {
      +                flags &= ~AV_LOG_PRINT_DATETIME;
      +            } else {
 3:  f0aa91d5c1 ! 3:  600020f36e doc/fftools-common-opts: document log timing flags
     @@ doc/fftools-common-opts.texi: and the "Last message repeated n times" line will
       Indicates that log output should add a @code{[level]} prefix to each message
       line. This can be used as an alternative to log coloring, e.g. when dumping the
       log to file.
     -+ at item timing
     -+Indicates that log lines should be prefixed with timing information.
     -+ at item datetiming
     -+Indicates that log lines should be prefixed with date and timing information.
     ++ at item time
     ++Indicates that log lines should be prefixed with time information.
     ++ at item datetime
     ++Indicates that log lines should be prefixed with date and time information.
       @end table
       Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single
       flag without affecting other @var{flags} or changing @var{loglevel}. When

-- 
ffmpeg-codebot


More information about the ffmpeg-devel mailing list