1

I have two separate Linux computers on the same LAN. One computer has speakers, the other computer has a monitor. To play a movie with video and sound I have two options:

  1. Play the movie on the computer with the speakers, and transfer the video over the network to the computer with the monitor.
  2. Play the movie on the computer with the monitor, and transfer the audio over the network to the computer with the speakers.

The first options works well using X11 forwarding:

$ ssh -X computer1
$ mpv movie.avi

For the second option I tried PulseAudio's network setup, setting the following in /etc/pulse/default.pa on both computers:

load-module module-native-protocol-tcp auth-anonymous=1
load-module module-zeroconf-publish
load-module module-zeroconf-discover

Then, I run mpv on the computer with the monitor. This works, but the audio is so choppy that it makes the movie unwatchable. Why is it that streaming video poses no problem but streaming audio is apparently hard? Doesn't uncompressed video use much more bandwidth than uncompressed audio?

4
  • 1
    Is the available bandwidth symmetric in both directions? Jun 13, 2022 at 14:41
  • Good question! I investigated and found that scp reports about 10MB/s in both directions. That isn't much, which could explain the choppy audio. However, I can't explain why the video still looks decent! Jun 13, 2022 at 15:16
  • 2
    When the video stream malfunctions, you can still see the last picture. When the audio stream malfunctions, you can keep the last sound alive. Well you can, but playing the same buffer over and over is not very pleasant!
    – Daniel B
    Jun 13, 2022 at 18:20
  • @DanielB this is the real answer to my question. Both audio and video were sub-par with only 10MB/s, it's just that I noticed the audio chopping way before I noticed the video skipping frames. Jun 14, 2022 at 2:25

2 Answers 2

2

You're right that bandwidth isn't the problem. What you're encountering is jitter and underruns. The classic fix for that is to increase latency (so the hose doesn't run dry, so to speak).
For PulseAudio itself, in /etc/pulse/daemon.conf, increase default-fragment-size-msec and maybe also default-fragments. Also see the Scheduling section in https://linux.die.net/man/5/pulse-daemon.conf, and a discussion thereof.
There may be further parameters to tweak for the TCP connection, but I'm unfamiliar with that end of things.

1
  • The problem can also be solved by increasing the bandwidth, so in a sense, bandwidth is the problem. Jun 14, 2022 at 0:00
1

For my own and anyone else's future reference, here's the setup I used to successfully stream audio without buffer underruns. It works flawlessly provided both systems have a decent network connection. (For me it was choppy on 2.4 GHz WiFi, but fine on 5 GHz WiFi.)

Let's call the system with the speakers speakers and the system with the screen screen.

  • On both systems, install the Zeroconf module:

    $ sudo apt install pulseaudio-module-zeroconf
    
  • On speakers, add the following to /etc/pulse/default.pa:

    load-module module-native-protocol-tcp
    load-module module-zeroconf-publish
    
  • On screen, add the following to /etc/pulse/default.pa:

    load-module module-zeroconf-discover
    
  • Copy the file ~/.config/pulse/cookie from screen to speakers (or the other way around, presumably).

  • On screen run pavucontrol to set the output device. As you can see in the screenshot below, the following "Virtual Output Devices" were automatically added (which also reveals that my speakers system is actually called sea).

pavucontrol

2
  • Your own explicit questions are "Why is it that streaming video poses no problem but streaming audio is apparently hard? Doesn't uncompressed video use much more bandwidth than uncompressed audio?". This answer does not answer these at all. You did not ask "how can I fix?", but judging by your answer this is what you wanted to ask. Please make the answer match the question or the other way around. In general this would be easy if your answer was the only one, not necessarily easy otherwise. Fortunately the other answer also tries to answer "how can I fix?", so this should be the question. Jun 14, 2022 at 18:15
  • @KamilMaciorowski you are completely right that my original question has not been answered. I posted my own answer to document what I have done to solve my problem, but the cause of the problem is still unknown. If you are anyone else would be willing to answer the original question I will mark it, rightfully, as the accepted answer. Jun 14, 2022 at 21:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .