It took me the better part of a day to convince the snotty ffmpeg source code that it’s quite alright to be compiled under Windows even if it was written originally for Linux.
For those of you who don’t know what ffmpeg is and for some reason are still reading this, ffmpeg is a library of codecs for every conceivable audio and video format out there. The best part about it is that it doesn’t depend on the codecs you have installed on your system (which is a particular nightmare on Windows-based machines).
As for me, I was trying to extract the first image of video files to use as thumbnails in a video upload tool I’m working on.
We’ll start with downloading some tools of the trade and the source for ffmpeg.
- Download MinGW from here.
- Download MSYS from here.
- Download updated bash for MSYS from here.
- Get the latest snapshot of ffmpeg from here (here’s a direct link).
Let’s install the tools.
- Install MinGW (choose “MinGW base tools” and “MinGW make”) into c:\mingw
- Install MSYS into c:\msys\1.0
- After MSYS installation it will run a postinstall script. It will ask you some questions which you should answer as following:
Do you wish to continue with the post install? [yn ] -> y
Do you have MinGW installed? [yn ] -> y
Where is your MinGW installation? -> C:/mingw
- Copy bash-2.05b-MSYS.tar.bz2 to c:\msys\1.0 and extract it (bash.exe should go into C:\MSYS\1.0\bin).
We need to do this because ffmpeg’s configure script doesn’t work with bash 2.0.4 that comes with MSYS.
- Extract the ffmpeg sources. I’ll assume you’ve extracted them to c:\work\ffmpeg .
Now it’s time to build the library.
- Create a file called myconfig in c:\work\ffmpeg and copy the following into it:
./configure –extra-cflags="-mno-cygwin -mms-bitfields"
–target-os=mingw32 –enable-shared –disable-static
- Run c:\msys\1.0\msys.bat. Run the following commands in the shell that starts:
$ cd /c/work/ffmpeg
- In order to run ffmpeg.exe, collect the binary files and put them together in one folder: