IceDBorn / pipewire-screenaudio

Extension to passthrough pipewire audio to WebRTC Screenshare
https://addons.mozilla.org/firefox/addon/pipewire-screenaudio/
GNU General Public License v3.0
167 stars 5 forks source link

Audio pitching info #22

Closed geoku closed 11 months ago

geoku commented 1 year ago

For me Firefox 117 didn't fix anything in relation to audio pitching. It behaves absolutely the same as before.

But today I've made a discovery: when my stream is already going and the receiving end is hearing heavily distorted audio, it turns out it can be fixed by going to the Voice & Video section of Discord's settings and making any change to the "Input Device" dropdown. For example, I have my Razer mic selected there, so I switch to anything else. As soon as I do this, audio pitching is immediately fixed on the fly. Then I switch the dropdown back to my Razer mic, and the audio stays fixed.

TL;DR steps:

  1. Share a node using the extension and start your stream (viewer hears distorted audio);
  2. Go to Voice & Video settings in Discord;
  3. Change "Input Device" from your mic to anything else;
  4. Audio is immediately fixed;
  5. Change "Input Device" back to your mic.

It works even in Firefox 116. Firefox 117 didn't change anything.

IceDBorn commented 1 year ago

This works on Jitsi too. A way to fix this would be removing the selected microphone from the call and then adding it back after getDisplayMedia evaluates.

IceDBorn commented 1 year ago

https://github.com/IceDBorn/pipewire-screenaudio/commit/952408dd513b47c20216f4a3cc7c108441eba58a

IceDBorn commented 1 year ago

For anyone interested, a mozilla employee posted this WIP build that fixes the audio pitching bug

geoku commented 1 year ago

Follow up to the initial post: turns out, if you do the steps described, your mic's audio becomes distorted for the listener instead of the stream audio. I didn't notice this initially, because I was testing with myself and didn't try speaking into the mic. But it was pointed out to me when I tried this in a call with another person. Ultimately, it seems like the last sound source connected to the call will have distorted audio.

Xefir commented 1 year ago

I found a way to not have any audio distortion, but you have to strictly respect this timeline of events :

Now, the screen, mic and share screen audio will be pitch perfect even if you share the same app on the same website or if you stop and restart the call after. But, you'll have to restart your browser and do the same upper steps if you want another window to share or a another website.

aeongdesu commented 1 year ago

let's go! 🚀

IceDBorn commented 1 year ago

We would be glad if anyone of you can test this out. You can just download the nightly version of Firefox. image

aeongdesu commented 1 year ago

@IceDBorn yeah works fine on my machine ✌️

OS: EndeavourOS Linux x86_64 
Kernel: 6.5.6-arch2-1
Shell: bash 5.1.16 
Resolution: 1920x1080 
DE: Plasma 5.27.8 
WM: KWin
CPU: Intel i5-9400F (6) @ 4.100GHz 
GPU: NVIDIA GeForce RTX 2060 Rev. A 
Memory: 3934MiB / 15938MiB 

[nyan@arch firefox]$ ./firefox -version
Mozilla Firefox 120.0a1
kheiken commented 1 year ago

Same for me, the latest nightly (120.0a1 from 2023-10-09) fixes the pitch issues. Also when using screenaudio and a microphone, enabled in any order and if disabled and re-enabled (which was an issue in early versions of the fix/workarounds).

Combined with #27 I can now screenshare on Debian 12 using e.g. Discord with microphone being on at the same time and pitch is fine for both.

Thanks to you all for this great project!

IceDBorn commented 1 year ago

We need testers for Firefox Beta!

jim3692 commented 1 year ago

Looks like NixOS Unstable is still on Beta 119. On Arch the Beta 120 is released in AUR. We need to test on 120.

pallaswept commented 1 year ago

I've been watching this repo and waiting for 120 to land here, and it just hit opensuse tumbleweed. Will test as soon as I wake up.

pallaswept commented 1 year ago

No problems with the audio on the receiving side in 120 here. I never experienced this bug (I didn't use the plugin until now) so I'm not sure what I should be listening out for, but everything sounds fine. There is definitely no pitch shifting or distortion.