Overview: This article describes how to create MP3 broadcasts with open source tools ICAST and ICES under Linux.
principle:
Icecast is an Internet broadcast system based on MPEG III technology, which has the following features compared to commercial software such as Shoutcast:
Icecast is a pure OpenSource software; do not need to run your own directory server; take up less system resources;
We can run your own stream server on the server - ICAST, use ICES to provide a stream source, and the client can use the most common WINAMP.
Test environment:
Server platform: Redhat 7.0
Streaming server: Icecast
Flow source: ICES
MP3 encoding tool: Lame
step:
1. Get relevant software
Flow server Icecast: http://www.icecast.org/releases/icecast 1.3.10-1.i386.rpm
Blow Source Tool Ices: http://www.icecast.org/releases/ices-0.0.1.beta5.tar.gz
Encoding Tool Lame: http://home.elka.pw.edu.pl/game/lame-3.87beta-1.i386.rpm
Lame Library: http://home.elka.pw.edu.pl/game/lame-devel-3.87beta-1.i386.rpm
Description:
A. You can usually use Liveice, Shout and other software to provide streams (ie, as a stream source), but I found ICES to stabilize in the process of use, although it is a beta version.
B. Usually your MP3 files cannot have the same property. At this time, there will be some strange phenomena, such as the sound intermittent, noise, etc., so we must use the MP3 encoding tool Lame to re-encode it to generate properties. Consistent MP3 file.
2. Install Icecase
Install Icecast using the following command:
RPM-Icecast-1.3.10-1.i386.rpm
3. Install ICES
Install ICES using the following command:
# TAR XVZF ICES-0.0.1.beta5.tar.gz
Will generate ICES-0.0.1.beta5 directories in the current directory, use the CD command to enter this directory
# CD ICES-0.0.1.beta5
Then execute:
# ./Configure
# Make
# Make install
Compiled with the default file installed in / usr / local / ity discast directory
4. Install Lame
Perform the following command to install the Lame MP3 encoding tool, which is used to re-encode the MP3 file to generate an MP3 file that is consistent with the properties.
RPM-IVH LAME-3.87BETA-1.I386.RPM
RPM-IVH LAME-DEVEL-3.87BETA-1.I386.rpm
5. Configuring Icecast
The main configuration file of Icecast is /etc/icecast.conf, there are many configuration options, but most of them can be used, some options mean the following:
Port: Defines the port of the Icecast service bound, only one, usually use 8000 ports.
Encoder_password: The password when the stream connection is connected to the ICECAST, and ICES must provide this password for security considerations. It can set a more complex password. Admin_password: You can use the Telnet to log in to Icecast for remote management. This password is the password that must be entered when logging in to IceCast.
Oper_password: The password when logging in to ICECAST when logging in to Icecast.
MAX_CLIENTS: The maximum number of customers who allowed to connect to the stream server in the same time.
Max_sources: Allows the maximum number of streams of the simultaneous broadcast, streaming and streaming server can be located on a different machine, and multiple streaming can be transmitted to the same stream server for broadcast.
MAX_ADMINS: You can log in to ICAST simultaneously for remote management connections.
Logfile: Set the location of the log file.
Hostname: Sets the IP address binding ICAST, default is bound to all IP addresses.
Server_name: Specifies the hostname of the Icecast server or an IP address.
Client_timeout: Setting When there is no stream, the server disconnects the timeout of the connected customer.
Stats_log: Sets the log file that records Icecast statistics.
Stats_time: Sets the update period of the stats_log log file.
MAX_CLIENTS_PER_SOURCE: Set the maximum number of customers that can be connected to the same source.
Reverse_lookups: Set whether to reverse DNS resolution on the reverse DNS parsing can be connected, the reverse DNS resolution is enabled at 1.
Location: Sets the location of the Icecast server and is not important.
RP_EMAIL: Sets the email address of the Icecast server administrator.
The bandwidth valve value that the Icecast server can use, if this threshold is reached, the new customer connection will be rejected, and the unit is megabytes / second.
LogfileDebuglevel: Define the information of the information of the log.
Server_URL: Defines the RUL of the Icecast server
Here is my profile, for reference only:
# itycast.conf
Location YUXI Yunnan China
RP_EMAIL BYE2000@yxtc.edu.cn
Server_URL http://www.yxtc.edu.cn/
MAX_CLIENTS 900
MAX_CLIENTS_PER_SOURCE 900
Max_sources 10
MAX_ADMINS 5
THROTTLE 10.0
Mount_fallback 1
ENCODER_PASSWORD SECRET
Admin_password Secret
Oper_password secret
Port 8000
Force_ServerName 0
Logfile Icecast.log
AccessFile Access.log
USAGEFILE USAGE.LOG
LogfileDebuglevel 0
Consoledebuglevel 0
REVERSE_LOOKUPS 0
Console_mode 0
Client_timeout 30
Kick_Clients 0
StaticDir / usr / share / icecast / static
Templatedir / usr / share / Icecast / Templates
LogDir / var / log / icecast
Stats_log stats.log
STATSHTML_LOG Stats.html
Stats_time 60kick_relays 10
TRANSPARENT_PROXY 0
ACL_POLICY 1
6. Start ICAST service
Perform the following script to start the Icecast service:
# /Etc/rc.d/init.d/icecast start
7. Recode all MP3 files
The MP3 file is re-encoded with Lame to generate an MP3 file that is consistent with the attribute.
This is used to use the following parameters of the lame command:
- MP3Input: Enter a file for mp3 file
-m S: Specify all frames to stereo
-b 56: Specify the baud rate of the newly generated MP3 file, here is specified as 56 Kbps, and the unit is kbps
--Resample 24: Specify the sampling frequency of the newly generated MP3 file, specified as 24 kHz, unit is kHz
Here is an example of a LAME:
Lame - MP3INPUT -M S -B 56 --Resample 24 Old.mp3 new.mp3
8. Generate playlist
You can generate playlists with the following file:
# Find / -name '* .mp3'> Play_List_File
Change the play_list_file to your playlist file name.
The following is an example of a playlist file:
#Play_list example
/DATA/MP3/Powerstation/Byemylove/1.mp3
/DATA/MP3/Powerstation/Byemylove/10.mp3
/Data/mp3/powerstation/byemylove/11.mp3
/DATA/MP3/Powerstation/Byemylove/2.mp3
/DATA/MP3/Powerstation/byemylove/3.mp3
/DATA/MP3/Powerstation/byemylove/4.mp3
/DATA/MP3/Powerstation/Byemylove/5.mp3
/Data/mp3/powerstation/byemylove/6.mp3
It can be seen that as long as the full path and the file name of the MP3 file are included.
9. Release stream
ICES can use XML-based configuration files, you can also use commands with options. Here we use the latter, common command options are:
-B: Specify ICES to run in a background program
-b: The baud rate specified
-d: convection description
-n: Set the name of the broadcast station
-g: Broadcast music type
-H: Flow server IP address
-p: Flow server listener port
-P: Password of the connection stream server
-r: Set random play songs
-S: Specify the type of playlist, usually use Builtin
-U: Specifies the URL of the stream server
-F: Specify playlist file
My example:
/ usr / local / icecast / bin / ib / ICAS -B -B 56 -D MUSIC
-N "Tom Radio" -g Music -h localhost
-P 8000 -P SECRUE -R -S Builtin -u
http://www.yxtc.edu.cn -f / etc / cecast / list
10. Receive broadcast
You can use the following ways to allow users to receive broadcasts:
Build a file extension M3U, such as my file is Tom.m3u, which contains the following:
http://www.yxtc.edu.cn:8000/
Then establish the hyperlink of the file on the home page, so that once the customer will click on the connection, you will start Winamp, RealPlay and other MP3 players to receive broadcast. It is recommended to use WINAMP to receive broadcast.
Ok, I'm taking it, sit down and soak the cup of coffee and slowly appreciate your MP3 broadcast.
11. Supplementary description:
I wrote a Perl script that automatically searches all the MP3 files in the system, and then converts non-56K baud rates and 24kHz sampling frequency MP3 files to 56K baud rates and 24kHz sampling frequency MP3 files, completed Automatically generate playlists after conversion.
Instructions:
./LIST_GEN LIST_FILE
You must build this list file with the touch command first.
This script requires your system to install the LAME tool.
The script source code is as follows, you can also download from here:
#! / usr / bin / perl
`RM -F / TMP / TEMP.MP3`;
IF ($ argv [0]) {
Print "usage: ./list_gen list_file_name";
Print "You Must Create The File First!";
exit (0);
}
$ FILES = `Find / -Name '* .mp3'`;
@file = split (/ /, $ files);
$ Num = @file;
For ($ I = 0; $ I <= $ NUM-1; $ I ) {
$ file_info = `file $ file [$ i]`;
IF ($ file_info = ~ / mp3 /) {
@ file_type = split (/ s /, $ file_info);
IF ($ file_type [2] = ~ / 56 /) {
} else {
`Lame - MP3INPUT -M S -B 56 --Resample 24 $ FILE [$ I] / TMP / TEMP.MP3`;
`mv -f /tmp/temp.mp3 $ file [$ 1]`;
}
Push (@List, "$ file [$ I]");
}
}
IF (-e $ argv [0]) {
$ Num = @List;
Open (List, "> $ argv [0]");
For ($ I = 0; $ I <= $ NUM; $ I ) {
Print List "$ list [$ I]";
}
Close (List);
Print "Play List Create OK, Good Luck !!!";
} else {
Print "I can't find file you specified!";
Print "You Must Create Play List File First!";
}