Skip to content

Instantly share code, notes, and snippets.

@non

non/cast.sh

Created Jun 3, 2019
Embed
What would you like to do?
#!/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