LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grab linux audio for streaming (https://www.linuxquestions.org/questions/linux-newbie-8/grab-linux-audio-for-streaming-4175588859/)

Sefyir 09-06-2016 10:45 AM

Grab linux audio for streaming
 
I want to stream audio from my desktop (which only has headphones) to my raspberry pi, which is attached to speakers.

The only thing I need is to be able to grab the audio playing from my computer... from the terminal so that I can pipe it. Eg

Code:

cat this_file | nc ip port
I know I can use some other programs (like audacity) to record sound, perhaps is there anything in the cli that can do this and write to stdout?

Using Linuxmint 18. I believe it uses pulseaudio

Sefyir 09-06-2016 11:57 AM

Got a working setup


Desktop:
Code:

arecord -t wav -f cd - | ffmpeg -i - -f opus - | nc ip 9876
Rpi:
Code:

nc -l 9876 | mplayer -vo null -
I'd like to remove the ffmpeg completely but it didn't seem to work unless it used a lossy compression (flac, wav didn't work but opus, ogg, mp3 worked)
I also put the nc -l in a while loop since it makes it easier to reconnect to it.

EDIT:

I have a much better command that uses ssh

Code:

ssh HOST aplay < <(arecord -f cd)

af7567 09-06-2016 03:05 PM

Does your raspberry pi have pulseaudio installed too? If so look at the "Direct Connection" section here: https://www.freedesktop.org/wiki/Sof.../User/Network/

On your PC you should be able to set the $PULSE_SERVER environment variable to be the IP address of the pi, and on the pi load the module-native-protocol-tcp module so it accepts network connections. You can either load the module using pacmd or if you have X use paprefs. If you use pacmd you will have pass some options to load-module to specify the allowed IP addresses that can connect. If you use paprefs (which is what I used) then under the network server tab you just need to enable network access and don't require authentication.


All times are GMT -5. The time now is 12:38 AM.