From a51f49007381701df18309c73083749413df3cb8 Mon Sep 17 00:00:00 2001
From: Alex Agranovsky <alex@sighthound.com>
Date: Thu, 8 Oct 2015 15:54:59 -0400
Subject: [PATCH] avfilter/drawtext: allow to format pts with strftime

---
 libavfilter/vf_drawtext.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 9fd9461..5c4a7fa 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -824,6 +824,12 @@ static int func_pts(AVFilterContext *ctx, AVBPrint *bp,
                        (int)(ms / 1000) % 60,
                        (int)ms % 1000);
         }
+    } else if (!strcmp(fmt, "strftime")) {
+	     struct tm ltime;
+        int64_t ms = (int64_t)pts;
+        const char *fmt = (argc >= 3) ? argv[2] : "%Y-%m-%d %H:%M:%S";
+        localtime_r(&ms, &ltime);
+        av_bprint_strftime(bp, fmt, &ltime);
     } else {
         av_log(ctx, AV_LOG_ERROR, "Invalid format '%s'\n", fmt);
         return AVERROR(EINVAL);
-- 
2.3.8 (Apple Git-58)

