status(" avutil:" FFMPEG_libavutil_VERSION THEN "YES (${FFMPEG_libavutil_VERSION})" ELSE NO)
status(" swscale:" FFMPEG_libswscale_VERSION THEN "YES (${FFMPEG_libswscale_VERSION})" ELSE NO)
status(" avresample:" FFMPEG_libavresample_VERSION THEN "YES (${FFMPEG_libavresample_VERSION})" ELSE NO)
+ if(OPENCV_FFMPEG_ENABLE_LIBAVDEVICE)
+ status(" avdevice:" FFMPEG_libavdevice_VERSION THEN "YES (${FFMPEG_libavdevice_VERSION})" ELSE NO)
+ endif()
endif()
if(WITH_GSTREAMER OR HAVE_GSTREAMER)
# --- FFMPEG ---
+OCV_OPTION(OPENCV_FFMPEG_ENABLE_LIBAVDEVICE "Include FFMPEG/libavdevice library support." OFF
+ VISIBLE_IF WITH_FFMPEG)
+
if(NOT HAVE_FFMPEG AND OPENCV_FFMPEG_USE_FIND_PACKAGE)
if(OPENCV_FFMPEG_USE_FIND_PACKAGE STREQUAL "1" OR OPENCV_FFMPEG_USE_FIND_PACKAGE STREQUAL "ON")
set(OPENCV_FFMPEG_USE_FIND_PACKAGE "FFMPEG")
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_libavresample_LIBRARIES})
list(APPEND _used_ffmpeg_libraries libavresample)
endif()
+ if(OPENCV_FFMPEG_ENABLE_LIBAVDEVICE)
+ ocv_check_modules(FFMPEG_libavdevice libavdevice) # optional
+ if(FFMPEG_libavdevice_FOUND)
+ list(APPEND FFMPEG_LIBRARIES ${FFMPEG_libavdevice_LIBRARIES})
+ list(APPEND _used_ffmpeg_libraries libavdevice)
+ endif()
+ endif()
set(HAVE_FFMPEG TRUE)
else()
set(_missing_ffmpeg_libraries "")
set(_min_libavutil_version 52.3.0)
set(_min_libswscale_version 2.1.1)
set(_min_libavresample_version 1.0.1)
+ set(_min_libavdevice_version 53.2.0)
foreach(ffmpeg_lib ${_used_ffmpeg_libraries})
if(FFMPEG_${ffmpeg_lib}_VERSION VERSION_LESS _min_${ffmpeg_lib}_version)
message(STATUS "FFMPEG is disabled. Can't find suitable ${ffmpeg_lib} library"
unset(_min_libavutil_version)
unset(_min_libswscale_version)
unset(_min_libavresample_version)
+ unset(_min_libavdevice_version)
endif()
#==================================
if(HAVE_FFMPEG_WRAPPER)
ocv_add_external_target(ffmpeg "" "" "HAVE_FFMPEG_WRAPPER")
elseif(HAVE_FFMPEG)
- ocv_add_external_target(ffmpeg "${FFMPEG_INCLUDE_DIRS}" "${FFMPEG_LIBRARIES}" "HAVE_FFMPEG")
+ if(OPENCV_FFMPEG_ENABLE_LIBAVDEVICE AND FFMPEG_libavdevice_FOUND)
+ set(HAVE_FFMPEG_LIBAVDEVICE TRUE)
+ ocv_add_external_target(ffmpeg "${FFMPEG_INCLUDE_DIRS}" "${FFMPEG_LIBRARIES}" "HAVE_FFMPEG;HAVE_FFMPEG_LIBAVDEVICE")
+ else()
+ ocv_add_external_target(ffmpeg "${FFMPEG_INCLUDE_DIRS}" "${FFMPEG_LIBRARIES}" "HAVE_FFMPEG")
+ endif()
set(__builtin_defines "")
set(__builtin_include_dirs "")
set(__builtin_libs "")
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
+#ifdef HAVE_FFMPEG_LIBAVDEVICE
+#include <libavdevice/avdevice.h>
+#endif
// https://github.com/FFmpeg/FFmpeg/blob/b6af56c034759b81985f8ea094e41cbd5f7fecfb/doc/APIchanges#L602-L605
#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(58, 9, 100)
void CvCapture_FFMPEG::init()
{
+#ifdef HAVE_FFMPEG_LIBAVDEVICE
+ //libavdevice is available, so let's register all input and output devices (e.g v4l2)
+ avdevice_register_all();
+#endif
ic = 0;
video_stream = -1;
video_st = 0;