[FFmpeg-devel] [PATCH] lavfi/drawtext: implement more generic expansion.
Stefano Sabatini
stefasab at gmail.com
Sun Nov 18 15:38:27 CET 2012
On date Sunday 2012-11-18 09:57:18 +0100, Nicolas George encoded:
> The new expansion mechanism uses the %{...} notation.
> For compatibility reasons, it must be enabled explicitly,
> but a warning is printed if a conflict is likely to happen.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> Changelog | 1 +
> doc/filters.texi | 61 +++++++++++++++-
> libavfilter/version.h | 2 +-
> libavfilter/vf_drawtext.c | 173 +++++++++++++++++++++++++++++++++++++++++++--
> 4 files changed, 227 insertions(+), 10 deletions(-)
[...]
> +static int func_strftime(AVFilterContext *ctx, AVBPrint *bp,
> + char *fct, unsigned argc, char **argv, int tag)
> +{
> + const char *fmt = argc ? argv[0] : "%Y-%m-%d %H:%M:%S";
> + time_t now;
> + struct tm tm;
> +
> + time(&now);
> + if (tag == 'L')
> + localtime_r(&now, &tm);
> + else
> + tm = *gmtime(&now);
> + av_bprint_strftime(bp, fmt, &tm);
> + return 0;
> +}
> +
> +static const struct drawtext_function {
> + const char *name;
> + unsigned argc_min, argc_max;
> + int tag; /** opaque argument to func */
> + int (*func)(AVFilterContext *, AVBPrint *, char *, unsigned, char **, int);
> +} functions[] = {
> + { "pts", 0, 0, 0, func_pts },
> + { "gmtime", 0, 1, 'G', func_strftime },
> + { "localtime", 0, 1, 'L', func_strftime },
> +};
Alternatively, you may pass the name to the function, and select the
variant according to !strcmp(name, ...) (feel free to push the version
you prefer, this can be changed safely later).
LGTM otherwise.
--
FFmpeg = Fostering Fostering MultiPurpose Exciting Guru
More information about the ffmpeg-devel
mailing list