Jul 31

What is FFmpeg ?

FFmpeg is a collection of free software that can record, convert and stream digital audio and video. It includes libavcodec, a leading audio/video codec library. FFmpeg is developed under Linux, but it can be compiled under most operating systems, including Windows.

What is FFmpeg-php ?

ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. It has methods for returning frames from movie files as images that can be manipulated using PHP’s image functions. This works well for automatically creating thumbnail images from movies. ffmpeg-php is also useful for reporting the duration and bitrate of audio files (mp3, wma…). ffmpeg-php can access many of the video formats supported by ffmpeg (mov, avi, mpg, wmv…)

Install dependency

  1. First we need to install apache, php , gcc and make

# yast2 –install apache2 apache2-devel apache2-mod_php5 apache2-mod_perl-devel apache2-mod_python php5 php5-devel php5-mbstring php5-mcrypt php5-mysql php5-zlib gcc make

Installing FFmpeg

  1. It is fortunate that opensuse have repositories that support FFmpeg installation, how to activate it ? just go to yast2 -> Software -> Software Repositories ->pick  Packman Repository ->  [Finish] , if youc annot find the repo you can add http://ftp.skynet.be/pub/packman/suse/11.0/    to your software repositories

ffmpeg1

2.  Now we just need to install FFmpeg from yast2 and  install libffmpeg-devel so we can install  FFmpeg-php

# yast2 –install ffmpeg libffmpeg-devel

or go to your yast2 -> Software Management -> tab until you get to Filter and press down arrow until you get Search -> press tab and type ffmpeg -> press tab until the cusrosr to search and enter -> press tab until the cusrosr goes to ffmpeg and press space and find libffmpeg-devel  -> tab until your cursor goes to [Accept]

ffmpeg2

our FFmpeg should be installed to checked it use this

# rpm -qa | grep ffmpeg
ffmpeg-0.5-0.pm.3
libffmpeg0-0.5-0.pm.3
libffmpeg-devel-0.5-0.pm.3

Installing FFmpeg-php

1.Unfortunately there isn’t any FFmpeg-php packet on opensuse you need to download the package source

# wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download

then extract it

# tar -xjf ffmpeg-php-0.6.0.tbz2

go to ffmpeg-php-0.6.0 directory

# cd ffmpeg-php-0.6.0

# phpize

Configure and build the extension.

# ./configure && make

Install the shared extension.

# make install

ffmpeg-php common error :

/root/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function âzim_ffmpeg_frame_toGDImageâ:
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: âPIX_FMT_RGBA32â undeclared (first use in this function)
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.)
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function âzim_ffmpeg_frame_ffmpeg_frameâ:
/root/ffmpeg-php-0.6.0/ffmpeg_frame.c:421: error: âPIX_FMT_RGBA32â undeclared (first use in this function)
make: *** [ffmpeg_frame.lo] Error 1

Solution:-

Under the ffmpeg-php-0.6.0 directory modify the file: ffmpeg_frame.c with nano or vi editor and replace every instance of PIX_FMT_RGBA32 with PIX_FMT_RGB32

# nano ffmpeg_frame.c
# Search for PIX_FMT_RGBA32 and replace it with PIX_FMT_RGB32
# Exit from the editor

Then run the following commands:

# cd /root/src/ffmpeg-php-0.6.0
# cp -aP ffmpeg_frame.loT ffmpeg_frame.lo
# make clean
# ./configure
#   make
#   make install

2. Now we need to add ffmpeg modules to php

# vi /etc/php5/apache2/php.ini

add this

; add ffmpeg.so

extension=ffmpeg.so

Reload the apache

# /etc/init.d/apache2 reload

3. Now checked your phpinfo and see if the FFmpeg installed or not

# php -r ‘phpinfo();’ | grep ffmpeg
OLDPWD => /root/ffmpeg-php-0.6.0
_SERVER[“OLDPWD”] => /root/ffmpeg-php-0.6.0

Checked on your phpinfo page <? phpinfo(); ?>

ffmpeg3

Jul 23

This is a tip for those who are using squirrel webmail. I have a user request to show HTML /picture on the squirrel email body and manually you can add the option by goin to your squirrel webmail -> Options -> Display Preferences -> Show HTML Version by Default:  -> and click Yes -> click the Submit button.

sqwebmail1

Okay it is easy right ? but if the user want all of the email account under your qmail mail server squirrel webmail by default set the Show HTML Version by Default to be Yes , what you gonna do ? set the squirrel mail account one by one 🙂 hmm i don’t think so. Here is some tips to changes the default user preference on squirrel webmail.

1.  The default preferences are stored in your data directory in a file called default_pref  it usually stored on your sqwebmail data in my case it is on /Web/apache/htdocs/mail.test.com/data/default_pref .  And every user have their own username.pref example /Web/apache/htdocs/mail.test.com/data/adityo@test.com.pref  .

Note that the default_pref file works only for users that don’t have an existing preference file (i.e. new users which haven’t logged in yet). If you want to add preferences to existing user accounts, you should edit (manually or by a script) their existing preference files. It’s not recommended to delete the preference files, since that will revert all preferences edited by your users, including such settings as their real names.

2. We need to set default_pref so it will be default setting for all new mail account
# vi /Web/apache/htdocs/mail.test.com/data/default_pref

full_name=
reply_to=
show_html_default=0 # -> changes it to 1 to enable Show HTML Version by Default
sort=0
show_num=100 #to set Number of Messages per Page
attachment_common_show_images=1 #to set Display Attached Images with Message to be yes

3. Okay we have edit the default_pref for new account and how about for the old account that already created ? you can create a new default.pref let say it is on /tmp/default.pref
# vi /tmp/default.pref
show_html_default=0 # -> changes it to 1 to enable Show HTML Version by Default
sort=0
show_num=100 #to set Number of Messages per Page
attachment_common_show_images=1 #to set Display Attached Images with Message to be yes
custom_css=sans-10.css #change the font to a custom one by using CSS

and go to your username.pref folder a
cd /Web/apache/htdocs/mail.test.com/data/
nd run this
#for l in `ls *.pref`; do cat /tmp/default.pref >> $l; done

Or if you want to use default_pre just run this
#for l in `ls *.pref`; do cat/Web/apache/htdocs/mail.test.com/data/default_pre > $l; done

it will changes your Squirrell webmail (SQWebmail) user preferences settings