ffmpeg一键编译

来源:互联网 发布:淘宝预售不能合并付款 编辑:程序博客网 时间:2024/06/01 10:32

iOS一键编译:

#!/bin/bash############################################################################  Choose your ffmpeg version and your currently-installed iOS SDK version:#VERSION="2.5.2"SDKVERSION="8.3"echo "install gas-* perl script"./install-gas.sh############################################################################### Don't change anything under this line!############################################################################# No need to change this since xcode build will only compile in the# necessary bits from the libraries we createARCHS="armv7 armv7s arm64 i386"DEVELOPER=`xcode-select -print-path`echo "DEVELOPER: $DEVELOPER"if [ "$DEVELOPER" == "" ]; thenecho "ERROR: not found xcode"exit 1;fi#cd "`dirname \"$0\"`"REPOROOT=$(pwd)# Where we'll end up storing things in the endOUTPUTDIR="$REPOROOT/dependencies"mkdir -p $OUTPUTDIR/includemkdir -p $OUTPUTDIR/libmkdir -p $OUTPUTDIR/binBUILDDIR="$REPOROOT/build"mkdir -p $BUILDDIR# where we will keep our sources and build from.#SRCDIR="$BUILDDIR/src"#mkdir -p $SRCDIR# where we will store intermediary buildsINTERDIR="$BUILDDIR/built"mkdir -p $INTERDIR#########################################cd $SRCDIR# Exit the script if an error happensset -eif [ ! -e "./ffmpeg-$VERSION.tar.bz2" ]; thenecho "Downloading ffmpeg-$VERSION.tar.bz2"    curl -LO http://ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2elseecho "Using ffmpeg-$VERSION.tar.bz2"fiif [ ! -e "./ffmpeg" ]; thentar zxf ffmpeg-$VERSION.tar.bz2 -C ./mv ffmpeg-$VERSION ffmpegelseecho "Using existing ffmpeg dir"fi#tar zxf ffmpeg-$VERSION.tar.bz2 -C $SRCDIR#cd "$SRCDIR/ffmpeg-$VERSION"cd "./ffmpeg"set +e # don't bail out of bash script if ccache doesn't existCCACHE=`which ccache`if [ $? == "0" ]; then    echo "Building with ccache: $CCACHE"    CCACHE="$CCACHE "else    echo "Building without ccache"    CCACHE=""fiset -e # back to regular "bail out on error" modefor ARCH in $ARCHSdomake clean >/dev/null && make distclean >/dev/nullif [ "${iARCH}" = "i386" ] || [ "${iARCH}" = "x86_64" ];thenPLATFORM="iPhoneSimulator"        EXTRA_CONFIG="--arch=$ARCH --disable-asm --enable-cross-compile --target-os=darwin --cpu=$ARCH"        EXTRA_CFLAGS="-arch $ARCH"        EXTRA_LDFLAGS="-I$DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk/usr/lib -mfpu=neon"elsePLATFORM="iPhoneOS"        EXTRA_CONFIG="--arch=arm --target-os=darwin --enable-cross-compile --disable-armv5te"        EXTRA_CFLAGS="-w -arch $ARCH -mfpu=neon"        EXTRA_LDFLAGS="-mfpu=neon"fi    mkdir -p "$INTERDIR/$ARCH"if [ "$ARCH" = "arm64" ]   thenEXPORT="GASPP_FIX_XCODE5=1"fi    ./configure --prefix="$INTERDIR/$ARCH" \    --disable-encoders \    --disable-muxers \    --disable-devices \    --disable-protocols \    --disable-network \    --disable-iconv \    --disable-bzlib \    --disable-asm \    --disable-armv6 \    --disable-armv6t2 \    --disable-ffmpeg \    --disable-ffplay \    --disable-ffprobe \    --disable-ffserver \    --disable-avdevice \    --disable-postproc \    --disable-avresample \    --disable-avfilter \    --disable-swscale \    --disable-swresample \    --disable-doc \    --disable-everything \    --enable-decoder=h264 \    --enable-decoder=jpeg2000 \    --enable-decoder=mpeg4 \    --sysroot="$DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk" \    --cc="$DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" \    --as='/usr/local/bin/gas-preprocessor.pl' \    --extra-cflags="$EXTRA_CFLAGS -miphoneos-version-min=$SDKVERSION -I$OUTPUTDIR/include" \    --extra-ldflags="-arch $ARCH $EXTRA_LDFLAGS -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk -miphoneos-version-min=$SDKVERSION -L$OUTPUTDIR/lib" \    $EXTRA_CONFIG \    --enable-pic \    --extra-cxxflags="$CPPFLAGS -I$OUTPUTDIR/include -isysroot $DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk"    make && make install && make clean >/dev/null done###################install iphoneos#####################mkdir -p "$INTERDIR/ios-iphoneos/lib"cd "$INTERDIR/armv7/lib"for file in *.adocd $INTERDIRxcrun -sdk iphoneos lipo -output ios-iphoneos/lib/$file  -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch arm64 arm64/lib/$fileecho "ios-iphoneos $file created."donecp -r $INTERDIR/armv7/include $INTERDIR/ios-iphoneos/echo "iphoneos Done."        ###################build iphonesimulator#####################mkdir -p "$INTERDIR/ios-iphonesimulator/lib"cd "$INTERDIR/i386/lib"for file in *.adocd $INTERDIRxcrun -sdk iphoneos lipo -output ios-iphonesimulator/lib/$file  -create -arch i386 i386/lib/$file -arch x86_64 x86_64/lib/$fileecho "ios-iphonesimulator $file created."done#cp -r $INTERDIR/i386/lib $INTERDIR/ios-iphonesimulator/cp -r $INTERDIR/i386/include $INTERDIR/ios-iphonesimulator/echo "iphonesimulator Done."


Android一键编译:

#!/bin/bash############################################################################  Choose your ffmpeg version and your currently-installed iOS SDK version:#VERSION="2.5.2"SDKVERSION="19"echo "install gas-* perl script"./install-gas.sh############################################################################### Don't change anything under this line!############################################################################# No need to change this since ndk-build will only compile in the# necessary bits from the libraries we createDEVELOPER=`which is ndk-build`DEVELOPER=`dirname $DEVELOPER`echo "NDK-PATH: $DEVELOPER"if [ "$DEVELOPER" == "" ]; thenecho "ERROR: not found ndk-build"exit 1;fiREPOROOT=$(pwd)# Where we'll end up storing things in the endOUTPUTDIR="$REPOROOT/dependencies"mkdir -p $OUTPUTDIR/includemkdir -p $OUTPUTDIR/libmkdir -p $OUTPUTDIR/binBUILDDIR="$REPOROOT/build"mkdir -p $BUILDDIR# where we will keep our sources and build from.#SRCDIR="$BUILDDIR/src"#mkdir -p $SRCDIR# where we will store intermediary buildsINTERDIR="$BUILDDIR/built"mkdir -p $INTERDIR#########################################cd $SRCDIR# Exit the script if an error happensset -eif [ ! -e "./ffmpeg-$VERSION.tar.bz2" ]; thenecho "Downloading ffmpeg-$VERSION.tar.bz2"    curl -LO http://ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2elseecho "Using ffmpeg-$VERSION.tar.bz2"fiif [ ! -e "./ffmpeg" ]; thentar zxf ffmpeg-$VERSION.tar.bz2 -C ./mv ffmpeg-$VERSION ffmpegelseecho "Using existing ffmpeg dir"fi###################build android#####################cd "./ffmpeg"make clean >/dev/null && make distclean >/dev/nullSYSROOT=$DEVELOPER/platforms/android-$SDKVERSION/arch-arm/##这里要注意,如果是linux换成linux-x86_64,看你的系统情况定TOOLCHAIN=$DEVELOPER/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64if [ ! -e $TOOLCHAIN ]; thenecho "ERROR: not found toolchain"exit 1;fiADDI_CFLAGS="-marm"EXTRA_CONFIG="--arch=arm --target-os=linux --enable-cross-compile --disable-armv5te"EXTRA_CFLAGS="-Os -fpic $ADDI_CFLAGS"EXTRA_LDFLAGS="$ADDI_LDFLAGS"./configure --prefix="$INTERDIR/android" \    --disable-encoders \    --disable-muxers \    --disable-devices \    --disable-protocols \    --disable-network \    --disable-iconv \    --disable-bzlib \    --disable-asm \    --disable-armv6 \    --disable-armv6t2 \    --disable-ffmpeg \    --disable-ffplay \    --disable-ffprobe \    --disable-ffserver \    --disable-avdevice \    --disable-postproc \    --disable-avresample \    --disable-avfilter \    --disable-swscale \    --disable-swresample \    --disable-doc \    --disable-everything \    --enable-decoder=h264 \    --enable-decoder=jpeg2000 \    --enable-decoder=mpeg4 \    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \    $EXTRA_CONFIG \    --sysroot=$SYSROOT \    --extra-cflags="$EXTRA_CFLAGS" \    --extra-ldflags="$EXTRA_LDFLAGS" \    $ADDITIONAL_CONFIGURE_FLAG    make && make install && make clean >/dev/nullecho "Android Done."


0 0