How To Install FFmpeg, Mplayer, Mencoder, FFmpeg-PHP on CentOS 5.x

on May 21 | in Hosting / Servers, Linux | by | with 72 Comments

In this how to i will describe how to install ffmpeg, mplayer, mencoder, flvtool2, ffmpeg-php with all supported codecs to convert / manipulate videos easily on CentOS 5.x. If you want to run sites like youtube e.g www.indianpad.in, www.danceindiadance.in this howto will help you to install the base for your software. There are many other way to perform this but this works for me, so i want to share.

1 Setting Up RPMForge Respository.

RPMForge repository (http://dag.wieers.com) is the biggest rpm respository for RHEL, CentOS for all versions. To enable RPMForge respository run following command to install all necessary files for getting RPMForge repository. The following command directly install rpm from http://da.wieers.com site.

For i386/i686

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

For x86_64

rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

This rpm will add necessary files in our repository configuration and can be viewed at /etc/yum.repos.d/rpmforge.repo

2 Install ffmpeg, mplayer, mencoder with all supported modules.

Now we have rpmforge repository, so we will use yum to install ffmpeg, mplayer, mencoder as well as all dependent software.

yum -y install ffmpeg ffmpeg-devel mplayer mencoder flvtool2

This command will some time to download and install all packages depends on your internet speed.

3 Install 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. ffmpeg-devel and php-devel is needed to compile ffmpeg-php from source code. Use following steps to install ffmpeg-php

cd /usr/src
wget http://garr.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
tar jxvf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
phpize
./configure
make
make install

It will copy the ffmpeg.so module in php default module location. Now you have to edit php.ini file to enable ffmpeg-php support in it by using ffmpeg.so module.

vi /etc/php.ini

and append following line

extension=ffmpeg.so

Restart apache service to take effect of php.ini

/etc/init.d/httpd restart

Run following command to ffmpeg module listing in php.

php -m | grep ffmpeg

Have a nice streaming. 🙂

pixelstats trackingpixel
Pin It

related posts

72 Responses to How To Install FFmpeg, Mplayer, Mencoder, FFmpeg-PHP on CentOS 5.x

  1. Suraj says:

    Hi, I am getting this error while installing ffmpeg-php.

    ============
    cd /usr/src
    wget http://garr.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
    tar jxvf ffmpeg-php-0.6.0.tbz2
    cd ffmpeg-php-0.6.0
    phpize
    ./configure
    make
    make install
    =========

    until ./configure is fine while i issue make & make install command both of them giving me “-bash: make: command not found” error.

    Please help me to fix it, i m using centos 5.5. Thanks a lot !

  2. @Suraj: Its seems like your server doesn’t have Development Tools install which help to compile source code. To install all necessary compiling software use following command to install and then go for ffmpeg-php make.

    yum groupinstall “Development Tools”

    —————
    Regards,

  3. Suraj says:

    Thanks a lot Sohail but I am getting another error when i run the command you provided above:

    Error:
    ———————–
    [root@server ffmpeg-php-0.6.0]# ffmpeg-php make.
    bash: ffmpeg-php: command not found
    [root@server ffmpeg-php-0.6.0]#
    [root@server ffmpeg-php-0.6.0]# yum groupinstall Development Tools
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    * Webmin: download.webmin.com
    * addons: mirrors.rit.edu
    * base: mirror.batblue.com
    * extras: mirror.rackspace.com
    * rpmforge: apt.sw.be
    * updates: mirror.rackspace.com
    Setting up Group Process
    Checking for new repos for mirrors
    base/group | 920 kB 00:00
    extras/group | 9.7 kB 00:00
    No packages in any requested group available to install or update

    Thanks

  4. @Suraj: Kindly following command and see what you get in return

    yum install make automake gcc

    ————-
    Regards,

  5. Suraj says:

    Sohail, many of us are getting this error”make” and “make install” so when we issue command “php -m | grep ffmpeg” then it will give the error “PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/modules/ffmpeg.so’ – /usr/lib/php/modules/ffmpeg.so: cannot open shared object file: No such file or directory in Unknown on line 0

    ” because the ffmpeg.so is not copying to the php mods directory.

    im using centos 5.5 i686 with kloxo installed.

  6. Suraj says:

    it asked to installed the package. i installed it and run the whole part again
    ==========================
    cd /usr/src
    wget http://garr.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
    tar jxvf ffmpeg-php-0.6.0.tbz2
    cd ffmpeg-php-0.6.0
    phpize
    ./configure
    make
    make install
    ==========================
    I got this
    ==========================
    [root@server ffmpeg-php-0.6.0]# make
    /bin/sh /usr/src/ffmpeg-php-0.6.0/libtool –mode=compile cc -I. -I/usr/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/src/ffmpeg-php-0.6.0/include -I/usr/src/ffmpeg-php-0.6.0/main -I/usr/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libavcodec/ -I/usr/include/libavformat/ -I/usr/include/libavutil/ -I/usr/include/libswscale/ -I/usr/include/libavfilter/ -I/usr/include/libavdevice/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/src/ffmpeg-php-0.6.0/ffmpeg-php.c -o ffmpeg-php.lo
    mkdir .libs
    cc -I. -I/usr/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/src/ffmpeg-php-0.6.0/include -I/usr/src/ffmpeg-php-0.6.0/main -I/usr/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libavcodec/ -I/usr/include/libavformat/ -I/usr/include/libavutil/ -I/usr/include/libswscale/ -I/usr/include/libavfilter/ -I/usr/include/libavdevice/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/src/ffmpeg-php-0.6.0/ffmpeg-php.c -fPIC -DPIC -o .libs/ffmpeg-php.o
    /bin/sh /usr/src/ffmpeg-php-0.6.0/libtool –mode=compile cc -I. -I/usr/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/src/ffmpeg-php-0.6.0/include -I/usr/src/ffmpeg-php-0.6.0/main -I/usr/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libavcodec/ -I/usr/include/libavformat/ -I/usr/include/libavutil/ -I/usr/include/libswscale/ -I/usr/include/libavfilter/ -I/usr/include/libavdevice/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c -o ffmpeg_movie.lo
    cc -I. -I/usr/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/src/ffmpeg-php-0.6.0/include -I/usr/src/ffmpeg-php-0.6.0/main -I/usr/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libavcodec/ -I/usr/include/libavformat/ -I/usr/include/libavutil/ -I/usr/include/libswscale/ -I/usr/include/libavfilter/ -I/usr/include/libavdevice/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c -fPIC -DPIC -o .libs/ffmpeg_movie.o
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c: In function ‘_php_read_av_frame’:
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:1215: warning: ‘avcodec_decode_video’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3454)
    /bin/sh /usr/src/ffmpeg-php-0.6.0/libtool –mode=compile cc -I. -I/usr/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/src/ffmpeg-php-0.6.0/include -I/usr/src/ffmpeg-php-0.6.0/main -I/usr/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libavcodec/ -I/usr/include/libavformat/ -I/usr/include/libavutil/ -I/usr/include/libswscale/ -I/usr/include/libavfilter/ -I/usr/include/libavdevice/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c -o ffmpeg_frame.lo
    cc -I. -I/usr/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/src/ffmpeg-php-0.6.0/include -I/usr/src/ffmpeg-php-0.6.0/main -I/usr/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libavcodec/ -I/usr/include/libavformat/ -I/usr/include/libavutil/ -I/usr/include/libswscale/ -I/usr/include/libavfilter/ -I/usr/include/libavdevice/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c -fPIC -DPIC -o .libs/ffmpeg_frame.o
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function ‘zim_ffmpeg_frame_toGDImage’:
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: ‘PIX_FMT_RGBA32’ undeclared (first use in this function)
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.)
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function ‘zim_ffmpeg_frame_ffmpeg_frame’:
    /usr/src/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

    ==========================

    i haven’t execute “make install” command yet coz i would like to get your comments first. thanks a for helping.

  7. @Suraj: This is some kind of known error,

    Open the file under ffmpeg-php source directory

    vi ffmpeg_frame.c

    and replace all PIX_FMT_RGBA32 to /PIX_FMT_RGB32

    or you can use search and replace like this

    :%s/PIX_FMT_RGBA32/PIX_FMT_RGB32

    ————
    Regards,

  8. Suraj says:

    Thanks Sohail, it’s installed now.

  9. sandip says:

    great article

    Thanks Sohail

    help me allot thanks for your contribution .

  10. sandip says:

    plz provide me your contact no. on my email id i.e

    sandip.gangdhar@gmail.com

    or else please contact me on 9594959897.

    Thanks ,
    Sandip.

  11. Ali says:

    I am getting this error any 1 help plz

    cpan ffmpeg icecast psa sources

  12. Salman Zaidi says:

    Sir, I am new to rhel. I have configured Red5 from your blog and now streaming nice in flash format. I also installed ffmeg and other tools but not know next what to do and how to do to start streaming. Please help.
    Salman

  13. Bill Deng says:

    Great instruction. Thank you.
    I have reposted in my blog:
    http://www.billdeng.com/archives/387.html

  14. 鲜万家 says:

    php -m | grep ffmpeg

  15. nickchacha says:

    NIcely done and it worked for me
    Thanks A million

  16. Bayam says:

    after restart apache (service httpd restart) all my website become like this
    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, webmaster@rilekscrew.org and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

    p/s ~ how to fix?? help me

  17. Hello,

    trying to build ffmpeg-php I have many errors like this:

    /usr/include/bits/stat.h:91: error: field ‘st_atim’ has incomplete type

    What’s wrong here?

  18. jai Shanker Verma says:

    /bin/sh /usr/src/ffmpeg-php-0.6.0/libtool –mode=compile cc -I. -I/usr/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/src/ffmpeg-php-0.6.0/include -I/usr/src/ffmpeg-php-0.6.0/main -I/usr/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libavcodec/ -I/usr/include/libavformat/ -I/usr/include/libavutil/ -I/usr/include/libswscale/ -I/usr/include/libavfilter/ -I/usr/include/libavdevice/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c -o ffmpeg_movie.lo
    libtool: compile: cc -I. -I/usr/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/src/ffmpeg-php-0.6.0/include -I/usr/src/ffmpeg-php-0.6.0/main -I/usr/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/libavcodec/ -I/usr/include/libavformat/ -I/usr/include/libavutil/ -I/usr/include/libswscale/ -I/usr/include/libavfilter/ -I/usr/include/libavdevice/ -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c -fPIC -DPIC -o .libs/ffmpeg_movie.o
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c: In function âzim_ffmpeg_movie___constructâ:
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:311: error: âlist_entryâ undeclared (first use in this function)
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:311: error: (Each undeclared identifier is reported only once
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:311: error: for each function it appears in.)
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:311: error: expected â;â before ânew_leâ
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:324: error: âleâ undeclared (first use in this function)
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:346: error: expected â;â before ânew_leâ
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:356: error: ânew_leâ undeclared (first use in this function)
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c: In function â_php_read_av_frameâ:
    /usr/src/ffmpeg-php-0.6.0/ffmpeg_movie.c:1215: warning: âavcodec_decode_videoâ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3452)
    make: *** [ffmpeg_movie.lo] Error 1

    Need help ..

  19. Shahil says:

    Sohail Sir,
    Need a Document clear ubderstating of
    Samba Primary Domain Controller with Open-LDAP .
    Please provide, I will be very grateful to you

  20. […] 以下方式一次安裝(除了ffmapeg 比較麻煩) yum install –enablerepo=rpmforge ImageMagick netpbm netpbm-progs jhead ffmpeg ffmpeg-devel flvtool2 mplayer mencoder lame libogg libvorbis libtheora swftools amrnb amrwb transcode x264 How To Install FFmpeg, Mplayer, Mencoder, FFmpeg-PHP on CentOS 5.x Sohail Riaz, Linux and Open Sourc… […]

  21. r00t says:

    If you get [ffmpeg_movie.lo] Error 1 when compiling ffmpeg-php, then you will need to do:
    Changes in ffmpeg_movie.c:

    row 311: list_entry *le; to zend_rsrc_list_entry *le;
    row 346: list_entry new_le; to zend_rsrc_list_entry new_le;
    row 360: hashkey_length+1, (void *)&new_le, sizeof(list_entry), to hashkey_length+1, (void *)&new_le,sizeof(zend_rsrc_list_entry),

  22. […] 以下方式一次安裝(除了ffmapeg 比較麻煩) yum install –enablerepo=rpmforge ImageMagick netpbm netpbm-progs jhead ffmpeg ffmpeg-devel flvtool2 mplayer mencoder lame libogg libvorbis libtheora swftools amrnb amrwb transcode x264 How To Install FFmpeg, Mplayer, Mencoder, FFmpeg-PHP on CentOS 5.x Sohail Riaz, Linux and Open Sourc… […]

Leave a Reply

Your email address will not be published. Required fields are marked *

« »