├── .gitignore ├── .gitmodules ├── .sf ├── .travis.yml ├── README.md └── build-ffmpeg.sh /.gitignore: -------------------------------------------------------------------------------- 1 | ffmpeg-2.* 2 | FFmpeg-iOS 3 | scratch 4 | thin 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "x264"] 2 | path = x264 3 | url = https://github.com/Diveinedu-CN/x264-for-iOS.git 4 | [submodule "librtmp-for-iOS"] 5 | path = librtmp-for-iOS 6 | url = https://github.com/Diveinedu-CN/librtmp-for-iOS.git 7 | -------------------------------------------------------------------------------- /.sf: -------------------------------------------------------------------------------- 1 | U2FsdGVkX1963CBvqs0HeUSGVyB5D9h3ZGt59hEumxSseCqcFaPYkWuVfH2Z7AAp 2 | IKSrSFVBJyjmOFCp0atyz43YHXRfNyxRr3+Y7fKAyTnkEnI+XZVl9GLCLAndeyiX 3 | 76V9+YomXl8VXJF7GJoa/37HMbFJ2XniDCsxsPuQm51lkhRUDqU9/g91x3WcQgWN 4 | TpJv1YFg8tL1Dsf82b+zvQ+VhDcbTOcB+BKhHe+MYyR7p13caN20j7hbzvxGXFsV 5 | tjugHZuIhg8EbrDdSP0vAhqgKt7NoW3Enino54/EVjX8VysuP4B3Z9Hi24dWccJf 6 | 9WxsTkoaAFPCPXkv5GZ95W73p41G1zPFh5kOHwnli7Kvb6IKSQq/yrfTf5SOTUox 7 | 85JAYk3pCPqVSA/v5i6z1e11382jdAszNA8+B916gjK84YRFAkYB40Y+BHvsrqHW 8 | 9XL0o6u0BZmUkx+hx78IrwmIewqbq2+6lU+vOTFWevl1pYHQIm8x3IwazM275zu/ 9 | e4Rth3sDGiELASjW+LZs2+PwchL7uyxGmlF/YuHJDePWWEl18Hk8lVBebjiY1DqA 10 | ZpaC9VdHpuioK5JxBcZktqw18hVR8hkVQpJUT0PokkEsEf2+oeymY6LgFbnIrO8/ 11 | SwBgqjHHRKwbzrLok3cRUiC+gxNWjHi+x+W/QVG4l4On/bsCT/EAxiF+Q+p1U7OC 12 | 4YkxNF7A2l1PcNk+PAhy4VyHfOtidcGeRomHj5DiS98QQJCLUaVE4kmVrF1wDYlO 13 | pc9qKtyvhFGz/eEpXmLV9gzHD3S7pKdBU0NAU8wVeeaGOGyX9ISpztQlvEWlPyEQ 14 | ke4M+Pj1CfOQxFc5rX6EoztI+qHogEUcBD9FBYtFswBAcSG9kYhIuORR44LPB6yF 15 | m98e+PfyXGVLGI5GFNV1Sw== 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | script: ./build-ffmpeg.sh 2>.stderr 4 | 5 | env: 6 | global: 7 | - secure: "POoeB0wNaIPKORu8solBfDwSbgk6bsxSJpVWqVawledYiZHnYLXUDzDawoKOXzjJ1oQQiluZWCmv+RXDA9gthTNrH08fuUEvsUHBr7sgHqaOskEbKN/s2962FLy4FRZdQyZFkrrzNcqnc3xaxgF5ZyjRewtB0JioaOSAPEH8ALc=" 8 | - TARBALL=ffmpeg-ios-$TRAVIS_BRANCH.tar.bz2 9 | 10 | after_success: 11 | - tar cjf $TARBALL FFmpeg-iOS .stderr scratch/*/config.log ffmpeg*/LICENSE.md ffmpeg*/COPYING.* README.md 12 | - openssl aes-256-cbc -k "$secret" -in .sf -d -a -out id_sf 13 | - chmod 600 id_sf 14 | - scp -i id_sf -o 'StrictHostKeyChecking no' $TARBALL koolbear@frs.sourceforge.net:/home/frs/project/ffmpeg-ios 15 | 16 | after_failure: cat .stderr 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FFmpeg iOS build script 2 | 3 | [![Build Status](https://travis-ci.org/kewlbear/FFmpeg-iOS-build-script.svg?branch=master)](https://travis-ci.org/kewlbear/FFmpeg-iOS-build-script) 4 | 5 | This is a shell script to build FFmpeg libraries for iOS apps. 6 | 7 | Tested with: 8 | 9 | * FFmpeg 2.8.4 10 | * Xcode 7.2 11 | 12 | ## Requirements 13 | 14 | * https://github.com/libav/gas-preprocessor 15 | * yasm 1.2.0 16 | 17 | ## Usage 18 | * Preparation: 19 | git submodule update 20 | 21 | * To build everything: 22 | 23 | ./build-ffmpeg.sh 24 | 25 | * To build arm64 libraries: 26 | 27 | ./build-ffmpeg.sh arm64 28 | 29 | * To build fat libraries for armv7 and x86_64 (64-bit simulator): 30 | 31 | ./build-ffmpeg.sh armv7 x86_64 32 | 33 | * To build fat libraries from separately built thin libraries: 34 | 35 | ./build-ffmpeg.sh lipo 36 | 37 | ## Download 38 | 39 | You can download a binary for FFmpeg 2.8.4 release at http://www.ffmpeg.org/releases/ffmpeg-2.8.4.tar.bz2 40 | 41 | ## External libraries 42 | 43 | You should link your app with 44 | 45 | * libz.dylib 46 | * libbz2.dylib 47 | * libiconv.dylib 48 | 49 | ## Influences 50 | 51 | * https://github.com/bbcallen/ijkplayer/blob/fc70895c64cbbd20f32f1d81d2d48609ed13f597/ios/tools/do-compile-ffmpeg.sh#L7 52 | -------------------------------------------------------------------------------- /build-ffmpeg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | git submodule foreach git pull origin master 5 | 6 | # directories 7 | SOURCE="ffmpeg-2.8.4" 8 | FAT="FFmpeg-iOS" 9 | 10 | SCRATCH="scratch" 11 | # must be an absolute path 12 | THIN=`pwd`/"thin" 13 | 14 | 15 | USE_LIBRTMP="n" 16 | 17 | OPENSSL="$PWD/OpenSSL-for-iPhone" 18 | LIBRTMP="$PWD/librtmp-for-iOS" 19 | 20 | # absolute path to x264 library 21 | X264=`pwd`/x264/x264-iOS 22 | 23 | #FDK_AAC=`pwd`/fdk-aac/fdk-aac-ios 24 | 25 | CONFIGURE_FLAGS="--enable-cross-compile --disable-debug --disable-programs \ 26 | --disable-doc --enable-pic --enable-nonfree --enable-gpl --enable-version3" 27 | 28 | if [ $USE_LIBRTMP = "y" ] && [ -d $LIBRTMP ]; then 29 | pushd librtmp-for-iOS 30 | echo "building libRTMP-iOS library for iOS..." 31 | git submodule init 32 | git submodule update 33 | ./build-librtmp.sh 34 | popd 35 | fi 36 | 37 | 38 | if [ $USE_LIBRTMP = "YES" ] && [ -d $LIBRTMP ]; then 39 | CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-librtmp --enable-openssl" 40 | export PKG_CONFIG_PATH="$LIBRTMP/lib/pkgconfig" 41 | fi 42 | 43 | if [ -d "$PWD/x264" ] 44 | then 45 | pushd x264 46 | echo "building x264 library for iOS..." 47 | git submodule init 48 | git submodule update 49 | ./build-x264.sh 50 | popd 51 | else 52 | echo "x264 submodule doesn't exist..." 53 | exit 1 54 | fi 55 | 56 | if [ "$X264" ] 57 | then 58 | CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libx264 --enable-gpl" 59 | fi 60 | 61 | if [ "$FDK_AAC" ] 62 | then 63 | CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libfdk-aac" 64 | fi 65 | 66 | # avresample 67 | CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample" 68 | 69 | ARCHS="armv7 armv7s arm64 x86_64 i386" 70 | 71 | COMPILE="y" 72 | LIPO="y" 73 | 74 | DEPLOYMENT_TARGET="6.0" 75 | 76 | if [ "$*" ] 77 | then 78 | if [ "$*" = "lipo" ] 79 | then 80 | # skip compile 81 | COMPILE= 82 | else 83 | ARCHS="$*" 84 | if [ $# -eq 1 ] 85 | then 86 | # skip lipo 87 | LIPO= 88 | fi 89 | fi 90 | fi 91 | 92 | if [ "$COMPILE" ] 93 | then 94 | if [ ! `which yasm` ] 95 | then 96 | echo 'Yasm not found' 97 | if [ ! `which brew` ] 98 | then 99 | echo 'Homebrew not found. Trying to install...' 100 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \ 101 | || exit 1 102 | fi 103 | echo 'Trying to install Yasm...' 104 | brew install yasm || exit 1 105 | fi 106 | if [ ! `which gas-preprocessor.pl` ] 107 | then 108 | echo 'gas-preprocessor.pl not found. Trying to install...' 109 | (curl -L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl \ 110 | -o /usr/local/bin/gas-preprocessor.pl \ 111 | && chmod +x /usr/local/bin/gas-preprocessor.pl) \ 112 | || exit 1 113 | fi 114 | 115 | if [ ! -r $SOURCE ] 116 | then 117 | echo 'FFmpeg source not found. Trying to download...' 118 | curl http://www.ffmpeg.org/releases/$SOURCE.tar.bz2 | tar xj \ 119 | || exit 1 120 | fi 121 | 122 | CWD=`pwd` 123 | for ARCH in $ARCHS 124 | do 125 | echo "building $ARCH..." 126 | mkdir -p "$SCRATCH/$ARCH" 127 | cd "$SCRATCH/$ARCH" 128 | 129 | CFLAGS="-arch $ARCH" 130 | if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ] 131 | then 132 | PLATFORM="iPhoneSimulator" 133 | CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET" 134 | else 135 | PLATFORM="iPhoneOS" 136 | CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET" 137 | if [ "$ARCH" = "arm64" ] 138 | then 139 | EXPORT="GASPP_FIX_XCODE5=1" 140 | fi 141 | fi 142 | 143 | XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'` 144 | CC="xcrun -sdk $XCRUN_SDK clang" 145 | CXXFLAGS="$CFLAGS" 146 | LDFLAGS="$CFLAGS" 147 | if [ $USE_LIBRTMP = "y" ] && [ -d $LIBRTMP ]; then 148 | CFLAGS="$CFLAGS -I$OPENSSL/include" 149 | LDFLAGS="$LDFLAGS -L$OPENSSL/lib" 150 | fi 151 | if [ "$X264" ] 152 | then 153 | CFLAGS="$CFLAGS -I$X264/include" 154 | LDFLAGS="$LDFLAGS -L$X264/lib" 155 | fi 156 | if [ "$FDK_AAC" ] 157 | then 158 | CFLAGS="$CFLAGS -I$FDK_AAC/include" 159 | LDFLAGS="$LDFLAGS -L$FDK_AAC/lib" 160 | fi 161 | 162 | CFLAGS="$CFLAGS -fembed-bitcode" 163 | TMPDIR=${TMPDIR/%\/} $CWD/$SOURCE/configure \ 164 | --target-os=darwin \ 165 | --arch=$ARCH \ 166 | --cc="$CC" \ 167 | $CONFIGURE_FLAGS \ 168 | --extra-cflags="$CFLAGS" \ 169 | --extra-cxxflags="$CXXFLAGS" \ 170 | --extra-ldflags="$LDFLAGS" \ 171 | --prefix="$THIN/$ARCH" \ 172 | || exit 1 173 | 174 | make -j3 install $EXPORT || exit 1 175 | cd $CWD 176 | done 177 | fi 178 | 179 | if [ "$LIPO" ] 180 | then 181 | echo "building fat binaries..." 182 | mkdir -p $FAT/lib 183 | set - $ARCHS 184 | CWD=`pwd` 185 | cd $THIN/$1/lib 186 | for LIB in *.a 187 | do 188 | cd $CWD 189 | echo lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 1>&2 190 | lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB || exit 1 191 | done 192 | 193 | cd $CWD 194 | cp -rf $THIN/$1/include $FAT 195 | fi 196 | 197 | echo Done 198 | --------------------------------------------------------------------------------