IceCast настройка под Linux - сетевое вещание
На примере Debian 9.3.0
Содержание
Установка
# apt install alsa-utils darkice icecast2 streamripper
Настройка звуковых карт
Проблема появилась откуда не ждали :)
Звуковые карты после перезагрузки определялись с разными id у меня например было 4 карты:
# cat /proc/asound/modules 0 snd_hda_intel 1 snd_emu10k1 2 snd_ctxfi 3 snd_ctxfi
В следующий раз:
# cat /proc/asound/modules 0 snd_ctxfi 1 snd_hda_intel 2 snd_emu10k1 3 snd_ctxfi
И тому подобное.... В общем решение, прописываем в файл /etc/modprobe.d/sound.conf
options snd_hda_intel index=0 options snd_emu10k1 index=1 options snd_ctxfi index=2,3
С желаемой последовательностью, правда остался вопрос с одинаковыми картами, но записываются они именно так, через запятую.
Icecast2
Настраиваем как тут, единственное, что конфигурационный файл тут:
/etc/icecast2/icecast.xml
Запускаем
# service icecast2 start
Darkice
Настраиваем как тут [1], возможно понадобится Darkice + aacPlus на Debian
Внимание! после изменений в /etc/init.d/ незабываем перезапускать systemctl
# systemctl daemon-reload
И выполнить update-rc.d с каждым экземпляром
update-rc.d darkice1 defaults update-rc.d darkice2 defaults
Отличие в darkice.cfg мы создадим тут несколько потоков с разной частотой дискретизации, во FreeBSD я делал это с помощью алиасов звуковой карты и использовал разные экземпляры darkice. Но в Debian я это в лоб победить не смог, и решил по другому darkice.cfg:
# sample DarkIce configuration file, edit for your needs before using
# see the darkice.cfg man page for details
# this section describes general aspects of the live streaming session
[general]
duration = 0 # duration of encoding, in seconds. 0 means forever
bufferSecs = 1 # size of internal slip buffer, in seconds
reconnect = yes # reconnect to the server(s) if disconnected
realtime = yes # run the encoder with POSIX realtime priority
rtprio = 3 # scheduling priority for the realtime threads
# this section describes the audio input that will be streamed
[input]
device = plughw:0,0 # OSS DSP soundcard device for the audio input
sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 2 # channels. 1 = mono, 2 = stereo
# this section describes a streaming connection to an IceCast2 server
# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections
[icecast2-0]
bitrateMode = abr # average bit rate
format = mp3 # format of the stream: ogg vorbis
bitrate = 128 # bitrate of the stream sent to the server
server = 127.0.0.1
# host name of the server
port = 8000 # port of the IceCast2 server, usually 8000
password = hackme # source password to the IceCast2 server
mountPoint = test_44100_128 # mount point of this stream on the IceCast2 server
name = mp3 128kHz 44100
[icecast2-1]
bitrateMode = abr # average bit rate
format = mp3 # format of the stream: ogg vorbis
bitrate = 8 # bitrate of the stream sent to the server
sampleRate = 22050 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 1 # channels. 1 = mono, 2 = stereo
server = 127.0.0.1
# host name of the server
port = 8000 # port of the IceCast2 server, usually 8000
password = hackme # source password to the IceCast2 server
mountPoint = test_8000_8 # mount point of this stream on the IceCast2 server
name = mp3 8kHz 8000