mammadalius
mammadalius

Reputation: 3343

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.

Upvotes: 3

Views: 5043

Answers (2)

Farzan Shojaee
Farzan Shojaee

Reputation: 126

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.

Upvotes: 6

filaton
filaton

Reputation: 2326

First, you probably want to use audiomixer over liveadder as the first guarantees synchronization of the different audio streams.

Then, about your mixing problem, you mention that the output sound is "noisy and corrupted", which makes me think of problem with audio levels. Though audiomixer clips the output audio to the maximum allowed amplitude range, it can result in audio artefacts if your sources are too loud. Thus, you might want to play with the volume property on both sources. See here and there for more information.

Upvotes: 1

Related Questions