diff mbox

[FFmpeg-devel] Patch: filter af_amix inputs

Message ID CAGeuTF141NsMwR1qqxRgZK5y9AByxbHw5tuO8BrVwa-3TR3R8w@mail.gmail.com
State New
Headers show

Commit Message

John Warburton April 6, 2017, 8:49 a.m. UTC
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

         { "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

Comments

Michael Niedermayer April 7, 2017, 9:25 a.m. UTC | #1
On Thu, Apr 06, 2017 at 09:49:21AM +0100, John Warburton wrote:
> 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" },
> 

this patch is corrupted by linebreaks

[...]
John Warburton April 7, 2017, 6:51 p.m. UTC | #2
On Fri, Apr 7, 2017 at 10:25 AM, Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> this patch is corrupted by linebreaks

I'm sorry about that. It's attached to this email, from a file made by
git format-patch.
J
--
John Warburton
Tonmeister, Director,
Associate Lecturer, University of Surrey Department of Music and Media
Michael Niedermayer April 9, 2017, 1:50 a.m. UTC | #3
On Fri, Apr 07, 2017 at 07:51:55PM +0100, John Warburton wrote:
> On Fri, Apr 7, 2017 at 10:25 AM, Michael Niedermayer
> <michael@niedermayer.cc> wrote:
> >
> > this patch is corrupted by linebreaks
> 
> I'm sorry about that. It's attached to this email, from a file made by
> git format-patch.
> J
> --
> John Warburton
> Tonmeister, Director,
> Associate Lecturer, University of Surrey Department of Music and Media

>  af_amix.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> ae2bf9f3ef52961f1702a508b73376128443c2f4  0001-libavfilter-af_amix.c-Increase-sources-from-32-to-10.patch
> From 0053f3a74159abbaf4f7868df0e97867f5f0c26c Mon Sep 17 00:00:00 2001
> From: Warblefly <john@johnwarburton.net>
> Date: Fri, 7 Apr 2017 19:35:56 +0100
> Subject: [PATCH] libavfilter/af_amix.c Increase sources from 32 to 1024

applied

thanks

[...]
diff mbox

Patch

--- 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" },