[FFmpeg-devel] [PATCH] avfilter/af_rubberband: add process_command()

Paul B Mahol onemda at gmail.com
Wed Sep 30 21:41:35 CEST 2015


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavfilter/af_rubberband.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/libavfilter/af_rubberband.c b/libavfilter/af_rubberband.c
index 0a15fdc..b958681 100644
--- a/libavfilter/af_rubberband.c
+++ b/libavfilter/af_rubberband.c
@@ -207,6 +207,39 @@ static int request_frame(AVFilterLink *outlink)
     return ret;
 }
 
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
+                           char *res, int res_len, int flags)
+{
+    RubberBandContext *s = ctx->priv;
+    int ret;
+
+    if (!strcmp(cmd, "tempo")) {
+        double arg;
+
+        sscanf(args, "%lf", &arg);
+        if (arg < 0.01 || arg > 100) {
+            av_log(ctx, AV_LOG_ERROR,
+                   "Tempo scale factor '%lf' out of range\n", arg);
+            return AVERROR(EINVAL);
+        }
+        rubberband_set_time_ratio(s->rbs, 1. / arg);
+    }
+
+    if (!strcmp(cmd, "pitch")) {
+        double arg;
+
+        sscanf(args, "%lf", &arg);
+        if (arg < 0.01 || arg > 100) {
+            av_log(ctx, AV_LOG_ERROR,
+                   "Pitch scale factor '%lf' out of range\n", arg);
+            return AVERROR(EINVAL);
+        }
+        rubberband_set_pitch_scale(s->rbs, arg);
+    }
+
+    return 0;
+}
+
 static const AVFilterPad rubberband_inputs[] = {
     {
         .name          = "default",
@@ -235,4 +268,5 @@ AVFilter ff_af_rubberband = {
     .uninit        = uninit,
     .inputs        = rubberband_inputs,
     .outputs       = rubberband_outputs,
+    .process_command = process_command,
 };
-- 
1.9.1



More information about the ffmpeg-devel mailing list