I cannot seem to configure OpenCV to link to a non-/usr/lib set of FFMPEG
libraries.
My LD_LIBRARY_PATH contains a direct link to the folder for the custom install of FFMPEG:
LD_LIBRARY_PATH=/pathto/ffmpeg-0.10.2/lib
Additionally, I've configured pkgconfig as:
PKG_CONFIG_PATH=/samepathto/ffmpeg-0.10.2/lib/pkgconfig/
Within CMake however I cannot find any setting for path to FFMPEG - either in basic or custom. The only setting related to FFMPEG appears to be WITH_FFMPEG
type setting (set to ON).
I can build OpenCV but it seems to link to the system libraries for libavcodec - this causes a conflict as the system libraries are version .52 and the version in my install of FFMPEG
are .53. Linking an app on a machine without the same system libraries seems to NOT link to my custom install of OpenCV (specifically the libavcodec) because of this (I'm installing these libraries on a shared network folder).
I am not sure if my problem is with building and linking to the wrong version of FFMPEG or if it is something with my environment after building (and then linking to the wrong ffmpeg).
I am building on Linux, Redhat 6, OpenCV 2.3.1.
Something like
export LD_LIBRARY_PATH=/ffmpeg_install_path/lib/
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/ffmpeg_install_path/lib/pkgconfig
export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR:/ffmpeg_install_path/lib/
should work. At least it works for OpenCV 2.4.x on my Ubuntu.
It's years after the question was asked, but I recently ran into the kinds of issues described in this question! I'd like to add my input.
First: I only built the static ffmpeg libraries (for reasons), which the opencv build process is somewhat hostile towards. There have been posts by opencv developers stating that they don't support an opencv build against static ffmpeg libraries, but my thinking was "what if you're also building static opencv libraries? Certainly that should be supported?"
And the answer is yes, you can compile static opencv libraries against static ffmpeg libraries! I did this with opencv 4.1.1 against ffmpeg 4.2. I had to use the following cmake options:
cmake3 \
-D BUILD_opencv_apps=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_SHARED_LIBS=OFF \
-D WITH_FFMPEG=ON \
-D OPENCV_FFMPEG_SKIP_BUILD_CHECK=ON \
These options result in a set of opencv static libraries that include whatever ffmpeg static libraries that you've also built, assuming your PKG_CONFIG_PATH is setup to correctly find those libraries (or if you've installed them to some default system location).
Q/A:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With