Building FFMpeg16 June 2012
In the past building FFMpeg for Windows had to be done by cross-compiling from Linux, which is OK if you are a cross-platform developer, but an utter pain if you only develop for Windows (my own company went Windows-only a few months ago). Nowhere near as challenging as recompiling GTK, but also not without its gotchas.
DependenciesFor a proper build, you need the following two utilities:
- Download the Win32 .exe, and rename it to
- Microsoft Library Manager
- Download and install Visual C++ 2010 Express, and you will need to copy the following files:
Build environmentI am using the same build environment that I used for building GTK for Win32. See the section on Installing MinGW/MSYS.
Doing the buildDownload the latest snap-shot from . The one I used had the name
ffmpeg-HEAD-0f73ac3.tar.gz. I will assume this file has been copied into
Start-up the MSYS shell and get a few things prepared:
export PATH=$PATH:/c/deps cd /d/src tar -xzvf ffmpeg-HEAD-0f73ac3.tar.gz cd ffmpeg-HEAD-0f73ac3
If you want a debug build, complete with GDB symbols, run the following. Bear in mind that this will take a but under 2 minutes, and it will not show any output until around halfway through:
./configure --arch=x86 --target-os=mingw32 \ --prefix=/d/FFmpeg \ --enable-memalign-hack --disable-static --enable-shared \ --extra-cflags=\"-mms-bitfields\" \ --extra-cflags=\"-ggdb\" \ --extra-ldflags=\"-Wl,-add-stdcall-alias\" \ --disable-stripping
If instead you want a release build, run the following.
./configure --arch=x86 --target-os=mingw32 \ --prefix=/d/FFmpeg \ --enable-memalign-hack --disable-static --enable-shared \ --extra-cflags=\"-mms-bitfields\" \ --extra-ldflags=\"-Wl,-add-stdcall-alias\" \
Once configuration is finished, start the build & install. On a 2010 Quad-Core i7 860 with 4GB RAM it took about 10 minutes.
make && make install
All done. Your newly build FFmpeg should be under
D:\FFmpeg. Enjoy.. :)
Only building H.264 decoderIf you are only interested in building H.264 decoding libraries, you can add the following switches to the configure command. Bear in mind that intra-dependencies within FFmpeg sometimes change, so in a future build this list might become shorter:
Import libraries missingIf you are getting this when running
INSTALL libavfilter/avfilter.dll install: cannot stat `libavfilter/avfilter.lib': No such file or directory make: *** [install-libavfilter-shared] Error 1
The problem is that lib.exe (which creates the
.lib files) is called during the building stage, and if not present it fails silently. It is not enough to run
make again - you have to do a
make clean and do rebuild from scratch.
YASM not foundThis is caused by
yasm not found, use --disable-yasm for a crippled build
Did you copy (as opposed to copying then renaming) YASM?
Missing function referencesFFmpeg is a collection of programs and libraries, and the inter-dependencies change with time. Don't be too surprised if you get errors like the following when you use the same configure script parameters with an upgraded FFmpeg source tree:
libavfilter/vf_scale.o: In function `query_formats': D:\ffmpeg-HEAD-0f73ac3/libavfilter/vf_scale.c:135: undefined reference to `sws_isSupportedInput' D:\ffmpeg-HEAD-0f73ac3/libavfilter/vf_scale.c:145: undefined reference to `sws_isSupportedOutput' libavfilter/vf_scale.o: In function `scale_slice': D:\ffmpeg-HEAD-0f73ac3/libavfilter/vf_scale.c:346: undefined reference to `sws_scale' libavfilter/vf_scale.o: In function `uninit': D:\ffmpeg-HEAD-0f73ac3/libavfilter/vf_scale.c:120: undefined reference to `sws_freeContext' D:\ffmpeg-HEAD-0f73ac3/libavfilter/vf_scale.c:121: undefined reference to `sws_freeContext' D:\ffmpeg-HEAD-0f73ac3/libavfilter/vf_scale.c:122: undefined reference to `sws_freeContext' libavfilter/vf_scale.o: In function `init': D:\ffmpeg-HEAD-0f73ac3/libavfilter/vf_scale.c:100: undefined reference to `sws_get_class' collect2: ld returned 1 exit status make: *** [libavfilter/avfilter-2.dll] Error 1
In this case, the culprit was using
--disable-swscale, which is the software scaling module. I suspect someone realised that scaling & filtering had common code.