From ab40630ff4b98ecc531cbb1d8f7a8c9f8a94f456 Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Sun, 1 Feb 2015 15:51:33 -0500 Subject: [PATCH 1/5] Use the CMake find_library command to find the FFmpeg libraries. --- cmake/OpenCVFindLibsVideo.cmake | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index ba2a3f716c..7e5bcff560 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -229,28 +229,27 @@ if(WITH_FFMPEG) if(FFMPEG_INCLUDE_DIR) set(HAVE_GENTOO_FFMPEG TRUE) set(FFMPEG_LIB_DIR "${FFMPEG_INCLUDE_DIR}/../lib" CACHE PATH "Full path of FFMPEG library directory") - if(EXISTS "${FFMPEG_LIB_DIR}/libavcodec.a") - set(HAVE_FFMPEG_CODEC 1) - set(ALIASOF_libavcodec_VERSION "Unknown") - if(EXISTS "${FFMPEG_LIB_DIR}/libavformat.a") - set(HAVE_FFMPEG_FORMAT 1) - set(ALIASOF_libavformat_VERSION "Unknown") - if(EXISTS "${FFMPEG_LIB_DIR}/libavutil.a") - set(HAVE_FFMPEG_UTIL 1) - set(ALIASOF_libavutil_VERSION "Unknown") - if(EXISTS "${FFMPEG_LIB_DIR}/libswscale.a") - set(HAVE_FFMPEG_SWSCALE 1) - set(ALIASOF_libswscale_VERSION "Unknown") - set(HAVE_FFMPEG 1) - endif() - endif() - endif() + find_library(FFMPEG_CODEC_LIB + NAMES "libavcodec.a" "libavcodec.dylib" + PATHS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_FORMAT_LIB + NAMES "libavformat.a" "libavformat.dylib" + PATHS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_UTIL_LIB + NAMES "libavutil.a" "libavutil.dylib" + PATHS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_SWSCALE_LIB + NAMES "libswscale.a" "libswscale.dylib" + PATHS "${FFMPEG_LIB_DIR}") + if(FFMPEG_CODEC_LIB AND FFMPEG_FORMAT_LIB AND + FFMPEG_UTIL_LIB AND FFMPEG_SWSCALE_LIB) + set(HAVE_FFMPEG 1) endif() endif(FFMPEG_INCLUDE_DIR) if(HAVE_FFMPEG) - set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} "${FFMPEG_LIB_DIR}/libavcodec.a" - "${FFMPEG_LIB_DIR}/libavformat.a" "${FFMPEG_LIB_DIR}/libavutil.a" - "${FFMPEG_LIB_DIR}/libswscale.a") + set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} + ${FFMPEG_CODEC_LIB} ${FFMPEG_FORMAT_LIB} + ${FFMPEG_UTIL_LIB} ${FFMPEG_SWSCALE_LIB}) ocv_include_directories(${FFMPEG_INCLUDE_DIR}) endif() endif(APPLE) From a1cc9380e59ced52603690bd48ddf6e5656e3503 Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Mon, 2 Feb 2015 11:54:09 -0500 Subject: [PATCH 2/5] Correct the new find_library commands. Thanks to SpecLad. --- cmake/OpenCVFindLibsVideo.cmake | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 7e5bcff560..9a712203f4 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -229,18 +229,10 @@ if(WITH_FFMPEG) if(FFMPEG_INCLUDE_DIR) set(HAVE_GENTOO_FFMPEG TRUE) set(FFMPEG_LIB_DIR "${FFMPEG_INCLUDE_DIR}/../lib" CACHE PATH "Full path of FFMPEG library directory") - find_library(FFMPEG_CODEC_LIB - NAMES "libavcodec.a" "libavcodec.dylib" - PATHS "${FFMPEG_LIB_DIR}") - find_library(FFMPEG_FORMAT_LIB - NAMES "libavformat.a" "libavformat.dylib" - PATHS "${FFMPEG_LIB_DIR}") - find_library(FFMPEG_UTIL_LIB - NAMES "libavutil.a" "libavutil.dylib" - PATHS "${FFMPEG_LIB_DIR}") - find_library(FFMPEG_SWSCALE_LIB - NAMES "libswscale.a" "libswscale.dylib" - PATHS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_CODEC_LIB "avcodec" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_FORMAT_LIB "avformat" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_UTIL_LIB "avutil" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_SWSCALE_LIB "swscale" HINTS "${FFMPEG_LIB_DIR}") if(FFMPEG_CODEC_LIB AND FFMPEG_FORMAT_LIB AND FFMPEG_UTIL_LIB AND FFMPEG_SWSCALE_LIB) set(HAVE_FFMPEG 1) From 98a157f589bfa03ce882bb836f23beacd7c7b815 Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Tue, 3 Feb 2015 23:12:50 -0500 Subject: [PATCH 3/5] Remove Apple-specific logic in finding the FFmpeg libraries. Thanks to SpecLad. --- cmake/OpenCVFindLibsVideo.cmake | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 9a712203f4..c0ca0a323a 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -218,10 +218,7 @@ if(WITH_FFMPEG) # Do an other trial FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib) endif() - endif(HAVE_FFMPEG) - endif() - - if(APPLE) + else() find_path(FFMPEG_INCLUDE_DIR "libavformat/avformat.h" PATHS /usr/local /usr /opt PATH_SUFFIXES include @@ -244,7 +241,8 @@ if(WITH_FFMPEG) ${FFMPEG_UTIL_LIB} ${FFMPEG_SWSCALE_LIB}) ocv_include_directories(${FFMPEG_INCLUDE_DIR}) endif() - endif(APPLE) + endif() + endif() endif(WITH_FFMPEG) # --- VideoInput/DirectShow --- From 8c68f1f6269ca39df2d8d5286915931b6aa4b63e Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Tue, 3 Feb 2015 23:17:43 -0500 Subject: [PATCH 4/5] Fix indentation of 98a157f5. --- cmake/OpenCVFindLibsVideo.cmake | 44 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index c0ca0a323a..1e2c8caab4 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -219,28 +219,28 @@ if(WITH_FFMPEG) FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib) endif() else() - find_path(FFMPEG_INCLUDE_DIR "libavformat/avformat.h" - PATHS /usr/local /usr /opt - PATH_SUFFIXES include - DOC "The path to FFMPEG headers") - if(FFMPEG_INCLUDE_DIR) - set(HAVE_GENTOO_FFMPEG TRUE) - set(FFMPEG_LIB_DIR "${FFMPEG_INCLUDE_DIR}/../lib" CACHE PATH "Full path of FFMPEG library directory") - find_library(FFMPEG_CODEC_LIB "avcodec" HINTS "${FFMPEG_LIB_DIR}") - find_library(FFMPEG_FORMAT_LIB "avformat" HINTS "${FFMPEG_LIB_DIR}") - find_library(FFMPEG_UTIL_LIB "avutil" HINTS "${FFMPEG_LIB_DIR}") - find_library(FFMPEG_SWSCALE_LIB "swscale" HINTS "${FFMPEG_LIB_DIR}") - if(FFMPEG_CODEC_LIB AND FFMPEG_FORMAT_LIB AND - FFMPEG_UTIL_LIB AND FFMPEG_SWSCALE_LIB) - set(HAVE_FFMPEG 1) - endif() - endif(FFMPEG_INCLUDE_DIR) - if(HAVE_FFMPEG) - set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} - ${FFMPEG_CODEC_LIB} ${FFMPEG_FORMAT_LIB} - ${FFMPEG_UTIL_LIB} ${FFMPEG_SWSCALE_LIB}) - ocv_include_directories(${FFMPEG_INCLUDE_DIR}) - endif() + find_path(FFMPEG_INCLUDE_DIR "libavformat/avformat.h" + PATHS /usr/local /usr /opt + PATH_SUFFIXES include + DOC "The path to FFMPEG headers") + if(FFMPEG_INCLUDE_DIR) + set(HAVE_GENTOO_FFMPEG TRUE) + set(FFMPEG_LIB_DIR "${FFMPEG_INCLUDE_DIR}/../lib" CACHE PATH "Full path of FFMPEG library directory") + find_library(FFMPEG_CODEC_LIB "avcodec" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_FORMAT_LIB "avformat" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_UTIL_LIB "avutil" HINTS "${FFMPEG_LIB_DIR}") + find_library(FFMPEG_SWSCALE_LIB "swscale" HINTS "${FFMPEG_LIB_DIR}") + if(FFMPEG_CODEC_LIB AND FFMPEG_FORMAT_LIB AND + FFMPEG_UTIL_LIB AND FFMPEG_SWSCALE_LIB) + set(HAVE_FFMPEG 1) + endif() + endif(FFMPEG_INCLUDE_DIR) + if(HAVE_FFMPEG) + set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} + ${FFMPEG_CODEC_LIB} ${FFMPEG_FORMAT_LIB} + ${FFMPEG_UTIL_LIB} ${FFMPEG_SWSCALE_LIB}) + ocv_include_directories(${FFMPEG_INCLUDE_DIR}) + endif(HAVE_FFMPEG) endif() endif() endif(WITH_FFMPEG) From c60fa84027ccddb0c1c2e5f9b355ceea6daf7a25 Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Wed, 4 Feb 2015 10:55:38 -0500 Subject: [PATCH 5/5] Add back the version variables removed in ab40630f. --- cmake/OpenCVFindLibsVideo.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 1e2c8caab4..6133d075f8 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -232,6 +232,10 @@ if(WITH_FFMPEG) find_library(FFMPEG_SWSCALE_LIB "swscale" HINTS "${FFMPEG_LIB_DIR}") if(FFMPEG_CODEC_LIB AND FFMPEG_FORMAT_LIB AND FFMPEG_UTIL_LIB AND FFMPEG_SWSCALE_LIB) + set(ALIASOF_libavcodec_VERSION "Unknown") + set(ALIASOF_libavformat_VERSION "Unknown") + set(ALIASOF_libavutil_VERSION "Unknown") + set(ALIASOF_libswscale_VERSION "Unknown") set(HAVE_FFMPEG 1) endif() endif(FFMPEG_INCLUDE_DIR)