# MediaSoup for audio-only - merging all streams?

**URL:** <https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968>\
**Category:** mediasoup libraries\
**Created:** [June 25, 2021, 9:14pm UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968 "2021-06-25T21:14:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rush](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/rush/32/1066_2.png) [@Rush](https://mediasoup.discourse.group/u/Rush)\
**Post date:** [June 25, 2021, 9:14pm UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/1 "2021-06-25T21:14:03Z")

</div>

Hello, I just found MediaSoup and I’ve been wondering if it’s a good fit for audio-only applications. Can video capabilities be disabled to allow for minimal server CPU usage?

I’d like to have audio sessions with up to 30 users. Obviously not everybody speaking at once, some people on mute or push to talk, but does MediaSoup optimize for the number of producers and consumers automatically? 30 \* 30 of streams sounds scary. 🙂

On the same note - can MediaSoup merge audio streams on the server side so that clients deal with only a single incoming stream?

---

<div class="post-metadata">

**Author:** ![jbaudanza](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jbaudanza/32/1996_2.png) [@jbaudanza](https://mediasoup.discourse.group/u/jbaudanza)\
**Post date:** [June 25, 2021, 11:13pm UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/2 "2021-06-25T23:13:00Z")

</div>

> Hello, I just found MediaSoup and I’ve been wondering if it’s a good fit for audio-only applications. Can video capabilities be disabled to allow for minimal server CPU usage?

I use it for an audio-only application and it works great. It’s sort of a clubhouse-style mobile app for language learning.

> I’d like to have audio sessions with up to 30 users. Obviously not everybody speaking at once, some people on mute or push to talk, but does MediaSoup optimize for the number of producers and consumers automatically? 30 \* 30 of streams sounds scary. 🙂

You can put producers into a “paused” state when the user is muted. In that state, they won’t consume as much CPU. If that’s what you mean by optimized, then yes. But it’s not automatic.

> On the same note - can MediaSoup merge audio streams on the server side so that clients deal with only a single incoming stream?

No. Mediasoup just forwards RTP packets. It doesn’t do any decoding of the media streams. If you want to do that, you need to mix in ffmpeg or GStreamer. However, that is quite expensive cpu-wise and you’ll add quite a bit of latency to the conversations. This is probably not the route you want to go.

---

<div class="post-metadata">

**Author:** ![Normando](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/normando/32/1046_2.png) [@Normando](https://mediasoup.discourse.group/u/Normando)\
**Post date:** [June 26, 2021, 12:11am UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/3 "2021-06-26T00:11:00Z")

</div>

As Jonathan said, maybe you want MCU. mediasoup is SFU. Anyway you can do it with SFU.

[https://antmedia.io/webrtc-servers/](https://antmedia.io/webrtc-servers/)

> **[An Introduction to Selective Forwarding Units | Voximplant.com](https://voximplant.com/blog/an-introduction-to-selective-forwarding-units)**
>
> Сloud platform for developing real-time communication apps with full control over voice and video. Our cloud application engine provides developers with a way to control every call leg using JavaScript logic.

---

<div class="post-metadata">

**Author:** ![Rush](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/rush/32/1066_2.png) [@Rush](https://mediasoup.discourse.group/u/Rush)\
**Post date:** [June 26, 2021, 12:32am UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/4 "2021-06-26T00:32:50Z")

</div>

Thank you very much! Do you mind sharing how many active (connected) users you can handle on a single CPU core?

---

<div class="post-metadata">

**Author:** ![jbaudanza](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jbaudanza/32/1996_2.png) [@jbaudanza](https://mediasoup.discourse.group/u/jbaudanza)\
**Post date:** [June 26, 2021, 12:54am UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/5 "2021-06-26T00:54:50Z")

</div>

I’m using AWS Fargate with 1VCPU tasks. I estimate each task can handle up to around 400 active consumers (unpaused). Right now, that number stays around 40-50 though so I haven’t pushed it

---

<div class="post-metadata">

**Author:** ![Rush](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/rush/32/1066_2.png) [@Rush](https://mediasoup.discourse.group/u/Rush)\
**Post date:** [June 26, 2021, 5:44am UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/6 "2021-06-26T05:44:15Z")

</div>

> [@jbaudanza](#):
>
> No. Mediasoup just forwards RTP packets. It doesn’t do any decoding of the media streams. If you want to do that, you need to mix in ffmpeg or GStreamer. However, that is quite expensive cpu-wise and you’ll add quite a bit of latency to the conversations. This is probably not the route you want to go.

I am wondering if this is really true. For example the API has this function [https://mediasoup.org/documentation/v3/mediasoup/api/#router-createAudioLevelObserver](https://mediasoup.org/documentation/v3/mediasoup/api/#router-createAudioLevelObserver) - does it mean MediaSoup can analyze volumes just from the RTP streams?

---

<div class="post-metadata">

**Author:** ![Rush](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/rush/32/1066_2.png) [@Rush](https://mediasoup.discourse.group/u/Rush)\
**Post date:** [June 26, 2021, 5:47am UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/7 "2021-06-26T05:47:02Z")

</div>

I think I can answer myself - [mediasoup/AudioLevelObserver.cpp at 0d7a50169eba3c9ac27a071ac5b2eb2099a34115 · versatica/mediasoup · GitHub](https://github.com/versatica/mediasoup/blob/0d7a50169eba3c9ac27a071ac5b2eb2099a34115/worker/src/RTC/AudioLevelObserver.cpp)

Looks like it’s pretty efficient!

---

<div class="post-metadata">

**Author:** ![jbaudanza](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jbaudanza/32/1996_2.png) [@jbaudanza](https://mediasoup.discourse.group/u/jbaudanza)\
**Post date:** [June 26, 2021, 5:58am UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/8 "2021-06-26T05:58:13Z")

</div>

Yup. webrtc adds these volumes to an RTP header extension (RFC6464).

---

<div class="post-metadata">

**Author:** ![Rush](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/rush/32/1066_2.png) [@Rush](https://mediasoup.discourse.group/u/Rush)\
**Post date:** [July 9, 2021, 9:46pm UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/9 "2021-07-09T21:46:04Z")

</div>

FYI - I was able to implement a voice-chat only server with MediaSoup. It wasn’t too hard given the abundance of example implementations. If anybody needs help please reach out! THank you for the help given.

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [July 12, 2021, 11:09pm UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/10 "2021-07-12T23:09:18Z")

</div>

> **[otalk/hark](https://github.com/otalk/hark)**
>
> Converts an audio stream to speech events in the browser - otalk/hark

Why waste the CPU for audio analysis server-sided. Perhaps if you had a talking stick it could really harness the queries per second to a minimal.

Above is a client-side library you attach with ease to your videos, it takes no time to setup and for fun I have it tell borders around videos/audio sources to light up to the dB detected.

As for CPU usage, audio only is single transports, so more units than if you were to host both audio/video. I generally say per-core cause quality is the same across many generations that you’ll get 100-150 of those active transports going at once per-core. How you sort that usage is up to you. I try to avoid loading up based on CPU cause the unstable CPU usage as RTP signals.

Enjoy.

---

<div class="post-metadata">

**Author:** ![Rush](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/rush/32/1066_2.png) [@Rush](https://mediasoup.discourse.group/u/Rush)\
**Post date:** [July 12, 2021, 11:58pm UTC](https://mediasoup.discourse.group/t/mediasoup-for-audio-only-merging-all-streams/2968/11 "2021-07-12T23:58:59Z")

</div>

Thanks for the advice. I actually I wrote my own version of “hark” for voice-level activation. In general I think audio volume detection on the server-side and on the client-side have very different uses.

Client-side is useful for voice-level activation as it needs to be near real-time.  
Server-side RTP monitoring is useful for monitoring other clients and when they are actually speaking.

I will soon deploy my solution to production and will report back how much CPU usage I’m seeing. I gave it its own dedicated server so the data should be fairly pure.
