Configure and build OpenCV for a custom installation of FFMPEG

I cannot configure OpenCV to reference a set of non-usr / lib libraries FFMPEG.

My LD_LIBRARY_PATH contains a direct link to the folder for the custom installation of FFMPEG:

LD_LIBRARY_PATH=/pathto/ffmpeg-0.10.2/lib

In addition, I configured pkgconfig as:

PKG_CONFIG_PATH=/samepathto/ffmpeg-0.10.2/lib/pkgconfig/

In CMake, however, I cannot find any settings for the path to FFMPEG - either mainly or in normal mode. The only setting related to FFMPEG is the type setting WITH_FFMPEG(set to ON).

I can create OpenCV, but it seems to refer to the system libraries for libavcodec - this causes a conflict, since the system libraries are version .52, and the version in my installation is FFMPEG-.53. Because of this, the connection of the application with the machine without the same system libraries is NOT associated with my custom OpenCV installation (in particular, libavcodec) (I install these libraries in a shared network folder).

I am not sure if my problem is building and linking to the wrong version of FFMPEG or if it is something to my environment after the build (and then link to the wrong ffmpeg).

I am working on Linux, Redhat 6, OpenCV 2.3.1.

+7
source share
3 answers

Sort of

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/

. , OpenCV 2.4.x Ubuntu.

+10

OpenCV 3.x ffmpeg 3.x

diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake
index 13b62ac..bab9df3 100644
--- a/cmake/OpenCVFindLibsVideo.cmake
+++ b/cmake/OpenCVFindLibsVideo.cmake
@@ -228,6 +228,12 @@ if(WITH_FFMPEG)
     if(FFMPEG_libavresample_FOUND)
       ocv_append_build_options(FFMPEG FFMPEG_libavresample)
     endif()
+   CHECK_MODULE(libavcodec HAVE_FFMPEG)
+   CHECK_MODULE(libavformat HAVE_FFMPEG)
+   CHECK_MODULE(libavutil HAVE_FFMPEG)
+   CHECK_MODULE(libswscale HAVE_FFMPEG)
+   CHECK_MODULE(libswresample HAVE_FFMPEG)
+   CHECK_MODULE(libavresample HAVE_FFMPEG)
     if(HAVE_FFMPEG)
       try_compile(__VALID_FFMPEG
           "${OpenCV_BINARY_DIR}"

script

#!/bin/bash

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/Applications/ffmpeg/lib
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/Applications/ffmpeg/lib/pkgconfig
export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR:$HOME/Applications/ffmpeg/lib

cmake \
    -D BUILD_EXAMPLES=ON \
    -D BUILD_TESTS=OFF \
    -D OPENCV_EXTRA_EXE_LINKER_FLAGS="-Wl,-rpath,$HOME/Applications/ffmpeg/lib" \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=$HOME/Applications/opencv \
    /path/to/opencv

, ffmpeg --enable-avresample.

+1

, , , ! .

-: ffmpeg ( ), opencv . opencv , opencv ffmpeg, : " , opencv? , ?"

- , opencv ffmpeg! opencv 4.1.1 ffmpeg 4.2. cmake:

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 \

opencv, ffmpeg, , , PKG_CONFIG_PATH ( - ).

Q/:

  • ?
    • opencv , , . , ; , - .
  • OPENCV_FFMPEG_SKIP_BUILD_CHECK?
    • ffmpeg cmake , , opencv. , , , ; , , . , , opencv , , , , , .
  • Python?
    • opencv python , Python.
  • , ?
    • .
0
source

All Articles