[FFmpeg-devel] [PATCH v5 2/3] fftools/opt_common: add time and datetime log flags

Soft Works softworkz at hotmail.com
Fri Feb 7 14:03:16 EET 2025


> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Soft Works
> Sent: Friday, February 7, 2025 12:27 PM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v5 2/3] fftools/opt_common: add
> time and datetime log flags
> 
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> > Tobias Rapp
> > Sent: Friday, February 7, 2025 11:42 AM
> > To: ffmpeg-devel at ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v5 2/3] fftools/opt_common: add
> > time and datetime log flags
> >
> > On 07/02/2025 08:57, softworkz wrote:
> >
> > > From: softworkz <softworkz at hotmail.com>
> > >
> > > This commit adds two logging flags: 'time' and 'datetime'.
> > >
> > > Usage:
> > >
> > > ffmpeg -loglevel +time
> > >
> > > or
> > >
> > > ffmpeg -loglevel +datetime
> > >
> > > Setting av_log_set_flags(0) in term_exit in ffmpeg.c prevents
> > > timing to be printed when exiting.
> > >
> > > Signed-off-by: softworkz <softworkz at hotmail.com>
> > > ---
> > >   fftools/ffmpeg.c     |  1 +
> > >   fftools/opt_common.c | 12 ++++++++++++
> > >   2 files changed, 13 insertions(+)
> > >
> > > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> > > index dc321fb4a2..f4c717afaa 100644
> > > --- a/fftools/ffmpeg.c
> > > +++ b/fftools/ffmpeg.c
> > > @@ -130,6 +130,7 @@ static void term_exit_sigsafe(void)
> > >
> > >   void term_exit(void)
> > >   {
> > > +    av_log_set_flags(0);
> > >       av_log(NULL, AV_LOG_QUIET, "%s", "");
> > >       term_exit_sigsafe();
> > >   }
> >
> > If I understand the purpose of AV_LOG_QUIET correctly the correct
> way
> > would be to skip writing time/datetime information in the log
> writer
> > itself (part of patch #1 in this patch-set) if level is <=
> > AV_LOG_QUIET,
> > rather than clearing the flags here.
> >
> > Regards,
> > Tobias
> 
> 
> Hi Tobias,
> 
> my understanding of AV_LOG_QUIET would be that when program code logs
> a message with that level, it will be printed even when the user has
> "-loglevel quiet".
> I would wonder why such log messages shouldn't be prefixed with the
> time (normally).
> To me it appears that the special case is rather the log invocation
> on exit which prints - well: nothing.
> 
> I'd rather question why it is not printing the log level for quiet.
> Is it really intended or was it only done to make it possible to
> print this empty message on exit?
> 
> Do I see it wrong? Then I'll change it of course.
> 
> Thanks a lot for reviewing!
> 
> sw
> 

Hi Tobias,

what do you think about this?


    if (*print_prefix && (flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME)))
        format_date_now(&part[4], flags & AV_LOG_PRINT_DATETIME);

    if (*print_prefix && (flags & AV_LOG_PRINT_LEVEL))
        av_bprintf(part+2, "[%s] ", get_level_str(level));

    av_vbprintf(part+3, fmt, vl);

    if ((level == AV_LOG_QUIET) && part[3].len == 0) {
        *print_prefix = 0;
    } else if(*part[0].str || *part[1].str || *part[2].str || *part[3].str) {
        char lastc = part[3].len && part[3].len <= part[3].size ? part[3].str[part[3].len - 1] : 0;
        *print_prefix = lastc == '\n' || lastc == '\r';
    }


(plus removal of the flags clearance ofc)

sw


More information about the ffmpeg-devel mailing list