[FFmpeg-devel] [PATCH] af_mix: mix two audio streams

Clément Bœsch ubitux at gmail.com
Tue Dec 13 17:19:29 CET 2011

On Tue, Dec 13, 2011 at 05:08:26PM +0100, Nicolas George wrote:
> Le tridi 23 frimaire, an CCXX, Matthieu Bouron a écrit :
> > Hi there,
> > 
> > Here is a first attempt to write an audio filter which merge two audio
> > streams.
> > Usage is:
> > ffplay -f lavfi "amovie=test1.mp3[a];amovie=test2.mp3[b];[a][b]mix=0.7:0.3[out]"
> > 
> > The volume of each streams can be configured and default to 0.5:0.5 is
> > not specified. It only support two s16 audio streams with same sample
> > rate.
> > Feel free to comment.
> This is a much asked for feature, but I do not like the design you adopted.
> I think your version is confusing two different tasks: merging the streams,
> and mixing the channels with configurable coefficients. Thus, it only
> satisfies the most basic needs.
> I believe that it is better to separate both tasks: first merging a
> n-channels streams and a p-channels streams into a stream with n+p channels,
> and then mixing the channels together if necessary.

I think this might get complicated with amerge+pan for the user... This
filter is IMO a really user friendly way to do a pretty common operation:
add a background music to a video.

Just like we can use af pan to downmix from 5.1 to stereo, having a "-ac
2" option is a nice have.

> For the first task, I started some time ago a "amerge" filter. The work as I
> left it is there:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2011-November/116523.html
> I intend to start working on it again soon.

Heh, I was just testing it again today :)

Unfortunately I got issues, I'm looking forward the next version.

So to sum up, I think this filter is pretty useful and might just be the
"easy way" for basic and common mixing usage.

Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111213/a7895f16/attachment.asc>

More information about the ffmpeg-devel mailing list