Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-06-2016, 10:45 AM   #1
Registered: Mar 2015
Distribution: Linux Mint
Posts: 524

Rep: Reputation: 238Reputation: 238Reputation: 238
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

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
Old 09-06-2016, 11:57 AM   #2
Registered: Mar 2015
Distribution: Linux Mint
Posts: 524

Original Poster
Rep: Reputation: 238Reputation: 238Reputation: 238
Got a working setup

arecord -t wav -f cd - | ffmpeg -i - -f opus - | nc ip 9876
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.


I have a much better command that uses ssh

ssh HOST aplay < <(arecord -f cd)

Last edited by Sefyir; 09-13-2016 at 12:16 PM.
Old 09-06-2016, 03:05 PM   #3
Registered: Nov 2012
Posts: 204

Rep: Reputation: 67
Does your raspberry pi have pulseaudio installed too? If so look at the "Direct Connection" section here:

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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Audio Streaming (server) BlackRabbit Linux - Software 9 12-25-2012 01:06 PM
[SOLVED] audio streaming in linux konsgia Linux - Newbie 1 05-19-2011 05:15 PM
how to grab audio amplitude from sound card in Linux for programming Linux app? bapigoo9 Programming 3 08-28-2008 07:15 PM
Audio/Video Streaming in Linux donaeux Linux - Software 2 11-21-2006 10:14 AM
Streaming audio in Linux? Van Gogh Linux - Newbie 8 12-30-2003 11:58 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:27 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration