Build FFMPEG for Windows Using Visual Studio Toolchain
FFMPEG for Windows is built under MinGW or Cygwin. We will be using MinGW.
You may need ZLib, the ZLib provided with MinGW does not come with a .a file for some reason. You can find ZLib at https://zlib.net/Build Zlib so that you get zlib.lib.
Follow this page: https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC
NOTE:
When following the instructions on the above page, they only give a configure command for a release version, which is:
./configure --target-os=win64 --arch=x86_64 --toolchain=msvc
If you want to do a full debug build, try this:
./configure --target-os=win64 --arch=x86_64 --toolchain=msvc --extra-cflags=" -EHa -nologo -D 'DEBUG' -D 'WINDOWS' -D 'HAVE_STRUCT_TIMESPEC' -D 'API_EXT_PARAM_LIST'" --enable-debug --disable-stripping --disable-optimizations --disable-cuda --disable-cuvid --disable-d3d11va --disable-dxva2 --disable-nvenc --disable-vaapi --disable-vdpau
You should now be ready to use ffmpeg in a MSVC project.
When including ffmpeg headers make sure to use extern "C", else MSVC will use C++ name mangling and it it won't find symbols during link. Like so:
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>
#include <libavutil/imgutils.h>
}
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>
#include <libavutil/imgutils.h>
}
Comments
Post a Comment