Message ID | bcdf1a41-1101-9a2c-3928-344a9a0038c8@mail.de |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] lavfi/drawtext: Add localtime_ms for millisecond precision | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
Plese resend it in new thread but rename it to .txt. thanks.
Valerii Zapodovnikov:
> Plese resend it in new thread but rename it to .txt. thanks.
Why should he do so?
- Andreas
Oh, so it worked on patchwork? Strnge, okay then. No need to.
Am 08.06.21 um 18:52 schrieb Valerii Zapodovnikov:
> Oh, so it worked on patchwork? Strnge, okay then. No need to.
Please read [1] and [2]. Please keep all old text and do inline-commenting.
-Thilo
[1] http://ffmpeg.org/developer.html
[2] http://ffmpeg.org/mailing-list-faq.html
вт, 8 июн. 2021 г., 19:57 Thilo Borgmann <thilo.borgmann@mail.de>: > Am 08.06.21 um 18:52 schrieb Valerii Zapodovnikov: > > Oh, so it worked on patchwork? Strnge, okay then. No need to. > > Please read [1] and [2]. Please keep all old text and do inline-commenting. > > -Thilo > No. > > [1] http://ffmpeg.org/developer.html > [2] http://ffmpeg.org/mailing-list-faq.html > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >
Am 08.06.21 um 19:00 schrieb Valerii Zapodovnikov: > вт, 8 июн. 2021 г., 19:57 Thilo Borgmann <thilo.borgmann@mail.de>: > >> Am 08.06.21 um 18:52 schrieb Valerii Zapodovnikov: >>> Oh, so it worked on patchwork? Strnge, okay then. No need to. >> >> Please read [1] and [2]. Please keep all old text and do inline-commenting. >> >> -Thilo >> > > No. In ignoring our rules for the mailing list as stated in [3] you just got yourself banned. -Thilo [3] http://ffmpeg.org/contact.html#MailingLists >> >> [1] http://ffmpeg.org/developer.html >> [2] http://ffmpeg.org/mailing-list-faq.html >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >> > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >
Am 08.06.21 um 18:42 schrieb Thilo Borgmann: > Hi, > > add %{localtime_ms} function to the drawtext filter. Same as %{localtime} but with additional millisecond part. Ping for a volunteer to actually have a look at the patch for review. Thanks, Thilo
Thilo Borgmann <thilo.borgmann@mail.de> 于2021年6月15日周二 上午3:14写道: > > Am 08.06.21 um 18:42 schrieb Thilo Borgmann: > > Hi, > > > > add %{localtime_ms} function to the drawtext filter. Same as %{localtime} but with additional millisecond part. > > Ping for a volunteer to actually have a look at the patch for review. lgtm > > Thanks, > Thilo > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". Thanks Steven
On Tue, 15 Jun 2021 11:42:44 +0800 Steven Liu <lingjiujianke@gmail.com> wrote: > Thilo Borgmann <thilo.borgmann@mail.de> 于2021年6月15日周二 > 上午3:14写道: > > > > Am 08.06.21 um 18:42 schrieb Thilo Borgmann: > > > Hi, > > > > > > add %{localtime_ms} function to the drawtext filter. Same as > > > %{localtime} but with additional millisecond part. > > > > Ping for a volunteer to actually have a look at the patch for > > review. > lgtm it has similar function with a previous patch from Zhao Zhili, but is more unified with current logic, thank you all for adding this I think it's very useful to adding millisecond timestamp at source frames, makeing detecting frame lost, reorder, repeat much easier. Hoping this patch can be merged soon :) BTW, if we has an OCR filter to extract this, it will be perfect :) > > > > > Thanks, > > Thilo > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > > Thanks > Steven > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". Regards, Lingjiang Fang
> 2021年6月16日 上午9:56,Lingjiang Fang <vacingfang@hotmail.com> 写道: > > On Tue, 15 Jun 2021 11:42:44 +0800 > Steven Liu <lingjiujianke@gmail.com> wrote: > >> Thilo Borgmann <thilo.borgmann@mail.de> 于2021年6月15日周二 >> 上午3:14写道: >>> >>> Am 08.06.21 um 18:42 schrieb Thilo Borgmann: >>>> Hi, >>>> >>>> add %{localtime_ms} function to the drawtext filter. Same as >>>> %{localtime} but with additional millisecond part. >>> >>> Ping for a volunteer to actually have a look at the patch for >>> review. >> lgtm > it has similar function with a previous patch from Zhao Zhili, but > is more unified with current logic, thank you all for adding this > > I think it's very useful to adding millisecond timestamp at source > frames, makeing detecting frame lost, reorder, repeat much easier. > > Hoping this patch can be merged soon :) > > BTW, if we has an OCR filter to extract this, it will be perfect :) Do you mean : libavfilter/vf_ocr.c ? > >> >>> >>> Thanks, >>> Thilo >>> _______________________________________________ >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>> >>> To unsubscribe, visit link above, or email >>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". >> >> Thanks >> Steven >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > > > > Regards, > Lingjiang Fang > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". Thanks Steven Liu
> On Jun 15, 2021, at 3:14 AM, Thilo Borgmann <thilo.borgmann@mail.de> wrote: > > Am 08.06.21 um 18:42 schrieb Thilo Borgmann: >> Hi, >> >> add %{localtime_ms} function to the drawtext filter. Same as %{localtime} but with additional millisecond part. > > Ping for a volunteer to actually have a look at the patch for review. > > Thanks, > Thilo > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe”. > > diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c > index 382d589e26..684f954236 100644 > --- a/libavfilter/vf_drawtext.c > +++ b/libavfilter/vf_drawtext.c > @@ -53,6 +53,7 @@ > #include "libavutil/parseutils.h" > #include "libavutil/timecode.h" > #include "libavutil/time_internal.h" > +#include "libavutil/time.h" > #include "libavutil/tree.h" > #include "libavutil/lfg.h" > #include "libavutil/detection_bbox.h" > @@ -1049,11 +1050,27 @@ static int func_strftime(AVFilterContext *ctx, AVBPrint *bp, > struct tm tm; > > time(&now); > - if (tag == 'L') > + if (tag == 'L' || tag == 'M') > localtime_r(&now, &tm); > else > tm = *gmtime_r(&now, &tm); > av_bprint_strftime(bp, fmt, &tm); > + > + if (tag == 'M') { > + char ms[5] = {0}; > + // get time returns time since epoch in micro seconds, localtime_r would > + // already take care of representing seconds part, so we need to get > + // milliseconds, to do that we round up microseconds to seconds > + // then convert seconds back to microseconds - this will drop microsecond > + // precision, then compute difference between av_gettime result and > + // rounded up sec -> usec representation and convert that to milliseconds > + int64_t usecs = av_gettime(); There is no guarantee that when av_gettime() is called, it’s in the same second as ’time(&now)’ was called. For example: time(&now) was called at 10.999999 second, and return 10. av_gettime() was called at 11.001 second It will show 10.001, which should be 11.001. > + int64_t secs = usecs / 1000000; > + int64_t msec_delta = (usecs - secs * 1000000) / 1000; > + snprintf(ms, 5, ".%03d", (int)msec_delta); > + av_bprint_append_data(bp, ms, 4); > + } > + > return 0; > } > > @@ -1153,6 +1170,7 @@ static const struct drawtext_function { > { "pts", 0, 3, 0, func_pts }, > { "gmtime", 0, 1, 'G', func_strftime }, > { "localtime", 0, 1, 'L', func_strftime }, > + { "localtime_ms", 0, 1, 'M', func_strftime }, Then why not add a gmtime_ms? > { "frame_num", 0, 0, 0, func_frame_num }, > { "n", 0, 0, 0, func_frame_num }, > { "metadata", 1, 2, 0, func_metadata }, > -- > 2.20.1 (Apple Git-117)
On Wed, 16 Jun 2021 10:52:31 +0800 Steven Liu <lq@chinaffmpeg.org> wrote: > > 2021年6月16日 上午9:56,Lingjiang Fang <vacingfang@hotmail.com> > > 写道: > > > > On Tue, 15 Jun 2021 11:42:44 +0800 > > Steven Liu <lingjiujianke@gmail.com> wrote: > > > >> Thilo Borgmann <thilo.borgmann@mail.de> 于2021年6月15日周二 > >> 上午3:14写道: > >>> > >>> Am 08.06.21 um 18:42 schrieb Thilo Borgmann: > >>>> Hi, > >>>> > >>>> add %{localtime_ms} function to the drawtext filter. Same as > >>>> %{localtime} but with additional millisecond part. > >>> > >>> Ping for a volunteer to actually have a look at the patch for > >>> review. > >> lgtm > > it has similar function with a previous patch from Zhao Zhili, but > > is more unified with current logic, thank you all for adding this > > > > I think it's very useful to adding millisecond timestamp at source > > frames, makeing detecting frame lost, reorder, repeat much easier. > > > > Hoping this patch can be merged soon :) > > > > BTW, if we has an OCR filter to extract this, it will be perfect :) > > > Do you mean : libavfilter/vf_ocr.c ? yes, vf_ocr is almost what I want, but need a little bit improve, supporting specify a sub region of the image, because I just want to know the timestamp on it, not the content of the image : ) I am working on it, demo can work now > > > >> > >>> > >>> Thanks, > >>> Thilo > >>> _______________________________________________ > >>> ffmpeg-devel mailing list > >>> ffmpeg-devel@ffmpeg.org > >>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >>> > >>> To unsubscribe, visit link above, or email > >>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > >> > >> Thanks > >> Steven > >> _______________________________________________ > >> ffmpeg-devel mailing list > >> ffmpeg-devel@ffmpeg.org > >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >> > >> To unsubscribe, visit link above, or email > >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > > > > > > > > Regards, > > Lingjiang Fang > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > > Thanks > > Steven Liu > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". Regards, Lingjiang Fang
diff --git a/doc/filters.texi b/doc/filters.texi index 78faf767cf..bf073e0560 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10953,6 +10953,10 @@ It can accept an argument: a strftime() format string. The time at which the filter is running, expressed in the local time zone. It can accept an argument: a strftime() format string. +@item localtime_ms +Same as @code{localtime} but with millisecond precision. +It can accept an argument: a strftime() format string. + @item metadata Frame metadata. Takes one or two arguments. diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 382d589e26..684f954236 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -53,6 +53,7 @@ #include "libavutil/parseutils.h" #include "libavutil/timecode.h" #include "libavutil/time_internal.h" +#include "libavutil/time.h" #include "libavutil/tree.h" #include "libavutil/lfg.h" #include "libavutil/detection_bbox.h" @@ -1049,11 +1050,27 @@ static int func_strftime(AVFilterContext *ctx, AVBPrint *bp, struct tm tm; time(&now); - if (tag == 'L') + if (tag == 'L' || tag == 'M') localtime_r(&now, &tm); else tm = *gmtime_r(&now, &tm); av_bprint_strftime(bp, fmt, &tm); + + if (tag == 'M') { + char ms[5] = {0}; + // get time returns time since epoch in micro seconds, localtime_r would + // already take care of representing seconds part, so we need to get + // milliseconds, to do that we round up microseconds to seconds + // then convert seconds back to microseconds - this will drop microsecond + // precision, then compute difference between av_gettime result and + // rounded up sec -> usec representation and convert that to milliseconds + int64_t usecs = av_gettime(); + int64_t secs = usecs / 1000000; + int64_t msec_delta = (usecs - secs * 1000000) / 1000; + snprintf(ms, 5, ".%03d", (int)msec_delta); + av_bprint_append_data(bp, ms, 4); + } + return 0; } @@ -1153,6 +1170,7 @@ static const struct drawtext_function { { "pts", 0, 3, 0, func_pts }, { "gmtime", 0, 1, 'G', func_strftime }, { "localtime", 0, 1, 'L', func_strftime }, + { "localtime_ms", 0, 1, 'M', func_strftime }, { "frame_num", 0, 0, 0, func_frame_num }, { "n", 0, 0, 0, func_frame_num }, { "metadata", 1, 2, 0, func_metadata },
Hi, add %{localtime_ms} function to the drawtext filter. Same as %{localtime} but with additional millisecond part. -Thilo From f3b32f3e2b01f50b4fa41f8432ccd5a5eeea1ec1 Mon Sep 17 00:00:00 2001 From: Kirill Pugin <ikir@fb.com> Date: Tue, 8 Jun 2021 18:32:45 +0200 Subject: [PATCH] lavfi/drawtext: Add localtime_ms for millisecond precision Suggested-By: ffmpeg@fb.com --- doc/filters.texi | 4 ++++ libavfilter/vf_drawtext.c | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-)