[FFmpeg-devel] [PATCH] avfilter/drawtext: allow to format pts with strftime
Nicolas George
george at nsup.org
Fri Oct 9 08:13:26 CEST 2015
Le septidi 17 vendémiaire, an CCXXIV, Alex Agranovsky a écrit :
> From a51f49007381701df18309c73083749413df3cb8 Mon Sep 17 00:00:00 2001
> From: Alex Agranovsky <alex at 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(+)
Thanks for the patch. Unfortunately, there are a few issues to be fixed.
First: please update the docs too.
Next: see below.
>
> 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;
There is a tab here.
> + int64_t ms = (int64_t)pts;
This is not the correct type: since it is passed as a pointer, it must be
time_t, nothing else.
> + const char *fmt = (argc >= 3) ? argv[2] : "%Y-%m-%d %H:%M:%S";
Did you test this? As far as I know, at this point it is not possible to
have argc >= 3.
> + localtime_r(&ms, <ime);
Are you sure about that? pts is only occasionally a wall-clock timestamp.
And if it is, the default formats leaves a timestamp without a time zone,
that is Evil. And maybe the user wants UTC.
> + av_bprint_strftime(bp, fmt, <ime);
> } else {
> av_log(ctx, AV_LOG_ERROR, "Invalid format '%s'\n", fmt);
> return AVERROR(EINVAL);
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151009/370a4999/attachment.sig>
More information about the ffmpeg-devel
mailing list