1 | initial version |
This worked for me to build the 64-bit FFmpeg API from source:
1. Build the FFmpeg .a static library archives(which are object that are inputs to a linker). On 64-bit Windows, I configured the FFmpeg build like this:
./configure --target-os=win32 --disable-programs --disable-doc --enable-static --enable-shared
make
make install
2. Copy the .a static library archives into a folder in the OpenCV source folder under \3rdparty\lib, and add the suffix 64 for the 64-bit archives:
3. Copy all the C/C++ header files in the FFmpeg source directory to a new OpenCV source directory called \3rdparty\include\ffmpeg_. For example:
cp /ffmpeg/libavcodec/*.h /opencv/3rdparty/include/ffmpeg_/libavcodec
cp /ffmpeg/libavdevice/*.h /opencv/3rdparty/include/ffmpeg_/libavdevice
cp /ffmpeg/libavfilter/*.h /opencv/3rdparty/include/ffmpeg_/libavfilter
cp /ffmpeg/libavformat/*.h /opencv/3rdparty/include/ffmpeg_/libavformat
cp /ffmpeg/libavresample/*.h /opencv/3rdparty/include/ffmpeg_/libavresample
cp /ffmpeg/libavutil/*.h /opencv/3rdparty/include/ffmpeg_/libavutil
cp /ffmpeg/libpostproc/*.h /opencv/3rdparty/include/ffmpeg_/libpostproc
cp /ffmpeg/libswresample/*.h /opencv/3rdparty/include/ffmpeg_/libswresample
cp /ffmpeg/libswscale/*.h /opencv/3rdparty/include/ffmpeg_/libswscale
4. In the OpenCV \3rdparty\ffmpeg folder, create a file called ffopencv.c, with these contents:
#include "cap_ffmpeg_impl.hpp"
5. From the OpenCV \3rdparty\ffmpeg folder, run the following from the Windows command line with Cygwin and MingW installed:
x86_64-w64-mingw32-g++ -m64 -Wall -static -static-libgcc -static-libstdc++ -shared -o opencv_ffmpeg320_64.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/videoio/src -I/../../modules/highgui/src ffopencv.c -L../lib -lavdevice64 -lavfilter64 -lavformat64 -lavcodec64 -lavutil64 -lswscale64 -lswresample64 -lws2_32 -liconv -lz -lbz2 -lsecur32
2 | No.2 Revision |
This worked for me to build the 64-bit FFmpeg API from source:
1. Build the FFmpeg .a static library archives(which are object that are inputs to a linker). On 64-bit Windows, I configured the FFmpeg build like this:
./configure --target-os=win32 --disable-programs --disable-doc --enable-static --enable-shared
make
make install
2. Copy the .a static library archives into a folder in the OpenCV source folder under \3rdparty\lib, and add the suffix 64 for the 64-bit archives:
3. Copy all the C/C++ header files in the FFmpeg source directory to a new OpenCV source directory called \3rdparty\include\ffmpeg_. For example:
cp /ffmpeg/libavcodec/*.h /opencv/3rdparty/include/ffmpeg_/libavcodec
cp /ffmpeg/libavdevice/*.h /opencv/3rdparty/include/ffmpeg_/libavdevice
cp /ffmpeg/libavfilter/*.h /opencv/3rdparty/include/ffmpeg_/libavfilter
cp /ffmpeg/libavformat/*.h /opencv/3rdparty/include/ffmpeg_/libavformat
cp /ffmpeg/libavresample/*.h /opencv/3rdparty/include/ffmpeg_/libavresample
cp /ffmpeg/libavutil/*.h /opencv/3rdparty/include/ffmpeg_/libavutil
cp /ffmpeg/libpostproc/*.h /opencv/3rdparty/include/ffmpeg_/libpostproc
cp /ffmpeg/libswresample/*.h /opencv/3rdparty/include/ffmpeg_/libswresample
cp /ffmpeg/libswscale/*.h /opencv/3rdparty/include/ffmpeg_/libswscale
4. In the OpenCV \3rdparty\ffmpeg folder, create a file called ffopencv.c, with these contents:
#include "cap_ffmpeg_impl.hpp"
5. From the OpenCV \3rdparty\ffmpeg folder, run the following from the Windows command line with Cygwin and MingW installed:
x86_64-w64-mingw32-g++ -m64 -Wall -static -static-libgcc -static-libstdc++ -shared -o opencv_ffmpeg320_64.dll -O2 -x c++ -I../include -I../include/ffmpeg_ -I../../modules/videoio/src -I/../../modules/highgui/src ffopencv.c -L../lib -lavdevice64 -lavfilter64 -lavformat64 -lavcodec64 -lavutil64 -lswscale64 -lswresample64 -lws2_32 -liconv -lz -lbz2 -lsecur32
This will produce the opencv_ffmpeg320_64.dll (or you can use another name, if applicable) in the correct folder. Whenever you change the OpenCV FFmpeg API, you will only have to re-run Step 5. Whenever you change FFmpeg source code, you will have to re-run Steps 1-5.