On 07.04.2016 20:45, Stefano Sabatini wrote:
On date Thursday 2016-04-07 12:32:47 +0200, Tobias Rapp encoded:
Signed-off-by: Tobias Rapp <t.r...@noa-archive.com>
---
doc/filters.texi | 7 ++++++-
libavfilter/vf_drawtext.c | 4 +++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 592fc24..3675b13 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -6499,7 +6499,12 @@ 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.
+Frame metadata. Takes one or two arguments.
+
+The first argument is mandatory and specifyies the metadata key.
specifies?
Fixed.
+
+The second argument is optional and specifies a default value, used when the
+metadata key is not found or empty.
@item n, frame_num
The frame number, starting from 0.
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 1ef3ecb..6b9af5b 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -860,6 +860,8 @@ static int func_metadata(AVFilterContext *ctx, AVBPrint *bp,
if (e && e->value)
av_bprintf(bp, "%s", e->value);
+ else if (argc >= 2)
+ av_bprintf(bp, "%s", argv[1]);
return 0;
}
@@ -975,7 +977,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 },
+ { "metadata", 1, 2, 0, func_metadata },
};
LGTM, possibly with a micro bump, thanks.
Attached an updated patch, including the micro bump.
>From 9b598d06602815f40e5ade70a3921c5c90a4603e Mon Sep 17 00:00:00 2001
From: Tobias Rapp <t.r...@noa-archive.com>
Date: Thu, 7 Apr 2016 10:20:53 +0200
Subject: [PATCH] avfilter/vf_drawtext: add optional default value to metadata
function
Signed-off-by: Tobias Rapp <t.r...@noa-archive.com>
---
doc/filters.texi | 7 ++++++-
libavfilter/version.h | 2 +-
libavfilter/vf_drawtext.c | 4 +++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 82be06d..e848584 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -6499,7 +6499,12 @@ 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.
+Frame metadata. Takes one or two arguments.
+
+The first argument is mandatory and specifies the metadata key.
+
+The second argument is optional and specifies a default value, used when the
+metadata key is not found or empty.
@item n, frame_num
The frame number, starting from 0.
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 0dbb7e5..4cb5a2e 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
#define LIBAVFILTER_VERSION_MAJOR 6
#define LIBAVFILTER_VERSION_MINOR 41
-#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 1ef3ecb..6b9af5b 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -860,6 +860,8 @@ static int func_metadata(AVFilterContext *ctx, AVBPrint *bp,
if (e && e->value)
av_bprintf(bp, "%s", e->value);
+ else if (argc >= 2)
+ av_bprintf(bp, "%s", argv[1]);
return 0;
}
@@ -975,7 +977,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 },
+ { "metadata", 1, 2, 0, func_metadata },
};
static int eval_function(AVFilterContext *ctx, AVBPrint *bp, char *fct,
--
1.9.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel