การทำ วิทยุออนไลน์ Radio Online ด้วย Ubuntu server ICECAST2 & DARKICE

ในบทความนี้ ผมใช้ระบบปฏิบัติการ Ubuntu เป็นตัวกระจาย ( ICECAST2 ) และตัวส่ง( DARKICE ) ในตัวเดียวกันเลย และใช้สัญญาณ Line In รับสัญญาญเสียงเข้ามา 

เริ่มกันเลยครับ

ติดตั้ง Ubuntu 10.04 ให้เรียบร้อย

1. การติดตั้ง ICECAST2

apt-get update

apt-get install icecast2

เปิดใช้งาน

nano /etc/default/icecast2

แก้ไข

ENABLE=true

แก้ไข  password config file

nano /etc/icecast2/icecast.xml

    <authentication>

        <!-- Sources log in with username 'source' -->

        <source-password>hackme</source-password>

        <!-- Relays log in username 'relay' -->

        <relay-password>hackme</relay-password>

        <!-- Admin logs in with the username given below -->

        <admin-user>admin</admin-user>

        <admin-password>hackme</admin-password>

    </authentication>

เริ่มทำงาน icecast2 server

/etc/init.d/icecast2 start

เข้าดูผ่านหน้า web

http://YOU_IP_HERE:8000/

2.ติดตั้งระบบเสียง

apt-get install alsa-utils

apt-get install alsa-oss

apt-get install oss-compat

ปรับ mixer

alsamixer

การกด F4 F5 ต้องทำที่หน้าเครื่อง หรือใช้ programe ไม่ puty

ให้กด F4 และกด space bar ที่ Line

และเพิ่มเสียงที่ CAPTURE สูงสุดไว้

หากต้องการฟังเสียง ให้ไปที่ F3 แล้วกด M เพื่อเปิดเสียงที่ต้องการ จะได้ยินเสียงออกทางลำโพง 

** แต่ละรุ่นจะไม่เหมือนกัน  แต่โดยหลักการให้ไป Capture จากแหล่งเสียงของเรา

คำสั่งทดสอบเสียงใช้

speaker-test

เป็นอันเรียบร้อยสั่ง restart

3. การติดตั้ง darkice

apt-get install darkice

cp /usr/share/doc/darkice/examples/darkice.cfg /etc/

nano  /etc/darkice.cfg

แก้ไข

duration        = 0

[icecast2-0]

format          = mp3

bitrate         = 48 

bitrateMode     = cbr

server          = localhost

port            = 8000     

password        = hackme    #ต้องตรงกับ Password Ice Cast

mountPoint      = live        #ตำแหน่งในการเรียกใช้จาก URL

name            = Radio

description     = Test Radio Online

url             = http://www.radio.com

genre           = my own 

ส่วนที่อยู่ภายใต้ [icecast-0] และ [shoutcast-0]  ให้เอาออกหรือใส่ # ด้านหน้าที่เหลือด้านหน้าทั้งหมด

เปิดใช้งาน

nano /etc/default/darkice

แก้ไข

RUN=yes

USER=root              

GROUP=root

++++++++++++++++++++++++++++++ไม่ต้องทำก็ได้+++++++++++++++++++++++++++++++++

แก้ไข nano /etc/init.d/darkice

โดยเพิ่ม --make-pidfile ในตำแหน่งตามตัวอย่างด้านล่าง

และลบ --chuid $USER:$GROUP ออก

start_server() {

# Start the process using the wrapper

        start-stop-daemon --start --quiet  --make-pidfile --pidfile $PIDFILE \

            --background --exec $DAEMON -- $DAEMON_OPTS

รัน

/etc/init.d/darkice start

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

4. การกำหนดให้ DaskICE ทำงานหลังจาก RUN ICECAST2

nano /etc/init.d/icecast2

ปรับให้ได้ดังนี้

#! /bin/sh

#

# icecast2

#

# Written by Miquel van Smoorenburg .

# Modified for Debian

# by Ian Murdock .

#

# Further modified by Keegan Quinn

# for use with Icecast 2

#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/usr/bin/icecast2

NAME=icecast2

DESC=icecast2

test -x $DAEMON || exit 0

# Defaults

CONFIGFILE="/etc/icecast2/icecast.xml"

CONFIGDEFAULTFILE="/etc/default/icecast2"

USERID=icecast2

GROUPID=icecast

ENABLE="false"

# Reads config file (will override defaults above)

[ -r "$CONFIGDEFAULTFILE" ] && . $CONFIGDEFAULTFILE

if [ "$ENABLE" != "true" ]; then

echo "$NAME daemon disabled - read $CONFIGDEFAULTFILE."

exit 0

fi

set -e

case "$1" in

start)

echo -n "Starting $DESC: "

start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \

--exec $DAEMON -- -b -c $CONFIGFILE

sleep 3

start-stop-daemon --start --quiet -m --pidfile /var/run/darkice.pid --background --exec /usr/bin/darkice

echo "$NAME."

;;

stop)

echo -n "Stopping $DESC: "

start-stop-daemon --stop --quiet --pidfile /var/run/darkice.pid --exec /usr/bin/darkice

start-stop-daemon --stop --oknodo --quiet --exec $DAEMON

echo "$NAME."

;;

reload|force-reload)

echo "Reloading $DESC configuration files."

start-stop-daemon --stop --quiet --pidfile /var/run/darkice.pid --exec /usr/bin/darkice

start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON

sleep 3

start-stop-daemon --start --quiet -m --pidfile /var/run/darkice.pid --background --exec /usr/bin/darkice

restart)

echo -n "Restarting $DESC: "

start-stop-daemon --stop --quiet --pidfile /var/run/darkice.pid --exec /usr/bin/darkice

start-stop-daemon --stop --oknodo --quiet --exec $DAEMON

sleep 3

start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \

--exec $DAEMON -- -b -c $CONFIGFILE

sleep 3

start-stop-daemon --start --quiet -m --pidfile /var/run/darkice.pid --background --exec /usr/bin/darkice

echo "$NAME."

;;

*)

echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2

exit 1

;;

esac

ทดสอบเข้า windows media player แล้วเปิด http://YOU_IP_HERE:8000/live    ตามรูป

ที่มา : http://attasit.ptl.ac.th/Jml/index.php?option=com_content&view=article&id=40:-radio-online-ubuntu-server&catid=10:2010-02-11-15-46-39&Itemid=22