Install OpenCV with ffmpeg
Written by Petar Jercic   

Recently I had a lot of trouble installing OpenCV library which uses ffmpeg for dealing with video.
Now I have been all around the forums compiling, with this and that option, recompiling, adding my own code in the libs and so on... But nothing seemed to work. The system that I am installing is Debian.


Since the last version of Ubuntu 9.10 OpenCV team has made a very detailed instructions for compiling and installing ffmpeg and OpenCV on Debian system. Detailed instructions can be seen at this address:

ffmpeg http://opencv.willowgarage.com/wiki/FFMPEG
OpenCV http://opencv.willowgarage.com/wiki/InstallGuide

If it happens that some packages and libs do not exist for a particular installation, for example libfaac-dev libfaad-dev libmp3lame-dev or at the ffmpeg configuration --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libx264 --enable-libxvid --enable-x11grab merely ignore and drop them from command because they are not absolutely necessary.
If the said installation fails (nonexisting tools for a particular distribution, the lack of packages, build tools, etc. ..), use the procedure listed below. The procedure is the same but simpler and more adapted to manual compilation and installation.


In short, it is necessary to install ffmpeg and OpenCV libs. To perform these actions you need to be logged in as root

0. Preparing for installation

Remove old and unused libs

apt-get autoremove
Install lib to draw windows and codecs to work with video

apt-get install libgtk2.0-dev
apt-get install gstreamer0.10-ffmpeg

1. Set up SVN

If we want to checkout fresh lib versions of their online repository, SVN application must be installed

apt-get update
apt-get install subversion

2. Get the installation libs

Get the ffmpeg and OpenCV libs for installation. We can are FTP them, download them from the official site or obtain them from SVN repository

svn co https://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk opencvlibrary

3. Installation of building tools

Install the latest building tools, if the tools are already updated to new versions then the command will do nothing.

apt-get install build-essential

4. Compiling and installing fame

Together with the OpenCV BUG tracking team together we concluded that is best when ffmpeg is installed with the help of apt-get tool that is tested Debian (.deb) packages.

apt-get install ffmpeg libavformat-dev libswscale-dev
This command installs ffmpeg in /usr path.
Notify the system that we have new libs

ldconfig

5. Compiling and installing OpenCV


./configure --prefix=/usr
make
make install
ldconfig -v
And finally it worked, happy hacki... coding I mean.

Comments (0)