Настройка потокового интернет-радио-вещания с использованием Icecast + streamTranscoderV3
1. Установка Icecast
http://siava.su/2011/02/18/icecast2-ices0-debian/
http://www.code-inside.com/icecast-server-na-baze-ubuntu/
В список репозиториев /etc/apt/sources.list добавьте мультимедиа репозиторий Debian
для squeeze:
deb http://mirror.yandex.ru/debian-multimedia/ squeeze main
для lenny:
deb http://mirror.yandex.ru/debian-multimedia/ lenny main
Для того, чтобы icecast запустился, необходимо в /etc/default/icecast2 установить значение:
Отредактируем файл конфигурации /etc/icecast2/icecast.xml
[spoiler]
<icecast>
<limits>
<clients>100</clients>
<sources>2</sources>
<threadpool>5</threadpool>
<queue-size>524288</queue-size>
<client-timeout>30</client-timeout>
<header-timeout>15</header-timeout>
<source-timeout>10</source-timeout>
<burst-on-connect>1</burst-on-connect>
<burst-size>165535</burst-size>
</limits>
<authentication>
<source-password>password</source-password>
<relay-password>password</relay-password>
<admin-user>admin</admin-user>
<admin-password>password</admin-password>
</authentication>
<hostname>siava.ru</hostname>
<listen-socket>
<port>8000</port>
</listen-socket>
<fileserve>1</fileserve>
<paths>
<basedir>/usr/share/icecast2</basedir>
<logdir>/var/log/icecast2</logdir>
<webroot>/usr/share/icecast2/web</webroot>
<adminroot>/usr/share/icecast2/admin</adminroot>
<pidfile>/usr/share/icecast2/icecast.pid</pidfile>
<alias source="/" dest="/status.xsl"/>
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
<logsize>10000</logsize> <!-- Max size of a logfile -->
</logging>
<security>
<chroot>0</chroot>
<changeowner>
<user>icecast2</user>
<group>icecast</group>
</changeowner>
</security>
</icecast> |
<icecast>
<limits>
<clients>100</clients>
<sources>2</sources>
<threadpool>5</threadpool>
<queue-size>524288</queue-size>
<client-timeout>30</client-timeout>
<header-timeout>15</header-timeout>
<source-timeout>10</source-timeout>
<burst-on-connect>1</burst-on-connect>
<burst-size>165535</burst-size>
</limits>
<authentication>
<source-password>password</source-password>
<relay-password>password</relay-password>
<admin-user>admin</admin-user>
<admin-password>password</admin-password>
</authentication>
<hostname>siava.ru</hostname>
<listen-socket>
<port>8000</port>
</listen-socket>
<fileserve>1</fileserve>
<paths>
<basedir>/usr/share/icecast2</basedir>
<logdir>/var/log/icecast2</logdir>
<webroot>/usr/share/icecast2/web</webroot>
<adminroot>/usr/share/icecast2/admin</adminroot>
<pidfile>/usr/share/icecast2/icecast.pid</pidfile>
<alias source="/" dest="/status.xsl"/>
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
<logsize>10000</logsize> <!-- Max size of a logfile -->
</logging>
<security>
<chroot>0</chroot>
<changeowner>
<user>icecast2</user>
<group>icecast</group>
</changeowner>
</security>
</icecast>
[/spoiler]
Рабочий конфиг
/etc/init.d/icecast2 start |
/etc/init.d/icecast2 start
Однако, так просто репозиторий не подключиться, делается несколько сложнее:
http://www.raspberrypi.org/phpBB3/viewtopic.php?t=9045&p=113210
1: Опять же, добавляем следующие строчки в /etc/apt/sources.list
deb-src http://www.deb-multimedia.org sid main
deb http://www.deb-multimedia.org wheezy main non-free |
deb-src http://www.deb-multimedia.org sid main
deb http://www.deb-multimedia.org wheezy main non-free
2: запускаем apt-get update
3: запускаем apt-get install deb-multimedia-keyring
4: удаляем/коментируем эту строку из /etc/apt/sources.list
deb http://www.deb-multimedia.org wheezy main non-free |
deb http://www.deb-multimedia.org wheezy main non-free
5: запускаем apt-get install <нужный пакет, например, icecast2>
Однако, и это помогает не особо.
Тогда идем прямиком на http://www.deb-multimedia.org/ и качаем нужный пакет руками.
Устанавливаем его
, а также, устанавливаем необходимые зависимости из списка на сайте.
2. Устанавливаем streamTranscoderv3
http://radiocms.ru/forum/showthread.php?p=2700
http://www.chrizdee.de/2007/04/20/streamtranscoder-unter-debian-installieren/
wget http://notes.norfolks.org/wp-content/uploads/2013/05/streamtranscoderv3.tar.gz
tar zxvf streamtranscoderv3.tar.gz
cd streamtranscoderv3-3.1.11
./configure
make & make install |
wget http://notes.norfolks.org/wp-content/uploads/2013/05/streamtranscoderv3.tar.gz
tar zxvf streamtranscoderv3.tar.gz
cd streamtranscoderv3-3.1.11
./configure
make & make install
Если возникли проблемы с компиляцией
apt-get install libogg-dev
apt-get install libvorbis-dev
apt-get install libmad0-dev
apt-get install libcurl3-dev
wget http://ftp.debian-unofficial.org/debian/pool/main/l/lame/libmp3lame0_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
dpkg --install libmp3lame0_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
wget http://ftp.debian-unofficial.org/debian/pool/main/l/lame/libmp3lame-dev_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
dpkg --install libmp3lame-dev_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
wget http://ftp.debian-unofficial.org/debian/pool/main/l/lame/lame_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
dpkg --install lame_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb |
apt-get install libogg-dev
apt-get install libvorbis-dev
apt-get install libmad0-dev
apt-get install libcurl3-dev
wget http://ftp.debian-unofficial.org/debian/pool/main/l/lame/libmp3lame0_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
dpkg --install libmp3lame0_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
wget http://ftp.debian-unofficial.org/debian/pool/main/l/lame/libmp3lame-dev_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
dpkg --install libmp3lame-dev_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
wget http://ftp.debian-unofficial.org/debian/pool/main/l/lame/lame_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
dpkg --install lame_3.96.99+3.97beta2+debian-1duo+sarge1_i386.deb
Создаем каталог для конфигов и переходим в него
mkdir /etc/streamTranscoder
cd /etc/streamTranscoder |
mkdir /etc/streamTranscoder
cd /etc/streamTranscoder
Для генерации базового конфига просто запускаем в этом каталоге:
в каталоге появится файл: streamTranscoder_0.cfg, там нужно изменить NumEncoders=0 на NumEncoders=1, для создания 1 дополнительного потока. По умолчанию там так же прописывается SourceURL=http://localhost:8000/live — точка откуда мызыка берётся для перекодирования.
Еще раз запускаем в этом каталоге:
появится файл streamTranscoder_1.cfg — это и есть конфиг вашего дополнительного потока. Удаляем из него всё и добавляем наш конфиг:
[spoiler]
Server=localhost
Port=8000
ServerPassword=password
ServerMountpoint=/live64
AutomaticReconnectSecs=10
# Output codec selection (Valid selections : MP3, OggVorbis, Ogg FLAC, AAC, AAC Plus)
Encode=MP3
# General settings (non-codec related). Note : NumberChannels = 1 for MONO, 2 for STEREO
BitrateNominal=64
NumberChannels=2
Samplerate=44100
# LAME specific settings. Note: Setting the low/highpass freq to 0 will disable them.
LameCBRFlag=1
LameQuality=5
LameCopywrite=0
LameOriginal=0
LameStrictISO=0
LameDisableReservior=0
LameLowpassfreq=0
LameHighpassfreq=0
# Destination server details (to where you are encoding). Valid server types : Shoutcast, Icecast, Icecast2
ServerType=Icecast2
# Log Level 1 = LOG_ERROR, 2 = LOG_ERROR+LOG_INFO, 3 = LOG_ERROR+LOG_INFO+LOG_DEBUG
LogLevel=1
# Log File
LogFile=oddcastv2.log
# Save Archives in WAV format
SaveAsWAV=0
# YP (Stream Directory) Settings
ServerPublic=0
ServerIRC=
ServerAIM=
ServerICQ=
ServerStreamURL=http://radiocms.ru
ServerName=
ServerDescription=
ServerGenre=
AutoConnect=0
BitrateMin=128
BitrateMax=128
# Ogg Vorbis specific settings. Note: Valid settings for BitrateQuality flag are (Quality, Bitrate Management)
OggQuality=0
OggBitrateQualityFlag=Quality
LameVBRMode=vbr_abr
LAMEPreset=0
# AAC (FAAC) specific settings.
AACQuality=100
AACCutoff=
# Save directory for archive streams
SaveDirectory=
# Flag which indicates if we are saving archives
SaveDirectoryFlag=0
# LAME Joint Stereo Flag
LAMEJointStereo=1 |
Server=localhost
Port=8000
ServerPassword=password
ServerMountpoint=/live64
AutomaticReconnectSecs=10
# Output codec selection (Valid selections : MP3, OggVorbis, Ogg FLAC, AAC, AAC Plus)
Encode=MP3
# General settings (non-codec related). Note : NumberChannels = 1 for MONO, 2 for STEREO
BitrateNominal=64
NumberChannels=2
Samplerate=44100
# LAME specific settings. Note: Setting the low/highpass freq to 0 will disable them.
LameCBRFlag=1
LameQuality=5
LameCopywrite=0
LameOriginal=0
LameStrictISO=0
LameDisableReservior=0
LameLowpassfreq=0
LameHighpassfreq=0
# Destination server details (to where you are encoding). Valid server types : Shoutcast, Icecast, Icecast2
ServerType=Icecast2
# Log Level 1 = LOG_ERROR, 2 = LOG_ERROR+LOG_INFO, 3 = LOG_ERROR+LOG_INFO+LOG_DEBUG
LogLevel=1
# Log File
LogFile=oddcastv2.log
# Save Archives in WAV format
SaveAsWAV=0
# YP (Stream Directory) Settings
ServerPublic=0
ServerIRC=
ServerAIM=
ServerICQ=
ServerStreamURL=http://radiocms.ru
ServerName=
ServerDescription=
ServerGenre=
AutoConnect=0
BitrateMin=128
BitrateMax=128
# Ogg Vorbis specific settings. Note: Valid settings for BitrateQuality flag are (Quality, Bitrate Management)
OggQuality=0
OggBitrateQualityFlag=Quality
LameVBRMode=vbr_abr
LAMEPreset=0
# AAC (FAAC) specific settings.
AACQuality=100
AACCutoff=
# Save directory for archive streams
SaveDirectory=
# Flag which indicates if we are saving archives
SaveDirectoryFlag=0
# LAME Joint Stereo Flag
LAMEJointStereo=1
[/spoiler]
ServerPassword — пароль source из icecast.xml
ServerMountpoint — точка потока
BitrateNominal — битрейт потока
Теперь когда всё готово запускаем в фоновом режиме, заходить в папку нужно при каждом запуске:
cd /etc/streamTranscoder && streamTranscoderv3
Для запуска в фоновом режиме:
cd /etc/streamTranscoder && streamTranscoderv3 -b
Остановка:
killall streamTranscoderv3
Для автоматизации последнего создаем в init.d скрипт
http://www.brain4free.org/wiki/doku.php/blog:streamtranscoderv3_linux_aac_patch
nano /etc/init.d/streamTranscoder |
nano /etc/init.d/streamTranscoder
[spoiler]
#! /bin/sh
#
# streamTranscoder
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Further modified by Keegan Quinn <ice@thebasement.org>
# for use with Icecast 2
#
# adopted to use with streamTranscoder v3 from oddsock
# by christoph zimmermann <christoph@bigbeat.ch>
#
### BEGIN INIT INFO
# Provides: streamTranscoder
# Required-Start: $net $syslog
# Required-Stop: $net $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starting StreamTranscoder
# Description: StreamTranscoder is the swiss army knife of the
streaming server user. ### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/streamTranscoderv3
CONF=/etc/streamTranscoder
NAME=streamTranscoderv3
DESC=streamTranscoderv3
test -x $DAEMON || exit 0
# Defaults
USERID=transcoder
GROUPID=transcoder
#set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
--background --chdir $CONF --nicelevel -3 --exec $DAEMON
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
--background --chdir $CONF --nicelevel -3 --exec
$DAEMON echo "$NAME."
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
exit 0 |
#! /bin/sh
#
# streamTranscoder
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Further modified by Keegan Quinn <ice@thebasement.org>
# for use with Icecast 2
#
# adopted to use with streamTranscoder v3 from oddsock
# by christoph zimmermann <christoph@bigbeat.ch>
#
### BEGIN INIT INFO
# Provides: streamTranscoder
# Required-Start: $net $syslog
# Required-Stop: $net $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starting StreamTranscoder
# Description: StreamTranscoder is the swiss army knife of the
streaming server user. ### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/streamTranscoderv3
CONF=/etc/streamTranscoder
NAME=streamTranscoderv3
DESC=streamTranscoderv3
test -x $DAEMON || exit 0
# Defaults
USERID=transcoder
GROUPID=transcoder
#set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
--background --chdir $CONF --nicelevel -3 --exec $DAEMON
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \
--background --chdir $CONF --nicelevel -3 --exec
$DAEMON echo "$NAME."
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
[/spoiler]