[tv/radio] Une instance de icecast pour les flux radio http

Ça permet de pouvoir aussi les écouter en wifi, comme la bande passante
que prennent les flux audio est faible.
This commit is contained in:
Valentin Samir 2013-12-21 03:33:54 +01:00
parent 4a06d155d8
commit 39c75f058d
4 changed files with 32 additions and 3 deletions

0
tv/radio/__init__.py Normal file
View file

25
tv/radio/icecast.py Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
import urlparse
import urllib
from config import *
i=0
for group in multicast.keys():
for (title, (name,dst,port,sources)) in multicast[group].items():
p=urlparse.urlparse(sources[0])
if ':' in p.netloc:
host=p.netloc.split(':')[0]
port=p.netloc.split(':')[1]
else:
host=p.netloc
port = 80
print """
<relay>
<server>%s</server>
<port>%s</port>
<mount>%s</mount>
<local-mount>/%s</local-mount>
<relay-shoutcast-metadata>1</relay-shoutcast-metadata>
<on-demand>1</on-demand>
</relay>""" % (host, port, p.path, name)

View file

@ -27,6 +27,8 @@ vlc_start() {
fi
fi
${DIR}vlm.py > ${TMP}vlm.vlm
${DIR}icecast.py > /etc/icecast2/radio.xml
/etc/init.d/icecast2 restart
/usr/bin/sudo -u www-data cvlc --extraintf telnet --ttl 12 --vlm-conf ${TMP}vlm.vlm --pidfile ${PIDFILE} --daemon >/dev/null
}

View file

@ -1,14 +1,16 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
import urllib
from config import *
i=0
for group in multicast.keys():
for (name,dst,port,sources) in multicast[group].values():
for (title, (name,dst,port,sources)) in multicast[group].items():
#name="channel%s" % i
print('new %s broadcast enabled loop' % name)
for source in sources:
print('setup %s input "%s"' % (name,source))
# for source in sources:
# print('setup %s input "%s"' % (name,source))
print('setup %s input "%s"' % (name,'http://tv.crans.org:8000/%s' % name))
print('setup %s output #udp{mux=ts,dst=%s:%s}' % (name,dst,port))
print('setup %s option network-caching=50' % name)
print('setup %s option sout-all' % name)