無語録むごろく

ムゴロク

Media Streaming -- Icecast 2 and MPD-SVN

註:寫這篇文章可能有點長,不過中間有很多地方日後可能會修改,所以這個是未完成的哦~!要是當成參考也是可以的,請給多一點耐心看一下。

某天忽發奇想,要是帶這麼多歌回公司,不如自已建一台 media streaming server ,那只要上網就可以聽到自已想聽的歌曲了。
(雖然好像非常浪費電力......我家那台舊機器辛苦了)

好,返回正題,我們先從 streaming server 入手,我選擇了 icecast2 ,原因無他,因為在 Linux 下選擇好像不多。

首先,想辨法安裝好 icecast 2 ,這個取決於你們用什麼 distro ,我這裏是 Gentoo ,其他看倌們自已想辦法好了。

之後就來到 Configuration 的階段︰

<icecast>
    <limits>
        <clients>100</clients>
        <sources>2</sources>
        <threadpool>5</threadpool>
        <queue-size>102400</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>65535</burst-size>
    </limits>

    <authentication>
        
        <source-password>hackme</source-password>
        
        <relay-password>hackme</relay-password>

        
        <admin-user>admin</admin-user>
        <admin-password>hackme</admin-password>
    </authentication>

    
    

    
    <hostname>127.0.0.1</hostname>

    
    
    

    
    <listen-socket>
        <port>8000</port>
        
<bind-address>127.0.0.1</bind-address>
    </listen-socket>
    <listen-socket>
    <port>8001</port>
<bind-address>192.168.11.8</bind-address>
    </listen-socket>
    

    
    
    
    
    

    

    <fileserve>1</fileserve>

    <paths>

        <basedir>/usr/share/icecast</basedir>

        
        <logdir>/var/log/icecast</logdir>
        <webroot>/usr/share/icecast/web</webroot>
        <adminroot>/usr/share/icecast/admin</adminroot>
        

        
        
        
        <alias source="/" dest="/status.xsl"/>
    </paths>

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
      <loglevel>4</loglevel> 
    </logging>

    <security>
        <chroot>0</chroot>
        
    </security>
</icecast>

以上是我個人的 Setting ,當然每個人的設定都不盡相同,我這裏是作參考的,有什麼問題可以自已到 icecast 的網頁自已慢慢研究,網址如下︰

Icecast Official Site

相搞好了 media streaming server ,那我們可以想一想用什麼來做 source client 。
當然,我們可以把曲目放到 icecast 的 base dir 中 ,寫好 playlist 就可以播。但我不喜歡把所有的曲歌曲都轉為 Ogg 格式,所以把可試的都試過後,選擇了 MPD。

MPD 是什麼可以看一下以下網址︰

MPD Official Site

當然我們要先安裝好,之後又是 Configuration ︰

# MPD CONFIG FILE
# For a full description of all config parameters,
# Check the mpd man page, "man mpd".

##################### REQUIRED ###########################
port "6600"
#music_directory "/var/lib/mpd/music"
music_directory "/home/steven/.xchat2/downloads/Songs/Singular_Songs"
playlist_directory "/var/lib/mpd/playlists"
#playlist_directory "/home/steven/.xchat2/downloads/Songs/playlists"
log_file "/var/log/mpd.log"
error_file "/var/log/mpd.error.log"
pid_file "/var/log/mpd.pid"
##########################################################

##########################################################
# EVERYTHING ELSE IS OPTIONAL
##########################################################

################# FILESYSTEM SETTINGS ####################
#
# If the names of files or directories are 
# not correctly displayed then set the 
# following to the filesystem coding. 
#
#Usually this is either:
#ISO-8859-1 or UTF-8
#
# After changing the filesystem_charset
# you will need to recreate the db:
#mpd --create-db
#
filesystem_charset "UTF-8"
#
##########################################################

#################### OPTIONAL FILES ######################
#
# Location of DB file 
#
db_file"~/.mpd/mpd.db"
#
# The state file (if set) will be a file
# for storing all current information 
# (playlist, playing/paused, etc...) from
# the last MPD session. This will be used
# to recreate your last MPD session after
# restart.
#
state_file "/var/lib/mpd/state"
#
##########################################################


################### VOLUME MIXER #########################
#
# Examples:
# ALSA Mixer 
mixer_type"alsa"
mixer_device"default"
mixer_control"PCM"
#
# OSS Mixer
#mixer_type"oss"
#mixer_device "/dev/mixer"
#mixer_control"PCM"
#
# Software Mixer
#mixer_type"software"
#
##########################################################


################## AUDIO OUTPUT ##########################
#
# OSS Audio Output
#ao_driver "oss"
#ao_driver_options "dsp=/dev/dsp"
#
# ALSA Audio Output
#ao_driver"alsa09"
#ao_driver_options"dev=hw:0,0"
#
# Set this if you have problems 
# playing audio files.
# This will resample your music so
# that it comes out at the set rate. 
#
audio_output_format"44100:16:2"
#
# You should not need mess with 
# this value unless you know 
# what you're doing.
#
#audio_write_size"1024"
#
##########################################################

################# REPLAYGAIN #############################
#
# Use Replay Gain (album or title)
#http://www.replaygain.org
#
#replaygain"album"
#
# Sets the pre-amp used for files that have replaygain
# info.  Valid values are between -15 to 15 (in dB).
#
#replaygain_preamp"0"
#
##########################################################


################ OUTPUT BUFFER SETTINGS ##################
#
# You should not need to mess with this
# unless you know what you're doing.
#
#audio_buffer_size"2048"
#
# This means exactly what it says, it will
# buffer your file up to the percentage of
# the buffer before it begins playing.
#
buffer_before_play "25%"
#
##########################################################


################### HTTP PROXY ###########################
#
# http_proxy_host"proxy.isp.com"
# http_proxy_port"8080"
# http_proxy_user"user"
# http_proxy_password"password"
#
##########################################################


################# SECURITY SETTINGS ######################
#
# It is encouraged to run MPD as 
# non-superuser.  If you start mpd as root
# (for example, in an init script), set
# this value, then  mpd will drop root priveleges
# and runs as the user specified.
#
#user "mpd"
user "steven"
#
# Set this value if you only have one 
# address you want to allow connection to. 
#
#bind_to_address "192.168.11.8"
bind_to_address "127.0.0.1"
#
# If you want to setup MPD to use 
# passwords set them here
#
#password "password1@read,add,control,admin"
#password "password2@read"
#
# Specify permissions used by default when no password is 
# given by for a connection/client.
#
#default_permissions"read,add,control,admin"
#
##########################################


################ MISCELLANEOUS OPTIONS ###################
#
# This setting exists as precaution against attacks.
#
#max_playlist_length "16384"
#
# Valid options are "default", "secure" or "verbose".
#log_level"default"
#
#connection_timeout "60"
#
# This should be fine for 2-3 people using clients 
# at the same time.
#
#max_connections "5"
#
# No need to change these unless you know better.
#
#max_command_list_size "2048"
#max_output_buffer_size "2048"
#
# This will make playlists compatible with normal music
# players.
#
#save_absolute_paths_in_playlists "no"
#
##########################################################

################# SHOUT STREAMING ########################
#
# Set this to allow mpd to stream its output to icecast2
# (i.e. mpd is a icecast2 source)
#
audio_output {
        type              "shout"
name              "mpd-svn stream"
host              "192.168.11.8"
port              "8001"
mount             "/live.ogg"
password          "hackme"
quality           "5.0"   
#       bitrate           "64"
format            "44100:16:1"

# Optional Paramters
user              "source"
#       description     "here's my long description"
#       genre           "jazz"
} # end of audio_output
###########################################################

當設定好後,便可以用 init script 把這個 service 啓動︰

/etc/init.d/mpd start

之後就是 MPD 的 front-end ,我選用了 MPC 因為可以在 shell 中控制,不用 GUI ,對我來說就可以 remote control 了。

安裝好 MPD 後,

請啓動以下 commands ︰

mpc update
mpc ls | mpc add
mpc play

好了,到了這個地步,所有的東西都準備好,只要用可以聽 stream 的 players ,就可以在任何一台可以上網的電腦上收聽了。

看起來很簡單吧,看倌們可以自已一試~!

選擇Nvidia Display problems

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.

February 2012
S M T W T F S
January 2012March 2012
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29