On-demand streaming audio server

Tags: music streaming streaming audio

Added: 2011-02-25T16:37:27

On-demand streaming audio server

So, you want to listen to your music files when you're away, at work, etc?

You'll need to reencode them, but you won't want to leave the re-encoding running all the time, as it's pretty juicy on the CPU. Solution? An on-demand streaming server.

You'll need to install xinetd and VLC (apt-get install cvlc xinetd), and configure a new xinetd "service".

cat /etc/xinetd.d/randomaudio

# default: off
# description: Plays random audio
service randomaudio
	disable		= no
	type		= UNLISTED
	id		= randomaudio
	socket_type	= stream
	protocol	= tcp
	port		= 12345 <-- Whatever port you want it to run on
	instances	= 1
	user		= username <-- Put your username here
	wait		= no
	rlimit_cpu	= 3600
	nice		= 20
	max_load	= 1.5
	log_on_failure	= HOST USERID ATTEMPT
	server		= /path/to/next/script

Then, put a script in the location specified above:


find /bigdrivea/ /bigdriveb/ -type f -iname "*.mp3" | sort -R > /some/path/random.m3u

#echo Random track is "$random"

echo -en "HTTP/1.1 200 OK\r\n"
echo -en "\r\n"
vlc -I telnet --telnet-host --sout '#transcode{acodec=vorb,ab=128,channels=2}:duplicate{dst=std{access=file,mux=ogg,dst=-}}' --sout-keep /some/path/random.m3u 2> /tmp/stream.err

Don't forget to make it executable (chmod 755 /path/to/next/script)

Then play it, using mplayer http://your.ip.add.ress:12345/
It's a quick and dirty hack. But it doesn't require much on your system, other than VLC.

posted by Calum on 2011-02-25T16:40 under

Add a comment

Your IP:
Please enter 4884125 here: