Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2013/07/09 03:55:08... | ... |
@@ -3328,6 +3328,9 @@ It can accept an argument: a strftime() format string. |
3328 | 3328 |
The time at which the filter is running, expressed in the local time zone. |
3329 | 3329 |
It can accept an argument: a strftime() format string. |
3330 | 3330 |
|
3331 |
+@item metadata |
|
3332 |
+Frame metadata. It must take one argument specifying metadata key. |
|
3333 |
+ |
|
3331 | 3334 |
@item n, frame_num |
3332 | 3335 |
The frame number, starting from 0. |
3333 | 3336 |
|
... | ... |
@@ -31,7 +31,7 @@ |
31 | 31 |
|
32 | 32 |
#define LIBAVFILTER_VERSION_MAJOR 3 |
33 | 33 |
#define LIBAVFILTER_VERSION_MINOR 79 |
34 |
-#define LIBAVFILTER_VERSION_MICRO 100 |
|
34 |
+#define LIBAVFILTER_VERSION_MICRO 101 |
|
35 | 35 |
|
36 | 36 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
37 | 37 |
LIBAVFILTER_VERSION_MINOR, \ |
... | ... |
@@ -165,6 +165,7 @@ typedef struct { |
165 | 165 |
int tc24hmax; ///< 1 if timecode is wrapped to 24 hours, 0 otherwise |
166 | 166 |
int reload; ///< reload text file for each frame |
167 | 167 |
int start_number; ///< starting frame number for n/frame_num var |
168 |
+ AVDictionary *metadata; |
|
168 | 169 |
} DrawTextContext; |
169 | 170 |
|
170 | 171 |
#define OFFSET(x) offsetof(DrawTextContext, x) |
... | ... |
@@ -620,6 +621,17 @@ static int func_frame_num(AVFilterContext *ctx, AVBPrint *bp, |
620 | 620 |
return 0; |
621 | 621 |
} |
622 | 622 |
|
623 |
+static int func_metadata(AVFilterContext *ctx, AVBPrint *bp, |
|
624 |
+ char *fct, unsigned argc, char **argv, int tag) |
|
625 |
+{ |
|
626 |
+ DrawTextContext *s = ctx->priv; |
|
627 |
+ AVDictionaryEntry *e = av_dict_get(s->metadata, argv[0], NULL, 0); |
|
628 |
+ |
|
629 |
+ if (e && e->value) |
|
630 |
+ av_bprintf(bp, "%s", e->value); |
|
631 |
+ return 0; |
|
632 |
+} |
|
633 |
+ |
|
623 | 634 |
#if !HAVE_LOCALTIME_R |
624 | 635 |
static void localtime_r(const time_t *t, struct tm *tm) |
625 | 636 |
{ |
... | ... |
@@ -677,6 +689,7 @@ static const struct drawtext_function { |
677 | 677 |
{ "localtime", 0, 1, 'L', func_strftime }, |
678 | 678 |
{ "frame_num", 0, 0, 0, func_frame_num }, |
679 | 679 |
{ "n", 0, 0, 0, func_frame_num }, |
680 |
+ { "metadata", 1, 1, 0, func_metadata }, |
|
680 | 681 |
}; |
681 | 682 |
|
682 | 683 |
static int eval_function(AVFilterContext *ctx, AVBPrint *bp, char *fct, |
... | ... |
@@ -985,6 +998,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) |
985 | 985 |
NAN : frame->pts * av_q2d(inlink->time_base); |
986 | 986 |
|
987 | 987 |
s->var_values[VAR_PICT_TYPE] = frame->pict_type; |
988 |
+ s->metadata = av_frame_get_metadata(frame); |
|
988 | 989 |
|
989 | 990 |
draw_text(ctx, frame, frame->width, frame->height); |
990 | 991 |
|