summaryrefslogtreecommitdiff
path: root/libavfilter/vf_drawtext.c
diff options
context:
space:
mode:
authorAlex Agranovsky <alex@sighthound.com>2015-10-10 14:52:34 -0400
committerNicolas George <george@nsup.org>2015-10-12 16:56:58 +0200
commitcf28490e564d91c89b4c56e605c6f391bddb9ba9 (patch)
tree7b93fc02271f7ddc7f00770b3307c8ae63e79131 /libavfilter/vf_drawtext.c
parent1f3a29e999b635fee913680402977eb1d51a8461 (diff)
downloadffmpeg-cf28490e564d91c89b4c56e605c6f391bddb9ba9.tar.gz
avfilter/drawtext: allow to format pts with strftime
Signed-off-by: Alex Agranovsky <alex@sighthound.com>
Diffstat (limited to 'libavfilter/vf_drawtext.c')
-rw-r--r--libavfilter/vf_drawtext.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 9fd9461863..8e21693534 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -824,6 +824,16 @@ static int func_pts(AVFilterContext *ctx, AVBPrint *bp,
(int)(ms / 1000) % 60,
(int)ms % 1000);
}
+ } else if (!strcmp(fmt, "localtime") ||
+ !strcmp(fmt, "gmtime")) {
+ struct tm tm;
+ time_t ms = (time_t)pts;
+ const char *timefmt = argc >= 3 ? argv[2] : "%Y-%m-%d %H:%M:%S";
+ if (!strcmp(fmt, "localtime"))
+ localtime_r(&ms, &tm);
+ else
+ gmtime_r(&ms, &tm);
+ av_bprint_strftime(bp, timefmt, &tm);
} else {
av_log(ctx, AV_LOG_ERROR, "Invalid format '%s'\n", fmt);
return AVERROR(EINVAL);
@@ -958,7 +968,7 @@ static const struct drawtext_function {
{ "expr_int_format", 2, 3, 0, func_eval_expr_int_format },
{ "eif", 2, 3, 0, func_eval_expr_int_format },
{ "pict_type", 0, 0, 0, func_pict_type },
- { "pts", 0, 2, 0, func_pts },
+ { "pts", 0, 3, 0, func_pts },
{ "gmtime", 0, 1, 'G', func_strftime },
{ "localtime", 0, 1, 'L', func_strftime },
{ "frame_num", 0, 0, 0, func_frame_num },