模拟器与真机下ffmpeg的编译方法
参考来自:http://www.cocoachina.com/bbs/read.php?tid=79169&keyword=ffmpeg
一、编译ffmpeg模拟器版本
1、到https://github.com/gabriel/ffmpeg-iphone-build下载ffmpeg-iphone-build
2、先将gas-preprocessor.pl拷贝到/usr/sbin/目录中。
下载地址:source snapshot
4、在终端下定位到ffmpeg的目录下运行
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk' --enable-pic --enable-decoder=rawvideo --disable-asm
5、输入make命令
6、将libavcodec.a,libavdevice.a,libavformat.a,libavutil.a,libswscale.a到对应的目录下拷贝出来。
7.在项目中就可以使用了。可以参考开源示例iFrameExtractor (git clone git://github.com/lajos/iFrameExtractor.git)需要将该项目的ffmpeg文件夹库替换为你编译的ffmpeg源码文件夹,在ffmpeg目录下新建lib目录,将刚刚拷贝出来的静态库拷贝进去。打开项目,添加libbz2.1.0.dylib系统库文件。点击编译运行就可以使用了。
8.注意如果使用的是ffmpeg0.8.5的库的话iFrameExtractor中的codec_type需要修改为AVMEDIA_TYPE_VIDEO。
二、编译真机arm7版本
1. 下载:
git clone git://github.com/lajos/iFrameExtractor.git
2. 编辑:
build_armv6和build_armv7,修改./configure后面的参数,主要是SDK版本.我的是5.0,修改为:
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --cpu=arm1176jzf-s --extra-cflags='-arch armv6' --extra-ldflags='-arch armv6'
3. 编译:
出错,提示:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc is unable to create an executable file.
C compiler test failed.
查看config.err文件,最后提示:
ld: file not found: /usr/lib/system/libcache.dylib for architecture armv7
collect2: ld returned 1 exit status
4. 重新修改configure参数为:
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk' --enable-pic
5、添加库libbz2.1.0.dylib,再次编译。