Skip to content

Instantly share code, notes, and snippets.

@non
Created June 3, 2019 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save non/d92e5136e6d0a04c5ff02a32b11f721a to your computer and use it in GitHub Desktop.
Save non/d92e5136e6d0a04c5ff02a32b11f721a to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# simple streaming from the command line:
#
# ./cast.sh send *.mp3 # stream some files
#
# ./cast.sh recv # listen to the stream
#
# currently hardcodes localhost port 9999.
#
# also currently set for mac. for linux, replace "-t coreaudio" with
# "-t alsa" or a similar linux driver.
send() {
mplayer -vo null -vc null -ao pcm:file=/dev/stdout -really-quiet "$@" | \
sox -e signed -r 44100 -b 16 -c 2 -t raw - -t ogg - | \
nc -l localhost 9999
}
recv() {
nc localhost 9999 | \
sox -t ogg - -t coreaudio
}
case "$1" in
send) shift; send "$@"; exit 0;;
recv) recv; exit 0;;
*) echo "expected send|recv, got: $@"; exit 1;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment