2012-01-27 05:13:08 +04:00
|
|
|
# - Try to find FFmpeg
|
|
|
|
# Using Pkg-config if available for path
|
|
|
|
#
|
|
|
|
# FFMPEG_FOUND - all required ffmpeg components found on system
|
|
|
|
# FFMPEG_INCLUDE_DIRS - combined include directories
|
|
|
|
# FFMPEG_LIBRARIES - combined libraries to link
|
|
|
|
|
2012-09-26 17:45:30 +04:00
|
|
|
set(REQUIRED_AVCODEC_VERSION 0.8)
|
|
|
|
set(REQUIRED_AVCODEC_API_VERSION 53.25.0)
|
|
|
|
|
2012-01-27 05:13:08 +04:00
|
|
|
include(FindPkgConfig)
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (PKG_CONFIG_FOUND)
|
2012-01-27 05:13:08 +04:00
|
|
|
pkg_check_modules(AVCODEC libavcodec)
|
|
|
|
pkg_check_modules(AVUTIL libavutil)
|
2018-10-04 09:57:54 +03:00
|
|
|
pkg_check_modules(AVRESAMPLE libavresample)
|
2018-10-04 04:56:20 +03:00
|
|
|
pkg_check_modules(SWRESAMPLE libswresample)
|
2018-02-20 14:15:30 +03:00
|
|
|
endif(PKG_CONFIG_FOUND)
|
2012-01-27 05:13:08 +04:00
|
|
|
|
|
|
|
# avcodec
|
2012-02-29 09:30:03 +04:00
|
|
|
find_path(AVCODEC_INCLUDE_DIR libavcodec/avcodec.h PATHS ${AVCODEC_INCLUDE_DIRS})
|
2020-02-27 18:21:29 +03:00
|
|
|
find_library(AVCODEC_LIBRARY avcodec PATHS ${AVCODEC_LIBRARY_DIRS})
|
2012-01-27 05:13:08 +04:00
|
|
|
|
|
|
|
# avutil
|
2012-02-29 09:30:03 +04:00
|
|
|
find_path(AVUTIL_INCLUDE_DIR libavutil/avutil.h PATHS ${AVUTIL_INCLUDE_DIRS})
|
2012-01-27 05:13:08 +04:00
|
|
|
find_library(AVUTIL_LIBRARY avutil PATHS ${AVUTIL_LIBRARY_DIRS})
|
|
|
|
|
2018-10-04 04:56:20 +03:00
|
|
|
# swresample
|
|
|
|
find_path(SWRESAMPLE_INCLUDE_DIR libswresample/swresample.h PATHS ${SWRESAMPLE_INCLUDE_DIRS})
|
2021-07-20 11:57:28 +03:00
|
|
|
find_library(SWRESAMPLE_LIBRARY NAMES swresample swresample-3 PATHS ${SWRESAMPLE_LIBRARY_DIRS})
|
|
|
|
|
|
|
|
if (SWRESAMPLE_INCLUDE_DIR AND SWRESAMPLE_LIBRARY)
|
|
|
|
set(SWRESAMPLE_FOUND ON)
|
|
|
|
endif()
|
2018-02-20 14:15:30 +03:00
|
|
|
|
2018-10-04 09:57:54 +03:00
|
|
|
# avresample
|
|
|
|
find_path(AVRESAMPLE_INCLUDE_DIR libavresample/avresample.h PATHS ${AVRESAMPLE_INCLUDE_DIRS})
|
|
|
|
find_library(AVRESAMPLE_LIBRARY avresample PATHS ${AVRESAMPLE_LIBRARY_DIRS})
|
2018-02-20 14:15:30 +03:00
|
|
|
|
2021-07-20 11:57:28 +03:00
|
|
|
if (AVRESAMPLE_INCLUDE_DIR AND AVRESAMPLE_LIBRARY)
|
|
|
|
set(AVRESAMPLE_FOUND ON)
|
|
|
|
endif()
|
|
|
|
|
2018-10-04 09:57:54 +03:00
|
|
|
if (AVCODEC_INCLUDE_DIR AND AVCODEC_LIBRARY)
|
2012-01-27 05:13:08 +04:00
|
|
|
set(AVCODEC_FOUND TRUE)
|
2018-10-04 09:57:54 +03:00
|
|
|
endif(AVCODEC_INCLUDE_DIR AND AVCODEC_LIBRARY)
|
2012-01-27 05:13:08 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (AVUTIL_INCLUDE_DIR AND AVUTIL_LIBRARY)
|
2012-01-27 05:13:08 +04:00
|
|
|
set(AVUTIL_FOUND TRUE)
|
2018-02-20 14:15:30 +03:00
|
|
|
endif(AVUTIL_INCLUDE_DIR AND AVUTIL_LIBRARY)
|
2012-01-27 05:13:08 +04:00
|
|
|
|
2012-11-03 03:27:01 +04:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2018-10-04 09:57:54 +03:00
|
|
|
if (SWRESAMPLE_FOUND)
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFmpeg DEFAULT_MSG AVUTIL_FOUND AVCODEC_FOUND SWRESAMPLE_FOUND)
|
|
|
|
else()
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFmpeg DEFAULT_MSG AVUTIL_FOUND AVCODEC_FOUND AVRESAMPLE_FOUND)
|
|
|
|
endif()
|
2012-01-27 05:13:08 +04:00
|
|
|
|
2012-09-26 17:45:30 +04:00
|
|
|
if (AVCODEC_VERSION)
|
|
|
|
if (${AVCODEC_VERSION} VERSION_LESS ${REQUIRED_AVCODEC_API_VERSION})
|
2018-02-20 14:15:30 +03:00
|
|
|
message(FATAL_ERROR
|
|
|
|
"libavcodec version >= ${REQUIRED_AVCODEC_VERSION} (API >= ${REQUIRED_AVCODEC_API_VERSION}) is required")
|
2012-09-26 17:45:30 +04:00
|
|
|
endif()
|
2018-02-20 14:15:30 +03:00
|
|
|
else(AVCODEC_VERSION)
|
|
|
|
message("Note: To build libavcodec version >= ${REQUIRED_AVCODEC_VERSION} (API >= ${REQUIRED_AVCODEC_API_VERSION}) is required")
|
|
|
|
endif(AVCODEC_VERSION)
|
2012-09-26 17:45:30 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (FFMPEG_FOUND)
|
2018-10-04 09:57:54 +03:00
|
|
|
if (SWRESAMPLE_FOUND)
|
|
|
|
set(FFMPEG_INCLUDE_DIRS ${AVCODEC_INCLUDE_DIR} ${AVUTIL_INCLUDE_DIR} ${SWRESAMPLE_INCLUDE_DIR})
|
|
|
|
set(FFMPEG_LIBRARIES ${AVCODEC_LIBRARY} ${AVUTIL_LIBRARY} ${SWRESAMPLE_LIBRARY})
|
|
|
|
elseif (AVRESAMPLE_FOUND)
|
|
|
|
set(FFMPEG_INCLUDE_DIRS ${AVCODEC_INCLUDE_DIR} ${AVUTIL_INCLUDE_DIR} ${AVRESAMPLE_INCLUDE_DIR})
|
|
|
|
set(FFMPEG_LIBRARIES ${AVCODEC_LIBRARY} ${AVUTIL_LIBRARY} ${AVRESAMPLE_LIBRARY})
|
|
|
|
endif()
|
2018-02-20 14:15:30 +03:00
|
|
|
endif(FFMPEG_FOUND)
|
2012-01-27 05:13:08 +04:00
|
|
|
|
2012-11-03 03:27:01 +04:00
|
|
|
mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES)
|