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
In addition to Andrey's answer:
I found that (for my configuration) the opencv 4.1.1 build-system did not correctly add the ffmpeg library path (though it did set the include directory.) My workaround was to supply these paths with the following cmake build arguments:
-DCMAKE_SHARED_LINKER_FLAGS=" -Wl,-rpath-link $FFMPEG_LIBDIR -L$FFMPEG_LIBDIR"
-DCMAKE_MODULE_LINKER_FLAGS=" -Wl,-rpath-link $FFMPEG_LIBDIR -L$FFMPEG_LIBDIR"
-DCMAKE_EXE_LINKER_FLAGS=" -Wl,-rpath-link $FFMPEG_LIBDIR -L$FFMPEG_LIBDIR"
where $FFMPEG_LIBDIR is the path to your ffmpeg library binaries. It was necessary to use the -rpath-link otpion, because the build system didn't supply all necessary ffmpeg library arguments for my ffmpeg installation.
Examining modules/videoio/cmake/detect_ffmpeg.cmake, it looks like FFMPEG can also be coerced to accept user supplied library paths by specifying:
-DHAVE_FFMPEG=ON
-DFFMPEG_INCLUDE_DIRS=(path to your ffmpeg include directories)
-DFFMPEG_LIBRARIES=(list of ffmpeg libraries, e.g. -lavcodec)
But if we perform this method, the build system displays "YES" to FFMPEG, but "NO" to the individual modules (didn't debug further.)
Some users will find that they may need to supply the --sysroot linker argument in the linker flags, or specify -DCMAKE_SYSROOT as a build argument
Hope this helps someone :)