How to stream audio over ssh?

Chat about Linux in general
Forum rules
Do not post support questions here. Before you post read the forum rules. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
jimallyn
Level 19
Level 19
Posts: 9075
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

How to stream audio over ssh?

Post by jimallyn »

I am looking for a way to stream audio from my Raspberry Pi to my Mint desktop computer over ssh. I have found a number of web sites that show how to stream audio coming into the RPi from an external source, but nothing that shows how to stream all audio played on the RPi. Most of the websites use a command line along this line:

Code: Select all

arecord -f cd -t raw | oggenc - -r | ssh <user>@<remotehost> mplayer -
or this:

Code: Select all

arecord -D plughw:1,0 -f dat | ssh -C user@192.168.1.21 aplay -f dat 
Again, both of these are intended to stream audio from an external source, like a microphone. There must be something similar to stream all the audio that is played on the RPi, but I don't know what it is. Some kind of redirection or pipeline of /dev/audio or something? Anybody got suggestions?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: How to stream audio over ssh?

Post by xenopeek »

PulseAudio is your sound server. It is network enabled and can forward sound from your machine to another machine, to be played there. If you Google "pulseaudio over ssh" you'll find several hits on how to set that up. Some will describe a way to forward sound without encrypting it (as addition to X remote over SSH), but there are a few hits describing an alternative that would encrypt the sound also (if that is what you need). I haven't done anything with this myself, but PulseAudio is the direction you should be looking in I think.
Image
User avatar
jimallyn
Level 19
Level 19
Posts: 9075
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: How to stream audio over ssh?

Post by jimallyn »

PulseAudio isn't installed by default on the RPi, but it is available in the repositories. I Googled as you suggested and found a couple of interesting pages, and will try their suggestions later.
“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
Locked

Return to “Chat about Linux”