Creating Zip Without Recording ROOT Paths


Hits: 4021  

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

Or you can use ….

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

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

Get zip file size

exec(“ls -ls /var/www/html/Media.zip | 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: 8880  

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

<?php

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

?>
PHP Process
PHP Process

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

 

Check if process is running

<?php

function isProcessRunning($PID)
{

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

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

}

?>

 

Display Process Logs

<?php

function displayProcessLog($logfile)
{

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

}

?>

 

Kill Process

<?php

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

?>

 

Save Process ID to file

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

Install Apache, PHP, MySQL on HP Cloud


Hits: 5615  

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: 8629  

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: libfaac.so.0:

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

# echo “/usr/local/lib” >> /etc/ld.so.conf
# echo “/usr/lib” >> /etc/ld.so.conf
# 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/librtmp.so

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

Recover MySQL root Password


Hits: 3085  

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.
mysql>

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

 

 

Install ImageMagick


Hits: 3226  

ImageMagick can be installed on Windows, Unix and Unix-like operating systems including Linux, Solaris, FreeBSD, Mac OS X, and others.

How to Install Imagemagick?
How to Install Imagemagick?

Note: Make sure you have installed GhostScript and FreeType already 😉
More help http://blog.svnlabs.com/install-openmeetings/

Download & Unpack

# wget http://www.imagemagick.org/download/ImageMagick.tar.gz
# tar xvfz ImageMagick.tar.gz

Configure

# cd ImageMagick-6.8.0-4 (or current version)
# ./configure

Build

# make

Install

# make install

Commands

[root@svnlabs ImageMagick-6.8.0-4]# which convert
/usr/local/bin/convert

[root@svnlabs ImageMagick-6.8.0-4]# which display
/usr/local/bin/display

Use ImageMagick to convert, edit, or compose bitmap images in a variety of formats. In addition, resize, rotate, shear, distort or transform images automatically.

Red5 Media Server iOS Android Setup


Hits: 11724  

Hope you already read our previous article “VOD to iOS” ?

 

How you can use Red5 Server for streaming to iPhone, iPads and Android?

S V N Labs Softwares implements an iOS/Android add-on setup for Red5 Server to stream both Flash, iOS and Android devices. This add-on also supports setup of JW Player, Flowplayer and HTML5 embed player using Red5 live and on-demand streams. We are expert in setting up Red5 applications and developing custom apps and plug-ins for Red5 and other media servers including Wowza, Flash Media Server, Union etc.

Red5 Recorder allows wordpress users to easily use Red5 Recorder Player on their website to record Video / Audio Streams.
Users can record their video response / review using embedable red5 recorder and after recording they can send video email to wordpress admin. Both user and admin will get email from Red5 Recorder system to get Red5 Recorded Video Streams.

Red5 includes support for the latest multi-user API’s including NetConnection, NetStream and SharedObject’s while providing a powerful RTMP / Servlet implementation. In addition to support for the RTMP protocol, the application server has an embedded Tomcat Servlet container for JEE Web Applications. Application development draws additional benefits from the Spring Framework and Scope based event driven services.

Open Source Red5 Media Server also help you for developing extensible platform that can be used in Video Conferences, Multi-User Gaming and Enterprise Application Software. S V N Labs Softwares are also expert in RED5 and most other media servers including Wowza, Flash Media Server, Union etc. and we can assist to set up transcoding, segmenting, and ipad/iphone/android server-side configuration.

Get more help for HTTP Live Video Stream Segmenter and Distributor Contact Us

Install rtmpdump in CentOS


Hits: 9854  

I was compiling FFmpeg with RTMP support, but it requires librtmp >= 2.2.f

[root@svnlabs ffmpeg]# ./configure –enable-gpl –enable-nonfree –enable-libmp3lame –enable-libfaac –enable-librtmp –enable-libtheora –enable-libvorbis –enable-libx264 –enable-shared –enable-postproc –disable-yasm
Package librtmp was not found in the pkg-config search path.
Perhaps you should add the directory containing `librtmp.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘librtmp’ found
ERROR: librtmp not found or RTMP_Socket() missing, librtmp version must be >= 2.2.f

If you think configure made a mistake, make sure you are using the latest
version from SVN. If the latest version fails, report the problem to the
ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file “config.log” produced by configure as this will help
solving the problem.
  
[root@svnlabs ffmpeg]# rtmpdump -v
RTMPDump v2.2e
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
ERROR: You must specify a hostname (–host) or url (-r “rtmp://host[:port]/playpath”) containing a hostname

Compiling latest rtmpdump-2.3.tgz

[root@svnlabs rtmpdump-2.3]# yum install openssl-devel

[root@svnlabs rtmpdump-2.3]# wget http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.3.tgz

[root@svnlabs rtmpdump-2.3]# tar xvf rtmpdump-2.3.tgz

[root@svnlabs rtmpdump-2.3]# cd rtmpdump-2.3
[root@svnlabs rtmpdump-2.3]# make
[root@svnlabs rtmpdump-2.3]# make install

Latest rtmpdump successfully installed…

[root@svnlabs rtmpdump-2.3]# rtmpdump
RTMPDump v2.3
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
ERROR: You must specify a hostname (–host) or url (-r “rtmp://host[:port]/playpath”) containing a hostname
 
 
[root@svnlabs rtmpdump-2.3]# whereis librtmp
librtmp: /usr/local/lib/librtmp.a /usr/local/lib/librtmp.so

If You still have issue … you can try magic path command 😉

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

 

How to check RTMP source stream is live or not?

 

VOD to iOS


Hits: 6332  

FFMpeg to encode and segment input video stream in the correct format for HTTP streaming protocol.

Download & Install HTTP Live Video Stream Segmenter and Distributor

# /usr/local/bin/live_segmenter <segment length> <output location> <filename prefix> <encoding profile>

 

M3U8 File:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:10,
http://ip-address/streamingvideo/test.m3u8-00001.ts
#EXTINF:10,
http://ip-address/streamingvideo/test.m3u8-00002.ts


….

#EXTINF:10,
http://ip-address/streamingvideo/test.m3u8-00011.ts
#EXT-X-ENDLIST

Errors:

Segmenter error: Could not open input file, make sure it is an mpegts file:

ffmpeg: relocation error: /usr/local/lib/libavfilter.so.1: symbol av_expr_free, version LIBAVUTIL_50 not defined in file libavutil.so.50 with link time reference

Point FFMpeg to the proper files

# export LD_LIBRARY_PATH=/usr/local/lib

OR

# sudo ldconfig -v

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

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

Helpful links:
C++ RTMP Server – http://www.rtmpd.com/
mpegts-segmenter – https://github.com/ElegantCloud/mpegts-segmenter

Install ionCube Loader


Hits: 6405  

1. Download ionCube loaders

# wget http://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz

2. Extract

# tar zxvf ioncube_loaders_lin_x86.tar.gz

3. Move to /usr/local

# mv ioncube /usr/local/

4. Add reference to php.ini file

Depending on PHP version select ioncube_loader_lin_5.x.so and ioncube_loader_lin_5.x_ts.so files

# ls /usr/local/ioncube/
ioncube_loader_lin_4.1.so ioncube_loader_lin_4.4.so ioncube_loader_lin_5.1.so ioncube_loader_lin_5.3.so
ioncube_loader_lin_4.2.so ioncube_loader_lin_4.4_ts.so ioncube_loader_lin_5.1_ts.so ioncube_loader_lin_5.3_ts.so
ioncube_loader_lin_4.3.so ioncube_loader_lin_5.0.so ioncube_loader_lin_5.2.so ioncube_loader_lin_5.4.so
ioncube_loader_lin_4.3_ts.so ioncube_loader_lin_5.0_ts.so ioncube_loader_lin_5.2_ts.so ioncube_loader_lin_5.4_ts.so

# vi /etc/php.ini

zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.3.so
zend_extension_ts=/usr/local/ioncube/ioncube_loader_lin_5.3_ts.so

5. Restart apache

# /etc/init.d/apache2 restart