Screenshare-with-audio-on-Discord-with-Linux
Screenshare-with-audio-on-Discord-with-Linux copied to clipboard
Firefox issue that was mentioned has been fixed
The issue mentioned in README has now been fixed by Mozilla (see here). While the fix isn't yet available in the latest stable release of Firefox (or at least I am fairly sure it isn't), the README should be updated to reflect the issue being fixed.
Thanks for letting me know, I'll try firefox 101 when I have time.
Script fails due to assuming a 'default' device exists if you don't use the virtmic thing, which it doesn't on Firefox; And if the id is undefined it picks the first available mic, and if it's the same as your mic it leads to Firefox collapsing the captures into one, meaning you can't change what the stream captures.
enumerateDevices's ordering is meaningful, that is the first device is your default mic, which you're the most likely to use in Discord, leading to the scenario above.
I'd make a PR for this, but this repo doesn't contain the actual script, so... Around line 35:
catch (error) {
// id = "default";
await navigator.mediaDevices.enumerateDevices().then(devices => {id = devices[devices.length-1].deviceId});
}
Be careful with that as it can select your desktop audio, leading to a loopback while you hear your own stream, however it didn't get loud for me, for whatever reason.
~~By the way, is there source code on the virtmic binary?~~ nvm, i'm blind
Script fails due to assuming a 'default' device exists if you don't use the virtmic thing, which it doesn't on Firefox; And if the id is undefined it picks the first available mic, and if it's the same as your mic it leads to Firefox collapsing the captures into one, meaning you can't change what the stream captures.
enumerateDevices's ordering is meaningful, that is the first device is your default mic, which you're the most likely to use in Discord, leading to the scenario above.
I'd make a PR for this, but this repo doesn't contain the actual script, so... Around line 35:
catch (error) { // id = "default"; await navigator.mediaDevices.enumerateDevices().then(devices => {id = devices[devices.length-1].deviceId}); }
Be careful with that as it can select your desktop audio, leading to a loopback while you hear your own stream, however it didn't get loud for me, for whatever reason.
~By the way, is there source code on the virtmic binary?~ nvm, i'm blind
default only exists on chromium browsers, the script is going to need few edits to be usable with firefox. We will need to enumeratedevices and pick a monitor probably since we must use a different device then the one discord uses as a mic.
Firefox 101 has just been released (on the 31st), and I can confirm that the new multiple microphone capture functionality works.
I was successful (with some caveats, see later) on the following setup:
- Firefox 101.0
- Pulse source named "virtmic" (here through a JACK bridge, but same effect as the virtmic tool)
- A different Pulse source selected as microphone in Discord web
- The script pasted into the JS console before joining a call and screensharing (except the first line, which looks like a typo)
There were a couple of problems, though:
- Screenshare audio quality was terrible, I suspect noise reduction etc. not being disabled correctly
- The script only seemed to work in Tampermonkey, with the following results in others.
- Greasemonkey: either
navigator.mediaDevices.chromiumGetDisplayMedia
never gets set, or a permission error on attempting screenshare - Violentmonkey:
navigator.mediaDevices.chromiumGetDisplayMedia
never gets set
- Greasemonkey: either
- As noted before, the script doesn't work without a virtmic source
Okay, I've definitely spent way too long getting this to work for me personally, so I suppose I'll share what I did.
I used the Firefox script changing every instance of audio: true
to audio: {autoGainControl: false, echoCancellation: false, noiseSuppression: false}
and everything appears to be working beautifully.
This does fix the previous comment's issue of audio quality, as this properly applies everywhere. However, this solution is not without its own problems:
- Due to the way it links audio with video, the audio changes pitch as the video framerate changes. While this may not be an issue for some, the transitioning isn't smooth and thus offers an annoying distraction in the audio depending on your stream quality.
- More importantly, the audio from your stream isn't disable-able on your end, meaning you hear the stream audio and the actual audio. You could silence Firefox, but then you'd lose the rest of the Discord voice chat audio. I've worked around this by turning the input volume to Firefox down so that my own volume drowns it out, but it's not an amazing solution. (It should be noted that this problem happens to me no matter the solution I implement.)
just checking in, has there been any progress on this?
just checking in, has there been any progress on this?
I haven't had time to test this yet, however I'm hopeful I'll be able to fix firefox within this month.
I checked firefox, the script works out of the box with violentmonkey as long as you have virtmic up and running. There audio issues however, it sounds like playing a vinyl record at inconsistent speed. I will have to check whether firefox has any additional flags that modify audio,
One issue I found out is that the first microphone capture is listed as AudioCallbackDriver while the second as input-only stream
There audio issues however, it sounds like playing a vinyl record at inconsistent speed.
Is there any update on this? Been screen sharing through Chromium with audio with zero issues up until recently but some update seems to have broken video encode on Chromium for me (even with the script off), practically locking the screen share at 1 FPS. Firefox has great performance as usual but still seems to have the audio distortion issue up to this point and unfortunately, just as you've pointed out in the readme, no one seems to have documented this issue outside of this repository.
https://bugzilla.mozilla.org/show_bug.cgi?id=1844181
https://github.com/IceDBorn/pipewire-screenaudio/commit/952408dd513b47c20216f4a3cc7c108441eba58a
Here's a WIP build of Firefox that fixes this issue.
@edisionnano The attached files
The audio pitching bug is now fixed in the nightly branch of Firefox. This is set to release to the stable branch on December 5th!
The audio pitching bug is now fixed in the nightly branch of Firefox. This is set to release to the stable branch on December 5th!
I'll keep the issue open until then, when it is released on the stable channel I'll close it and update the readme with a pr
Bit late to point out because I forgot the exact date/update that the relevant fix would come in, but I can confirm that audio no longer seems to be distorted in screenshares. Weirdly, I still have the other issue mentioned of the stream audio getting played back to you on regular Firefox whereas the issue does not exist on developer edition (ironically however this helped me confirm on my end that the issue is fixed, as before the fix I could also hear the distortion in the playback). Not sure if it's a difference in configuration I've overlooked or if there's actually something different in the builds, but for now I'm continuing to stick with developer edition for convenience.
Are there 0 issues left on stable Firefox?