# Building FFmpeg on Windows The script ffmpeg_build.sh allows compiling FFmpeg on Windows for the following targets : - Win32 using VS2015 - Android arm/arm64/x86/x86_64 using CLANG The script allows to build both release and debug versions of the library. ## Prerequisites - MSYS : http://www.mingw.org or MSYS2 (https://msys2.github.io/) - FFmpeg sources : get the sources of a release from https://github.com/FFmpeg/ (tested with 2.8.4) - YASM : http://yasm.tortall.net/Download.html (use a "Win32 .exe" release) (note : needs VC2010 redistributable) Rename the YASM executable to yasm.exe and put in in your PATH. ## Building for Win32 with VS2013 ### Prerequisites - C99-to-C89 : https://github.com/libav/c99-to-c89/releases Needed because VS only supports C99 from version 2013 onwards. - msinttypes : https://code.google.com/p/msinttypes/ For inttypes.h and possibly stdint.h if your VS doesn't already have it. Unzip C99-to-C89 and msinttypes to the same folder. Add this folder to your PATH and INCLUDE variables (create INCLUDE if needed). ### Build - Launch a Visual Studio shell (there should be a shortcut in your start menu). For Windows 64bits exec : C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat x86_amd64 From this shell, launch an MSYS shell (msys32\msys2_shell.bat or msys32\msys2_shell.cmd -full-path) - To initialise MSYS configuration the first time run the command: $ pacman -Syu $ pacman -S make - Make sure cl and link point to VS executables (`which cl`, `which link`). If it isn't the case for win32: $ export "PATH=/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin:$PATH" for win64: $ export "PATH=/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64:$PATH" - You can now build FFmpeg (use absolute paths to specify directories) : `./ffmpeg_build.sh ` Windows commands: cd $SCOL_DEPENDENCIES_PATH/ffmpeg/sources ./ffmpeg_build.sh win32 release $SCOL_DEPENDENCIES_PATH/ffmpeg/sources/FFmpeg $SCOL_DEPENDENCIES_PATH/ffmpeg/sdk/windows/x86 ./ffmpeg_build.sh win64 release $SCOL_DEPENDENCIES_PATH/ffmpeg/sources/FFmpeg $SCOL_DEPENDENCIES_PATH/ffmpeg/sdk/windows/x64 If the build fails because of mutliple int type declarations, remove stdint.h from the folder where you unpacked msinttypes. *Note* : You can't link a debug Scol build with a release FFmpeg build, and vice versa. ## Building for Android ### Prerequisites - Android NDK (tested with 19b) - Make installed in MSYS ### Build In an MSYS shell: $ cd $SCOL_DEPENDENCIES_PATH/ffmpeg/sources $ ./ffmpeg_build_android.sh Or manually: Use this command to add the binaries of the Android NDK to the PATH : export PATH="$ANDROID_NDK/toolchains/llvm/prebuilt/windowsx86-64/bin":$PATH Build FFmpeg with the desired options (use absolute paths to specify directories) : `./ffmpeg_build.sh android ` export PATH="$ANDROID_NDK/toolchains/llvm/prebuilt/windowsx86-64/bin":$PATH cd $SCOL_DEPENDENCIES_PATH/ffmpeg/sources ./ffmpeg_build.sh android release $SCOL_DEPENDENCIES_PATH/ffmpeg/sources/FFmpeg $SCOL_DEPENDENCIES_PATH/ffmpeg/sdk/android/armeabi-v7a $ANDROID_NDK 19 armeabi-v7a $SCOL_DEPENDENCIES_PATH/sdk/android/armeabi-v7a ./ffmpeg_build.sh android release $SCOL_DEPENDENCIES_PATH/ffmpeg/sources/FFmpeg $SCOL_DEPENDENCIES_PATH/ffmpeg/sdk/android/arm64-v8a $ANDROID_NDK 21 arm64-v8a $SCOL_DEPENDENCIES_PATH/sdk/android/arm64-v8a ./ffmpeg_build.sh android release $SCOL_DEPENDENCIES_PATH/ffmpeg/sources/FFmpeg $SCOL_DEPENDENCIES_PATH/ffmpeg/sdk/android/x86 $ANDROID_NDK 19 x86 $SCOL_DEPENDENCIES_PATH/sdk/android/x86 ./ffmpeg_build.sh android release $SCOL_DEPENDENCIES_PATH/ffmpeg/sources/FFmpeg $SCOL_DEPENDENCIES_PATH/ffmpeg/sdk/android/x86_64 $ANDROID_NDK 21 x86_64 $SCOL_DEPENDENCIES_PATH/sdk/android/x86_64