Search code examples
audiostreamgstreameraudio-streamingmixer

Mix multiple audio streams into one playback-sound using Gstreamer


I want to use Gstreamer to receive audio streams from multiple points on the same port. Indeed I want to stream audio from different nodes on the network to one device that listen to incoming audio streams, and it should mix multiple audios before playback. I know that I should use audiomixer or liveadder to do such a task. But I can't do it, and the mixer doesn't act correctly and when two audio streams came, the output sound would be so noisy and corrupted.

I used the following command :

gst-launch-1.0.exe -v udpsrc port=5001 caps="application/x-rtp" ! queue ! rtppcmudepay ! mulawdec ! audiomixer name=mix mix. ! audioconvert ! audioresample ! autoaudiosink

but it doesn't work.


Solution

  • Packets on a same port couldn't demux from each other as normal way you wrote in your command, to receive multiple audio streams from same port you should use SSRC and rtpssrcdemux demux. However to receive multiple audio streams on multiple ports and mix them, you could use liveadder element. An example to receive two audio streams from two ports and mix them is as follows:

    gst-launch-1.0 -v udpsrc name=src5001 caps="application/x-rtp" port=5001 ! rtppcmudepay ! mulawdec ! audioresample ! liveadder name=m_adder ! alsasink device=hw:0,0 udpsrc name=src5002 caps="application/x-rtp" port=5002 ! rtppcmudepay ! mulawdec ! audioresample ! m_adder.