[FFmpeg-cvslog] lavfi/volume: implement process_command() callback, with the volume command

Stefano Sabatini git at videolan.org
Wed Dec 25 18:28:44 CET 2013


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Mon Dec 23 18:24:57 2013 +0100| [97aa554634044b84a498f41ac9bd88b688731c3b] | committer: Stefano Sabatini

lavfi/volume: implement process_command() callback, with the volume command

Address trac ticket #2868.

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

 doc/filters.texi        |   15 ++++++++++++++-
 libavfilter/af_volume.c |   17 +++++++++++++++++
 libavfilter/version.h   |    2 +-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 548cb43..a579964 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1828,7 +1828,8 @@ Set when the volume expression is evaluated.
 It accepts the following values:
 @table @samp
 @item once
-only evaluate expression once during the filter initialization
+only evaluate expression once during the filter initialization, or
+when the @samp{volume} command is sent
 
 @item frame
 evaluate expression for each incoming frame
@@ -1870,6 +1871,18 @@ Note that when @option{eval} is set to @samp{once} only the
 @var{sample_rate} and @var{tb} variables are available, all other
 variables will evaluate to NAN.
 
+ at subsection Commands
+
+This filter supports the following commands:
+ at table @option
+ at item volume
+Modify the volume expression.
+The command accepts the same syntax of the corresponding option.
+
+If the specified expression is not valid, it is kept at its current
+value.
+ at end table
+
 @subsection Examples
 
 @itemize
diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index b4ab6fe..9dc868f 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -296,6 +296,22 @@ static int config_output(AVFilterLink *outlink)
     return set_volume(ctx);
 }
 
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
+                           char *res, int res_len, int flags)
+{
+    VolumeContext *vol = ctx->priv;
+    int ret = AVERROR(ENOSYS);
+
+    if (!strcmp(cmd, "volume")) {
+        if ((ret = set_expr(&vol->volume_pexpr, args, ctx)) < 0)
+            return ret;
+        if (vol->eval_mode == EVAL_MODE_ONCE)
+            set_volume(ctx);
+    }
+
+    return ret;
+}
+
 #define D2TS(d)  (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
@@ -403,4 +419,5 @@ AVFilter ff_af_volume = {
     .inputs         = avfilter_af_volume_inputs,
     .outputs        = avfilter_af_volume_outputs,
     .flags          = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
+    .process_command = process_command,
 };
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 59fef97..51c049a 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   4
 #define LIBAVFILTER_VERSION_MINOR   0
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MICRO 102
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list