Le septidi 17 vendémiaire, an CCXXIV, Alex Agranovsky a écrit :
> From a51f49007381701df18309c73083749413df3cb8 Mon Sep 17 00:00:00 2001
> From: Alex Agranovsky <a...@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, &ltime);

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, &ltime);
>      } else {
>          av_log(ctx, AV_LOG_ERROR, "Invalid format '%s'\n", fmt);
>          return AVERROR(EINVAL);

Regards,

-- 
  Nicolas George

Attachment: signature.asc
Description: Digital signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to