View Single Post
Old 27th September 2014, 01:59   #6
dopelabs
Major Dude
 
dopelabs's Avatar
 
Join Date: Oct 2006
Location: Silicon Valley
Posts: 534
Send a message via AIM to dopelabs
a quick example using liquidsoap

connects to a remote shoutcast server and transcodes to aac and mp3 and rebroadcasts to multiple shoutcast servers.

shoutast based sources (djs) connect, switching from the remote source to the live source immediately, and back on disconnect


code:

#!/usr/bin/liquidsoap

# set full path to logfile
set("log.file.path","/var/log/liquidsoap/radiostation.log")

# enable daemon mode
set("init.daemon",true)

# change to run under a custom user/group
set("init.daemon.change_user",true)
set("init.daemon.change_user.group","username")
set("init.daemon.change_user.user","groupname")

# do not create a pid file
set("init.daemon.pidfile",false)

# ip to listen on for djs and sources
set("harbor.bind_addr","127.0.0.1")

# remote source to be transcoded
url = "http://www.remotehost.com:8000"
relay = mksafe(input.http(url))

# port and pass for djs
live = input.harbor("/",port=8000,password="djpassword")

# local file
emergency = single("/path/to/some/lastresort.mp3")

# fallback function
radio = fallback(track_sensitive=false,[live,relay,emergency])

# output to shoutcast servers
output.shoutcast(%mp3(bitrate=256,samplerate=44100,stereo=true),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8000,password = "changeme",radio)
output.shoutcast(%mp3(bitrate=128,samplerate=44100,stereo=true),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8010,password = "changeme",radio)
output.shoutcast(%mp3(bitrate=64,samplerate=44100,stereo=true),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8020,password = "changeme",radio)
output.shoutcast(%mp3(bitrate=24,samplerate=22050,stereo=false),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8030,password = "changeme",radio)
output.shoutcast(%aac(bitrate=256),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8000,password = "changeme",radio)
output.shoutcast(%aac(bitrate=128),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8010,password = "changeme",radio)
output.shoutcast(%aac(bitrate=64),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8020,password = "changeme",radio)
output.shoutcast(%aac(bitrate=24),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8030,password = "changeme",radio)




this can be easily modified to just play a directory of media and perform the same live dj switching:


code:

#!/usr/bin/liquidsoap

# set full path to logfile
set("log.file.path","/var/log/liquidsoap/radiostation.log")

# enable daemon mode
set("init.daemon",true)

# change to run under a custom user/group
set("init.daemon.change_user",true)
set("init.daemon.change_user.group","username")
set("init.daemon.change_user.user","groupname")

# do not create a pid file
set("init.daemon.pidfile",false)

# ip to listen on for djs and sources
set("harbor.bind_addr","127.0.0.1")

# remote source to be transcoded
# A playlist
archives = playlist("/some/directory/of/mp3")

# port and pass for djs
live = input.harbor("/",port=8000,password="djpassword")

# fallback function
radio = mksafe(archives)
radio = fallback(track_sensitive=false,[live,archives])

# output to shoutcast servers
output.shoutcast(%mp3(bitrate=256,samplerate=44100,stereo=true),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8000,password = "changeme",radio)
output.shoutcast(%mp3(bitrate=128,samplerate=44100,stereo=true),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8010,password = "changeme",radio)
output.shoutcast(%mp3(bitrate=64,samplerate=44100,stereo=true),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8020,password = "changeme",radio)
output.shoutcast(%mp3(bitrate=24,samplerate=22050,stereo=false),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8030,password = "changeme",radio)
output.shoutcast(%aac(bitrate=256),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8000,password = "changeme",radio)
output.shoutcast(%aac(bitrate=128),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8010,password = "changeme",radio)
output.shoutcast(%aac(bitrate=64),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8020,password = "changeme",radio)
output.shoutcast(%aac(bitrate=24),name="Radio Station",genre="Genre",host="127.0.0.1",port = 8030,password = "changeme",radio)

dopelabs is offline   Reply With Quote