Icecast2 Intro
出自DebianWiki
目錄 |
[編輯] 基本原理
Client —→ Server (icecast2)
↑ ↓
└----------- Streamer (darkice) ←— Source
它的運作方式就如上,client 端一般都是 stream player (串流播放軟體),連接到 server 後,server 就像中介人一樣,它會幫你連接到 streamer 上,streamer 就會直接抓 source 送資料給 stream player 播放。
- Server: 其實不只 icecast/icecast2,但這裡主要是介紹 icecast2。
- Streamer: 同樣的也有很多選擇,用 google 查可以查到很多。
- Source: 可以是音效檔,也可以是 device 的輸入,例如: 音效卡。
- Source 的格式: source 是有格式的,每一種 server 用的格式都不盡相同,而 icecast/icecast2 用的是 ogg。
[編輯] 安裝
[編輯] Server 端
- Icecast2:
apt-get install icecast2
[編輯] Client 端
- Ices2: 這是另一套 steamer for Icecast2
apt-get install ices2
- darkice:
apt-get install darkice
[編輯] 設定方式
[編輯] Server 設定方式
- 這個部份 debian 會幫你設定好大部份的值,你如果需要自訂,請參閱: /usr/share/doc/icecast2 或者 Icecast
- 在 /etc/icecast2/ 底下會有兩個目錄 admin/ 和 web/ 裡頭多是 xsl 檔和 css 檔,這是用來設定網頁樣式的檔案,而 icecast.xml 就是組態檔啦!!
- 連進 server 後主要呈現的頁面在 /usr/share/icecas2 裡頭一樣有兩個目錄 admin/ 和 web/
- admin: 裡面有一些給管理員用的頁面。
- web: 這就是你連進去 server 後會呈現的頁面。
[編輯] Client 設定方式
- darkice:darkice 的組態檔可以放在任何地方,名稱為 "darkice.cfg"。而組態檔的詳細設定請 "man darkice.cfg"。這裡說明幾個較特別的地方
- bufferSecs: 這是指你從 source 讀進了 buffer 多少秒之後,就將 buffer 內的資料輸出給 encoder 轉檔。簡單講就是每隔幾秒輸出一次就對了。
- mountpoint: 這個和你的磁碟路徑無關,直接打個名稱就好了,請看底下的範例和圖示。
[編輯] 執行
- 因為 debian 的貼心,所以直接從 /etc/init.d 執行就行了
# /etc/init.d/icecast2 stop # /etc/init.d/icecast2 start (其實可以直接用 /etc/init.d/icast2 restart,但我在用時有時候沒啥用)
如果沒有錯誤訊息就可以直接連到 http://127.0.0.1:8000/,預設會看到狀態頁,你會發現什麼內容都沒有,這是正常的。
- 執行 darkice
# darkice -c /path/to/foo.xml (執行檔是可以放在任何地方的,所以要指定路徑)
這時再連到 http://127.0.0.1:8000/ 你就會發現你的 streamer 秀在頁面上啦!
- 注意! 一旦你結束掉 darkice 後,網頁上的資訊也會跟著被清掉,如果你要 darkice 永遠都不會結束,就修改設定檔裡的 duration 這個值,並將它設定為 '0' 就好了。
[編輯] darkice 設定檔範例
- 這個範例就是直接用麥克風講話,然後別人可以線上直接收聽你的妙語。
[general]
duration = 600 // 設定 darkice 執行 10 分鐘
bufferSecs = 5
[input]
device = /dev/dsp // 這是麥克風的 output
sampleRate = 22050
bitsPerSample = 16
channel = 2
[icecast2-0]
format = vorbis // 格式為 ogg
bitrateMode = cbr
bitrate = 96
quality = 0.8
server = 127.0.0.1 // 這只是名稱,可以自己隨便寫
port = 8000
password = hackme
mountPoint = live
name = DarkIce trial
description = This is only a trial
url = http://127.0.0.1/
genre = live
public = no
fileAddDate = no
[編輯] 相關資源
- Icecast.org - icecast 官方站包含 ices 的文件
- DarkIce - darkice 的官方站
![[Main Page]](/upload/4/49/Debian_taiwan_out.png)