[FFmpeg-cvslog] avfilter/vf_chromakey: add support for commands

Paul B Mahol git at videolan.org
Thu Nov 21 18:21:19 EET 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Nov 21 17:19:40 2019 +0100| [94c0b27397873efb534ca3ee7cb0844619edb854] | committer: Paul B Mahol

avfilter/vf_chromakey: add support for commands

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=94c0b27397873efb534ca3ee7cb0844619edb854
---

 doc/filters.texi           | 14 ++++++++++++++
 libavfilter/vf_chromakey.c | 16 +++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 73f1b03128..8fd85fdd4c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -6863,6 +6863,13 @@ Literal colors like "green" or "red" don't make sense with this enabled anymore.
 This can be used to pass exact YUV values as hexadecimal numbers.
 @end table
 
+ at subsection Commands
+This filter supports same @ref{commands} as options.
+The command accepts the same syntax of the corresponding option.
+
+If the specified expression is not valid, it is kept at its current
+value.
+
 @section chromakey
 YUV colorspace color/chroma keying.
 
@@ -6892,6 +6899,13 @@ Literal colors like "green" or "red" don't make sense with this enabled anymore.
 This can be used to pass exact YUV values as hexadecimal numbers.
 @end table
 
+ at subsection Commands
+This filter supports same @ref{commands} as options.
+The command accepts the same syntax of the corresponding option.
+
+If the specified expression is not valid, it is kept at its current
+value.
+
 @subsection Examples
 
 @itemize
diff --git a/libavfilter/vf_chromakey.c b/libavfilter/vf_chromakey.c
index 83b34906cb..3781506ca2 100644
--- a/libavfilter/vf_chromakey.c
+++ b/libavfilter/vf_chromakey.c
@@ -353,6 +353,18 @@ static av_cold int config_input(AVFilterLink *inlink)
     return 0;
 }
 
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
+                           char *res, int res_len, int flags)
+{
+    int ret;
+
+    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
+    if (ret < 0)
+        return ret;
+
+    return config_output(ctx->outputs[0]);
+}
+
 static const AVFilterPad chromakey_inputs[] = {
     {
         .name           = "default",
@@ -374,7 +386,7 @@ static const AVFilterPad chromakey_outputs[] = {
 };
 
 #define OFFSET(x) offsetof(ChromakeyContext, x)
-#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption chromakey_options[] = {
     { "color", "set the chromakey key color", OFFSET(chromakey_rgba), AV_OPT_TYPE_COLOR, { .str = "black" }, CHAR_MIN, CHAR_MAX, FLAGS },
@@ -395,6 +407,7 @@ AVFilter ff_vf_chromakey = {
     .inputs        = chromakey_inputs,
     .outputs       = chromakey_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
+    .process_command = process_command,
 };
 
 static const AVOption chromahold_options[] = {
@@ -436,4 +449,5 @@ AVFilter ff_vf_chromahold = {
     .inputs        = chromahold_inputs,
     .outputs       = chromahold_outputs,
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
+    .process_command = process_command,
 };



More information about the ffmpeg-cvslog mailing list