Browse code

avfilter/vf_drawtext: add optional default value to metadata function

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>

Tobias Rapp authored on 2016/04/07 17:20:53
Showing 3 changed files
... ...
@@ -6682,7 +6682,12 @@ The time at which the filter is running, expressed in the local time zone.
6682 6682
 It can accept an argument: a strftime() format string.
6683 6683
 
6684 6684
 @item metadata
6685
-Frame metadata. It must take one argument specifying metadata key.
6685
+Frame metadata. Takes one or two arguments.
6686
+
6687
+The first argument is mandatory and specifies the metadata key.
6688
+
6689
+The second argument is optional and specifies a default value, used when the
6690
+metadata key is not found or empty.
6686 6691
 
6687 6692
 @item n, frame_num
6688 6693
 The frame number, starting from 0.
... ...
@@ -31,7 +31,7 @@
31 31
 
32 32
 #define LIBAVFILTER_VERSION_MAJOR   6
33 33
 #define LIBAVFILTER_VERSION_MINOR  41
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, \
... ...
@@ -860,6 +860,8 @@ static int func_metadata(AVFilterContext *ctx, AVBPrint *bp,
860 860
 
861 861
     if (e && e->value)
862 862
         av_bprintf(bp, "%s", e->value);
863
+    else if (argc >= 2)
864
+        av_bprintf(bp, "%s", argv[1]);
863 865
     return 0;
864 866
 }
865 867
 
... ...
@@ -975,7 +977,7 @@ static const struct drawtext_function {
975 975
     { "localtime", 0, 1, 'L', func_strftime },
976 976
     { "frame_num", 0, 0, 0,   func_frame_num },
977 977
     { "n",         0, 0, 0,   func_frame_num },
978
-    { "metadata",  1, 1, 0,   func_metadata },
978
+    { "metadata",  1, 2, 0,   func_metadata },
979 979
 };
980 980
 
981 981
 static int eval_function(AVFilterContext *ctx, AVBPrint *bp, char *fct,