冷凍庫

個人用メモ

ubuntu で icecast サーバを立てる

  1. icecast2 と ezstream をインストールする
    • sudo apt-get install icecast2 ezstream
      • icecast2 のインストールで管理パスワードの設定が始まるので適当にやる
    • icecast のデーモンが立ち上がるところまでやられるので localhost:8000 を適当に確認してみる
  2. 適当な mp3 とプレイリストを用意する
  3. ezstream の設定ファイルを用意する
    • # 以降があると死ぬ気がするので実際には削除する
    • url は、 nginx でプロキシしてるからといって 80 とかにすると login failed とか言われたりするので、実際にアクセスする URL がどうであれとりあえず localhost:<icecast_port> にしておくのが安定な気がする
<ezstream>
<url>http://localhost:8000/stream1</url> #your streaming server’s http://ip-or-host:port/stream1
<sourcepassword>hackme</sourcepassword> #refer to your icecast.xml’s <source-password>
<format>MP3</format>
<filename>/path/to/playlist.m3u</filename>#this still needs to be created
<stream_once>0</stream_once>#when file from <filename> is done being streamed, repeat.
<metadata_format>@s@</metadata_format># artist - title ..
<svrinfoname>Streamy Stream Stream</svrinfoname>
<svrinfourl>http://www.openserverproject.com</svrinfourl>
<svrinfogenre>Cantopop</svrinfogenre>
<svrinfodescription>These sections are for YP listing information only</svrinfodescription>
<svrinfobitrate>128</svrinfobitrate>
<svrinfochannels>2</svrinfochannels>
<svrinfosamplerate>44100</svrinfosamplerate>
<svrinfopublic>0</svrinfopublic>
</ezstream>
  1. ezstream を起動する
    • ezstream -c stream1.xml &
  2. 聞く
    • icecast の管理ページを見ると新たにリストされてる
      • この場合、 example.com:8000/stream1.m3u とかいう URL で聞けるようになる
      • つまり、 mount point が stream1 ということっぽい
  3. ついでに、 nginx で ic. を 8000 にプロキシするようにしたりする

Source Client

Icecast は、それ単体ではプレイリストを読む、音を生成するといった機能はなく、そのために Source Client が 必要になる。 上記の例では、 ezstream を source client として使ってる。

liquidsoap が管理しやすくて良さそう

liquidsoap

  1. インストールする
    • apt-get install liquidsoap
  2. 設定ファイルを設置する
    • 以下のように書いたファイルを、 /etc/liquidsoap/stream2.liq として保存する
output.icecast (%mp3,
  host = "localhost", port = 8000,
  password = "hackme", mount = "stream2",
  mksafe(playlist("/path/to/playlist.m3u")))
  1. サービスを開始する
    • service liquidsoap start

日本語

  • したいこと
    • タイトルとかを日本語で出したい
  • status
    • できてない
      • ezstream が日本語対応してない感じある?
    • できた
      • liquidsoap 使う
  • したこと
    • タグを UTF-8 に治す
      • apt-get install python-mutagen && find . -name '*.mp3' -print0 | xargs -0 mid3iconv --force-v1 -d -e shift_jis
    • icecast.xml に以下の設定を追記する
    <mount>
        <mount-name>/stream1</mount-name>
        <charset>UTF8</charset>
    </mount>

Mount Point 追加方法

  1. rsync -av analbum/ user@host:./analbum/ などとして曲を icecast を動かしてるサーバに転送する
  2. 必要であれば、 convmv -f sjis -t utf8 -r --notest * などとしてファイル名を utf-8 に変換する
  3. プレイリストを作成する
    • find $PWD -name '*.mp3' >analbum.m3u
  4. 必要であれば、上の方法にしたがってタグを UTF-8 に治す
  5. 上記のように /etc/liquidsoap/analbum.liq ファイルを作成し、 liquidsoap を再起動する
  6. 必要であれば、 icecast.xml でタグを utf8 で表示するように設定する
    • liquidsoap の out.icecast の引数に encoding があるのでこれでうまくできるかもしれないけど試してない
  7. ソースの数が、 icecast.xml で決まった数を超えてないことを確認する
  8. service liquidsoap restart する
    • icecast.xml の設定を変更した場合、 icecast2 もリスタートする

参考