Notes on a building FFmpeg and a PyAV wheel for win32
Created by: beville
Today I did a full build of FFmpeg and PyAV on Windows 10, 32-bit. Here are some notes on my experience. My goal wasn't to fix the build, but to just get through it. Hopefully this will be of some help.
System Setup
-
Set up my system with python 2.7.11 from Python.org. Added "C:\Python27;C:\Python27\Scripts" to PATH
-
pip install wheel Cython
-
Installed MinGw, and set up mys environment. Added "C:\MinGW\bin;C:\MinGW\msys\1.0\bin" to PATH
-
Installed Git for windows, Added "C:\Program Files\Git\bin" to PATH
-
To prepare for ffmpeg build, there were some pre-requisites: pkg-config.exe, liglib-2.0-0.dll, and intl.dll. I followed the instructions here: http://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw_how_to.html#pkg-config
First of all, you must download pkg-config.exe from GTK+ for Windows. Then you can simply unzip this downloaded zip-file, and then copy the pkg-config.exe executable into /MinGW/bin
That's not enough: this executable depends on the GLib DLL. So you must download GLib DLL too, always from GTK+ for Windows. Once again, you have to unzip this downloaded zip-file, and then copy liglib-2.0-0.dll into /MinGW/bin
You have not yet finished: pkg-config still has an unresolved DLL dependency. But this time simply performing a trivial copy will suffit. So you must now open an MSYS shell:
cd C:/MinGW/bin cp libintl-8.dll intl.dll
And this time that's really all: now you have pkg-config properly installed and ready to work.
-
Also needed yasm for ffmpeg build. I got it here: http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win32.exe I renamed it to yasm.exe, and copied it to C:/MinGW/bin
Building FFmpeg 2.8.6
- I first tried v3.0, but it failed to build, so I went to the previous: ffmepg-2.8.6 Download here: https://ffmpeg.org/download.html#releases. Unpack and open a shell in the source root.
- Build it:
./configure --enable-shared
make
DESTDIR=./build make install
Building PyAV package
- Set the pkg-config env var:
set PKG_CONFIG_PATH=C:\path\to\ffmpeg-source\build\usr\local\lib\pkgconfig
Note: if you're doing the build in an msys shell: export PKG_CONFIG_PATH="C:\path\to\ffmpeg-source\build\usr\local\lib\pkgconfig"
- I ended up having to fiddle with the setup.py file, since the pkg-config setting didn't seem to take
Edit No. 1 .in setup.py Edit extension_extra dict to point to paths where ffmpeg is installed
'include_dirs': ['include', 'C:\\path\\to\\ffmpeg-source\\build\\usr\local\\include'],
'library_dirs': ['C:\\path\\to\\ffmpeg-source\\build\\usr\\local\\lib'],
Edit No. 2 Comment out a few other lines in setup.py:
# 'avformat_open_input': ('function', True),
# 'AVStream__index': ('member', True),
- Copy the dlls from C:\path\to\ffmpeg-source\build\usr\local\bin to av folder
- Copy the C:\Mingw\bin\libgcc_s_dw2-1.dll to av folder
- Copy C:\Mingw\bin\pthreadGC2.dll to av folder (renamed to libwinpthread-1.dll) (not sure if this is right?)
- Copy C:\Mingw\bin\libiconv-2.dll to av folder
- There was a line in the makefile
mv *.pyd av
that I had to pre-pend with a '-' to keep it from generating an error. - Do the build:
make build-mingw32
make wheel
- I found that the DLLs in the av folder didn't get put into the wheel file, so I added them, manually, by adding ".zip" to the end of the .whl file, and opening it in windows explorer, and dropping in the missing DLLs in to the av folder. Rename file to end in .whl
- Whew!
- link to the wheel file is here: https://drive.google.com/open?id=0BwcYeKKuUtN2RWg5NHc4RUZOd0E