IOS 编译ffmpeg For SDK6.1,模拟器、armv7、armv7s均可使用
来源:互联网 发布:mac versions 注册码 编辑:程序博客网 时间:2024/06/01 15:48
最近在研究IOS视频播放器,需要使用到ffmpeg4ios,所以整理编译过程。
需要使用到Git,Linux Shell脚本执行install-ffmpeg.sh即可。
下述Linux Shell脚本下载地址:http://ishare.iask.sina.com.cn/f/37135883.html
install-ffmpeg.sh
SRCDIR=`pwd`VERSION="1.2.1"echo "install gas-* perl script"./install-gas.shecho "download ffmpeg"set -eif [ ! -e ffmpeg-${VERSION}.tar.bz2 ]; then echo "Downloading ffmpeg-${VERSION}.tar.bz2" curl -O http://ffmpeg.org/releases/ffmpeg-${VERSION}.tar.bz2else echo "Using ffmpeg-${VERSION}.tar.bz2"fitar jxvf ffmpeg-${VERSION}.tar.bz2echo "copy install shell script to ffmpeg"cp ./compile-*.sh "ffmpeg-${VERSION}"cd "ffmpeg-${VERSION}"if [ -d x264 ] then (cd $SRCDIR/ffmpeg-${VERSION}/x264; git pull) else git clone git://git.videolan.org/x264.git x264fiecho "compile armv7s ..."./compile-armv7s.shecho "compile armv7 ..."./compile-armv7.shecho "compile i386 for Simulator ..."./compile-i386.shecho "packaging universal version ..."./compile-universal.sh
install-gas.sh
echo "install gas-preproccesor.pr"git clone git://github.com/mansr/gas-preprocessor.gitecho "copy gas-preprocessor.pl to /usr/sbin"sudo cp -f gas-preprocessor/gas-preprocessor.pl /usr/sbin/echo "set execute right"chmod +x /usr/sbin/gas-preprocessor.plecho "install finished."
compile-armv7s.sh
SRCDIR=`pwd`SDKVERSION="6.1"cd $SRCDIR/x264make cleanCC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ ./configure \ --host=arm-apple-darwin \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk \ --prefix=build/armv7s \ --extra-cflags='-arch armv7s' \ --extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/system -arch armv7s" \ --enable-pic --disable-shared --enable-staticmake && make installcd $SRCDIRmake clean./configure \ --prefix=armv7s \ --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk \ --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/system \ --target-os=darwin \ --arch=arm \ --cpu=cortex-a9 \ --extra-cflags='-I./x264/build/armv7s/include -arch armv7s' \ --extra-ldflags='-L./x264/build/armv7s/lib -arch armv7s' \ --enable-pic \ --enable-cross-compile \ --enable-gpl \ --enable-libx264 \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffserver \ --disable-doc # build for armv7smake cleanmake# copy out the armv7s libsmkdir -p ./build/armv7scp -f ./libavcodec/libavcodec.a ./build/armv7s/libavcodec.acp -f ./libavdevice/libavdevice.a ./build/armv7s/libavdevice.acp -f ./libavfilter/libavfilter.a ./build/armv7s/libavfilter.acp -f ./libavformat/libavformat.a ./build/armv7s/libavformat.acp -f ./libavutil/libavutil.a ./build/armv7s/libavutil.acp -f ./libswscale/libswscale.a ./build/armv7s/libswscale.a
compile-armv7.sh
SRCDIR=`pwd`SDKVERSION="6.1"cd $SRCDIR/x264make cleanCC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ ./configure \ --host=arm-apple-darwin \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk \ --prefix=build/armv7 \ --extra-cflags='-arch armv7' \ --extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/system -arch armv7" \ --enable-pic --disable-shared --enable-staticmake && make installcd $SRCDIRmake clean./configure \ --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk \ --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/system \ --target-os=darwin \ --arch=arm \ --cpu=cortex-a8 \ --extra-cflags='-I./x264/build/armv7/include -arch armv7' \ --extra-ldflags='-L./x264/build/armv7/lib -arch armv7' \ --enable-pic \ --enable-cross-compile \ --enable-gpl \ --enable-libx264 \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffserver \ --disable-doc # build for armv7make cleanmake# copy out the armv7 libsmkdir -p ./build/armv7cp -f ./libavcodec/libavcodec.a ./build/armv7/libavcodec.acp -f ./libavdevice/libavdevice.a ./build/armv7/libavdevice.acp -f ./libavfilter/libavfilter.a ./build/armv7/libavfilter.acp -f ./libavformat/libavformat.a ./build/armv7/libavformat.acp -f ./libavutil/libavutil.a ./build/armv7/libavutil.acp -f ./libswscale/libswscale.a ./build/armv7/libswscale.a
compile-i386.sh
SRCDIR=`pwd`SDKVERSION="6.1"cd $SRCDIR/x264echo "compile x264 i386 ..."make cleanCC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \ ./configure \ --host=i386-apple-darwin \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk \ --prefix=build/i386 \ --extra-cflags='-arch i386' \ --extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk/usr/lib/system -arch i386" \ --enable-pic --disable-shared --enable-static --disable-asmmake && make installcd $SRCDIRecho "compile ffmpeg i386 ..."make clean./configure \ --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc' \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk \ --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk/usr/lib/system \ --target-os=darwin \ --arch=i386 \ --cpu=i386 \ --extra-cflags='-I./x264/build/i386/include -arch i386' \ --extra-ldflags='-L./x264/build/i386/lib -arch i386' \ --enable-pic \ --enable-cross-compile \ --enable-gpl \ --enable-libx264 \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffserver \ --disable-doc \ --disable-asm# build for i386make cleanmake# copy out the i386 libsmkdir -p ./build/i386cp -f ./libavcodec/libavcodec.a ./build/i386/libavcodec.acp -f ./libavdevice/libavdevice.a ./build/i386/libavdevice.acp -f ./libavfilter/libavfilter.a ./build/i386/libavfilter.acp -f ./libavformat/libavformat.a ./build/i386/libavformat.acp -f ./libavutil/libavutil.a ./build/i386/libavutil.acp -f ./libswscale/libswscale.a ./build/i386/libswscale.a
compile-universal.sh
# make fat (universal) libsxcrun -sdk iphoneos lipo -output ./build/libavcodec.a \ -create \ -arch armv7s ./build/armv7s/libavcodec.a \ -arch armv7 ./build/armv7/libavcodec.a \ -arch i386 ./build/i386/libavcodec.axcrun -sdk iphoneos lipo -output ./build/libavdevice.a \ -create \ -arch armv7s ./build/armv7s/libavdevice.a \ -arch armv7 ./build/armv7/libavdevice.a \ -arch i386 ./build/i386/libavdevice.axcrun -sdk iphoneos lipo -output ./build/libavfilter.a \ -create \ -arch armv7s ./build/armv7s/libavfilter.a \ -arch armv7 ./build/armv7/libavfilter.a \ -arch i386 ./build/i386/libavfilter.axcrun -sdk iphoneos lipo -output ./build/libavformat.a \ -create \ -arch armv7s ./build/armv7s/libavformat.a \ -arch armv7 ./build/armv7/libavformat.a \ -arch i386 ./build/i386/libavformat.axcrun -sdk iphoneos lipo -output ./build/libavutil.a \ -create \ -arch armv7s ./build/armv7s/libavutil.a \ -arch armv7 ./build/armv7/libavutil.a \ -arch i386 ./build/i386/libavutil.axcrun -sdk iphoneos lipo -output ./build/libswscale.a \ -create \ -arch armv7s ./build/armv7s/libswscale.a \ -arch armv7 ./build/armv7/libswscale.a \ -arch i386 ./build/i386/libswscale.axcrun -sdk iphoneos lipo -output ./x264/build/libx264.a \ -create \ -arch armv7s ./x264/build/armv7s/lib/libx264.a \ -arch armv7 ./x264/build/armv7/lib/libx264.a \ -arch i386 ./x264/build/i386/lib/libx264.a
编译出来的文件为:
libavcodec.a
用于各种类型声音/图像编解码;
libavdevice.a
libavfilter.a
libavformat.a
libavutil.a
包含一些公共的工具函数;
libswscale.a
用于视频场景比例缩放、色彩映射转换;
libx264.a
开源示例iFrameExtractor
git clone git://github.com/lajos/iFrameExtractor.git
这是一个iOS下利用ffmpeg解码播放的例子。不过这个例子是利用贴图的方式来显示,效果不是很好,而且没有加入声音解码。
要想项目顺利运行需要添加支持库
Project References -> Targets -> Build Phases -> Link Binary With Librarys
- libbz.dylib
- libz.dylib
- libiconv.2.4.0.dylib
修改头文件搜索路径(头文件下载地址:http://www.ffmpeg4ios.org/releases/ffmpeg4ios-1.0-include.zip)
Project References -> Targets -> Build Settings -> Header Search Paths
修改库文件搜索路径(编译出来.a文件的路径)
Project References -> Targets -> Build Settings -> Library Search Paths
有疑问者可以留言
<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- IOS 编译ffmpeg For SDK6.1,模拟器、armv7、armv7s均可使用
- IOS 编译ffmpeg For SDK6.1,模拟器、armv7、armv7s均可使用
- IOS 编译ffmpeg For SDK6.1,模拟器、armv7、armv7s均可使用
- IOS 编译ffmpeg For SDK6.1,模拟器、armv7、armv7s均可使用
- iOS下完美编译ffmpeg+x264,支持armv7, armv7s, 模拟器
- iOS下完美编译ffmpeg+x264,支持armv7, armv7s, 模拟器
- ffmpeg for ios 交叉编译 (支持i686 armv7 armv7s) 包含lame支持
- ffmpeg for ios 交叉编译 (支持i686 armv7 armv7s) 包含lame支持
- ffmpeg armv7,armv7s (for iOS)(验证通过,Mac10.8.2+xCode4.5.1可以编译)
- ffmpeg for ios 交叉编译 (支持i686 armv7 armv7s) 包含lame支持
- iOS下完美编译ffmpeg+x264,支持armv7, armv7s, 模拟器 (验证不通过,估计和ffmpeg版本有关)
- iOS下完美编译ffmpeg+x264,支持armv7, armv7s, 模拟器 (验证不通过,估计和ffmpeg版本有关)
- compile ffmpeg for armv7 armv7s
- Compile ffmpeg for iOS 6, support Simulator & armv7 & armv7s
- iOS 编译armv7 armv7s openssl
- build ffmpeg for armv7 and armv7s
- build ffmpeg for armv7 and armv7s
- build ffmpeg for armv7 and armv7s
- linux驱动学习--第五天:第四章 Linux 内核模块 之 Linux 内核模块简介
- iOS UIKit:UITableView
- HDU-4476
- NET操作Excel的通用类ExecelHelper.cs
- linux查看文件内容
- IOS 编译ffmpeg For SDK6.1,模拟器、armv7、armv7s均可使用
- Centos --VPN虑拟局域网的配置与使用
- AspectJ_aop
- hdu 1166
- 错误报告
- HDFS副本放置策略
- Java接口的作用和抽象类的区别总结
- 对象的序列化和反序列化
- (ios)内存优化笔记