Skip to content

Commit 458bd16

Browse files
authored
Merge pull request opencv#18146 from VadimLevin:dev/vlevin/ffmpeg-remove-obsolte-versions-support
Remove obsolete FFMPEG versions support * refactor: removed obsolete FFMPEG version support - Oldest available version via official FFMPEG repository mirror has tag v.0.5 LIBAVFORMAT version for this tag is 52.31.0 * refactor: prefer std::min function to MIN macro * refactor: use appropriate macro instead of manual version calculation * refactor: remove macros for versions prior 0.5.15 release * refactor: remove libavcodec macros for versions < 54.35.1 (default to Ubuntu 14.04) * refactor: remove libavformat macro for versions < 54.20.4 (default ubuntu 14.04) * refactor: remove libavutil macro for versions < 52.3.0 (default ubuntu 14.04) * refactor: remove missed macros for libavcodec and libavformat * refactor: remove unused _opencv_ffmpeg_free function * build: add FFMPEG libraries versions checks - Add verbose message about what FFMPEG libraries are missing. - Add minimal versions check set to libav 9.20 release (default ubuntu 14.04) and FFMPEG 1.1.16 release. If the check is failed CMake produces user-friendly message instead of build error. * fix: libavcodec version guard for AVDISCARD_NONINTRA * fix: libav check of libavcodec version guard for AVDISCARD_NONINTRA * fix: version check for AV_CODEC_FLAG_GLOBAL_HEADER * fix: missing FFMPEG libraries output
1 parent e5e08ec commit 458bd16

File tree

2 files changed

+71
-281
lines changed

2 files changed

+71
-281
lines changed

modules/videoio/cmake/detect_ffmpeg.cmake

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,56 @@ if(NOT HAVE_FFMPEG AND WIN32 AND NOT ARM AND NOT OPENCV_FFMPEG_SKIP_DOWNLOAD)
2424
endif()
2525
endif()
2626

27+
set(_required_ffmpeg_libraries libavcodec libavformat libavutil libswscale)
28+
set(_used_ffmpeg_libraries ${_required_ffmpeg_libraries})
2729
if(NOT HAVE_FFMPEG AND PKG_CONFIG_FOUND)
2830
ocv_check_modules(FFMPEG libavcodec libavformat libavutil libswscale)
2931
if(FFMPEG_FOUND)
3032
ocv_check_modules(FFMPEG_libavresample libavresample) # optional
3133
if(FFMPEG_libavresample_FOUND)
3234
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_libavresample_LIBRARIES})
35+
list(APPEND _used_ffmpeg_libraries libavresample)
3336
endif()
3437
set(HAVE_FFMPEG TRUE)
38+
else()
39+
set(_missing_ffmpeg_libraries "")
40+
foreach (ffmpeg_lib ${_required_ffmpeg_libraries})
41+
if (NOT FFMPEG_${ffmpeg_lib}_FOUND)
42+
list(APPEND _missing_ffmpeg_libraries ${ffmpeg_lib})
43+
endif()
44+
endforeach ()
45+
message(STATUS "FFMPEG is disabled. Required libraries: ${_required_ffmpeg_libraries}."
46+
" Missing libraries: ${_missing_ffmpeg_libraries}")
47+
unset(_missing_ffmpeg_libraries)
3548
endif()
3649
endif()
3750

51+
#=================================
52+
# Versions check.
53+
if(HAVE_FFMPEG AND NOT HAVE_FFMPEG_WRAPPER)
54+
set(_min_libavcodec_version 54.35.1)
55+
set(_min_libavformat_version 54.20.4)
56+
set(_min_libavutil_version 52.3.0)
57+
set(_min_libswscale_version 2.1.1)
58+
set(_min_libavresample_version 1.0.1)
59+
foreach(ffmpeg_lib ${_used_ffmpeg_libraries})
60+
if(FFMPEG_${ffmpeg_lib}_VERSION VERSION_LESS _min_${ffmpeg_lib}_version)
61+
message(STATUS "FFMPEG is disabled. Can't find suitable ${ffmpeg_lib} library"
62+
" (minimal ${_min_${ffmpeg_lib}_version}, found ${FFMPEG_${ffmpeg_lib}_VERSION}).")
63+
set(HAVE_FFMPEG FALSE)
64+
endif()
65+
endforeach()
66+
if(NOT HAVE_FFMPEG)
67+
message(STATUS "FFMPEG libraries version check failed "
68+
"(minimal libav release 9.20, minimal FFMPEG release 1.1.16).")
69+
endif()
70+
unset(_min_libavcodec_version)
71+
unset(_min_libavformat_version)
72+
unset(_min_libavutil_version)
73+
unset(_min_libswscale_version)
74+
unset(_min_libavresample_version)
75+
endif()
76+
3877
#==================================
3978

4079
if(HAVE_FFMPEG AND NOT HAVE_FFMPEG_WRAPPER AND NOT OPENCV_FFMPEG_SKIP_BUILD_CHECK)
@@ -53,6 +92,8 @@ if(HAVE_FFMPEG AND NOT HAVE_FFMPEG_WRAPPER AND NOT OPENCV_FFMPEG_SKIP_BUILD_CHEC
5392
endif()
5493

5594
#==================================
95+
unset(_required_ffmpeg_libraries)
96+
unset(_used_ffmpeg_libraries)
5697

5798
if(HAVE_FFMPEG_WRAPPER)
5899
ocv_add_external_target(ffmpeg "" "" "HAVE_FFMPEG_WRAPPER")

0 commit comments

Comments
 (0)