`

ffmpeg-0.10.2 xcode4.3 IOS5.1 真机调试编译过程

 
阅读更多

折腾了一下午总算把这个搞定了,之前在模拟器上运行iFrameExtractor怎么样都可以,但是在真机上总报错。到处查文章,找到的资料大多的ios4.x系列的,ffmpeg的版本也不太一样,因此折腾出来后把详细过程记录在这里,一来方便自己下次什么还需要再玩一遍,二来供有需要的人查找,不用绕我当初走的一些弯路。

首先下载以下工程代码:iFrameExtractor(https://github.com/lajos/iFrameExtractor), gas-preprocessor(https://github.com/yuvi/gas-preprocessor), ffmpeg(http://ffmpeg.org/download.html)。

把iFrameExtractor工程目录下的那个ffmpeg删掉,里面的ffmpeg版本实在太老。将自己下载的ffmpeg代码解压拷贝到iFrameExtractor目录下。 把gas-preprocessor.pl放到工程目录,或者干脆直接丢到/usr/bin下也成。 使用ffmpeg下面的configure来进行编译设置。

编译成真机调试还是模拟器调试的关键在于CC的类型,是用于编译macos程序的gcc还是供iPhone platform程序使用的gcc,以及config参数中arch是指定成x86还是armv7。 Xcode4.3中iPhone platform编译的gcc路径如下:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc IOS5.1的SDK目录为:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk 用于真机调试的configure运行参数如下:

export DEVRoot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
export SDKRoot=$DEVRoot/SDKs/iPhoneOS5.1.sdk
export CC=$DEVRoot/usr/bin/llvm-gcc
 
./configure \
--cc=${CC} \
--as="gas-preprocessor.pl ${CC}" \
--sysroot=${SDKRoot} \
--enable-cross-compile \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags="-arch armv7" \
--extra-ldflags="-arch armv7 -isysroot ${SDKRoot}" \
--enable-pic \
--disable-doc \
--disable-ffplay \
--disable-ffserver \
--disable-gpl \
--disable-shared \
--enable-static \
--disable-mmx \
--disable-debug \
--enable-decoder=h264  \
--disable-asm

脚本中使用了“--disable-asm”来禁用了汇编生成。这条会严重影响视频播放的效率。以iFrameExtractor为例,在iPhone4S上运行还成,在iPod touch上就显得有些慢动作了。但是不这么干,configure和make过程中会出错。使用IOS4.3 SDK编译的话,则不会出现此问题。stackoverflow上有人曾经提过,可以通过禁用不需要的解码器及修改源代码来避免,可惜我还没试成功过。大家有什么好办法,请千万留言。 整个脚本,可以在此下载。 设置编译成功后,将dist目录下的五个.a文件拖到Xcode中iFrameExtractor项目中去,替换掉原来那5个,再链上libbz2.1.0.dylib就可以在Xcode中进行真机调试了。

configure过程如果出现错误,可以查看生成的config.log,根据具体的错误信息来调整configure的参数。

祝大家好运吧,折腾这东西可真累且无聊。

同事因为需要在旧iOS设备上进行调试,这是他折腾出来的armv6的版本,适用于iPhone及iPhone3G系统:

#!/bin/sh
 
 export FFMPEG_DIR=ffmpeg
 
 export DEVRoot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
 export SDKRoot=$DEVRoot/SDKs/iPhoneOS5.1.sdk
 export CC=$DEVRoot/usr/bin/llvm-gcc
 export LD=$DEVRoot/usr/bin/ld
 
 cd $FFMPEG_DIR
 mkdir -p lib
 
 make clean
 
 ./configure \
 --cc=${CC} \
 --as="gas-preprocessor.pl ${CC}" \
 --sysroot=${SDKRoot} \
 --enable-cross-compile \
 --target-os=darwin \
 --arch=arm \
 --cpu=arm1176jzf-s \
 --extra-cflags="-arch armv6" \
 --extra-ldflags="-arch armv6 -isysroot ${SDKRoot}" \
 --disable-doc \
 --disable-ffplay \
 --disable-ffserver \
 --disable-gpl \
 --disable-shared \
 --enable-static \
 --disable-mmx \
 --disable-debug \
 --enable-decoder=h264  \
 --disable-asm
 
 echo "ready to make "
 
 make 
 
 mv libavcodec/libavcodec.a lib/
 mv libavdevice/libavdevice.a lib/
 mv libavformat/libavformat.a lib/
 mv libavutil/libavutil.a lib/
 mv libswscale/libswscale.a lib/

转帖:http://www.cnblogs.com/wupher/articles/2456421.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics