[FFmpeg-devel] [PATCH] libavfilter/vf_drawtext.c:add support to generte ms level timestamp
Siyuan Huang
saber.huang at samsung.com
Fri May 29 10:16:54 EEST 2020
for test latency , need sub-seconds level timestamp watermark
Signed-off-by: SiyuanHuang <saber.huang at samsung.com>
---
libavfilter/vf_drawtext.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
mode change 100644 => 100755 libavfilter/vf_drawtext.c
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
old mode 100644
new mode 100755
index abe1ca6c35..cfd08b4092
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -61,6 +61,8 @@
#include "internal.h"
#include "video.h"
+#include <sys/timeb.h>
+#include <time.h>
#if CONFIG_LIBFRIBIDI
#include <fribidi.h>
#endif
@@ -1322,8 +1324,22 @@ static int draw_text(AVFilterContext *ctx, AVFrame
*frame,
return ret;
break;
case EXP_STRFTIME:
- localtime_r(&now, <ime);
- av_bprint_strftime(bp, s->text, <ime);
+ if(NULL!=av_stristr(s->text,"mspts")) {
+ struct tm *ptm;
+ struct timeb stTimeb;
+ static char szTime[24];
+
+ ftime(&stTimeb);
+ ptm = localtime(&stTimeb.time);
+ sprintf(szTime, "%04d-%02d-%02d %02d:%02d:%02d.%03d",
+ ptm->tm_year+1900,ptm->tm_mon + 1, ptm->tm_mday,
ptm->tm_hour, ptm->tm_min, ptm->tm_sec, stTimeb.millitm);
+ szTime[23] = 0;
+ av_bprintf(bp, "%s", szTime);
+ } else {
+ localtime_r(&now, <ime);
+ av_bprint_strftime(bp, s->text, <ime);
+ }
+
break;
}
--
2.17.1
More information about the ffmpeg-devel
mailing list