[FFmpeg-devel] [PATCH v2] lavfi/drawtext: Add localtime_ms for millisecond precision

Michael Niedermayer michael at niedermayer.cc
Fri Dec 10 18:46:57 EET 2021


On Fri, Dec 10, 2021 at 12:36:21PM +0100, Thilo Borgmann wrote:
> 
> 
> On 10 Dec 2021, at 3:47, zhilizhao(赵志立) wrote:
> 
> > > On Dec 10, 2021, at 3:11 AM, Thilo Borgmann <thilo.borgmann at mail.de>
> > > wrote:
> > > 
> > > Hi,
> > > 
> > > add %{localtime_ms}, %{gmtime_ms} functions to the drawtext filter.
> > > Same as %{localtime}/%{gmtime} but with additional millisecond part.
> > > 
> > > sorry for delay, second version including review remarks:
> > > 
> > > -get timing once
> > > -also add gmtime_ms instead of just localtime_ms
> > > 
> > 
> > > +    if (tag == 'M' || tag == 'm') {
> > > +        char ms[5] = {0};
> > > +        int64_t dnow = (unow - ((int64_t)now) * 1000000) / 1000;
> > > +        snprintf(ms, 5, ".%03d", (int)dnow);
> > > +        av_bprint_append_data(bp, ms, 4);
> > > +    }
> > > 
> > 
> > 
> > How about
> > 
> >     av_bprintf(&bp, ".%03d", (int)(unow % 1000000) / 1000);
> 
> Makes way too much sense. I need holidays…
> 
> Attached v3.
> 
> Thanks!
> -Thilo

>  doc/filters.texi          |    8 ++++++++
>  libavfilter/vf_drawtext.c |   12 ++++++++++--
>  2 files changed, 18 insertions(+), 2 deletions(-)
> 87d34e4106b829d42c5e57c847c28bed08bf3a81  v3-0001-lavfi-drawtext-Add-localtime_ms-for-millisecond-p.patch
> From fd34d1434e2243a881c24f6db4cc0db92289f4bb Mon Sep 17 00:00:00 2001
> From: Thilo Borgmann <thilo.borgmann at mail.de>
> Date: Fri, 10 Dec 2021 12:34:23 +0100
> Subject: [PATCH v3] lavfi/drawtext: Add localtime_ms for millisecond precision

Iam missining something here as it doesnt build

AR	libavdevice/libavdevice.a
CC	libavfilter/vf_drawtext.o
libavfilter/vf_drawtext.c: In function ‘func_strftime’:
libavfilter/vf_drawtext.c:1052:12: error: implicit declaration of function ‘av_gettime’; did you mean ‘av_get_token’? [-Werror=implicit-function-declaration]
     unow = av_gettime();
            ^~~~~~~~~~
            av_get_token
libavfilter/vf_drawtext.c:1061:20: warning: passing argument 1 of ‘av_bprintf’ from incompatible pointer type [-Wincompatible-pointer-types]
         av_bprintf(&bp, ".%03d", (int)(unow % 1000000) / 1000);
                    ^
In file included from libavfilter/vf_drawtext.c:47:0:
./libavutil/bprint.h:127:6: note: expected ‘AVBPrint * {aka struct AVBPrint *}’ but argument is of type ‘AVBPrint ** {aka struct AVBPrint **}’
 void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
      ^~~~~~~~~~
cc1: some warnings being treated as errors
ffbuild/common.mak:70: recipe for target 'libavfilter/vf_drawtext.o' failed
make: *** [libavfilter/vf_drawtext.o] Error 1

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211210/37359f50/attachment.sig>


More information about the ffmpeg-devel mailing list