dimtpap / obs-pipewire-audio-capture

🔊 Audio device and application capture for OBS Studio using PipeWire
https://obsproject.com/forum/resources/pipewire-audio-capture.1458/
GNU General Public License v2.0
383 stars 12 forks source link

Audio cutout after 20 minutes, and again about 40 minutes #42

Open oparada1988 opened 11 months ago

oparada1988 commented 11 months ago

Hi Team,

Pipewire 1.0.0 Focusrite 2i2 3rd Gen 2x Elgato Wave XLR OBS 30.0.1 Ubuntu 22.04.3 6.2.0-1018-lowlatency

So This is on a new fresh install of the OS, I had this on my previous install and did a new install to see if I could recreate it. So, within 21 minutes of recording I get this audio cut out, it also happens later on around 40 minutes. and wanted to see if anyone has experienced this before?

https://obsproject.com/tools/analyzer?log_url=https%3A%2F%2Fobsproject.com%2Flogs%2FDoBGdIdaHcqvLTMr

qpwgraph:

Screenshot from 2023-12-20 15-19-22

recording sample:

https://github.com/dimtpap/obs-pipewire-audio-capture/assets/4031078/54d19d34-2815-4e38-a5cb-60944fbdd815

dimtpap commented 11 months ago

It sounds like under/overrunning. What's PipeWire's quantum set to? (https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Config-PipeWire#setting-buffer-size-quantum)

oparada1988 commented 11 months ago

Sorry, I was our for the xmas holiday. Looking at /etc/pipewire/pipewire.conf I do not have this file. Should I proceed and create it with the values in the guide?

default.clock.min-quantum = 32 default.clock.max-quantum = 8192

Or, since there is no client specified should I do the one stated?

default.clock.quantum = 1024

dimtpap commented 11 months ago

See https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Config-PipeWire#configuration-file-pipewireconf then try setting default.clock.min-quantum to 64, 128 etc and see if it happens again

oparada1988 commented 11 months ago

See https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Config-PipeWire#configuration-file-pipewireconf then try setting default.clock.min-quantum to 64, 128 etc and see if it happens again

Done, will report back :-)

oparada1988 commented 11 months ago

Hi, I recorded a 1:30:00 podcast episode and the issue occured. I will proceed to chnage the value from 64 to 128. Please keep this open and will update as I go along. Next recording that I will be making is next week.

oparada1988 commented 11 months ago

on OBS I have it set to 48khz for audio. thought id mention this in case anyone has any input.

dimtpap commented 11 months ago

Does it happen in general or only with your podcast recording setup? If you replicate the issue could you also provide a screenshot of pw-top while you're recording? Thanks

oparada1988 commented 11 months ago

tbh only with my podcast recording set up, I havent recorded anything else. I will do pw-top during the next recording and will share here.

oparada1988 commented 11 months ago

Screenshot from 2024-01-03 07-30-48

As requested

dimtpap commented 11 months ago

Quantum is reasonable on everything so there's no need to try other quantums in your config. It's most definitely a bug.

Unrelated suggestion: You seem to be rerouting audio manually with qpwgraph from single ports to stereo audio input sources. You may want to consider pipewire-jack and OBS's JACK input sources. They're a much better fit for custom routing

dimtpap commented 11 months ago

In fact, could you try with a JACK Input Client source next time? The code I'm suspecting to be the problem is pretty much the same in both, I want to see if it's problematic in general or if there's something wrong just here

oparada1988 commented 11 months ago

Interestingly, when I tried using Jack it doesnt even appear in the qjackctl graph for me to route it. I went ahead and deleted the Pipewire input capture

Screenshot from 2024-01-05 08-04-34

Screenshot from 2024-01-05 08-05-19

dimtpap commented 11 months ago

They should show up in qpwgraph if you have pipewire-jack installed

oparada1988 commented 11 months ago

Same thing, I select jack input client and it doesnt show up in qpwgraph :-(

pipewire-jack is also installed on my system:

Screenshot from 2024-01-05 16-34-02

https://github.com/dimtpap/obs-pipewire-audio-capture/assets/4031078/2f52fa28-0c7c-4b61-944b-8dd9948f0d41

dimtpap commented 10 months ago

Taking a shot in the dark. Can you try with this build? Diff:

diff --git a/src/pipewire-audio.c b/src/pipewire-audio.c
index 95ee923..b43c936 100644
--- a/src/pipewire-audio.c
+++ b/src/pipewire-audio.c
@@ -177,7 +177,17 @@ static void on_process_cb(void *data)

    struct obs_pw_audio_stream *s = data;

-   struct pw_buffer *b = pw_stream_dequeue_buffer(s->stream);
+   struct pw_buffer *b = NULL;
+   {
+       struct pw_buffer *t;
+       while ((t = pw_stream_dequeue_buffer(s->stream)) != NULL) {
+           if (b) {
+               pw_stream_queue_buffer(s->stream, b);
+           }
+
+           b = t;
+       }
+   }

    if (!b) {
        return;
oparada1988 commented 10 months ago

Will do! Sorry about no follow up, been working but we did one more recording and it happens. We will record again this tuesday and I will report back if the issue persists with the above build you shared.

oparada1988 commented 9 months ago

Issue persists, however it happened only once. Is there something else I should be looking for??

dimtpap commented 8 months ago

Can you try the latest commit? Build here

oparada1988 commented 8 months ago

Can you try the latest commit? Build here

Heya, Yeah ill try it out today!

adromel commented 6 months ago

Hi! For what it's worth, I have the same issue as OP (except that it was much more frequent), and switching to JACK input client did the trick: no more audio stuttering/crackling/popping.

~~Tried most of what I've found : commit 5c47e1a, switching kernels, niceness, removing easyeffects. None succeeded. I'm on up-to-date Arch and obs-studio package, and quantum are the same as above.~~

Edit: So this finally happened with JACK as well, but i got it fixed with this workaround: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3098#note_1823699

Sorry for the false alarm, OPAC is working as intended. Thanks for the useful work that should be merged in obs!

oparada1988 commented 5 months ago

~Hi! For what it's worth, I have the same issue as OP (except that it was much more frequent), and switching to JACK input client did the trick: no more audio stuttering/crackling/popping.~

~Tried most of what I've found : commit 5c47e1a, switching kernels, niceness, removing easyeffects. None succeeded. I'm on up-to-date Arch and obs-studio package, and quantum are the same as above.~

Edit: So this finally happened with JACK as well, but i got it fixed with this workaround: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3098#note_1823699

Sorry for the false alarm, OPAC is working as intended. Thanks for the useful work that should be merged in obs!

Im sorry, what exactly did you do? Im reading the issue report and im kinda confused...

I'm on Ubuntu 22.04 btw

oparada1988 commented 3 months ago

Im about to give up, im still having this issue. I tried Jack and same thing. I really dont want to move back to windows for this little thing :-( if anyone else has any other suggestions please let me know

alterNERDtive commented 3 months ago

I’ve been having similar crackling issues with my mic (completely unrelated to this plugin, btw). Seems to be solved for me, hasn’t happened in weeks; I just set a fixed PIPEWIRE_LATENCY for OBS.

oparada1988 commented 3 months ago

I’ve been having similar crackling issues with my mic (completely unrelated to this plugin, btw). Seems to be solved for me, hasn’t happened in weeks; I just set a fixed PIPEWIRE_LATENCY for OBS.

Can you provide some steps or guide on what you did?

dimtpap commented 3 months ago

@oparada1988 PIPEWIRE_LATENCY is an environment variable. The PipeWire README explains it.

dimtpap commented 3 months ago

Can you try with a build from here? Under "artifacts"