ffmpeg一键编译

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 create
ARCHS="armv7 armv7s arm64 i386"

DEVELOPER=`xcode-select -print-path`
echo "DEVELOPER: $DEVELOPER"
if [ "$DEVELOPER" == "" ]; then
	echo "ERROR: not found xcode"
	exit 1;
fi

#cd "`dirname \"$0\"`"
REPOROOT=$(pwd)

# Where we'll end up storing things in the end
OUTPUTDIR="$REPOROOT/dependencies"
mkdir -p $OUTPUTDIR/include
mkdir -p $OUTPUTDIR/lib
mkdir -p $OUTPUTDIR/bin


BUILDDIR="$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 builds
INTERDIR="$BUILDDIR/built"
mkdir -p $INTERDIR

########################################

#cd $SRCDIR

# Exit the script if an error happens
set -e

if [ ! -e "./ffmpeg-$VERSION.tar.bz2" ]; then
	echo "Downloading ffmpeg-$VERSION.tar.bz2"
    curl -LO http://ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2
else
	echo "Using ffmpeg-$VERSION.tar.bz2"
fi

if [ ! -e "./ffmpeg" ]; then
	tar zxf ffmpeg-$VERSION.tar.bz2 -C ./
	mv ffmpeg-$VERSION ffmpeg
else
	echo "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 exist
CCACHE=`which ccache`
if [ $? == "0" ]; then
    echo "Building with ccache: $CCACHE"
    CCACHE="$CCACHE "
else
    echo "Building without ccache"
    CCACHE=""
fi
set -e # back to regular "bail out on error" mode

for ARCH in $ARCHS
do
	make clean >/dev/null && make distclean >/dev/null
	
	if [ "${iARCH}" = "i386" ] || [ "${iARCH}" = "x86_64" ];
	then
		PLATFORM="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"
	else
		PLATFORM="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" ]
   	then
		EXPORT="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 *.a
do

cd $INTERDIR
xcrun -sdk iphoneos lipo -output ios-iphoneos/lib/$file  -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch arm64 arm64/lib/$file
echo "ios-iphoneos $file created."

done
cp -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 *.a
do

cd $INTERDIR
xcrun -sdk iphoneos lipo -output ios-iphonesimulator/lib/$file  -create -arch i386 i386/lib/$file -arch x86_64 x86_64/lib/$file
echo "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 create

DEVELOPER=`which is ndk-build`
DEVELOPER=`dirname $DEVELOPER`

echo "NDK-PATH: $DEVELOPER"

if [ "$DEVELOPER" == "" ]; then
	echo "ERROR: not found ndk-build"
	exit 1;
fi


REPOROOT=$(pwd)

# Where we'll end up storing things in the end
OUTPUTDIR="$REPOROOT/dependencies"
mkdir -p $OUTPUTDIR/include
mkdir -p $OUTPUTDIR/lib
mkdir -p $OUTPUTDIR/bin


BUILDDIR="$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 builds
INTERDIR="$BUILDDIR/built"
mkdir -p $INTERDIR

########################################

#cd $SRCDIR

# Exit the script if an error happens
set -e

if [ ! -e "./ffmpeg-$VERSION.tar.bz2" ]; then
	echo "Downloading ffmpeg-$VERSION.tar.bz2"
    curl -LO http://ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2
else
	echo "Using ffmpeg-$VERSION.tar.bz2"
fi

if [ ! -e "./ffmpeg" ]; then
	tar zxf ffmpeg-$VERSION.tar.bz2 -C ./
	mv ffmpeg-$VERSION ffmpeg
else
	echo "Using existing ffmpeg dir"
fi

###################build android#####################

cd "./ffmpeg"

make clean >/dev/null && make distclean >/dev/null

SYSROOT=$DEVELOPER/platforms/android-$SDKVERSION/arch-arm/

##这里要注意,如果是linux换成linux-x86_64,看你的系统情况定
TOOLCHAIN=$DEVELOPER/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64

if [ ! -e $TOOLCHAIN ]; then
	echo "ERROR: not found toolchain"
	exit 1;
fi

ADDI_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/null

echo "Android Done."


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值