The [pretty much] Complete Guide to Installing ffMPEG and Audio Binaries
Posted by Nessa | Posted in centos,linux,php,tutorials | Posted on January 7, 2008
30
I know you’ve provably seen a lot of guides on how to install ffMPEG, but I’ve noticed that most of them are incomplete and don’t cover the possible issues that can arise during installation. I’ve installed ffMPEG on dozens of servers and have devised a standardized procedure on what I feel is the best way to perform this installation.
This walkthrough has been tested on systems running Redhat 9, RHEL 4, and CentOS 4.5 and it may also work on other distributions and versions. Our servers also run cPanel 11, but this is in no way required in order to install ffMPEG. I assume at this point that you have root access and that yum (or another similar package manager) is installed.
ffMPEG commonly consists of and includes the following software:
- Essential / MPlayer
- FLVtool2 (Requires a Ruby Core)
- LAME MP3 Encoder
- php-ffMPEG
- ffMPEG
- libOgg
- libvorbis
To start out, enter into a temporary source directory and download all the binaries:
cd /usr/src wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2 wget http://www4.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc2.tar.bz2 wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
*These are the latest stable versions at the time this article was written. If you are unable to download any of the above, you’ll need to visit the distributor’s site and download the latest stable version available.
Now extract everything:
bunzip2 essential-20061022.tar.bz2; tar xvf essential-20061022.tar tar zxvf flvtool2-1.0.6.tgz tar zxvf lame-3.97.tar.gz bunzip2 ffmpeg-php-0.5.0.tbz2; tar xvf ffmpeg-php-0.5.0.tar bunzip2 MPlayer-1.0rc2.tar.bz2 ; tar -xvf MPlayer-1.0rc2.tar
Create and import the Codecs directory:
mkdir /usr/local/lib/codecs/ mv essential-20061022/* /usr/local/lib/codecs/ chmod -Rf 755 /usr/local/lib/codecs/
Install Subversion and Ruby
yum install subversion yum install ruby (If you're on cPanel you can alternatively use /scripts/installruby) yum install ncurses-devel
Get ffMPEG and MPlayer from SVN:
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
Install LAME:
cd /usr/src/lame-3.97 ./configure && make && make install
Install libOgg and libVorbis:
yum install libogg.i386 yum install libvorbis.i386 yum install libvorbis-devel.i386
Install flvtool2
cd /usr/src/flvtool2-1.0.6/ ruby setup.rb config ruby setup.rb setup ruby setup.rb install
Install MPlayer:
cd /usr/src/MPlayer-1.0rc2 ./configure && make && make install
Install ffMPEG:
cd /usr/src/ffmpeg/ ./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared make && make install
This is the typical configure line that I use, but you can customize this to what you need. For available configure options, type ./configure –help. Your custom configuration may require the installation of additional software on the server.
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50 ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51 ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49 ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0 ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
You may get an error about a library path not being found, if so, run
export LD_LIBRARY_PATH=/usr/local/lib
If this is being installed on a dedicated server, you might also get an error about the /tmp directory not be executable, which is common when installing on a dedicated server with a separate /tmp partition mounted noexec. In this case, you will need to create a tmp dir in the ffmpeg folder and use that as the tmp disk for now:
mkdir tmp chmod 777 tmp export TMPDIR=./tmp
Then run the configure command and set the TMPDIR variable back.
export TMPDIR=/tmp
Install ffMPEG-php
cd /usr/src/ffmpeg-php-0.5.0/ phpize ./configure && make && make install
ln -s /usr/local/bin/ffmpeg /usr/bin/ffmpeg ln -s /usr/local/bin/mplayer /usr/bin/mplayer
When the installation is complete, it will give you a long path to the shared libraries. This needs to be copied to the php.ini as so:
[ffmpeg] extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so
or in most cases where the extension_dir variable is set, just do:
extension="/ffmpeg.so"
The ‘no-debug-non-zts-xxxxxxxx’ directory will be the one provided during installation. When this is done, restart Apache and check that the module is loaded in PHP:
/etc/init.d/httpd restart php -r 'phpinfo();' | grep ffmpeg
Look for this:
ffmpeg fmpeg support (ffmpeg-php) => enabled ffmpeg-php version => 0.5.0 ffmpeg.allow_persistent => 0 => 0
If you only get output for the ‘PWD’ variables, make sure that the extension_dir path is correct in the phpinfo file. Sometimes there are two specified, and if that is the case then the incorrect one should be commented out.
Test out ffmpeg for errors just by typing ffmpeg at the command line. The most common error is:
ffmpeg: error while loading shared libraries: libavformat.so.51: cannot open...
To correct this, edit /etc/ld.so.conf and add the line
/usr/local/lib
then save and exit.
Now run this command to reload the library cache:
ldconfig -v
You’re all done…enjoy!
Related posts:












[...] Source: v-nessa.net [...]
Thanks a lot for your tutorial! I performed the installation on a Debian Etch server and had to change some commands, but that was really easy to find out.
Again, thank you!
- Jérôme
It’s a bit simpler on debian/ubuntu:
sudo apt-get install lame libvorbisidec1 ruby mplayer ffmpeg
the only thing you need to install manually is flvtool2 which can be done via the steps you detailed:
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
tar zxvf flvtool2-1.0.6.tgz
cd flvtool2-1.0.6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
Holy crap, thank you so much.
Very detailed… Wish I read past the initial ./configure… instructions for ffmpeg rather than spending 10 minutes setting up the DAG rpm repositories…
Thanks
hi, great guide, but I get this error
checking for ffmpeg headers… configure: error: ffmpeg headers not found. Make sure you’ve built ffmpeg as shared libs using the –enable-shared option
I have used every single line from top to bottom in this guide, but when i got to the
cd /usr/src/ffmpeg-php-0.5.0/
phpize
./configure && make && make install
i got the above error,
any help would be greatly appreciated
./configure –enable-libmp3lame –enable-libvorbis –disable-mmx –enable-shared
I know it doesn’t come up well in the post, but make sure you’re using double dashes before each option first.
What is are the errors right before the error that you posted? Usually it’ll say that something is missing, then give you the ‘ffmpeg headers no found’ error. ..possible something about libav*
Hi!
Thanks for the reply,
I did use double dashes when installing the ffmpeg and used the –enable-shared option,
however when I reached the ffmpeg-php installation it said that ffmpeg hearder were not found.
the message before the error was like this:
checking for gawk… gawk
checking for ffmpeg support… yes, shared
checking for ffmpeg headers… configure: error: ffmeg headers not found. Make sure you’ve bult ffmpeg as shared libs using the –enable-shared option
after that the root console appears and nothing is being installed.
I followed exactly a a line by line on your post, but could not proceed after that error,
I have fedora 8, Apache, php5, mysql, phpmyadmin installed on the system and it is still fresh, nothing else is installed.
Would you recommend installing ffmped before mysql or apache or any other option? Or should i choose another linux distro?
I have been reinstalling the system for 5-7 times already and it just doesn’t work
Thanks very much for your help!
hi,
im trying your tutorial. so far it is the best one i have seen. im looking to offer this as a service to the customers at my site hosty.net. im following your tutorial and i get all the way to installing ffmpeg-php and i can’t seem to get it.
i get an error saying ffmpeg headers not found and that i should build it with the –enable-shared option.
my problem is have done this. im fairly certian that it built without error……how do i fix this?
kevin
both of you — look at these:
http://groups.google.com/group/ffmpeg-php/browse_thread/thread/7902bd06430ad75c/6368262cfd139604#6368262cfd139604
http://www.nabble.com/FFmpeg-include-files-location-td15459307.html
For the ffmpeg-php one, did you compile PHP from source or from yum/rpm? If you did it from RPM you may have to use the ffmpeg-php rpm instead of compiling it from source.
It may be centered more around Fedora. All of our servers use CentOS which in my opinion is better hosting platform.
alright guys, I was finally able to see this issue firsthand on one of our customer’s servers. When you run ‘ffmpeg -v’ do you get any errors?
Not sure if this is an error:
[root@localhost ffmpeg-php-0.5.0]# ffmpeg -v
FFmpeg version SVN-r12397, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: –enable-libmp3lame –disable-mmx –enable-shared
libavutil version: 49.6.0
libavcodec version: 51.51.0
libavformat version: 52.9.0
libavdevice version: 52.0.0
built on Mar 10 2008 03:48:19, gcc: 4.1.2 20070626 (Red Hat 4.1.2-14)
ffmpeg: missing argument for option ‘-v’
[root@localhost ffmpeg-php-0.5.0]#
^under Cent 5.1. Where to snag an RPM that fixes this?
sorry, it’s “ffmpeg -version”
Nessa,
thank you so much for the fix from google groups it helped indeed,
and I was able to get this thing running,
I switched to CentOS 5 and fixed headers problem by placing them in the appropriate folder and everything worked out,
ffmpeg -version did not return any errors, except showing the configuration and version
thanks again!!!
[root@localhost ffmpeg]# ffmpeg -version
ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory
[root@localhost ffmpeg]#
What’s strange is that everything appeared to compile properly. I also got ffmpeg-php to ‘make’/'make test’ yesterday (with a few failed tests):
ffmpeg getAudioBitRate test [tests/getAudioBitRate.phpt]
ffmpeg getAudioSampleRate test [tests/getAudioSampleRate.phpt]
ffmpeg getID3Info() test [tests/getID3Info.phpt]
ffmpeg getVideoBitRate test [tests/getVideoBitRate.phpt]
ffmpeg persistent movie test [tests/persistentMovie.phpt]
by symlinking the .h’s generated by ffmpeg under /usr/local/lib/whatever/ to /usr/local/lib, although as your google URL rightfully points out, modifying the CC line would’ve done just fine too. Thank goodness this client wrote me back and said they don’t need ffmpeg-php, only ffmpeg, and are knowledgeable enough to fix anything that might be borken.
@Nessa: I would be remiss if I didn’t point out that you’d be downright cute if you didn’t have that nasty metal thing in your face.
The tip about running ldconfig just helped me a whole bunch. Just wanted to say thanks!
–
Aaron
sorry, but maybe you can help me with that? I cant install some libraries under debian.. and ffmpeg is not working.
swswsw:~# ffmpeg -v
ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory
Plz, help… I was searching for a solution 2 nights…
thanks, Val.
edit /etc/ld.so.conf and add the line
/usr/local/lib
then save and exit.
Now run this command to reload the library cache:
ldconfig -v
V,
Thank you for your informative post. While most of this information can be found anywhere, your’s was the only one that pointed me to the google groups. You might consider updating your posting to include verifying that /usr/local/includes/ffmpeg exists after compiling ffmpeg but before compiling ffmpeg-php
Thanks a million!@
[...] 7th 2008 6:39pm [-] From: v-nessa.net [...]
Thank You!!!
Great tutorial! I have started to learn Linux one week ago, but reading your tutorial + Q&A solved all problems I had installing FFMPEG. Thanks!
Hi there!
I have the following error, and I do not know how to solve it:
[root@lin7 ffmpeg-php-0.5.0]# php -i | grep ffmpeg
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/modules/ffmpeg.so’ – /usr/lib/php/modules/ffmpeg.so: undefined symbol: le_ffmpeg_frame in Unknown on line 0
PWD => /usr/src/ffmpeg-php-0.5.0
_SERVER["PWD"] => /usr/src/ffmpeg-php-0.5.0
_ENV["PWD"] => /usr/src/ffmpeg-php-0.5.0
Any idea?
Thanks in advance.
J. Pablo.
Hello there,
Great tutorial I must say! I praise God for it because I was searching for answers all day long and they were here!
I have one more problem. In the phpinfo() the entries are only ‘PWD’ variables and the extension path is the same… What should I do now?
Thank you.
Hello,
when i typed svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
it is showing command not found
What could be the reason behind this?
please help me out on this.
And what ever you mentioned in the complete guide, is it applicable to all versions of red hat?
This is because you don’t have subversion installed – one of the earlier steps says:
yum install subversion
This procedure has been tested on Redhat 9 and Centos 3/4/5, so I know that it at least works on those systems.
Thanks a bunch. This is absolutely the best guide for installing ffmpeg and related software. I followed the instructions and were able to installed every thing on a SuSE 11.0 box.
However, should I be concerned about the following failed tests when doing a “make test” in ffmpeg-php:
Number of tests : 29 21
Tests skipped : 8 ( 27.6%) ——–
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 21 ( 72.4%) (100.0%)
Tests passed : 0 ( 0.0%) ( 0.0%)
———————————————————————
Time taken : 5 seconds
=====================================================================
=====================================================================
FAILED TEST SUMMARY
———————————————————————
ffmpeg getAudioBitRate test [tests/getAudioBitRate.phpt]
ffmpeg getAudioChannels test [tests/getAudioChannels.phpt]
ffmpeg getAudioCodec test [tests/getAudioCodec.phpt]
ffmpeg getAudioSampleRate test [tests/getAudioSampleRate.phpt]
ffmpeg getAudioStreamId test [tests/getAudioStreamId.phpt]
ffmpeg getBitRate test [tests/getBitRate.phpt]
ffmpeg getDuration test [tests/getDuration.phpt]
ffmpeg getFileName test [tests/getFileName.phpt]
ffmpeg getFrameCount test [tests/getFrameCount.phpt]
ffmpeg getFrameHeight test [tests/getFrameHeight.phpt]
ffmpeg getFrameNumber test [tests/getFrameNumber.phpt]
ffmpeg getFrameRate test [tests/getFrameRate.phpt]
ffmpeg getFrameWidth test [tests/getFrameWidth.phpt]
ffmpeg getID3Info() test [tests/getID3Info.phpt]
ffmpeg getPixelAspectRatio test [tests/getPixelAspectRatio.phpt]
ffmpeg getPixelFormat test [tests/getPixelFormat.phpt]
ffmpeg getVideoBitRate test [tests/getVideoBitRate.phpt]
ffmpeg getVideoCodec test [tests/getVideoCodec.phpt]
ffmpeg getVideoStreamId test [tests/getVideoStreamId.phpt]
ffmpeg hasAudio test [tests/hasAudio.phpt]
ffmpeg persistent movie test [tests/persistentMovie.phpt]
Hey, thank you so much,
very detail and usefull
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?
The [pretty much] Complete Guide to Installing ffMPEG and Audio ……
[...]… of the above, you’ll need … server, you might also get an error about the /tmp directory not be … And what ever you mentioned in the complete guide, is it applicable to all …[...]…