update ffmpeg wrapper binaries

Scripts are updated for Linux-based (Ubuntu 14.04) mingw cross-compilation (full stack of scripts provided)
Part of these scripts may work under Windows installation of MinGW, but it is not supported.

FFMPEG update: 2.7.1
Added OpenH264 Cisco binaries support for H264 encoding: v1.4.0
pull/4154/head
Alexander Alekhin 10 years ago
parent ca8312b0b3
commit 56ad207d37
  1. 3
      3rdparty/ffmpeg/.gitignore
  2. 42
      3rdparty/ffmpeg/build_win32.txt
  3. 25
      3rdparty/ffmpeg/ffmpeg.cmake
  4. 13
      3rdparty/ffmpeg/ffmpeg_version.cmake
  5. 1
      3rdparty/ffmpeg/ffopencv.c
  6. 2
      3rdparty/ffmpeg/make.bat
  7. BIN
      3rdparty/ffmpeg/opencv_ffmpeg.dll
  8. BIN
      3rdparty/ffmpeg/opencv_ffmpeg_64.dll
  9. 16
      3rdparty/ffmpeg/readme.txt
  10. 2
      cmake/OpenCVFindLibsVideo.cmake
  11. 73
      cmake/OpenCVUtils.cmake

@ -0,0 +1,3 @@
downloads/
*.dll
ffmpeg_version.cmake

@ -1,42 +0,0 @@
The build script is to be fixed.
Right now it assumes that 32-bit MinGW is in the system path and
64-bit mingw is installed to c:\Apps\MinGW64.
It is important that gcc is used, not g++!
Otherwise the produced DLL will likely be dependent on libgcc_s_dw2-1.dll or similar DLL.
While we want to make the DLLs with minimum dependencies: Win32 libraries + msvcrt.dll.
ffopencv.c is really a C++ source, hence -x c++ is used.
How to update opencv_ffmpeg.dll and opencv_ffmpeg_64.dll when a new version of FFMPEG is release?
1. Install 32-bit MinGW + MSYS from
http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/
Let's assume, it's installed in C:\MSYS32.
2. Install 64-bit MinGW. http://mingw-w64.sourceforge.net/
Let's assume, it's installed in C:\MSYS64
3. Copy C:\MSYS32\msys to C:\MSYS64\msys. Edit C:\MSYS64\msys\etc\fstab, change C:\MSYS32 to C:\MSYS64.
4. Now you have working MSYS32 and MSYS64 environments.
Launch, one by one, C:\MSYS32\msys\msys.bat and C:\MSYS64\msys\msys.bat to create your home directories.
4. Download ffmpeg-x.y.z.tar.gz (where x.y.z denotes the actual ffmpeg version).
Copy it to C:\MSYS{32|64}\msys\home\<loginname> directory.
5. To build 32-bit ffmpeg libraries, run C:\MSYS32\msys\msys.bat and type the following commands:
5.1. tar -xzf ffmpeg-x.y.z.tar.gz
5.2. mkdir build
5.3. cd build
5.4. ../ffmpeg-x.y.z/configure --enable-w32threads
5.5. make
5.6. make install
5.7. cd /local/lib
5.8. strip -g *.a
6. Then repeat the same for 64-bit case. The output libs: libavcodec.a etc. need to be renamed to libavcodec64.a etc.
7. Then, copy all those libs to <opencv>\3rdparty\lib\, copy the headers to <opencv>\3rdparty\include\ffmpeg_.
8. Then, go to <opencv>\3rdparty\ffmpeg, edit make.bat
(change paths to the actual paths to your msys32 and msys64 distributions) and then run make.bat

@ -0,0 +1,25 @@
# Binary branch name: ffmpeg/master_20150703
# Binaries were created for OpenCV: e379ea6ed60b0caad4d4e3eea096e9d850cb8c86
set(FFMPEG_BINARIES_COMMIT "8aeefc4efe3215de89d8c7e114ae6f7a6091b8eb")
set(FFMPEG_FILE_HASH_BIN32 "89c783eee1c47bfc733f08334ec2e31c")
set(FFMPEG_FILE_HASH_BIN64 "35fe6ccdda6d7a04e9056b0d73b98e76")
set(FFMPEG_FILE_HASH_CMAKE "8606f947a780071f8fcce8cbf39ceef5")
set(FFMPEG_DOWNLOAD_URL ${OPENCV_FFMPEG_URL};$ENV{OPENCV_FFMPEG_URL};https://raw.githubusercontent.com/Itseez/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/)
ocv_download(PACKAGE opencv_ffmpeg.dll
HASH ${FFMPEG_FILE_HASH_BIN32}
URL ${FFMPEG_DOWNLOAD_URL}
DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})
ocv_download(PACKAGE opencv_ffmpeg_64.dll
HASH ${FFMPEG_FILE_HASH_BIN64}
URL ${FFMPEG_DOWNLOAD_URL}
DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})
ocv_download(PACKAGE ffmpeg_version.cmake
HASH ${FFMPEG_FILE_HASH_CMAKE}
URL ${FFMPEG_DOWNLOAD_URL}
DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})
include(${CMAKE_CURRENT_LIST_DIR}/ffmpeg_version.cmake)

@ -1,13 +0,0 @@
set(HAVE_FFMPEG 1)
set(HAVE_FFMPEG_CODEC 1)
set(HAVE_FFMPEG_FORMAT 1)
set(HAVE_FFMPEG_UTIL 1)
set(HAVE_FFMPEG_SWSCALE 1)
set(HAVE_FFMPEG_RESAMPLE 0)
set(HAVE_GENTOO_FFMPEG 1)
set(ALIASOF_libavcodec_VERSION 55.18.102)
set(ALIASOF_libavformat_VERSION 55.12.100)
set(ALIASOF_libavutil_VERSION 52.38.100)
set(ALIASOF_libswscale_VERSION 2.3.100)
set(ALIASOF_libavresample_VERSION 1.0.1)

@ -1 +0,0 @@
#include "cap_ffmpeg_impl.hpp"

@ -1,2 +0,0 @@
set path=c:\dev\msys32\bin;%path% & gcc -Wall -shared -o opencv_ffmpeg.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/highgui/src ffopencv.c -L../lib -lavformat -lavcodec -lavdevice -lswscale -lavutil -lws2_32
set path=c:\dev\msys64\bin;%path% & gcc -m64 -Wall -shared -o opencv_ffmpeg_64.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/highgui/src ffopencv.c -L../lib -lavformat64 -lavcodec64 -lavdevice64 -lswscale64 -lavutil64 -lws2_32

Binary file not shown.

Binary file not shown.

@ -3,19 +3,19 @@
he/she should use --enabled-shared configure flag and make sure that no GPL components are
enabled (some notable examples are x264 (H264 encoder) and libac3 (Dolby AC3 audio codec)).
See https://www.ffmpeg.org/legal.html for details.
If you want to play very safe and do not want to use FFMPEG at all, regardless of whether it's installed on
your system or not, configure and build OpenCV using CMake with WITH_FFMPEG=OFF flag. OpenCV will then use
AVFoundation (OSX), GStreamer (Linux) or other available backends supported by opencv_videoio module.
There is also our self-contained motion jpeg codec, which you can use without any worries.
It handles CV_FOURCC('M', 'J', 'P', 'G') streams within an AVI container (".avi").
* On Windows OpenCV uses pre-built ffmpeg binaries, built with proper flags (without GPL components) and
wrapped with simple, stable OpenCV-compatible API.
The binaries are opencv_ffmpeg.dll (version for 32-bit Windows) and
opencv_ffmpeg_64.dll (version for 64-bit Windows).
See build_win32.txt for the build instructions, if you want to rebuild opencv_ffmpeg*.dll from scratch.
The pre-built opencv_ffmpeg*.dll is:
@ -24,9 +24,15 @@
If it succeeds, ffmpeg can be used to decode/encode videos;
otherwise, other API is used.
FFMPEG build contains H264 encoder based on the OpenH264 library, that should be installed separatelly.
OpenH264 Video Codec provided by Cisco Systems, Inc.
See https://github.com/cisco/openh264/releases for details and OpenH264 license.
Downloaded binary file can be placed into global system path (System32 or SysWOW64) or near application binaries.
You can also specify location of binary file via OPENH264_LIBRARY_PATH environment variable.
If LGPL/GPL software can not be supplied with your OpenCV-based product, simply exclude
opencv_ffmpeg*.dll from your distribution; OpenCV will stay fully functional except for the ability to
decode/encode videos using FFMPEG (though, it may still be able to do that using other API,
such as Video for Windows, Windows Media Foundation or our self-contained motion jpeg codec).
See license.txt for the FFMPEG copyright notice and the licensing terms.

@ -190,7 +190,7 @@ endif(WITH_XIMEA)
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)
if(WITH_FFMPEG)
if(WIN32 AND NOT ARM)
include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg_version.cmake")
include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg.cmake")
elseif(UNIX)
CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC)
CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)

@ -836,3 +836,76 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
ocv_list_reverse(${lst})
endforeach()
endmacro()
function(ocv_download)
cmake_parse_arguments(DL "" "PACKAGE;HASH;URL;DESTINATION_DIR;DOWNLOAD_DIR" "" ${ARGN})
if(NOT DL_DOWNLOAD_DIR)
set(DL_DOWNLOAD_DIR "${DL_DESTINATION_DIR}/downloads")
endif()
if(DEFINED DL_DESTINATION_DIR)
set(DESTINATION_TARGET "${DL_DESTINATION_DIR}/${DL_PACKAGE}")
if(EXISTS "${DESTINATION_TARGET}")
file(MD5 "${DESTINATION_TARGET}" target_md5)
if(NOT target_md5 STREQUAL DL_HASH)
file(REMOVE "${DESTINATION_TARGET}")
else()
set(DOWNLOAD_PACKAGE_LOCATION "" PARENT_SCOPE)
unset(DOWNLOAD_PACKAGE_LOCATION)
return()
endif()
endif()
endif()
set(DOWNLOAD_TARGET "${DL_DOWNLOAD_DIR}/${DL_HASH}/${DL_PACKAGE}")
get_filename_component(DOWNLOAD_TARGET_DIR "${DOWNLOAD_TARGET}" PATH)
if(EXISTS "${DOWNLOAD_TARGET}")
file(MD5 "${DOWNLOAD_TARGET}" target_md5)
if(NOT target_md5 STREQUAL DL_HASH)
message(WARNING "Download: Local copy of ${DL_PACKAGE} has invalid MD5 hash: ${target_md5} (expected: ${DL_HASH})")
file(REMOVE "${DOWNLOAD_TARGET}")
file(REMOVE_RECURSE "${DOWNLOAD_TARGET_DIR}")
endif()
endif()
if(NOT EXISTS "${DOWNLOAD_TARGET}")
set(__url "")
foreach(__url_i ${DL_URL})
if(NOT ("${__url_i}" STREQUAL ""))
set(__url "${__url_i}")
break()
endif()
endforeach()
if("${__url}" STREQUAL "")
message(FATAL_ERROR "Download URL is not specified for package ${DL_PACKAGE}")
endif()
if(NOT EXISTS "${DOWNLOAD_TARGET_DIR}")
file(MAKE_DIRECTORY ${DOWNLOAD_TARGET_DIR})
endif()
message(STATUS "Downloading ${DL_PACKAGE}...")
#message(STATUS " ${__url}${DL_PACKAGE}")
file(DOWNLOAD "${__url}${DL_PACKAGE}" "${DOWNLOAD_TARGET}"
TIMEOUT 600 STATUS __status
EXPECTED_MD5 ${DL_HASH})
if(NOT __status EQUAL 0)
message(FATAL_ERROR "Failed to download ${DL_PACKAGE}. Status=${__status}")
else()
# Don't remove this code, because EXPECTED_MD5 parameter doesn't fail "file(DOWNLOAD)" step on wrong hash
file(MD5 "${DOWNLOAD_TARGET}" target_md5)
if(NOT target_md5 STREQUAL DL_HASH)
message(FATAL_ERROR "Downloaded copy of ${DL_PACKAGE} has invalid MD5 hash: ${target_md5} (expected: ${DL_HASH})")
endif()
endif()
message(STATUS "Downloading ${DL_PACKAGE}... Done")
endif()
if(DEFINED DL_DESTINATION_DIR)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${DOWNLOAD_TARGET}" "${DL_DESTINATION_DIR}/"
RESULT_VARIABLE __result)
if(NOT __result EQUAL 0)
message(FATAL_ERROR "Downloader: Failed to copy package from ${DOWNLOAD_TARGET} to ${DL_DESTINATION_DIR} with error ${__result}")
endif()
endif()
set(DOWNLOAD_PACKAGE_LOCATION ${DOWNLOAD_TARGET} PARENT_SCOPE)
endfunction()

Loading…
Cancel
Save