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