[FFmpeg-devel] [PATCH] avfilter/af_volume: add support for command

Paul B Mahol onemda at gmail.com
Tue Sep 24 17:50:09 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---

I would prefer that there is much simpler way to do same.

---

 libavfilter/af_volume.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index a777249..fc9afb7 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -269,6 +269,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
     return ff_filter_frame(outlink, out_buf);
 }
 
+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;
+
+    if (!strcmp(cmd, "volume")) {
+        scanf("%lf", &vol->volume);
+        init(ctx);
+        ret = 0;
+    } else {
+        ret = AVERROR(ENOSYS);
+    }
+    return ret;
+}
+
 static const AVFilterPad avfilter_af_volume_inputs[] = {
     {
         .name           = "default",
@@ -293,6 +309,7 @@ AVFilter avfilter_af_volume = {
     .query_formats  = query_formats,
     .priv_size      = sizeof(VolumeContext),
     .priv_class     = &volume_class,
+    .process_command = process_command,
     .init           = init,
     .inputs         = avfilter_af_volume_inputs,
     .outputs        = avfilter_af_volume_outputs,
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list