Creating Zip Without Recording ROOT Paths

Hits: 3986  

Simply use chdir() to change the working directory before you exec()

Or you can use ….

exec(“cd /var/www/html/media; zip -r -9 . 2>&1”, $log);

exec(“mv /var/www/html/media/ /var/www/html/”);

Get zip file size

exec(“ls -ls /var/www/html/ | awk ‘{print $6}’ 2>&1”, $size);

$zipsize = implode(” “, $size);

Without this solution

Length Date Time Name
——– —- —- —-
0 03-08-13 15:10 /var/www/html/media/dialogs/
125305 08-07-12 16:31 /var/www/html/media/dialogs/1.3.mp3
125305 08-07-12 16:33 /var/www/html/media/dialogs/1.5.mp3
184864 08-07-12 16:32 /var/www/html/media/dialogs/1.4.mp3
125305 08-07-12 16:30 /var/www/html/media/dialogs/1.1.mp3
125305 02-24-13 16:48 /var/www/html/media/dialogs/1.2.mp3
125305 08-07-12 16:34 /var/www/html/media/dialogs/1.6.mp3

With this solution

Length Date Time Name
——– —- —- —-
0 03-08-13 16:40 dialogs/
125305 08-07-12 16:51 dialogs/1.3.mp3
125305 08-07-12 16:53 dialogs/1.5.mp3
184864 08-07-12 16:52 dialogs/1.4.mp3
125305 08-07-12 16:50 dialogs/1.1.mp3
125305 02-24-13 16:58 dialogs/1.2.mp3
125305 08-07-12 17:04 dialogs/1.6.mp3

PHP Run Background Process using Exec

Hits: 8832  

If you need to start process in background and get its PID to manage it later using PHP.


function runInBackground($command,$log,$priority=0)
   $PID=shell_exec("nohup nice -n $priority $command > $log 2>&1 & echo $!");
   $PID=shell_exec("nohup $command > $log 2>&1 & echo $!");

PHP Process
PHP Process

echo $! will return process ID
# Command & echo $!


Check if process is running


function isProcessRunning($PID)

if($PID==0)return false;
if($PID=="")return false;

exec("ps -p $PID 2>&1",$state);




Display Process Logs


function displayProcessLog($logfile)

exec('cat $logfile 2>&1',$log);
return implode("\r\n",$log);




Kill Process


function killProcess($PID)
 exec('kill '.$PID.' 2>&1',$status);
 return implode("\r\n",$status);



Save Process ID to file

Command &
echo $! >/path/to/pid.file

Install Streaming Audio Server With Icecast 2.3.3

Hits: 10653  

I need to install streaming audio server with Icecast (OGG/MP3) for one of my great client in service of Icecast was designed to stream any audio file using ices and icegenerator for MP3 and OGG/Vorbis audio files.

HTML5 MP3 Player with Playlist
HTML5 MP3 Player with Playlist

I already did lot of work using Shoutcast, SAMCast and SAM Broadcaster, Its very easy to use audio casting server online.

Today we will try to install Icecast 2.3.3 on CentOS x86_64 Server…

icecast is free server software for streaming multimedia.
icecast is free server software for streaming multimedia.

Setup Icecast Server

Download source and rpm needed

# yum groupinstall “Development Tools”
# yum install -y curl-devel libtheora-devel libvorbis-devel libxslt-devel speex-devel libxslt
# rpm –import
# cd /home
# wget
# mkdir -p /usr/src/icecast
# cd /usr/src/icecast
# wget

Unzip Icecast source

# tar xf icecast-2.3.3.tar.gz
# cd icecast-2.3.3

Configure, Compile and Install

# ./configure –prefix=/opt/icecast/2.3.3
# make
# make install

You might find icecast binary .. please confirm 😉

# ls /opt/icecast/2.3.3/bin/

Configure icecast with icecast.xml
# cd /opt/icecast/2.3.3/etc
# vi icecast.xml

Find more help here to setup xml file

Create icecast user & group

# groupadd -g 200 icecast
# useradd -d /var/log/icecast -m -g icecast -s /bin/bash -u 200 icecast

Before start icecast server check permission and make log folder
# mkdir -p /var/run/icecast
# chown -R icecast:icecast /var/run/icecast

Start the icecast server

# /opt/icecast/2.3.3/bin/icecast -c /opt/icecast/2.3.3/etc/icecast.xml -b   (background)

You will find Icecast server running here

Icegenerator – MP3 streaming client

Compile libshout and lib3lib (ID3 support), run ldconfig

# cd /usr/src/icecast
# wget

# tar xf libshout-2.3.1.tar.gz
# cd libshout-2.3.1

# ./configure –prefix=/opt/icecast/2.3.3
# make
# make install

Install icegenerator

# cd /usr/src/icecast
# wget
# tar xfz icegenerator-0.5.5-pre2.tar.gz
# cd icegenerator-0.5.5-pre2

# ./configure
# make
# make install

Now configure icegenerator to create MP3 radio station

# vi /usr/local/etc/svnlabs

NAME=SVNLabs MixStreams

You can even use MP3 folder path


Create playlist file

# vi /usr/local/etc/svnlabs.m3u


Or try ….

# find /var/www/html/songs/ -name “*.mp3” > /var/www/html/svnlabs.m3u

Make sure you have setup all paths
# su – icecast -c “export LD_LIBRARY_PATH=/opt/icecast/2.3.3/lib:$LD_LIBRARY_PATH; /usr/local/bin/icegenerator -f /usr/local/etc/svnlabs”

Get more help from here for icegenerator variables


Start other radio station using Running Icecast Server

# /usr/local/bin/icegenerator -f /usr/local/etc/indie

Icecast Streaming Media Server
Icecast Streaming Media Server

Install Apache, PHP, MySQL on HP Cloud

Hits: 5583  

I am playing with all cloud services these days, so today we will try to setup Apache, PHP, MySQL on HP Cloud. HP Cloud is based on OpenStack Compute

Hope you already read our old article “Installing Apache, MySQL, PHP in CentOS 5.5 on Rackspace Cloud”?

In the HP Cloud Console Area you can manage

– Servers / Storage
– Floating IPs
– Images
– Key Pairs
– Security Groups
– Volumes

First you need to create Key Pairs and some rule in security default group…

Security Group Rules
Security Group Rules

HP Cloud Compute Overview

HP Cloud Object Storage Overview

You can start any type of server CentOS, Ubuntu using HP Cloud GUI …

Server on HP Cloud
Server on HP Cloud

Also you can manage running instances easily…

Manager Server on HP Cloud
Manager Server on HP Cloud

You can connect to server using SSH on port 22

# ssh -i KEYPair.pem root@IP-Address

In windows.. create PPK file from PEM Keypair using PuTTYgen

Install Apache

# sudo yum install httpd mod_ssl

Install MySQL

# yum install mysql mysql-server
# /etc/init.d/mysqld start

Install PHP

# yum install php php-common php-gd php-mcrypt php-pear php-pecl-memcache php-mhash php-mysql php-xml php-mbstring

# /etc/init.d/httpd start

You can access HP Cloud using HP Cloud Services APIs and HP Cloud Services CLI

FFmpeg – ERROR: librtmp not found

Hits: 8532  

I was installing FFmpeg for segmenting Red5 Streams to stream live video from Red5 Server to iOS or Android devices.

RTMP (Red5) -> FFMpeg -> Segementer -> .ts files -> iOS (m3u8)

I really needed mp4 (AAC/H.264) and ogg (Vorbis/Theora) format for best HTML5 output.

I checkout FFmpeg source and tryed below command to install / configure it

# ./configure –enable-gpl –enable-nonfree –enable-libmp3lame –enable-libfaac –enable-librtmp –enable-libtheora –enable-libvorbis –enable-libx264 –enable-shared –enable-postproc

error while loading shared libraries:

I have already installed all dependencies, but links to shared libraries was not found … so …

# echo “/usr/local/lib” >> /etc/
# echo “/usr/lib” >> /etc/
# ldconfig

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.

Another error ERROR: librtmp not found

# ls /usr/local/lib/librtmp*

/usr/local/lib/librtmp.a /usr/local/lib/

On CenOS before compiling ffmpeg, make sure you have valid path of packages in PKG_CONFIG_PATH

# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

We worked on RTMP (Live Red5 CAM) to iOS (iPhone or iPad). Get more help for HTTP Live Video Stream Segmenter and Distributor Contact Us

Read more…. VOD to iOS | Red5 Media Server iOS Android Setup

Upload Large Files from Amazon S3 Bucket to Dropbox Folder

Hits: 6912  

Dropbox Uploader is a BASH script (only needs cURL) which can be used to upload, download, list or delete files from Dropbox, an online file sharing, synchronization and backup service.


Amazon S3 to Dropbox
Amazon S3 to Dropbox

Secure:It’s not required to provide your username/password to this script, because it uses the official Dropbox API for authentication process.


# chmod +x
# ./

It will ask “App key”, “App secret” and “Access level (App folder or Full Dropbox)”

As shell script authorize token…

Please visit this URL from your Browser, and allow Dropbox Uploader
to access your DropBox account:


Dropbox token for Command Line
Dropbox token for Command Line

If everything go well …

> Access Token request… OK

Setup completed!

Now you can download Amazon S3 Bucket files on server using “wget” then you can run command like…

# ./ upload /var/www/aws/s3/svnlabs.mp4 /DROPBOX-FOLDER/svnlabs.mp4

I have uploaded media file upto 500MB on dropbox successfully using this shell script 😉

Alternate Options:

You can try Node.js for reading files from Amazon S3 and then upload to Dropbox

Useful JavaScript Tools—Amazon-S3

Build your business on Google Cloud Platform

Hits: 5296  

Hope you already read my old article “Application Setup on Google App Engine”

Google Cloud Platform allows to build applications and websites, store and analyze data on Google’s infrastructure.

Google Cloud Platform
Google Cloud Platform

Features of Google Cloud Platform

* Scale your app – Take advantage of the speed and scale of Google’s applications.

* Focus on building – Deal with capacity planning and data center infrastructure.

* Save on costs – Pay only for what used.

* Fast Data Access – Quick and easy access to data around multiple regions.

* Reliable & Secure infrastructure – Google provides highly available, robust storage for your mission-critical data.

* Unlimited Storage – Store and manage unlimited number of objects within Application.

* Fully managed – Google will take care of replication, patch management or database management.

Solutions on Google Cloud Platform

Google App Engine
Google Cloud Storage
Google BigQuery
Google Cloud SQL
Google Compute Engine
Google Prediction API
Google Translation API

Google Cloud Platform
Google Cloud Platform

Over 1M applications run on Google Cloud Platform

Build Apps and Websites – Build apps and websites on Google’s infrastructure with Google App Engine.

Compute at Google Scale – Run Linux Virtual Machines in the cloud using Google Compute Engine.

Store your Data – Store and manage data on Google’s infrastructure with Google Cloud Storage.

Analyze Big Data – Analyze Big Data at astonishing speed using Google BigQuery.

Mobile Apps using Google App Engine

Google App Engine provide friction-less development environment to makes scale-able mobile back-end on Google’s infrastructure with less worries.

It goes live fast, scale infinitely and get started easily…

Business on Google Cloud Platform

Business on Google Cloud Platform
Business on Google Cloud Platform

You can download SDK to start building your app on Google App Engine.

If you are interested for creating Applications on Google Cloud Platform … Please Contact us

Email: svnlabs[at]
Skype: svnlabs
MSN: svnlabs[at]

Audio Video Formats

Hits: 3291  

You might have problem understanding audio video formats. All formats vary from size and quality.

Audio Formats

WAV This is a uncompressed format used for CD quality audio.

MP3 This is compressed format, it remove some frequency to optimize music files.

WMA This format is developed by Microsoft used for DRM (copy protection) facility.

AAC Advanced Audio Coding (AAC) is a standardized, lossy compression and encoding scheme for digital audio. Designed to be the successor of the MP3 format, AAC generally achieves better sound quality than MP3 at similar bit rates.

FLAC FLAC ( Free Lossless Audio Codec) is a codec (compressor-decompressor or coder-decoder) which allows digital audio to be losslessly compressed such that file size is reduced without any information being lost.

OGG This is better audio format as compared to MP3. This format is ideal for audio streaming.

AMR This format is used in mobile devices for recording audio files.

AIFF This is developed by Apple. This is loss-less and uncompressed format.

RI/RM This is good for audio streaming on internet.

RAW This is uncompressed format used in testing devices.

Audio Video Formats
Audio Video Formats

Video Formats

FLV Flash Video is a container file format used to deliver video over the Internet using Adobe Flash Player. Flash Video content may also be embedded within SWF files.

MP4 MPEG-4 is a multimedia container format standard specified as a part of MPEG-4. It is most commonly used to store digital video and digital audio streams. Very good for video streaming in iOS devices.

DIVX (AVI) DivX Codec became popular due to its ability to compress lengthy video segments into small sizes while maintaining relatively high visual quality.

MPEG The Moving Picture Experts Group (MPEG) is a working group of experts for audio and video compression and transmission.

WMV Windows Media Video (WMV) is a video compression format for several proprietary codecs developed by Microsoft.

MKV/M2TS It is used to compress HD video files. It support multi channel audio.

VOB VOB (Video Object) is the container format in DVD-Video media. VOB can contain digital video, digital audio, subtitles, DVD menus and navigation contents multiplexed together into a stream form. Files in VOB format may be encrypted.

RM/RMVB It is used for high compression video streaming.

MOV QuickTime File Format (QTFF) is a computer file format used natively by the QuickTime framework.

3GP 3GP (3GPP file format) is a multimedia container format defined by the Third Generation Partnership Project (3GPP) for 3G multimedia services. It is used on 3G mobile phones but can also be played on some 2G and 4G phones.

Comparison of container formats

Recover MySQL root Password

Hits: 3058  

1. Stop the MySQL server.

# /etc/init.d/mysql stop

2. Start the MySQL server process with the –skip-grant-tables option so that it will not prompt for password.

# mysqld_safe –skip-grant-tables &

3. Connect to mysql server as the root.

# mysql -u root

mysql password
mysql password

Welcome to the MySQL monitor….
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

4. Setup new mysql root account password i.e. reset mysql password.

mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

5. Exit and restart the MySQL server.

# /etc/init.d/mysql stop

6. Start MySQL server.

# /etc/init.d/mysql start
# mysql -u root -p



Make New Application in Red5

Hits: 3949  

1. Make a new directory “svnlabs” under the webapps directory, it will be name of the application “svnlabs”.

Red5 New Apps
Red5 New Apps

2. Create a sub-directory called WEB-INF

– red5-web.xml
– web.xml

webapp.virtualHosts=*, localhost, localhost:8088,

Download “svnlabs” Red5 App here…

3. Restart Red5 Server