-
Notifications
You must be signed in to change notification settings - Fork 111
Home
Supports mingw gcc, msvc(>=2013) for desktop and store, android, ios, raspberry pi, sailfish etc.
You have to set FFmpeg source dir before build: export FFSRC=ffmpeg/source/dir
You can pass arguments to the script, ./avbuild.sh $TARGET_OS "$TARGET_ARCHS"
.
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}
for single architecture build.
./avbuild.sh
Install mingw-w64 compiler on linux or macOS, run ./avbuild.sh mingw64 x86
or ./avbuild.sh mingw64 x86_64
MSYS2 is required. Environment var MSYS2_DIR
must be set, for example C:\msys64
. Click a shortcut in tools dir. Follow the guide in the new shell window.
You can also start a vs prompt, go to msys' bin dir and run
sh --login -i
and./avbuild.sh vc
to build for desktop
Environment var ANDROID_NDK
is required. ./avbuild.sh android[api_level] "arch1 arch2 ... arch1-clang arch2-clang..."
api_level
can be empty to use default value. Default is 14 for 32bit and 21 for 64bit.
Unified headers are used if present.
export FFSRC=/path/to/ffmpeg # if no ffmpeg source fold under this dir
./avbuild.sh android # gcc build for default archs (armv5, armv7, arm64, x86)
./avbuild.sh android armv7 # gcc build for armv7
./avbuild.sh android16 "armv7 arm64" # gcc build for armv7 api level 16 and arm64 api level 21(21 is min level for 64bit)
./avbuild.sh android "armv7-clang arm64" # clang build for armv7, gcc build for arm64
The result dir struct is sdk-android-{gcc,clang}/{include,lib/{armeabi,armeabi-v7a,arm64,x86}}
TODO:
./avbuild android$version ...
To build universal library contains multiple architectures (default are armv7, arm64, i386, x86_64), run ./avbuild.sh ios[version] "arch1 arch2 ..."
version
is min deployment target version. The default version is 5.0 for 32bit and 7.0 for 64bit. Leave it empty to use default version
export FFSRC=/path/to/ffmpeg # if no ffmpeg source fold under this dir
./avbuild.sh ios # armv7, arm64, i386, x86_64. destination dir is sdk-ios
./avbuild.sh ios8.0 "armv7 arm64" # build for armv7 and arm64, min supported version is ios8.0. destination dir is sdk-ios
./avbuild.sh ios "arm64" # build for arm64 only, destination dir is sdk-ios-arm64
The result libraries are in sdk-ios for multiple architectures build.
Bitcode is enabled for devices by default. Bitcode can be disable by environment var BITCODE=0
, for example run BITCODE=0 ./avbuild.sh ...
Download toolchains and sysroot
- http://gnutoolchains.com/raspberry/ (windows, sysroot included)
- http://www.jaredwolff.com/toolchains/ (macOS)
- https://github.com/raspberrypi/tools/tree/master/arm-bcm2708 (linux)
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 ./avbuild.sh rpi #or rpi2, rpi3
or CROSS_PREFIX=gcc_prefix SYSROOT=your_sysroot ./avbuild.sh rpi
.
Requirements: clang + lld + sysroot
Ubuntu install: apt install clang-5.0 lld-5.0 # latest release
If lld is found, gcc cross toolchain and CROSS_PREFIX
is not required. You can build on any host such as windows, linux and macOS
If lld is not found, gcc cross toolchain is required to invoke binutils such as strip, ld.
Examples:
- clang + gcc binutils:
CROSS_PREFIX=gcc_prefix SYSROOT=your_sysroot ./avbuild.sh rpi armv6zk-clang-5.0
- clang + lld:
SYSROOT=your_sysroot ./avbuild.sh rpi armv7-a-clang-5.0
- clang asm can not build swscale: https://travis-ci.org/wang-bin/avbuild/jobs/294735568
FFmpeg configure script is slow because only 1 job is running. Multiarch build can simultaneously run configure to reduce configure time. In build command $ENV_VARS ./avbuild.sh $TARGET_OS "$TARGET_ARCHS"
, "$TARGET_ARCHS"
can be a list of target arch[-compiler]
. For example:
./avbuild android "armv7 armv8-clang"
./avbuild mingw64 "x86 x86_64"
./avbuild rpi "armv6-clang-5.0 armv7 armv8"
./avbuild ios "arm64 x86_64"
The result directory structure is
sdk-$TARGET_ARCHS-$COMPILER1
/arch11
/arch12
sdk-$TARGET_ARCHS-$COMPILER2
/arch21
/arch22
Copy config-lite.sh to config.sh. Only frequently used features are enabled. Encoding is disabled except hardware accelerated encoders.