FFmpeg 0.11.5
Since* 0.10
#

Forward two audio streams and control the order the buffers are forwarded.

The argument to the filter is an expression deciding which stream should be forwarded next: if the result is negative, the first stream is forwarded; if the result is positive or zero, the second stream is forwarded. It can use the following variables:

b1 b2

number of buffers forwarded so far on each stream

s1 s2

number of samples forwarded so far on each stream

t1 t2

current timestamp of each stream

The default value is t1-t2, which means to always forward the stream that has a smaller timestamp.

Example: stress-test amerge by randomly sending buffers on the wrong input, while avoiding too much of a desynchronization:

amovie=file.ogg [a] ; amovie=file.mp3 [b] ;
[a] [b] astreamsync=(2*random(1))-1+tanh(5*(t1-t2)) [a2] [b2] ;
[a2] [b2] amerge