Build OpenCV with Video Support on Ubuntu

jklontz edited this page Aug 21, 2013 · 1 revision

If you are experiencing issues decoding videos with OpenCV, your best bet may to be to rebuild x264 & ffmpeg from source.

Install Dependencies

$ sudo apt-get update
$ sudo apt-get install build-essential checkinstall libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg libgtk2.0-0 libgtk2.0-dev libjpeg62 libjpeg62-dev libv4l-dev

Download, build, and install latest x264

$ tar -xf ~/Downloads/last_stable_x264.tar.bz2
$ cd x264-snapshot-<version>-stable
$ ./configure --enable-shared --enable-pic
$ make
$ sudo make install

Download, build, and install latest ffmpeg

$ tar -xf ~/Downloads/ffmpeg-<version>
$ cd ffmpeg-<version>
$ ./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared --enable-pic
$ make
$ sudo make install

Rebuild & reinstall opencv

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.