melnijir / Dicaffeine

Repository for things connected to Dicaffeine player/streamer.
https://dicaffeine.com
MIT License
112 stars 5 forks source link

Stuttering / choppy NDI audio #15

Closed alessionossa closed 2 years ago

alessionossa commented 2 years ago

I am using a Raspberry Pi 4 Model B (4GB) with latest version of Raspberry Pi OS (64-bit, release date: January 28th 2022) to display output of OBS running on another machine.

After playing around with the settings I was able to get a smooth video stream, however every 2/3 seconds the audio is missing for a moment.

I am sure this is not caused by the Network because the same source viewed on my MacBook works fine. I am confident it's not related to Raspberry's computing power because it also happens when OBS's output is set to 720p.

je71175 commented 2 years ago

Out of curiosity - what settings did you use to get a good video? Thanks

lplassman commented 2 years ago

I am also experiencing the same issue when playing any NDI source. This issue occurs on both an Intel i5-6500 Mini PC as well as a Raspberry Pi 4.

melnijir commented 2 years ago

Hi, I've just tried Dicaffeine on i3-8130U Intel NUC. Streaming from another PC with OBS 27.2.4 works fine for me. Both PCs are running Xubuntu 20.04.4. What OBS version/system do you use? Thanks!

alessionossa commented 2 years ago

I was using OBS 27.2.0 (probably the latest version at the time) running on a MacBook Pro (15-inch, 2016) with Quad-Core Intel Core i7. As mentioned above, to receive the stream I was using a Raspberry Pi 4 Model B (4GB) with Raspberry Pi OS (64-bit, release date: January 28th 2022). All connected with Ethernet cables and the network can handle the stream between other other devices.

melnijir commented 2 years ago

Thanks for the information, I'll check that on Monday with OBS on MacBook.

lplassman commented 2 years ago

When playing an audio only NDI stream, the issue is more apparent. I ran yuri2 from the command line and captured the output. It appears that the NDI receiver is stopping and then starting, only to stop again.

WARNING 29: 17:11:20 [NDIInput/ndi_input_0] Error setting parameter event_time INFO 35: 17:11:20 [webserver/websrv] Created socket INFO 37: 17:11:20 [web_static/webstatic] Resizing to 12 INFO 39: 17:11:20 [glx_window/window_auto] Geometry 800x600+0+0 INFO 39: 17:11:20 [glx_window/window_auto] Connected to display :0.0 INFO 39: 17:11:20 [glx_window/window_auto] Screen number is 0 INFO 39: 17:11:20 [glx_window/window_auto] Found root window INFO 39: 17:11:21 [glx_window/window_auto] Found visual 604 INFO 39: 17:11:21 [glx_window/window_auto] geometry 1920x1080+0+0 INFO 39: 17:11:21 [glx_window/window_auto] X Window Created INFO 35: 17:11:21 [webserver/websrv] Starting worker thread INFO 37: 17:11:21 [web_static/webstatic] Registered to server INFO 35: 17:11:21 [webserver/websrv] Helper thread started INFO 33: 17:11:21 [web_control/webctrl] Registered to server INFO 29: 17:11:21 [NDIInput/ndi_input_0] Found stream "LUKES-MACBOOK-AIR.LOCAL (macOS AV Output)" with id 0 INFO 29: 17:11:21 [NDIInput/ndi_input_0] Receiving started INFO 29: 17:11:21 [NDIInput/ndi_input_0] Sender doest not support PTZ, disabling events. INFO 39: 17:11:21 [glx_window/window_auto] Created GLX Context INFO 39: 17:11:21 [glx_window/window_auto] Decorations XChangeProperty returned 1 INFO 39: 17:11:21 [glx_window/window_auto] setting on top: 0 INFO 39: 17:11:21 [glx_window/window_auto] Fullscreen XChangeProperty returned 1 INFO 39: 17:11:21 [glx_window/window_auto] Stereo method: none INFO 18: 17:11:21 [pulse_output/audio_output] Initialized for 48000 Hz INFO 18: 17:11:21 [pulse_output/audio_output] Initialized for 6 channels INFO 18: 17:11:21 [pulse_output/audio_output] New format for pulse audio set. WARNING 18: 17:11:21 [pulse_output/audio_output] Not able to write data to pulse audio. WARNING 18: 17:11:21 [pulse_output/audio_output] Not able to write data to pulse audio. INFO 41: 17:11:21 [GL] Generated texture 1 ERROR 41: 17:11:21 [GL] Error 1280 setting texture params ERROR 41: 17:11:21 [GL] Error 1280 setting texture params INFO 29: 17:11:22 [NDIInput/ndi_input_0] Stopping receiver INFO 29: 17:11:22 [NDIInput/ndi_input_0] Found stream "LUKES-MACBOOK-AIR.LOCAL (macOS AV Output)" with id 0 INFO 29: 17:11:22 [NDIInput/ndi_input_0] Receiving started INFO 29: 17:11:22 [NDIInput/ndi_input_0] Sender doest not support PTZ, disabling events. INFO 29: 17:11:24 [NDIInput/ndi_input_0] Stopping receiver INFO 29: 17:11:25 [NDIInput/ndi_input_0] Found stream "LUKES-MACBOOK-AIR.LOCAL (macOS AV Output)" with id 0 INFO 29: 17:11:25 [NDIInput/ndi_input_0] Receiving started INFO 29: 17:11:25 [NDIInput/ndi_input_0] Sender doest not support PTZ, disabling events. INFO 39: 17:11:25 [glx_window/window_auto] FPS: 25.339 INFO 29: 17:11:26 [NDIInput/ndi_input_0] Stopping receiver INFO 29: 17:11:27 [NDIInput/ndi_input_0] Found stream "LUKES-MACBOOK-AIR.LOCAL (macOS AV Output)" with id 0 INFO 29: 17:11:27 [NDIInput/ndi_input_0] Receiving started INFO 29: 17:11:27 [NDIInput/ndi_input_0] Sender doest not support PTZ, disabling events. INFO 29: 17:11:28 [NDIInput/ndi_input_0] Stopping receiver

melnijir commented 2 years ago

Normally the Stopping receiver message means that no video data is received for more than 1 second and the playback is automatically restarted. I've changed the behaviour that even receiving audio only is fine and the stream should not be stopped. Can you please update your installation:

sudo apt update && sudo apt upgrade -y

and try that again?

Thanks!

lplassman commented 2 years ago

Since updating, that appeared to fix the issue with playing an audio-only NDI stream. However, micro audio stutters still remain when playing any NDI stream with audio and video from my 2020 M1 MacBook Air. I have tried NDI Scan Converter and OBS with the same results. I can play the same NDI stream from my MacBook on another NDI receiver (NDI Monitor on my iPad) and it sounds fine. These tests were all performed using an Ethernet connection to both my MacBook and Raspberry Pi 4.

I also tried a Windows 10 PC with NDI Scan Converter and OBS. With either NDI source, I am getting very little to no audio stutters. When 'Low Resolution' mode is turned off, I get a few more audio stutters on the Raspberry Pi than when the setting is on, but I am also streaming a 1080p stream. So it appears that the issue is related to a Mac in some way.

alessionossa commented 2 years ago

After updating with the command sudo apt update && sudo apt upgrade -y, I still get some audio stutters, even though they have now decreased. I do not know if it is my perception, but it seems to me that the audio is reproduced faster than its real speed. If so, it is understandable that there are these interruptions because once the audio is reproduced at a speed higher than the real one, it is reached a point where the audio stops, waiting for the microphone.

melnijir commented 2 years ago

I've made some changes in audio buffering. On my setup MacBook Pro (OBS) -> Raspberry Pi 400 / x86 PC (Dicaffeine) everything works fine now. Can you please confirm? Again update with the command:

sudo apt update && sudo apt upgrade -y

Thanks!

lplassman commented 2 years ago

Just updated and works great for me with my MacBook. No stutters at all with audio only source, or audio and video source. Thank you!

melnijir commented 2 years ago

Perfect, thanks for the confirmation!