DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Discord screen share with audio on Linux!
Lorenzo Rizzotti
Lorenzo Rizzotti

Posted on

Discord screen share with audio on Linux!

Unfortunately, if you're using Discord on a Linux-based operating system, you know that Discord screen sharing doesn't include audio from your apps like how Windows and macOS does.
I searched for a way to get audio working for Discord screen share on Linux; I found another guy with the same frusration, so I decided to work with him to create Tuxphones, a program made of two components: a daemon and a BetterDiscord plugin.
The daemon creates a virtual PulseAudio sink, and the BetterDiscord plugin sends discord stream information to the daemon and blocks the default Discord stream.

After the information is sent over, the daemon takes over and creates a WebSocket connection with Discord's gateway then connects to Discord’s RTC servers.

After a lot of trial and error, we managed to get a video stream to the discord server with our external using H264 but we still haven't managed to make discord's webrtc backend read our Opus audio stream.
We don't know what the error is and we are trying to investiage it, but neither of us know that much about WebRTC.

If anyone wants Discord screenshare with audio on Linux as bad as we do and knows WebRTC, please help us out.

You can find our code on Github:
Tuxphones: https://github.com/ImTheSquid/Tuxphones
gst-webrtcredux (the plugin that we developed to use webrtc-rs with gstreamer): https://github.com/ImTheSquid/gst-webrtcredux

Top comments (4)

Collapse
 
fmgordillo profile image
Facundo Martin Gordillo

It works like a charm, thank you for it!

If anyone needs a little help in how it works, let me share my experience

  1. (Download and) Install Discord in your OS if you haven't already (in my case I'm using Pop_OS and I've got it from the Pop!_Shop as a .deb package)
  2. Download BetterDiscord if you haven't already (in my case I downloaded the .AppImage, gave execution permissions to the file doing chmod +x <better_discord_file.AppImage> and execute it ./<better_discord_file.AppImage>)
  3. Your Discord client will be closed (if it was previously opened), so no worries about it. Open Discord and you will be prompted with a message (like a changelog)
  4. Install Tuxphones (in my case I'm using asdf to get the packages needed for it, like rust, but you can install it from the Rust webpage itself)
  5. Try it out!
Collapse
 
dreamingcodes profile image
Lorenzo Rizzotti

Hi, I'm glad you tried Tuxphones!
Was the stream for viewers visible right away? Also can you confirm that the audio is not working for you too?

Collapse
 
fmgordillo profile image
Facundo Martin Gordillo

The stream was working just fine, it was weird when I've wanted to show a game because there was a glich for a second on the audio, but that's about it

Maybe tomorrow I will have problems or not, I'll let you know in Github!

Thread Thread
 
dreamingcodes profile image
Lorenzo Rizzotti

This is really weird. As you can read from the post we are trying to understand why dicord does not read our audio stream but now you tell us that everything works

Image description

Join the One Year Club

You can earn this badge by being a registered member of the DEV Community for at least one year. Create an account and get started today.