2
回答
编译opencore-amr for iOS
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

amr在传声音中应用较多,因为十多K大小就可以长达一分钟的内容。在ios sdk4.0以后就不再支持这种格式的文件,只有用开源opencore-amr,今天试着编译了一下,结果成功了。

写了一个脚本:

#!/bin/sh

###########################################################################
#  Change values here													  #
#																		  #
VERSION="0.1.2"		  											          #
SDKVERSION="4.2"														  #
#																		  #
###########################################################################
#																		  #
# Don't change anything under this line!								  #
#																		  #
###########################################################################

#opencore-amr-0.1.2

CURRENTPATH=`pwd`

mkdir -p "${CURRENTPATH}/src"
tar zxf opencore-amr-${VERSION}.tar.gz -C "${CURRENTPATH}/src"
cd "${CURRENTPATH}/src/opencore-amr-${VERSION}"

############
# iPhone Simulator
echo "Building opencore-amr for iPhoneSimulator ${SDKVERSION} i386"
echo "Please stand by..."

mkdir -p "${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}.sdk"
LOG="${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}.sdk/build-openamr-${VERSION}.log"

SDK=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk
export CC ="/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -arch i386"
export CXX="/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++ -arch i386"
LDFLAGS="-Wl,-syslibroot,$SDK" 
./configure --disable-shared --prefix="${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}.sdk"

make >> "${LOG}" 2>&1
make install >> "${LOG}" 2>&1
make clean >> "${LOG}" 2>&1
#############

#############
# iPhoneOS armv6
echo "Building opencore-amr for iPhoneOS ${SDKVERSION} armv6"
echo "Please stand by..."

mkdir -p "${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv6.sdk"
LOG="${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv6.sdk/build-openamr-${VERSION}.log"

SDK=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk
export CC ="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6 --sysroot=$SDK"
export CXX="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++ -arch armv6 --sysroot=$SDK"
LDFLAGS="-Wl,-syslibroot,$SDK"
./configure --host=arm-apple-darwin --target=darwin --prefix="${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv6.sdk" --disable-shared

make >> "${LOG}" 2>&1
make install >> "${LOG}" 2>&1
make clean >> "${LOG}" 2>&1
#############

#############
# iPhoneOS armv7
echo "Building opencore-amr for iPhoneOS ${SDKVERSION} armv7"
echo "Please stand by..."

mkdir -p "${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk"
LOG="${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/build-openamr-${VERSION}.log"

SDK=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk
export CC ="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7 --sysroot=$SDK"
export CXX="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++ -arch armv7 --sysroot=$SDK"
LDFLAGS="-Wl,-syslibroot,$SDK"
./configure --host=arm-apple-darwin --target=darwin --prefix="${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk" --disable-shared 

make >> "${LOG}" 2>&1
make install >> "${LOG}" 2>&1
make clean >> "${LOG}" 2>&1
#############


echo "Build library..."
mkdir -p ${CURRENTPATH}/lib
lipo -create -arch i386 ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}.sdk/lib/libopencore-amrwb.a -arch armv6 ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv6.sdk/lib/libopencore-amrwb.a -arch armv7 ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libopencore-amrwb.a -output ${CURRENTPATH}/lib/libopencore-amrwb.a

lipo -create -arch i386 ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}.sdk/lib/libopencore-amrnb.a -arch armv6 ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv6.sdk/lib/libopencore-amrnb.a -arch armv7 ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libopencore-amrnb.a -output ${CURRENTPATH}/lib/libopencore-amrnb.a


mkdir -p ${CURRENTPATH}/include
cp -R ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}.sdk/include ${CURRENTPATH}/include/
echo "Building done."
echo "Cleaning up..."
rm -rf ${CURRENTPATH}/src
rm -rf ${CURRENTPATH}/bin
echo "Done."


1.将上面脚本内容存入一个.sh文件, 

2. 然后修改为有可运行chmod 777 xxx.sh.  

3. 再将下载下来的opencore-amr.tar.gz与xxx.sh放同一目录,

4. 然后在命令行运行./xxx.sh

这样在目录下就生成一个include与lib文件夹,里面就是你想要的库了。


关于库的使用,我另写了一篇文章介绍,传送门,其过程也遇到了一个小问题,不过最后还是解决了。

这儿有一个demo将amr转成wav


参考资料:

http://sourceforge.net/mailarchive/forum.php?thread_name=alpine.DEB.2.00.1106152258040.2333%40cone.martin.st&forum_name=opencore-amr-devel

http://sourceforge.net/mailarchive/forum.php?thread_name=alpine.DEB.2.00.1103211053460.3794%40cone.home.martin.st&forum_name=opencore-amr-devel

http://tinsuke.wordpress.com/2011/02/17/how-to-cross-compiling-libraries-for-ios-armv6armv7i386/


原文链接:http://blog.csdn.net/favormm/article/details/6772097
<无标签>
举报
长平狐
发帖于5年前 2回/4K+阅
顶部