ffmpeg---移植到MAC、IOS系统的步骤总结

本次编译环境:

MACOS  10.8.3

XCode4.6.2版本

ios 6.1

ffmpeg2.0.1

 

具体步骤:

1.      到https://github.com/yuvi/gas-preprocessor下载gas-preprocessor.pl文件并将其放置到/usr/sbin路径下,然后对其赋予权限,

命令:

      cd /usr/sbin

      chmod 777 gas-preprocessor.pl

 

 

运行终端

 

//备注:用命令解释: ls 显示当前文件下面的文件;

cd filename

cd 转换成上一级目录

2. 下载案例代码:

在终端输入: git clonegit://github.com/lajos/iFrameExtractor.git

3. 下载ffmpeg源码;http://www.ffmpeg.org 下载代码后把整个文件夹ffmpeg拷贝到iFrameExtrator/ffmpeg

4. 在终端输入: cdiFrameExtrator/ffmpeg(这里如果没有将前面下载的ffmpeg源码拖到iFram中的话会返回无路径,故将ffmpeg文件夹拖到iFrameExractor中。)

5. 编译配置,分为模拟器(i386)和真机(armv7)两种情况。

6. 编译—armv7:

在终端下面拷贝:

 

./configure\
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc\
--as='/usr/sbin/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/iPhoneOS6.1.sdk\
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-archarmv7' \
--extra-ldflags='-archarmv7 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk'\
--prefix=compiled/armv7\
--enable-cross-compile\
--enable-nonfree \
--enable-gpl \
--disable-armv5te \
--disable-swscale-alpha\
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm \
--disable-debug

 

 

备注上述加颜色的根据自己的系统和xcode安装的路径,及gas-preprocessor.pl放置的路径。

 

 

 

7:终端下输入make。(如果不识别make命令就到Xcode/Preferences/Downloads/Components 安装Command Line Tools)。

8:终端下输入 make install.(如果make install返回77error显示没有权限之类的,就在终端下输入 sudo -s,输入密码后重现cd 到ffmpeg目录,重现make install,不放心的话这里可以make clean下,但make clean后需要重新configure然后make,make install)。

这里确定有无安装成功的最好办法就是确认ffmpeg目录下有没生成compiled/armv7/include(头文件)和lib(库文件)。

 

//备注:

关于make命令

mac下无make命令解决方法

突然报错:-bash: make:command not found

系统中竟然没有make命令,上网查找原因,说要装Xcode,其内部集成make的命令,但我已经装xcode了为什么还是不行呢

 于是到xcode中preferences-》Download-》components中找原因,发现需要装command Line Tools软件,

而我在装xcode时默认没有command Line Tools需要自己下下来安装

安装command Line Tools后即可使用make命令了

 

 

编译成功后的结果截图:


 


 

 

9.打开iFrameExractor工程,选择armv7.确认Header Search Paths里有:"$(SRCROOT)/ffmpeg/compied/arm7/include"路径(这里的路径表示开始时必须把ffmpeg文件夹拖到iFrameExractor下)。再把compiled/armv7/lib下的库文件添加进来。

run 即可成功。这里编译的是armv7版本普通的pad,4,4s均ok。

 

 

备注:

当提示:使用iconv时,虽然包含了iconv.h,但最后link时报错:
Undefined symbols for architecture i386:
  "_iconv", referenced from ...

由于Mac系统下XCode中需要实现AnsiUnicode字符集转换,但是没有找到windows可用的WideCharToMultiByte函数,还有CP_ACPCP_UTF8等常量也没有找到导致的错误;

解决方法:

libiconv.dylib,加入后就编译通过了

 

备注上述变量必须用真机进行测试。

 

下面是用模拟器进行测试的方法。(i386)

 

 

./configure \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc\
--as='/usr/sbin/gas-preprocessor.pl/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc'\
--extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/usr/lib/system\
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk\
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffserver \
--disable-armv5te \
--disable-asm \
--enable-cross-compile\
--enable-decoder=h264\
--enable-pic \
--target-os=darwin \
--arch=i386 \
--cpu=i386 \
--extra-cflags='-archi386' \
--extra-ldflags='-archi386'

//==注意的地方:
创建文件夹:/usr/local/bin

 

编译步骤参照7、8、9过程。

编译后,运行程序的结果如下图;

 

 

 

关于文件夹的路径:可以通过搜索,或者前往文件夹:



文档下载地址:http://download.csdn.net/detail/lyd_253261362/6210159


编译后的ffmpeg库以及demo编译程序;

http://download.csdn.net/detail/lyd_253261362/6210295
http://download.csdn.net/detail/lyd_253261362/6210333

http://download.csdn.net/detail/lyd_253261362/6210421

 

 

 

 


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值