Setting up Mp3 Streaming Server (Icecast) on VPS (port 80)

Step 1: Download RPM from following url as per your VPS architecture (e.g. Centos 64bit)

http://pkgs.org/centos-6-rhel-6/centalt-x86_64/icecast-2.3.3-1.el6.x86_64.rpm.html

cd /opt
wget http://pkgs.org/centos-6-rhel-6/centalt-x86_64/icecast-2.3.3-1.el6.x86_64.rpm/download/

Step 2: Install it using yum

yum install icecast-2.3.3-1.el6.x86_64.rpm

Step 3: Set Config

vim /etc/icecast.xml

Change source password, relay password, admin password. Also set mount point to ‘/live

<authentication>
<!-- Sources log in with username 'source' -->
 <source-password>mynewpass</source-password>
<!-- Relays log in username 'relay' -->
 <relay-password>mynewpass</relay-password>
<!-- Admin logs in with the username given below -->
 <admin-user>admin</admin-user>
 <admin-password>mynewpass</admin-password>
 </authentication>
<listen-socket>
 <port>8000</port>
  <shoutcast-mount>/live</shoutcast-mount>
 </listen-socket>

And that’s it. It will start listening on port 8000, when you start service.

Optionally you can also have multiple mount points by adding following config.

<mount>
 <mount-name>/live</mount-name>
 <password>pass-live</password>
 <max-listeners>100</max-listeners>
<dump-file>/tmp/live.mp3</dump-file>
 <fallback-mount>/live-backup</fallback-mount>
 <fallback-override>1</fallback-override>
 <fallback-when-full>1</fallback-when-full>
</mount>

Step 4: Start service + Set for auto start on boot

service icecast start
chkconfig incecast on

Step 5: Run on Port 80

If you want to run it on port 80, due to firewall issue of listeners … you can manage it using mod_proxy module of apache.

For that, check your httpd.conf and see if mod_proxy module is not commented.

LoadModule proxy_module modules/mod_proxy.so

Next, go to your apache public_html, and in .htaccess write following rule.

# streaming on port 80 - icecast
RewriteRule ^live.mp3$ http://domain.com:8000/live [P,L]

This will enable streaming via http. You can now access http://domain.com/live.mp3 to connect to live broadcast.

Step 6: Setting Streaming Server

Icecast is supported many free streaming servers like VLC and Winamp. But i prefer Samcast due to simpler interface but it’s trial and shows popup at random time to buy.

Open Samcast.
Click of Settings link on top -> Capture sound form device
You can select ‘Sound Mapper’ to broadcast speaker out or ‘Mic’

Click Encoder -> Click +
Choose MP3 Lame encoder -> Click OK

On first tab ‘Converter’ select your desired bitrate to stream (16k) and mode (mono/stereo)

On second tab ‘Server details’, select ‘Server Type’ to IceCast
Server IP: your-domain.com

Server Port: 8000 (default)
Password: mynewpass (as set above in tutorial)
Mount: /live (as set in config)
Optionally set, station name, description and website options.

Click OK, and it will add new encoder.

Select newly added encoder and click ‘Play’ button.
If everything goes fine, it’s will update status as ‘Encoding’

Now on main Samcast window, click circle blue button ‘Start’ to start streaming.

Debugging: If you wish to see log, please check

# tail -f /var/log/icecast/error.log

Step 7: Setting up client

We can have desktop clients like winamp or vlc which work smooth. Just open file and give your streamer path.

In our case, it’s http://domain.com/live.mp3
You will hear the playback after little buffering.

If you wish to have web based player, visit following link
http://andy.ehandysoft.com/shoutcast-players.html

JWPlayer is also very stable and work for mp3 streaming. A

In both cases, all we have to do is to give file path:
http://domain.com/live.mp3

That’s It. Phew, long article.

Copying File (Server to Server) – wget.php

Here in Pakistan, For home users downloading/uploading speed is not comparable (very less) to the one we get on our LIVE hosting servers.
I had to install a PHP opensource solution LIVE, traditional process is that we download the archive on our PC from website, and then upload on our Server, which is definitely very much time consuming (downloading/uploading time) if your archive is 100MB+.

So, I wrote a little PHP script, which when executed on server, It will fetch the downloadable file content from source server and store locally on destination server (local). It is equivalent to the wget command we have in linux, if your hosting allow SSH access. If it is not like in my case … you can use wget.php wrapper. This can also be used to backup one server files to another.

Here is the sample code for file "wget.php"

<?php
error_reporting(E_ALL);
ini_set("display_errors","on");

$url = $_GET["url"];
$f = explode("/",$url);

$f = $f[count($f)-1];

function get_contents($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);

$data = curl_exec($ch);
curl_close($ch);
return $data;
}

$d = get_contents($url);
if (file_put_contents($f,$d))
echo $f ." downloaded";
else
echo "Failed";

Mysql Client for Ubuntu / Eclipse

Today, i found a nice Mysql client after migrating to Ubuntu. Previouly i was using Emma which was not so user friendly.

QuantumDB is a simple but powerful database access plug-in for the Eclipse Development Platform. QuantumDB allows you to:

  • connect to databases using standard JDBC drivers
  • review schemas, tables, views and sequences
  • look up column, index and foreign key information
  • issue ad-hoc queries or other SQL statements against the database
  • manage, edit, and work with SQL files (*.sql)
  • issue updates, deletes, and inserts using simple, easy-to-use wizards

QuantumDB works with any JDBC-complaint database, including:

  • Adabas
  • DB2
  • DB2 on AS400
  • HSQLDB
  • Informix
  • MySQL
  • Oracle
  • Pointbase
  • PostgreSQL
  • Sybase

The QuantumDB developers regularly use a wide variety of database products as they add new features to the plugin.

Point eclipse at : http://quantum.sourceforge.net/update-site

You will still have to download mysql java connector from here or download connector file here

[Image]

Updated 03 Oct, 2009:  It has very poor usability with eclipse version. I think the currently realeased version is not stable enough.

Enable “ll” command in ubuntu

This might be known to many *nix gurus, but it was new to me. Many systems come with the ll command that is a shortcut for ‘ls -al’.

To activate this in ubuntu, modify your ~/.bashrc file and uncomment the alias command settings

alias ll=’ls -l’

There are other options available. Now all you have to do is type ll and you get the equivalent of ‘ls-al’!

source: http://jimcortez.com/blog/?p=5