diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-07-08 18:55:08 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-07-09 15:21:01 +0000 |
commit | c5a1b18f183ddd793a44043ca7c3546fae13782e (patch) | |
tree | bacdb0c22ff200e1ef11a2d5877205bbd7a23b73 | |
parent | 87fb18c3e4fea70d264c49428a66f86baf048450 (diff) | |
download | ffmpeg-c5a1b18f183ddd793a44043ca7c3546fae13782e.tar.gz |
lavfi/drawtext: add support for printing frame metadata
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | doc/filters.texi | 3 | ||||
-rw-r--r-- | libavfilter/version.h | 2 | ||||
-rw-r--r-- | libavfilter/vf_drawtext.c | 14 |
3 files changed, 18 insertions, 1 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index 234ff2e507..33436ad267 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3328,6 +3328,9 @@ It can accept an argument: a strftime() format string. The time at which the filter is running, expressed in the local time zone. It can accept an argument: a strftime() format string. +@item metadata +Frame metadata. It must take one argument specifying metadata key. + @item n, frame_num The frame number, starting from 0. diff --git a/libavfilter/version.h b/libavfilter/version.h index 15ddcdd8e9..c24e129af1 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 3 #define LIBAVFILTER_VERSION_MINOR 79 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 7cafafefc7..69124a99cd 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -165,6 +165,7 @@ typedef struct { int tc24hmax; ///< 1 if timecode is wrapped to 24 hours, 0 otherwise int reload; ///< reload text file for each frame int start_number; ///< starting frame number for n/frame_num var + AVDictionary *metadata; } DrawTextContext; #define OFFSET(x) offsetof(DrawTextContext, x) @@ -620,6 +621,17 @@ static int func_frame_num(AVFilterContext *ctx, AVBPrint *bp, return 0; } +static int func_metadata(AVFilterContext *ctx, AVBPrint *bp, + char *fct, unsigned argc, char **argv, int tag) +{ + DrawTextContext *s = ctx->priv; + AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0); + + if (e && e->value) + av_bprintf(bp, "%s", e->value); + return 0; +} + #if !HAVE_LOCALTIME_R static void localtime_r(const time_t *t, struct tm *tm) { @@ -677,6 +689,7 @@ static const struct drawtext_function { { "localtime", 0, 1, 'L', func_strftime }, { "frame_num", 0, 0, 0, func_frame_num }, { "n", 0, 0, 0, func_frame_num }, + { "metadata", 1, 1, 0, func_metadata }, }; static int eval_function(AVFilterContext *ctx, AVBPrint *bp, char *fct, @@ -985,6 +998,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) NAN : frame->pts * av_q2d(inlink->time_base); s->var_values[VAR_PICT_TYPE] = frame->pict_type; + s->metadata = av_frame_get_metadata(frame); draw_text(ctx, frame, frame->width, frame->height); |