pimp, lame, ssh, and streaming! #tags pimp,shell,networking,ssh tricks So since pimp has a cheap shoutcast server thing, I decided to use that to play music while I'm at home.
Playing normal mp3s uses too much bandwidth to waste on my DSL connection (~20-30k/s with 128-160kbit mp3s). So, I decided to use lame as a middleman to down-encode the shoutcasted output from pimp. The following is a little script that uses netcat to connect to the shoutcasty thing aswell as act as a server elsewhere for the down-encoded mp3 data to be sent off.
#!/usr/local/bin/ksh
foo() {
killall nc
exit 1
}
trap foo int
nc -lp 8081 |&
echo "ICY 200 OK" >&p
echo >&p
nc whack 8080 | lame --mp3input -b 64 - - >&p
whack(~) > ./projects/pimp/pimp & whack(~) > ./mp3foo ... over on my laptop ... nightfall(~) > mplayer http://whack:8081
Furthermore, here's a nice oneliner to do inbound(download) bandwidth monitoring:
netstat -w 1 | perl -e 'while (<>) { next unless m/^\s+\S+\s+\S+\s+(\d+)/; \
$b++; $a += $1; print "Total/Avg/Cur = $a / " . ($a / $b) . " / $1\n"; }'