Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
3ae19907
Commit
3ae19907
authored
Dec 01, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7769 from alalek:cmake_ffmpeg_cleanup
parents
735f5a01
39ff8a0d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
108 additions
and
141 deletions
+108
-141
ffmpeg.cmake
3rdparty/ffmpeg/ffmpeg.cmake
+13
-0
CMakeLists.txt
CMakeLists.txt
+7
-8
OpenCVFindLibsVideo.cmake
cmake/OpenCVFindLibsVideo.cmake
+23
-67
OpenCVUtils.cmake
cmake/OpenCVUtils.cmake
+38
-0
ffmpeg_test.cpp
cmake/checks/ffmpeg_test.cpp
+24
-0
cvconfig.h.in
cmake/templates/cvconfig.h.in
+0
-6
cap_ffmpeg_impl.hpp
modules/videoio/src/cap_ffmpeg_impl.hpp
+2
-42
ffmpeg_codecs.hpp
modules/videoio/src/ffmpeg_codecs.hpp
+1
-18
No files found.
3rdparty/ffmpeg/ffmpeg.cmake
View file @
3ae19907
...
@@ -23,3 +23,16 @@ ocv_download(PACKAGE ffmpeg_version.cmake
...
@@ -23,3 +23,16 @@ ocv_download(PACKAGE ffmpeg_version.cmake
DESTINATION_DIR
${
CMAKE_CURRENT_LIST_DIR
}
)
DESTINATION_DIR
${
CMAKE_CURRENT_LIST_DIR
}
)
include
(
${
CMAKE_CURRENT_LIST_DIR
}
/ffmpeg_version.cmake
)
include
(
${
CMAKE_CURRENT_LIST_DIR
}
/ffmpeg_version.cmake
)
# Compatibility glue code
set
(
FFMPEG_libavcodec_FOUND 1
)
set
(
FFMPEG_libavformat_FOUND 1
)
set
(
FFMPEG_libavutil_FOUND 1
)
set
(
FFMPEG_libswscale_FOUND 1
)
set
(
FFMPEG_libavresample_FOUND 1
)
set
(
FFMPEG_libavcodec_VERSION
${
ALIASOF_libavcodec_VERSION
}
)
set
(
FFMPEG_libavformat_VERSION
${
ALIASOF_libavformat_VERSION
}
)
set
(
FFMPEG_libavutil_VERSION
${
ALIASOF_libavutil_VERSION
}
)
set
(
FFMPEG_libswscale_VERSION
${
ALIASOF_libswscale_VERSION
}
)
set
(
FFMPEG_libavresample_VERSION
${
ALIASOF_libavresample_VERSION
}
)
CMakeLists.txt
View file @
3ae19907
...
@@ -1068,19 +1068,18 @@ if(DEFINED WITH_1394)
...
@@ -1068,19 +1068,18 @@ if(DEFINED WITH_1394)
status
(
" DC1394 2.x:"
HAVE_DC1394_2 THEN
"YES (ver
${
ALIASOF_libdc1394-2_VERSION
}
)"
ELSE NO
)
status
(
" DC1394 2.x:"
HAVE_DC1394_2 THEN
"YES (ver
${
ALIASOF_libdc1394-2_VERSION
}
)"
ELSE NO
)
endif
(
DEFINED WITH_1394
)
endif
(
DEFINED WITH_1394
)
if
(
DEFINED WITH_FFMPEG
)
if
(
DEFINED WITH_FFMPEG
OR HAVE_FFMPEG
)
if
(
WIN32
)
if
(
WIN32
)
status
(
" FFMPEG:"
WITH_FFMPEG THEN
"YES (prebuilt binaries)"
ELSE NO
)
status
(
" FFMPEG:"
WITH_FFMPEG THEN
"YES (prebuilt binaries)"
ELSE NO
)
else
()
else
()
status
(
" FFMPEG:"
HAVE_FFMPEG THEN YES ELSE NO
)
status
(
" FFMPEG:"
HAVE_FFMPEG THEN YES ELSE NO
)
endif
()
endif
()
status
(
" codec:"
HAVE_FFMPEG_CODEC THEN
"YES (ver
${
ALIASOF_libavcodec_VERSION
}
)"
ELSE NO
)
status
(
" avcodec:"
FFMPEG_libavcodec_FOUND THEN
"YES (ver
${
FFMPEG_libavcodec_VERSION
}
)"
ELSE NO
)
status
(
" format:"
HAVE_FFMPEG_FORMAT THEN
"YES (ver
${
ALIASOF_libavformat_VERSION
}
)"
ELSE NO
)
status
(
" avformat:"
FFMPEG_libavformat_FOUND THEN
"YES (ver
${
FFMPEG_libavformat_VERSION
}
)"
ELSE NO
)
status
(
" util:"
HAVE_FFMPEG_UTIL THEN
"YES (ver
${
ALIASOF_libavutil_VERSION
}
)"
ELSE NO
)
status
(
" avutil:"
FFMPEG_libavutil_FOUND THEN
"YES (ver
${
FFMPEG_libavutil_VERSION
}
)"
ELSE NO
)
status
(
" swscale:"
HAVE_FFMPEG_SWSCALE THEN
"YES (ver
${
ALIASOF_libswscale_VERSION
}
)"
ELSE NO
)
status
(
" swscale:"
FFMPEG_libswscale_FOUND THEN
"YES (ver
${
FFMPEG_libswscale_VERSION
}
)"
ELSE NO
)
status
(
" resample:"
HAVE_FFMPEG_RESAMPLE THEN
"YES (ver
${
ALIASOF_libavresample_VERSION
}
)"
ELSE NO
)
status
(
" avresample:"
FFMPEG_libavresample_FOUND THEN
"YES (ver
${
FFMPEG_libavresample_VERSION
}
)"
ELSE NO
)
status
(
" gentoo-style:"
HAVE_GENTOO_FFMPEG THEN YES ELSE NO
)
endif
()
endif
(
DEFINED WITH_FFMPEG
)
if
(
DEFINED WITH_GSTREAMER
)
if
(
DEFINED WITH_GSTREAMER
)
status
(
" GStreamer:"
HAVE_GSTREAMER THEN
""
ELSE NO
)
status
(
" GStreamer:"
HAVE_GSTREAMER THEN
""
ELSE NO
)
...
...
cmake/OpenCVFindLibsVideo.cmake
View file @
3ae19907
...
@@ -213,79 +213,35 @@ if(WITH_XIMEA)
...
@@ -213,79 +213,35 @@ if(WITH_XIMEA)
endif
(
WITH_XIMEA
)
endif
(
WITH_XIMEA
)
# --- FFMPEG ---
# --- FFMPEG ---
ocv_clear_vars
(
HAVE_FFMPEG
HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_FFMPEG_RESAMPLE HAVE_GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG
)
ocv_clear_vars
(
HAVE_FFMPEG
)
if
(
WITH_FFMPEG
)
if
(
WITH_FFMPEG
)
if
(
WIN32 AND NOT ARM
)
if
(
WIN32 AND NOT ARM
)
include
(
"
${
OpenCV_SOURCE_DIR
}
/3rdparty/ffmpeg/ffmpeg.cmake"
)
include
(
"
${
OpenCV_SOURCE_DIR
}
/3rdparty/ffmpeg/ffmpeg.cmake"
)
elseif
(
UNIX
)
set
(
HAVE_FFMPEG TRUE
)
CHECK_MODULE
(
libavcodec HAVE_FFMPEG_CODEC
)
elseif
(
PKG_CONFIG_FOUND
)
CHECK_MODULE
(
libavformat HAVE_FFMPEG_FORMAT
)
ocv_check_modules
(
FFMPEG libavcodec libavformat libavutil libswscale
)
CHECK_MODULE
(
libavutil HAVE_FFMPEG_UTIL
)
ocv_check_modules
(
FFMPEG_libavresample libavresample
)
CHECK_MODULE
(
libswscale HAVE_FFMPEG_SWSCALE
)
if
(
FFMPEG_libavresample_FOUND
)
CHECK_MODULE
(
libavresample HAVE_FFMPEG_RESAMPLE
)
ocv_append_build_options
(
FFMPEG FFMPEG_libavresample
)
CHECK_INCLUDE_FILE
(
libavformat/avformat.h HAVE_GENTOO_FFMPEG
)
CHECK_INCLUDE_FILE
(
ffmpeg/avformat.h HAVE_FFMPEG_FFMPEG
)
if
(
NOT HAVE_GENTOO_FFMPEG AND NOT HAVE_FFMPEG_FFMPEG
)
if
((
NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/ffmpeg/libavformat/avformat.h
)
OR HAVE_FFMPEG_SWSCALE
)
set
(
HAVE_GENTOO_FFMPEG TRUE
)
endif
()
endif
()
endif
()
if
(
HAVE_FFMPEG_CODEC AND HAVE_FFMPEG_FORMAT AND HAVE_FFMPEG_UTIL AND HAVE_FFMPEG_SWSCALE
)
set
(
HAVE_FFMPEG TRUE
)
endif
()
if
(
HAVE_FFMPEG
)
if
(
HAVE_FFMPEG
)
# Find the bzip2 library because it is required on some systems
try_compile
(
__VALID_FFMPEG
FIND_LIBRARY
(
BZIP2_LIBRARIES NAMES bz2 bzip2 libbz2.so.1
)
"
${
OpenCV_BINARY_DIR
}
"
else
()
"
${
OpenCV_SOURCE_DIR
}
/cmake/checks/ffmpeg_test.cpp"
find_path
(
FFMPEG_INCLUDE_DIR
"libavformat/avformat.h"
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES:STRING=
${
FFMPEG_INCLUDE_DIRS
}
"
PATHS /usr/local /usr /opt
"-DLINK_DIRECTORIES:STRING=
${
FFMPEG_LIBRARY_DIRS
}
"
PATH_SUFFIXES include
"-DLINK_LIBRARIES:STRING=
${
FFMPEG_LIBRARIES
}
"
DOC
"The path to FFMPEG headers"
)
OUTPUT_VARIABLE TRY_OUT
if
(
FFMPEG_INCLUDE_DIR
)
)
set
(
HAVE_GENTOO_FFMPEG TRUE
)
if
(
NOT __VALID_FFMPEG
)
set
(
FFMPEG_LIB_DIR
"
${
FFMPEG_INCLUDE_DIR
}
/../lib"
CACHE PATH
"Full path of FFMPEG library directory"
)
#message(FATAL_ERROR "FFMPEG: test check build log:\n${TRY_OUT}")
find_library
(
FFMPEG_CODEC_LIB
"avcodec"
HINTS
"
${
FFMPEG_LIB_DIR
}
"
)
message
(
STATUS
"WARNING: Can't build ffmpeg test code"
)
find_library
(
FFMPEG_FORMAT_LIB
"avformat"
HINTS
"
${
FFMPEG_LIB_DIR
}
"
)
else
()
find_library
(
FFMPEG_UTIL_LIB
"avutil"
HINTS
"
${
FFMPEG_LIB_DIR
}
"
)
ocv_append_build_options
(
VIDEOIO FFMPEG
)
find_library
(
FFMPEG_SWSCALE_LIB
"swscale"
HINTS
"
${
FFMPEG_LIB_DIR
}
"
)
endif
()
find_library
(
FFMPEG_RESAMPLE_LIB
"avresample"
HINTS
"
${
FFMPEG_LIB_DIR
}
"
)
if
(
FFMPEG_CODEC_LIB
)
set
(
HAVE_FFMPEG_CODEC 1
)
endif
()
if
(
FFMPEG_FORMAT_LIB
)
set
(
HAVE_FFMPEG_FORMAT 1
)
endif
()
if
(
FFMPEG_UTIL_LIB
)
set
(
HAVE_FFMPEG_UTIL 1
)
endif
()
if
(
FFMPEG_SWSCALE_LIB
)
set
(
HAVE_FFMPEG_SWSCALE 1
)
endif
()
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
)
if
(
FFMPEG_RESAMPLE_LIB
)
set
(
HAVE_FFMPEG_RESAMPLE 1
)
set
(
ALIASOF_libavresample_VERSION
"Unknown"
)
endif
()
endif
()
endif
(
FFMPEG_INCLUDE_DIR
)
if
(
HAVE_FFMPEG
)
set
(
VIDEOIO_LIBRARIES
${
VIDEOIO_LIBRARIES
}
"
${
FFMPEG_LIB_DIR
}
/libavcodec.a"
"
${
FFMPEG_LIB_DIR
}
/libavformat.a"
"
${
FFMPEG_LIB_DIR
}
/libavutil.a"
"
${
FFMPEG_LIB_DIR
}
/libswscale.a"
)
if
(
HAVE_FFMPEG_RESAMPLE
)
set
(
VIDEOIO_LIBRARIES
${
VIDEOIO_LIBRARIES
}
"
${
FFMPEG_LIB_DIR
}
/libavresample.a"
)
endif
()
ocv_include_directories
(
${
FFMPEG_INCLUDE_DIR
}
)
endif
(
HAVE_FFMPEG
)
endif
()
endif
()
else
()
message
(
STATUS
"Can't find ffmpeg - 'pkg-config' utility is missing"
)
endif
()
endif
()
endif
(
WITH_FFMPEG
)
endif
(
WITH_FFMPEG
)
...
...
cmake/OpenCVUtils.cmake
View file @
3ae19907
...
@@ -398,6 +398,44 @@ macro(OCV_OPTION variable description value)
...
@@ -398,6 +398,44 @@ macro(OCV_OPTION variable description value)
unset
(
__value
)
unset
(
__value
)
endmacro
()
endmacro
()
# Usage: ocv_append_build_options(HIGHGUI FFMPEG)
macro
(
ocv_append_build_options var_prefix pkg_prefix
)
foreach
(
suffix INCLUDE_DIRS LIBRARIES LIBRARY_DIRS
)
if
(
${
pkg_prefix
}
_
${
suffix
}
)
list
(
APPEND
${
var_prefix
}
_
${
suffix
}
${${
pkg_prefix
}
_
${
suffix
}}
)
list
(
REMOVE_DUPLICATES
${
var_prefix
}
_
${
suffix
}
)
endif
()
endforeach
()
endmacro
()
# Usage is similar to CMake 'pkg_check_modules' command
# It additionally controls HAVE_${define} and ${define}_${modname}_FOUND variables
macro
(
ocv_check_modules define
)
unset
(
HAVE_
${
define
}
)
foreach
(
m
${
ARGN
}
)
if
(
m MATCHES
"(.*[^><])(>=|=|<=)(.*)"
)
set
(
__modname
"
${
CMAKE_MATCH_1
}
"
)
else
()
set
(
__modname
"
${
m
}
"
)
endif
()
unset
(
${
define
}
_
${
__modname
}
_FOUND
)
endforeach
()
pkg_check_modules
(
${
define
}
${
ARGN
}
)
if
(
${
define
}
_FOUND
)
set
(
HAVE_
${
define
}
1
)
endif
()
foreach
(
m
${
ARGN
}
)
if
(
m MATCHES
"(.*[^><])(>=|=|<=)(.*)"
)
set
(
__modname
"
${
CMAKE_MATCH_1
}
"
)
else
()
set
(
__modname
"
${
m
}
"
)
endif
()
if
(
NOT DEFINED
${
define
}
_
${
__modname
}
_FOUND AND
${
define
}
_FOUND
)
set
(
${
define
}
_
${
__modname
}
_FOUND 1
)
endif
()
endforeach
()
endmacro
()
# Macros that checks if module have been installed.
# Macros that checks if module have been installed.
# After it adds module to build and define
# After it adds module to build and define
...
...
cmake/checks/ffmpeg_test.cpp
0 → 100644
View file @
3ae19907
#include <stdlib.h>
extern
"C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
}
#define CALC_FFMPEG_VERSION(a,b,c) ( a<<16 | b<<8 | c )
static
void
test
()
{
AVFormatContext
*
c
=
0
;
AVCodec
*
avcodec
=
0
;
AVFrame
*
frame
=
0
;
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
int
err
=
avformat_open_input
(
&
c
,
""
,
NULL
,
NULL
);
#else
int
err
=
av_open_input_file
(
&
c
,
""
,
NULL
,
0
,
NULL
);
#endif
}
int
main
()
{
test
();
return
0
;
}
cmake/templates/cvconfig.h.in
View file @
3ae19907
...
@@ -71,12 +71,6 @@
...
@@ -71,12 +71,6 @@
/* FFMpeg video library */
/* FFMpeg video library */
#cmakedefine HAVE_FFMPEG
#cmakedefine HAVE_FFMPEG
/* ffmpeg's libswscale */
#cmakedefine HAVE_FFMPEG_SWSCALE
/* ffmpeg in Gentoo */
#cmakedefine HAVE_GENTOO_FFMPEG
/* Geospatial Data Abstraction Library */
/* Geospatial Data Abstraction Library */
#cmakedefine HAVE_GDAL
#cmakedefine HAVE_GDAL
...
...
modules/videoio/src/cap_ffmpeg_impl.hpp
View file @
3ae19907
...
@@ -75,48 +75,8 @@ extern "C" {
...
@@ -75,48 +75,8 @@ extern "C" {
#include <libavutil/imgutils.h>
#include <libavutil/imgutils.h>
#endif
#endif
#ifdef WIN32
#include <libavcodec/avcodec.h>
#define HAVE_FFMPEG_SWSCALE 1
#include <libswscale/swscale.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#else
#ifndef HAVE_FFMPEG_SWSCALE
#error "libswscale is necessary to build the newer OpenCV ffmpeg wrapper"
#endif
// if the header path is not specified explicitly, let's deduce it
#if !defined HAVE_FFMPEG_AVCODEC_H && !defined HAVE_LIBAVCODEC_AVCODEC_H
#if defined(HAVE_GENTOO_FFMPEG)
#define HAVE_LIBAVCODEC_AVCODEC_H 1
#if defined(HAVE_FFMPEG_SWSCALE)
#define HAVE_LIBSWSCALE_SWSCALE_H 1
#endif
#elif defined HAVE_FFMPEG
#define HAVE_FFMPEG_AVCODEC_H 1
#if defined(HAVE_FFMPEG_SWSCALE)
#define HAVE_FFMPEG_SWSCALE_H 1
#endif
#endif
#endif
#if defined(HAVE_FFMPEG_AVCODEC_H)
#include <ffmpeg/avcodec.h>
#endif
#if defined(HAVE_FFMPEG_SWSCALE_H)
#include <ffmpeg/swscale.h>
#endif
#if defined(HAVE_LIBAVCODEC_AVCODEC_H)
#include <libavcodec/avcodec.h>
#endif
#if defined(HAVE_LIBSWSCALE_SWSCALE_H)
#include <libswscale/swscale.h>
#endif
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
modules/videoio/src/ffmpeg_codecs.hpp
View file @
3ae19907
...
@@ -60,24 +60,7 @@ extern "C" {
...
@@ -60,24 +60,7 @@ extern "C" {
#include <errno.h>
#include <errno.h>
#endif
#endif
// if the header path is not specified explicitly, let's deduce it
#include <libavformat/avformat.h>
#if !defined HAVE_FFMPEG_AVCODEC_H && !defined HAVE_LIBAVCODEC_AVCODEC_H
#if defined(HAVE_GENTOO_FFMPEG)
#define HAVE_LIBAVFORMAT_AVFORMAT_H 1
#elif defined HAVE_FFMPEG
#define HAVE_FFMPEG_AVFORMAT_H 1
#endif
#if defined(HAVE_FFMPEG_AVFORMAT_H)
#include <ffmpeg/avformat.h>
#endif
#if defined(HAVE_LIBAVFORMAT_AVFORMAT_H) || defined(WIN32)
#include <libavformat/avformat.h>
#endif
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment