`

倾情奉献ios5.0编译ffmpeg,真机ok!

 
阅读更多
(转帖注明出处和作者-xiaochengfei,尊重我得劳动成果,谢谢!)

我不是蛋疼弄这个哈~搞这个是因为之前我的264视频是baseline的,效果不是特别好,现在要升到main profile。

申明一下,我用的是xcode4.2/.4.3.2,ios sdk5.0/5.1,是在真机上运行ok,越狱的ios5.0 和ios5.1的iphone都可以播示例视频。我选择target是ios4.3也可以的。不过如果是4.1我就不清楚了,应为貌似ffmpeg不支持编译成armv6,有这么个说法:The armv6 arch doesn't seem to be working properly so you can force building via armv7 on your 3GS until we figure that out.


1. 到https://github.com/gabriel/ffmpeg-iphone-build下载ffmpeg-iphone-build
2.先将gas-preprocessor.pl拷贝到/usr/sbin/目录中。
3.到这里下载最新的ffmpeg:http://ffmpeg.org/download.html或者命令行安装:git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

下载一个事例工程:git clone git://github.com/lajos/iFrameExtractor.git

然后到命令行下到ffmpeg的目录下,执行:
./configure \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \
--extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7' \
--extra-ldflags='-arch armv7' \
--enable-pic \
--enable-cross-compile \
--enable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--disable-asm \
--disable-encoders \
--disable-decoders \
--enable-decoder=h264 \
--disable-doc

注意:在Mac OS X 10.7.4上用XCode 4.3.2 iOS5.1编译的时候,只能用下面的脚本后面的make与make install才能通过:

./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-asm --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc --as='gas-preprocessor/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc' --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk' --enable-pic


也可以用下面这个配置,优化一下,我都是真机器测试ok,有问题发出来生儿子没*****,好吧。:
./configure \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \
--extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-arch armv7' \
--extra-ldflags='-arch armv7' \
--extra-cflags='-mfpu=neon' \
--extra-cflags='-mfloat-abi=softfp' \
--enable-pic \
--enable-cross-compile \
--enable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--disable-asm \
--disable-encoders \
--disable-decoders \
--enable-decoder=h264 \
--disable-doc

注意了,上面有--disable-asm \,这是没办法的,禁用了汇编,这样应该是会影响效率的,如果不禁用就编译不通过。谁有更好的办法不禁用,麻烦分享一下。
一般是ok的,如果提示permission deny,那就chmod 777 configure(这个情况是我同事在windows上改了这个文件)

然后就make,完了再make install一下
如果给代码做了修改,就先make clean,然后make一下

编译完了后在/usr/local/lib就是一些你用得上的.a文件,先拷贝到别的地方,比如:cp -rf lib* /src
编译完了后在/usr/local/include就是一些你用得上的.h头文件,先拷贝到别的地方,比如:cp -rf include* /src
然后把lib和include放到你的工程中,你可以在你的工程根目录下创建一个叫ffmpeg的文件夹,把lib和linclude里面的东西放进去
工程中制定head file path :"$(SRCROOT)/ffmpeg" 这样编译就可以通过了


然后,打开iFrameExtractor这个工程,在ffmpeg这个文件夹建一个lib文件夹,把之前拷贝(就这个cp -rf lib* /src)出来的.a文件全部丢进去。为什么要这么做呢?应为iFrameExtractor里面的ffmpeg版本比较老,所以我没有编译它,没有编译,就不会产生一个lib文件夹。至于这个老的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


然后在link binary with library中导入这些.a文件和libbz.2.1.0.dylib。
然后插上真机,运行工程,ok,成功啦!!!看下面的图片。



最后分享几个帖子:
模拟器与真机下ffmpeg的编译方法(总结版):http://www.cocoachina.com/bbs/read.php?tid=79169&page=1
这个里面的ffmepg模拟器版本用的ios4.3,我这只有ios5.0和ios5.1,很遗憾,都编译不成功,想想我们就是要真机跑,模拟器意义不大,就没继续研究了。

Building FFmpeg for iPhone:http://blog.sina.com.cn/s/blog_51396f890102dyde.html或者:http://blog.sina.com.cn/s/blog_4b8ba47f0100ve2j.html




转帖:http://www.cocoachina.com/bbs/read.php?tid=98563


////////////////////////////////////////////////////////////////////////////////////////////////////////

ffmpeg成功在xcode4.2下的编译使用记录

弄iPhone上面的流媒体客户端也有段时间了,前面都是在模拟器上跑的。最近拿到了机器和ADP,准备把项目弄到真机上跑跑,但模拟器上的ffmpeg编译的框架是i386,这个框架不能在模拟器上用,所以又回到那个烦人的ffmpeg编译。不过这次还算比较顺利,遇到的问题不是很多,最后成功了。现向大家分享下过程,写得比较详细,按照这个过程可以成功运行。
2012-4-19 10:12
环境:Mac OS X 10.7.3
1.83GHz Intel Core 2 Duo
2GB 667MHz RAM
Xcode 4.2.1
iPad 2 ( iOS 5.0 )
1.打开终端(Terminal);
2.键入 git clone git://github.com/lajos/iFrameExtractor.git ,下载iFrameExtractor开源项目到 user/目录下;
3.键入 cd iFrameExtractor/ffmpeg,到ffmpeg文件目录下;
4.键入 ./build_armv7,不成功,在生成的armv7文件夹下没有生成的5个库文件,终端输出信息为:

rm: No match.
Makefile:1: config.mak: No such file or directory
libavdevice/Makefile:1: libavdevice/../config.mak: No such file or directory
libavformat/Makefile:1: libavformat/../config.mak: No such file or directory
libavcodec/Makefile:1: libavcodec/../config.mak: No such file or directory
libavutil/Makefile:1: libavutil/../config.mak: No such file or directory
libswscale/Makefile:1: libswscale/../config.mak: No such file or directory
make: *** No rule to make target `libswscale/../config.mak'. Stop.
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from SVN. If the latest version fails, report the problem to the
ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.err" produced by configure as this will help
solving the problem.
Makefile:1: config.mak: No such file or directory
libavdevice/Makefile:1: libavdevice/../config.mak: No such file or directory
libavformat/Makefile:1: libavformat/../config.mak: No such file or directory
libavcodec/Makefile:1: libavcodec/../config.mak: No such file or directory
libavutil/Makefile:1: libavutil/../config.mak: No such file or directory
libswscale/Makefile:1: libswscale/../config.mak: No such file or directory
make: *** No rule to make target `libswscale/../config.mak'. Stop.
mv: rename libavcodec/libavcodec.a to armv7/libavcodec.a: No such file or directory
mv: rename libavdevice/libavdevice.a to armv7/libavdevice.a: No such file or directory
mv: rename libavformat/libavformat.a to armv7/libavformat.a: No such file or directory
mv: rename libavutil/libavutil.a to armv7/libavutil.a: No such file or directory
mv: rename libswscale/libswscale.a to armv7/libswscale.a: No such file or directory
rm: No match.
cp: No match.

5.键入 ./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
输出一堆编译文件过程后,在ffmpeg目录下生成一个lib文件夹并在其中包含了5个库文件,在armv7文件夹下也有了5个库文件;
6.打开iFrameExtractor.xcodeproj,可以看到项目中已经自动加入了lib文件夹下的5个库文件,链接库中添加libbz2.1.0.dylib,调整目标为真机iPad,编译成功(仍然有203个警告,不管),run成功,真机上运行正常。


如果想在模拟器上运行,在下载好iFrameExtractor后,进入ffmpeg文件夹,直接./build_i386。然后把项目中加入生成的5个.a库文件,注意项目中头文件的路径(以防提示什么.h找不到的)。链接库加入libz.dylib,就可以了。
转帖:http://www.cocoachina.com/bbs/read.php?tid=100282

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics