[FFmpeg-devel] Patch: filter af_amix inputs

John Warburton john at johnwarburton.net
Thu Apr 6 11:49:21 EEST 2017


Dear All,

While needing automatically to mix several hundred audio files, I
noticed that the libavfilter module af_amix.c (audio filter 'amix') is
hard-coded to limit inputs to 32. Of course, I believe this to be
sensible as no doubt you do, too.

However, because the code appears to be written robustly, it was
trivial to increase the limit to 1024 and, on a fast machine with SATA
drives, I have used FFmpeg to mix simultaneously over 400 16-bit
stereo wav files (48kHz sample rate) at approximately 2 x realtime. It
starts very slowly, but speed soon builds up.

Naturally, memory use increased. But the job was done. It's generating
files for a sound installation in an art exhibition in Brighton, UK,
where many hundreds of migrant birds' songs must be heard together
("SWAY" at the ONCA Gallery).

Below is the very trivial patch in case the result of this experiment
is of interest.

Thank you for all the work you do to make FFmpeg so incredibly useful.
J

--- libavfilter/af_amix.c.orig 2017-04-05 22:26:26.326379600 +0100
+++ libavfilter/af_amix.c 2017-04-05 18:00:59.291196000 +0100
@@ -177,7 +177,7 @@
 #define F AV_OPT_FLAG_FILTERING_PARAM
 static const AVOption amix_options[] = {
     { "inputs", "Number of inputs.",
-            OFFSET(nb_inputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, 32, A|F },
+            OFFSET(nb_inputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, 1024, A|F },
     { "duration", "How to determine the end-of-stream.",
             OFFSET(duration_mode), AV_OPT_TYPE_INT, { .i64 =
DURATION_LONGEST }, 0,  2, A|F, "duration" },
         { "longest",  "Duration of longest input.",  0,
AV_OPT_TYPE_CONST, { .i64 = DURATION_LONGEST  }, INT_MIN, INT_MAX,
A|F, "duration" },





--
John Warburton
Tonmeister, Director,
Associate Lecturer, University of Surrey Department of Music and Media


More information about the ffmpeg-devel mailing list