www.mingjianhua.com

转载请注明出处。

上一篇文章讲了用NDKr9编译最新ffmpeg2.0.1到android平台,一般做了Android平台的编解码就免不了要做iOS,这次一起把iOS的ffmpeg编译也一起写一篇吧。

一、首先准备开发环境

1、XCode大家都有了吧,就不说了。

2、Command line tools,得装个。

3、gas-preprocessor,

安装方式是直接copy文件 gas-preprocessor.pl 到 /usr/bin ,记得修改权限可执行.

因为在编译ffmpeg的时候,gas-preprocessor版本必须和ffmpeg配合,所以如果你下载的ffmpeg源码是最新的,那么建议去 libav网站 下载最新的 gas-preprocessor.

如果之后在编译时候遇到类似这样的错误

unknown register alias 'TCOS_D0_HEAD'

那么可以尝试更换 gas-preprocessor版本来解决.

4、

然后 pkg-config, 可以直接通过MacPorts来安装

sudo port install pkgconfig

其实没有也行,装macports各种蛋疼。

2. 下载ffmpeg的源码

下载地址:http://ffmpeg.org/download.html

3. 编译armv7的支持

建一个build_armv7.sh文件,把下面内容拷进去。

#!/bin/sh

#armv7

./configure \

--disable-shared \

--enable-static \

--prefix=armv7 \

--enable-small \

--disable-ffmpeg \

--disable-ffplay \

--disable-ffprobe \

--disable-ffserver \

--disable-avdevice \

--disable-avformat \

--disable-swresample \

--disable-swscale \

--disable-postproc \

--disable-avfilter \

--disable-everything \

--disable-encoders \

--disable-decoders \

--enable-decoder=h264 \#要开什么编解码器自己看着办

--disable-muxers \

--disable-devices \

--disable-protocols \

--disable-network \

--disable-avdevice \

--enable-cross-compile \

--sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk" \

--target-os=darwin \

--cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" \

--extra-cflags="-arch armv7 -mfpu=neon -miphoneos-version-min=5.1" \

--extra-ldflags="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -miphoneos-version-min=5.1" \

--arch=arm \

--cpu=cortex-a9 \

--enable-pic \

--enable-neon

make clean

make

make install

然后在命令行里输入

./build_armv7.sh

然后就可以等结果了

完了后可以看到在ffmpeg路径下有个armv7路径下有了你要的include 和lib文件了。

3. 编译armv7s,i386的支持

跟上面差不多。就不多说了,就只贴configure文件了

#armv7s

./configure \

--prefix=armv7s \

--disable-ffmpeg \

--disable-ffplay \

--disable-ffprobe \

--disable-ffserver \

--disable-encoders \

--disable-muxers \

--disable-devices \

--disable-protocols \

--disable-network \

--disable-avdevice \

--enable-avresample \

--enable-cross-compile \

--sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk" \

--target-os=darwin \

--cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" \

--extra-cflags="-arch armv7s -mfpu=neon -miphoneos-version-min=5.1" \

--extra-ldflags="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -miphoneos-version-min=5.1" \

--arch=arm \

--cpu=cortex-a9 \

--enable-pic \

--enable-neon

make clean

make

make install

#i386

./configure \

--prefix=i386 \

--disable-ffmpeg \

--disable-ffplay \

--disable-ffprobe \

--disable-ffserver \

--disable-encoders \

--disable-muxers \

--disable-devices \

--disable-protocols \

--disable-network \

--disable-avdevice \

--enable-avresample \

--enable-cross-compile \

--sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk" \

--target-os=darwin \

--cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc" \

--extra-cflags="-arch i386" \

--extra-ldflags="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk" \

--arch=i386 \

--cpu=i386 \

--enable-pic \

--disable-asm

make clean

make

make install

6. 最后,我们合并armv7、armv7s、i386

建立merge.sh文件并运行

#merge

cd armv7/lib

for file in *.a

do

cd ../..

xcrun -sdk iphoneos lipo -output universal/lib/$file  -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch i386 i386/lib/$file

echo "Universal $file created."

cd -

done

cd ../..

完成后在universal/lib/下就是我们需要的静态库了。

www.mingjianhua.com


编译最新ffmpeg2.0.1到iOS设备的更多相关文章

  1. 用NDKr9编译最新ffmpeg2.0.1到android平台

    原文来自http://www.mingjianhua.com 本文参照 http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/ 在linux下的 ...

  2. iPhone调用ffmpeg2.0.2解码h264视频的示例代码

    iPhone调用ffmpeg2.0.2解码h264视频的示例代码 h264demo.zip 关于怎么在MAC下编译iOS下的ffmpeg请看 编译最新ffmpeg2.0.1(ffmpeg2.0.2)到 ...

  3. Windows(x64)编译FFMPEG-2.0.1

    一.引言 公司需要做网络视频传输的相关项目,初步选定用这么几个东西FFMPEG,ORTP,Live555这么几个东东.研究了也有一个月了,把一些心得写出来,这篇文章主要介绍FFMPEG在windows ...

  4. 【转】编译Lua5.3.0的iOS静态库

    This is a tutorial on how to compile Lua 5.3.0 as an iOS static library (liblua.a) on Mac OS X 10.10 ...

  5. iOS学习——获取iOS设备的各种信息

    不管是在Android开发还是iOS开发过程中,有时候我们需要经常根据设备的一些状态或信息进行不同的设置和性能配置,例如横竖屏切换时,电池电量低时,内存不够时,网络切换时等等,我们在这时候需要进行一些 ...

  6. iOS开发的另类神器:libimobiledevice开源包【类似android adb 方便获取iOS设备信息】

    简介 libimobiledevice又称libiphone,是一个开源包,可以让Linux支持连接iPhone/iPod Touch等iOS设备.由于苹果官方并不支持Linux系统,但是Linux上 ...

  7. 基于APNs最新HTTP/2接口实现iOS的高性能消息推送(服务端篇)

    1.前言 本文要分享的消息推送指的是当iOS端APP被关闭或者处于后台时,还能收到消息/信息/指令的能力. 这种在APP处于后台或关闭情况下的消息推送能力,通常在以下场景下非常有用: 1)IM即时通讯 ...

  8. Mac平台下部署UE4工程到iOS设备的流程

    1.开发环境 UE4.Xcode.iOS版本情况如下: 1.UE4:当前最新版本Unreal Engine 4.17.2. 2.Xcode:当前最新版本Xcode9.0. 3.iOS:当前最新版本iO ...

  9. VS2015编译Qt5.7.0生成支持XP的静态库(很不错)

    一.编译工具 1.VS2015 编译Qt5.7.0的所需VS版本:Visual Studio 2013 (Update1)或Visual Studio 2015 (Update2).因为Update补 ...

随机推荐

  1. SimpleXML 使用详细例子

    要处理XML 文件,有两种传统的处理思路:SAX 和DOM.SAX 基于事件触发机制, 对XML 文件进行一次扫描,完成要进行的处理:DOM 则将整个XML 文件构造为一棵DOM 树,通过对DOM 树 ...

  2. perl正则表达式第三周笔记

    正则引擎的分类 正则引擎的分类 正则引擎的分类主要分两种: DFA:egrep.awk.lex.flex NFA:.NET.PHP.Perl.Ruby.Python.GNU Emacs.ed.sec. ...

  3. 本地环境下 WordPress 环境搭建与安装

    本地环境:Ubuntu 14.04 使用软件: WordPress 4.1.1 中文优化版 EasyEngine 安装步骤: 安装 LNMP 环境; wget -qO ee rt.cx/ee & ...

  4. Gulp 从0开始

    http://www.w3ctech.com/topic/134  (该文章有很多错误) http://markpop.github.io/2014/09/17/Gulp%E5%85%A5%E9%97 ...

  5. SeaJS 简单试用

    http://seajs.org/docs/#quick-start 感觉seajs的语法有点罗嗦... 它既有RequireJS的特点也有NodeJS引入模块的特点 例子是抄的官方的例子  在官方的 ...

  6. android小知识之SparseArray(HaspMap替换)

    最近编程时,发现一个针对HashMap<Integer, E>的一个提示: 翻译过来就是:用SparseArray<E>来代替会有更好性能.那我们就来看看源码中SparseAr ...

  7. 由Mifare 1卡破解带来的危险以及应对方法

    今年年初以来,一个消息的传出震惊了整个IC卡行业.最近,德国和美国的研究人员成功地破解了NXP的Mifare1芯片的安全算法.Mifare1芯片主要用于门禁系统访问控制卡,以及一些小额支付卡,应用范围 ...

  8. 如何使用 Android Studio 的 git hub 功能

    How to use GitHub with Android Studio This article will explain how to use GitHub with Android Studi ...

  9. 教你看懂C++类库函数定义之三---_stdcall

    一切从一个C++ 类库头文件开始,现在在做一个C++的项目,期间用到一个开源的界面库DUILib(类似MFC),这个东西还不错能很容易的写出漂亮的界面,比如QQ的界面,可以去下载下来研究研究,地址:h ...

  10. 在两个Android设备间通过UDP传输目录内文件

    这两天下了一个使用UDP传输目录内文件的程序,发出来给大家一起看看,共同进步.有问题请指教. 由于udp丢包比较厉害,因此使用了自定义的内部协议,进行双方的确认. 程序跑起来后,看网络状况,有时候会一 ...