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

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. ๐Ÿ™‚

Related Posts

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

  1. after running
    php -m | grep ffmpeg
    i m getting the following error:

    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/ffmpeg.so’ – libavformat.so.51: cannot open shared object file: No such file or directory in Unknown on line 0

    so i checked about file:
    libavformat.so.51
    and i cant find in anywhere

  2. can you please check this software, does it has any update version.
    ffmpeg-php-0.6.0.tbz2
    If yes compile that instead of it.

    Regards,

  3. Yeah, I followed this verbatim and it didn’t work on Centos 5.3 – fresh installation too. Make test fails and despite not giving errors php doesn’t show it in php test

  4. @Mike: Can you describe what fails. First of assure you have install ffmpeg, mplayer, mencoder and ffmpeg-php installed correctly. For this execute following commands and you should see some help
    ffmpeg
    mplayer
    mencoder
    ———–
    For ffmpeg-php, you should see ffmpeg module in phpinfo, you can see on shell by issuing following command
    php -m | grep -i ffmpeg
    ——
    Regards,

  5. Hi!
    I m having also issues with Centos 64bit.
    This is what i get when i run your commands:
    ffmpeg:
    FFmpeg version SVN-r19583, Copyright (c) 2000-2009 Fabrice Bellard, et al.
    configuration: –enable-libmp3lame –disable-mmx –enable-shared
    libavutil 50. 3. 0 / 50. 3. 0
    libavcodec 52.32. 0 / 52.32. 0
    libavformat 52.37. 0 / 52.37. 0
    libavdevice 52. 2. 0 / 52. 2. 0
    libswscale 0. 7. 1 / 0. 7. 1
    built on Sep 18 2009 10:48:22, gcc: 4.1.2 20080704 (Red Hat 4.1.2-44)

    mplayer:
    MPlayer SVN-r29475-4.1.2 (C) 2000-2009 MPlayer Team

    mencoder:
    MEncoder SVN-r29475-4.1.2 (C) 2000-2009 MPlayer Team
    No file given

    Exiting… (error parsing command line)

    after restarting php and running
    php -r ‘phpinfo();’ | grep ffmpeg
    i get the following:

    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/ffmpeg.so/libavformat.so.51: cannot open shared object file: No such file or directory in Unknown on line 0

    after doing an ls for usr/lib for libavformat.so.51 i get a result for libavformat.so.51 in red background.
    While ls /usr/lib64/libavformat.so.51
    give a not found message.
    Since i m in 64bit i believe the lib should be found under lib64

  6. @Makis: FFMPEG with Mplayer and Mencoder installation is successful. The issue is with ffmpeg-php module.
    php should load
    /usr/lib64/php/modules/ffmpeg.so
    not
    /usr/lib64/php/modules/ffmpeg.so/libavformat.so.51
    —————–
    Whats you have in your php.ini for ffmpeg
    ———
    Regards,

  7. I m trying this installation for the last 3 hours ๐Ÿ˜€
    Managed to get ffmpeg working since i get all my videos converted successfully but i noticed that my video length is not calculated properly so i guess ffmpeg-php is not working as it should.

    ffmpeg give me this:
    FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
    configuration: –enable-gpl
    libavutil 49.15. 0 / 49.15. 0
    libavcodec 52.20. 0 / 52.20. 0
    libavformat 52.31. 0 / 52.31. 0
    libavdevice 52. 1. 0 / 52. 1. 0
    built on Sep 20 2009 15:47:16, gcc: 4.1.2 20080704 (Red Hat 4.1.2-44)
    At least one output file must be specified

    php -i | grep -i ffmpeg
    gives me this:
    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/ffmpeg.so’ – /usr/lib64/php/modules/ffmpeg.so: undefined symbol: img_convert in Unknown on line 0
    PWD => /usr/local/src/ffmpeg-0.5
    _SERVER[“PWD”] => /usr/local/src/ffmpeg-0.5
    _ENV[“PWD”] => /usr/local/src/ffmpeg-0.5

    my php.ini has the following:
    [ffmpeg]
    extension=ffmpeg.so

    ps: thank you for helping us out

  8. When I am at your step 2, I ran into this error:

    flvtool2-1.0.6-1.el5.rf.noarch from rpmforge has depsolving problems
    –> Missing Dependency: ruby is needed by package flvtool2-1.0.6-1.el5.rf.noarch (rpmforge)
    flvtool2-1.0.6-1.el5.rf.noarch from rpmforge has depsolving problems
    –> Missing Dependency: /usr/bin/ruby is needed by package flvtool2-1.0.6-1.el5.rf.noarch (rpmforge)
    Error: Missing Dependency: ruby is needed by package flvtool2-1.0.6-1.el5.rf.noarch (rpmforge)
    Error: Missing Dependency: /usr/bin/ruby is needed by package flvtool2-1.0.6-1.el5.rf.noarch (rpmforge)

    At the end of the installation. Can you show me how to fix this?

  9. @Michael: its seems your centos default repository doesnt contain ruby rpm. You can first clean yum cache and then try to install ruby first
    yum clean all
    yum -y install ruby
    ——————-
    If again says nothing to do, please install ruby rpm manually from http://www.centos.org for correct OS. then reapply step 2 again.
    ——–
    Regards,

  10. Now i have installed phpize. then after i get this error

    phpize
    Configuring for:
    PHP Api Version: 20041225
    Zend Module Api No: 20060613
    Zend Extension Api No: 220060519
    [root@air923 ffmpeg-php-0.6.0]#
    [root@air923 ffmpeg-php-0.6.0]# ./configure
    checking for egrep… grep -E
    checking for a sed that does not truncate output… //bin/sed
    checking for cc… no
    checking for gcc… no
    configure: error: no acceptable C compiler found in $PATH
    See `config.log’ for more details.
    [root@air923 ffmpeg-php-0.6.0]#

  11. @Raj: Your machine didnt have compilers to compile ffmpeg-php, kindly execute following command then do ./configure
    ——–
    yum -y groupinstall “Development Tools”
    ——–
    Regards,

  12. Thanks i have now installed Development Tools. But i have another problem, because i am newbie in linux, ssh etc.

    I typed vi /etc/php.ini and closed the session.
    Then i logged in again. then it shows me about the php.ini swap files exist.

    i have now
    php.ini.rpmnew
    php.ini_saved_by_psa

    And i have deleted my original php.ini file by misstake.
    How can i delete the swap files. and is php.ini.rpmnew the new file?

    Now i have to do following delete swap files. and resotre old php.ini or do i have to rename php.ini.rpm to php.ini?

    Please help

  13. i m still getting this error after
    php -i | grep -i ffmpeg

    —-
    PHP Warning: PHP Startup: Unable to load dynamic library โ€˜/usr/lib64/php/modules/ffmpeg.soโ€™ โ€“ /usr/lib64/php/modules/ffmpeg.so: undefined symbol: img_convert in Unknown on line 0
    —-

    any help?

  14. @Makis: Kindly confirm that you have following software installed…. you can get your answer by running following commands.

    yum list | grep gd

    php -m | grep -i gd

  15. Well for yum list | grep gd i get:


    Not using downloaded repomd.xml because
    it is older than what we have:
    Current : Sun Dec 27 05:43:47 2009
    Downloaded: Fri Nov 27 05:35:18 2009
    — gd.i386
    2.0.33-9.4.el5_1.1(installed)
    — gd.x86_64
    2.0.33-9.4.el5_1.1(installed)
    — gd-devel.i386
    2.0.33-9.4.el5_1.(installed)
    — gd-devel.x86_64
    2.0.33-9.4.el5_1.1(installed)
    — gdb.x86_64
    6.8-37.el5(installed)
    — gdbm.i386
    1.8.0-26.2.1(installed)
    — gdbm.x86_64
    .8.0-26.2.1(installed)
    — php-gd.x86_64
    5.2.11-2.el5.art(installed)
    — sysklogd.x86_64
    1.4.1-44.el5(installed)
    — aspell-gd.x86_64
    50:0.50-4.2.2(base)
    — eggdrop.x86_64
    1.6.19-1.el5.rf(dag)
    — gd-progs.x86_64
    2.0.33-9.4.el5_1.1(base)
    — gdal.x86_64
    1.4.4-2.el5.rf(dag)
    — gdal-devel.x86_64
    1.4.4-2.el5.rf(dag)
    — gdbm-devel.i386
    1.8.0-26.2.1(base)
    — gdbm-devel.x86_64
    1.8.0-26.2.1(base)
    — gdk-pixbuf.i386
    1:0.22.0-25.el5(base)
    — gdk-pixbuf.x86_64
    1:0.22.0-25.el5(base)
    — gdk-pixbuf-devel.i386
    1:0.22.0-25.el5(base)
    — gdk-pixbuf-devel.x86_64
    1:0.22.0-25.el5(base)
    — gdm.x86_64
    1:2.16.0-56.el5.centos(base)
    — gdm-docs.x86_64
    1:2.16.0-56.el5.centos(base)
    — jigdo.x86_64
    0.7.3-1.el5.rf(dag)
    — libgdiplus.x86_64
    1.2.5-1.el5.centos(extras)
    — libgdiplus-devel.x86_64
    1.2.5-1.el5.centos(extras)

    and for php -m | grep -i gd i get:


    PHP Warning: PHP Startup:
    Unable to load dynamic library ‘/usr/lib64/php/modules/ffmpeg.so’ – /usr/lib64/php/modules/ffmpeg.so:
    cannot open shared object file:
    No such file or directory in Unknown on line 0
    gd

  16. please disregard my reply regarding php -m | grep -i gd
    because i got the wrong copy paste.
    The real output after running php -m | grep -i gd is:


    PHP Warning: PHP Startup:
    Unable to load dynamic library ‘/usr/lib64/php/modules/ffmpeg.so’ – /usr/lib64/php/modules/ffmpeg.so: undefined symbol: ffmpeg_img_convert in Unknown on line 0

  17. @makis: put full output of
    php -m

    because in first output its clear that gd is installed… but in second ouput it shows its not installed.

    do php -m and if the list contain gd then its good. else please install gd module for php.

    Regards,

  18. here you go:


    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/module s/ffmpeg.so’ – /usr/lib64/php/modules/ffmpeg.so: undefined symbol: ffmpeg_img_co nvert in Unknown on line 0
    [PHP Modules]
    bcmath
    bz2
    calendar
    ctype
    curl
    date
    dbase
    dom
    exif
    filter
    ftp
    gd
    gettext
    gmp
    hash
    iconv
    imap
    ionCube Loader
    json
    ldap
    libxml
    mysql
    mysqli
    odbc
    openssl
    pcntl
    pcre
    PDO
    pdo_mysql
    PDO_ODBC
    pdo_sqlite
    phpSHIELD
    readline
    Reflection
    session
    shmop
    SimpleXML
    sockets
    SPL
    standard
    tokenizer
    wddx
    xml
    xmlreader
    xmlrpc
    xmlwriter
    xsl
    Zend Optimizer
    zip
    zlib

    [Zend Modules]
    Zend Optimizer
    the ionCube PHP Loader

  19. Note: If you’re on WHM / cPanel, you need to edit /etc/yum.conf and remove the ruby* entry under exclusions so you can install ruby.

  20. Sorry for the newbie question but how do I connect to the server in the first place? Do I use WinSCP for that or what client should I use? I’m pretty sure that I can follow the steps in this “how to” but I’m missing the very first step which is what client to use and how to connect to my server.

    Thanks in advance.

  21. I was trying to install ffmpeg-php on Fedora9, I’ve downloaded the ffpmeg-php-0.6.0 and used phpize and ./configure –enable-shared –prefix=/usr and both of them workrd find but when I tried to run make I got the following error:
    “make: *** No targets specified and no makefile found. Stop.”

    I tried the same procedure with ffmpeg-php-0.5.1 and ffmpeg-0.5.0 but failed.
    Can anyone help me with this. ๐Ÿ˜

  22. I was trying to install ffmpeg-php on Fedora9, I’ve downloaded the ffpmeg-php-0.6.0 and used phpize and ./configure –enable-shared –prefix=/usr and both of them worked fine but when I tried to run make I got the following error:
    “make: *** No targets specified and no makefile found. Stop.”

    I tried the same procedure with ffmpeg-php-0.5.1 and ffmpeg-0.5.0 but failed.
    Can anyone help with this. ๐Ÿ˜

  23. @Sayan: Make sure your ./configure execute correctly and generate Makefile. If possible put last 10 lines from ./configure
    ————–
    Regards,

  24. GREAT ! i INSTALLED SUCCESFULLY.
    BUT CONVERSION OF 3GP FILE IS PLAYING TOO FAST WITH NO SOUND AND CONVERSION OF X264 IS PLAYING WITH NO SOUND.

    ANY ISSUE ?..

    THANKS ANY WAY…..

  25. I have installed to Centos 5.3 with your instruction:
    ffmpeg: error while loading shared libraries: libavutil.so.50 No Such file or directory.

    I have found only libavutil.so.49……. What is the problem?

    Any solution?

  26. Hi i tried to install ffmpeg-php
    when am configuring by this
    ./configure

    it throws this message

    checking for egrep… grep -E
    checking for a sed that does not truncate output… //bin/sed
    checking for gcc… no
    checking for cc… no
    checking for cc… no
    checking for cl… no
    configure: error: no acceptable C compiler found in $PATH
    See `config.log’ for more details.

    And config.log i cant understand whats the problem. Please solve me this

    Thanks

  27. Hi

    i solved by installing make and gss commands using yum
    yum install make
    yum install gcc

    thanks

  28. Thank you. Great simple and efficient. It is how all things should be. I tried to install by myself and messed up a couple of things. Found your tutorial and folowed your staps and all went ok. Thanks again.

  29. hi

    i try to installed ffmpeg on my centos 5.4 32 bit, but failed . you guys can help me to isntalled this ffmpeg on my centos 32 bit

    thanks

    waiting for good response

  30. Thank you Sohail Riaz. Your tutorial is great simple, and efficient. It is how all things should be. I tried to install following your steps and all went okay. Thanks again.

    But I’ve an issue when I try to convert and mpg file I got this error:
    [libmp3lame @ 0x8e105b0]lame: output buffer too small (buffer index: 9508, free
    bytes: 284)
    Audio encoding failed

    more over video time is not being calculated. While googling I came to know this “This seems to be fixed by going back to 3.98 or 3.97 versions of lame.” Can you help me how can I replace the lame or fix this issue.
    Thank you!

  31. Hi,

    I have followed the above steps, and I successfully installed ffmpeg on my centos5.3 32 bit. Thank you very much.

    Jino

  32. I also get the error PHP Warning: PHP Startup: Unable to load dynamic library โ€˜/usr/lib64/php/modules/ffmpeg.soโ€™ โ€“ libavformat.so.51: cannot open shared object file: No such file or directory in Unknown on line 0
    I looked and found libavformat.so.52 but not libavformat.so.51.
    Any ideas how to fix that?

  33. i got wrong directory error, then i change module directory to usr/li64/php/module. i still get this error
    Failed loading /usr/lib/kloxophp/ioncube/ioncube_loader_lin_5.2.so: /usr/lib/kloxophp/ioncube/ioncube_loader_lin_5.2.so: wrong ELF class: ELFCLASS32
    Failed loading /usr/lib/kloxophp/zend/lib/ZendExtensionManager.so: /usr/lib/kloxophp/zend/lib/ZendExtensionManager.so: wrong ELF class: ELFCLASS32
    ffmpeg

  34. I got stuck at FFMPEG configuration. I am getting this error

    Unknown option โ€œโ€“enable-liboggโ€.
    See ./configure โ€“help for available options.

    Can anyone help me?

  35. Sohail,

    I am getting the following warning

    Warning: dl() [function.dl]: Unable to load dynamic library ‘/usr/lib64/php/modules/ffmpeg.so’ – /usr/lib64/php/modules/ffmpeg.so: undefined symbol: av_free_packet in /var/www/vhosts/webswings.com/httpdocs/test_ffmpeg.php on line 8
    Can’t load extension /usr/lib64/php/modules/ffmpeg.so

    I tried the methods listed above like installation of RUBY but it’s not working.

    Can you please help?

    Thanks,
    Shahzad

Leave a Reply

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