[FFmpeg-devel] [PATCH] avfilter/drawtext: allow to format pts with strftime

Alex Agranovsky alex at sighthound.com
Sat Oct 10 16:40:15 CEST 2015


Hi — are there still outstanding issues with the patch, or is it good to go?

Thanks,
- Alex
On October 9, 2015 at 8:57:22 AM, Alex Agranovsky (alex at sighthound.com) wrote:

Thanks for your comments. I’m attaching the amended patch, hopefully it addresses all of them. Please let me know if something else is out of order.

- Alex




On October 9, 2015 at 2:23:42 AM, Nicolas George (george at nsup.org) wrote:

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, &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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list