Skip to content
WangBin edited this page Feb 14, 2017 · 50 revisions

Supports mingw gcc, msvc(>=2013) for desktop and store, android, ios, maemo5, maemo6(meego), sailfish os etc. Just run

export FFSRC=/path/to/ffmpeg # if no ffmpeg source fold under this dir
./build_ffmpeg.sh            # build for host platform

You can pass arguments to the script, ./build_ffmpeg.sh TARGET_OS TARGET_ARCH.

For example

./build_ffmpeg.sh android        # android armv7
./build_ffmpeg.sh android x86    # android x86
./build_ffmpeg.sh ios arm64

You may have to set some vars in config-${TARGET_OS}.sh.

After building, the result headers and libs you need are in sdk-${TARGET_OS}-${TARGET_ARCH}

Host Build

./build_ffmpeg.sh

Windows

MinGW Cross Build

Install mingw-w64 compiler on linux or macOS, run ./build_ffmpeg.sh mingw64 x86 or ./build_ffmpeg.sh mingw64 x86_64

Windows Desktop(MinGW/VC), Store, Phone

MSYS2 is required. Modify MSYS2_BIN in msys2.bat. Click a shortcut in tools dir. Follow the guide in the new shell window.

  • gas-preprocessor.pl and cpp.exe from gcc toolchain is required to build arm asm code. Otherwise asm will be disabled.

You can also start a vs prompt, go to msys' bin dir and run sh --login -i and ./build_ffmpeg.sh vc to build for desktop

Android

Environment var ANDROID_NDK is required

./build_ffmpeg.sh android [armv5|armv7|x86]                         # gcc
android_toolchain=clang ./build_ffmpeg.sh android [armv5|armv7|x86] # clang

iOS

To build for 1 architecture, run

export FFSRC=/path/to/ffmpeg # if no ffmpeg source fold under this dir
./build_ffmpeg.sh ios armv7 # or arm64, i386, x86, x86_64 etc.

The result libraries are in sdk-ios-armv7.

To build s universal library supports all architectures (default are armv7, arm64, i386, x86_64), run

export FFSRC=/path/to/ffmpeg # if no ffmpeg source fold under this dir
./ios.sh

The result libraries are in sdk-ios

Bitcode is enabled for devices by default. To disable bitcode, run BITCODE=0 ./build_ffmpeg.sh ... or BITCODE=0 ./ios.sh instead

Use ./build_ffmpeg.sh ios4.0 armv7 to set minimal supported iOS version (4.0 here)

Raspberry Pi Cross Build

Download toolchains and sysroot

The default gcc is arm-linux-gnueabihf-gcc, sysroot is gcc sysroot. Set PATH to include gcc dir export PATH=$GCC_BIN_DIR:$PATH. Run ./build_ffmpeg.sh rpi or CROSS_PREFIX=your_prefix SYSROOT=your_sysroot ./build_ffmpeg.sh rpi.

Lite Build

Copy config-lite.sh to config.sh. Only frequently used features are enabled. Encoding is disabled except hardware accelerated encoders.

Prebuilt FFmpeg