Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@justinatcamfil
Last active May 5, 2023 08:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinatcamfil/b4f1a8c4eab249a91863 to your computer and use it in GitHub Desktop.
Save justinatcamfil/b4f1a8c4eab249a91863 to your computer and use it in GitHub Desktop.
stream linux audio from sound card through netcat
#!/bin/bash
# run on mac in terminal
while TRUE; do
nc <server_address> 15000 | play -q -t mp3 - || echo Attempting to connect...
sleep 1;
done
#!/bin/bash
# run on linux box
MONITOR=$(pactl list | grep -A2 '^Source #' | \
grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1)
parec -d "$MONITOR" | sox -v 0.8 -s -S -t raw -r 44100 -sLb 16 -c 2 - -t mp3 -C 196 - | netcat -l 15000 -k
# why doesn't this work? sounds like playing a record with a pencil lead
# rec -t raw -b 16 -r 44100 -e signed -c 2 -L - -t mp3 -C 196 - | netcat -l 15000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment