howto install ffmpeg-php

According to the official ffmpeg-php website: 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

Inodder to use this extension;you must first install ffmpeg http://gnusys.net/install-ffmpeg-with-amr-nb-and-amr-wb-support/

and after that

1.Download ffmpeg-php from http://ffmpeg-php.sourceforge.net/

2.Untar the source package and run the following commands in the source directory

phpize

./configure && make

make install

You must also ensure that the extension is loaded correctly in the php configuration file

php –ini

will show the location of the php.ini file .You must ensure that the following line is present in your php.ini

extension=ffmpeg.so

Thats it.If you are using php as a DSO of apache ;then you may have to restart apache for the change to take effect

Posted under ffmpeg, php

This post was written by Anoop Alias on July 12, 2008

Tags: ,

Install ffmpeg with amr-nb and amr-wb support

ffmpeg is a popular audio/video encoder and decoder . If you are planning to roll out a website that does video conversion like the popular youtube this document is for you . Now if you allow your users to upload content shot using mobile phones inoder to decode the same you may need AMR codec support which unfortunately is not shipped with ffmpeg binary packages available on the internet as this is a proprietary software and the license does not allow you to distribute any software that use this codec!. So what we do is compile these codec support into ffmpeg by grabbing the ffmpeg sources and compiling and installing the various external codecs

From the ffmpeg FAQ : FFmpeg can be hooked up with a number of external libraries to add support for more formats. None of them are used by default, their use has to be explicitly requested by passing the appropriate flags to `./configure’.

Here is the full configure options

neutron:~# ffmpeg -v
FFmpeg version SVN-r14147, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: –enable-shared –enable-gpl –enable-nonfree –enable-liba52 –enable-liba52bin –enable-libamr-nb –enable-libamr-wb –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-libgsm –enable-libmp3lame –enable-libtheora
libavutil version: 49.7.0
libavcodec version: 51.60.0
libavformat version: 52.17.0
libavdevice version: 52.0.0
built on Jul 11 2008 06:00:59, gcc: 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

Here is the step by step instruction to accomplish this configuration

Since the libraries are installed while compiling from source to /usr/local/lib ; we must include this in the linux loaders config file

neutron:~# vi /etc/ld.so.conf.d/usrlocal.conf

and add the following line in it

neutron:~# cat /etc/ld.so.conf.d/usrlocal.conf
/usr/local/lib
neutron:~#

1.Now you must download and install AMR codec libraries from

http://www.penguin.cz/~utx/amr

download amrnb ,amrwb and untar it

you must run

./configure && make && make install

inside the source directory inoder to install the amr(nb and wb) header files in /usr/local/include which is required by ffmpeg

!Please note that you do not have to install the codes from 3gp.org as this will be automatically downloaded in amr installation

2. Now you must download and nstall FAAC and FAAD2 from

http://www.audiocoding.com/downloads.html

And compile them in the same way

inside the source directory you must run

./bootstrap && ./configure && make && make install

3.Download and install liba52

http://liba52.sourceforge.net/downloads.html

install it in the same way using the following commands inside the source

./configure && make && make install

4.Now you have to install LAME

you can download the source from http://lame.sourceforge.net/index.php

instal lit using

./configure && make && make install

5.I needed the theora development libraries which was available in my apt repository.You can do a

apt-cache search theora or yum search theora according to the distribution you use

In debian sarge the folling command should be fine

apt-get install libtheora-dev

Done !.now its time to get ffmpeg sources. you can get the same from

http://lame.sourceforge.net/index.php . Please note that ffmpeg does not have a “official release”.So you must either checkout ffmpeg from svn or use the daily snapshot available at

http://ffmpeg.mplayerhq.hu/download.html

Untar the sources and cd to the source directory and run the following commands

./configure –enable-shared –enable-gpl –enable-nonfree –enable-liba52 –enable-liba52bin –enable-libamr-nb –enable-libamr-wb –enable-libfaac –enable-libfaad –enable-libfaadbin –enable-libgsm –enable-libmp3lame –enable-libtheora

make

make install

If everything goes well you must now have ffmpeg installed.If there is error check the file configure.err in the ffmpeg source directory for the cause of the error

Now as a final step you must check if all shared libraries are loaded fine

You must run the following commands to check this

neutron:~# which ffmpeg
/usr/local/bin/ffmpeg
neutron:~# ldd /usr/local/bin/ffmpeg
linux-gate.so.1 => (0×001b2000)
libavdevice.so.52 => /usr/local/lib/libavdevice.so.52 (0×005e2000)
libavformat.so.52 => /usr/local/lib/libavformat.so.52 (0×009a4000)
libavcodec.so.51 => /usr/local/lib/libavcodec.so.51 (0×00a43000)
libavutil.so.49 => /usr/local/lib/libavutil.so.49 (0×00110000)
libm.so.6 => /lib/tls/libm.so.6 (0×0011f000)
libc.so.6 => /lib/tls/libc.so.6 (0×007c7000)
libz.so.1 => /usr/lib/libz.so.1 (0×0026d000)
libdl.so.2 => /lib/tls/libdl.so.2 (0×00649000)
libamrnb.so.3 => /usr/local/lib/libamrnb.so.3 (0×00144000)
libamrwb.so.3 => /usr/local/lib/libamrwb.so.3 (0×00180000)
libfaac.so.0 => /usr/local/lib/libfaac.so.0 (0×001b3000)
libgsm.so.1 => /usr/lib/libgsm.so.1 (0×00582000)
libmp3lame.so.0 => /usr/local/lib/libmp3lame.so.0 (0×001c4000)
libtheora.so.0 => /usr/lib/libtheora.so.0 (0×00281000)
/lib/ld-linux.so.2 (0×00737000)
libogg.so.0 => /usr/lib/libogg.so.0 (0×007ad000)
neutron:~#

Sometimes you will receive ” cannot load shared library ” error while running ffmpeg or library “no found” in the ldd output.This is caused because you have not created/ updates the necessary links and cache (for use by the run-time linker, ld.so) to the most recent shared libraries

you can fix this error simply by running the following command

neutron:~# ldconfig

Please do not forget to include /usr/local/lib in your ld.so.conf which i have mentioned at the start of this article by editing the file /etc/ld.so.conf.d/usrlocal.conf. you can also add /usr/local/lib directly to ld.so.conf in older versions of GNU/Linux that does not use the /etc/ld.so.conf.d/ directory scheme

Hope you enjoyed this article..If you need me to install this for you just send me a mail at anoop[at]gnusys.net

WARNING:

libamr is copyrighted without any sort of license grant. This means that you can use it if you legally obtained it but you are not allowed to redistribute it in any way. Any FFmpeg binaries with libamr support you create are non-free and unredistributable!

REFERENCES:

http://ffmpeg.mplayerhq.hu/general.html#SEC1

Posted under ffmpeg, hosting

This post was written by Anoop Alias on July 11, 2008

Tags: ,