编译环境:Mac OS X 10.9.2 + XCode 5.1 + iOS7.1
FFmpeg版本:2.1
Support universal ffmpeg library for iOS7 and XCode5:
Make sure you have the latest Command Line Tools under Xcode >; Preferences >; Downloads >; Components
我的Xcode版本是5.1,Command Line Tools 位于 Xcode -> Preferences -> Locations.
一、安装gas-preprocessor
Install gas-preprocessor
- Click on the ZIP icon to download https://github.com/mansr/gas-preprocessor.
- Copy gas-preprocessor.pl to /usr/bin directory.
- Change permission of gas-preprocessor.pl by setting the privilege to Read & Write for all.
install-gas.sh:
echo "install gas-preproccesor.pr" git clone git://github.com/mansr/gas-preprocessor.git echo "copy gas-preprocessor.pl to /usr/sbin" sudo cp -f gas-preprocessor/gas-preprocessor.pl /usr/sbin/ echo "set execute right" chmod a+rwx /usr/sbin/gas-preprocessor.pl echo "install finished."
二.开始编译ffmpeg
Download my shell script from: https://gist.github.com/m1entus/6983547
Run sh build-ffmpeg.sh
.
改写了脚本,install-ffmpeg.sh:
注意:
1. VERSION改为ffmpeg版本,SDKVERSION改为iOS SDK版本
2. 编译针对armv7和armv7s平台要加入
--disable-armv6 \
--disable-armv6t2 \
3. gcc xcode5默认使用的是clang:
--cc="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" \
4. 最好分别针对armv7、armv7s、i386进行编译:i386代表模拟器,armv6、armv7、armv7s是arm CPU的指令集,一般是向下兼容的。
一键编译FFmpeg脚本:Dowload
三、调试kxmovie和iFrameExtractor(推荐使用kxmovie,已经视频和音频同步)
kxmovie主页:https://github.com/kolyvan/kxmovie
iFrameExtractor:https://github.com/lvjian700/ffmpegc-demo(推荐使用这个,官方的版本太老了)
iFrmaeExtractor只能播放视频,没有音频,不推荐。
使用kxmovie的方法:
1.添加依赖库文件:MediaPlayer, CoreAudio, AudioToolbox, Accelerate, QuartzCore, OpenGLES and libz.dylib,libiconv.dylib
2.添加ffmpeg lib库文件:libavcodec.a, libavformat.a, libavutil.a, libswscale.a, libswresample.a
3.添加头文件搜索路径
参考资料:
iOS下完美编译ffmpeg+x264,支持armv7, armv7s, 模拟器(支持iOS7&XCode5)
Installing ffmpeg ios libraries armv7, armv7s, i386 and universal on Mac with 10.8
iOS: FFmpeg编译和使用问题总结(也不错的,针对ffmpeg 2.X 和 ffmpeg 0.7编译)
http://witcheryne.iteye.com/blog/1734706
编译ffmpeg for iOS,并调试iFrameExtractor demo
iOS使用ffmpeg播放rstp实时监控视频数据流(使用kxmovie)
ffmpeg历史版本下载地址:http://ffmpeg.org/releases/
gas-preprocessor脚本地址: https://github.com/mansr/gas-preprocessor
FFmpeg 2.X 编译脚本:https://gist.github.com/m1entus/6983547
kxmovie git地址:https://github.com/kolyvan/kxmovie
iFrameExtractor:https://github.com/lvjian700/ffmpegc-demo(推荐使用这个,官方的版本太老了)
编译过程中碰到的问题:
1. 报错:
cputype (12) does not match previous archive members cputype (7)(all members must match)
解决方案:http://www.xcoder.cn/html/mobile/iOS/2013/0307/1604.html
So be sure tomake clean
to start anew.
2.如果是针对armv7、armv7s编译,ffmpeg configure中要加入
--disable-armv6 \
--disable-armv6t2 \
3.gcc xcode5默认使用的是clang
http://www.cnblogs.com/wyymaomi/p/3603643.html
iOS下完美编译ffmpeg+x264,支持armv7, armv7s, 模拟器(支持iOS7&XCode5)
Installing ffmpeg ios libraries armv7, armv7s, i386 and universal on Mac with 10.8