編譯ffmepg模擬器版本:
1. 到https://github.com/gabriel/ffmpeg-iphone-build下載ffmpeg-iphone-build
2.先將gas-preprocessor.pl拷貝到/usr/sbin/目錄中。
3.到ffmpeg官網上下載ffmpeg源碼
4.在終端下定位到ffmpeg的目錄運行
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-avfilter --disable-debug --disable-encoders --enable-cross-compile --disable-decoders --disable-armv5te --enable-decoder=h264 --enable-pic --cc=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc' --extra-ldflags=-L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib/system --sysroot=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk --target-os=darwin --arch=i386 --cpu=i386 --extra-cflags='-arch i386' --extra-ldflags='-arch i386'
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版本,網上搜到的版本,完全按照以下步驟做就行了。可以編譯出arm7的庫。
1. 下載:
git clone git://github.com/lajos/iFrameExtractor.git
2. 編輯:
build_armv6和build_armv7,修改./configure后面的參數,主要是SDK版本.我的是4.3,修改為:
./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=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. 編譯:
build_armv7
最后生成靜態庫,在lib目錄和armv7目錄.
6.用xcode打開iFrameExtractor.xcodeproj,現在編譯會出錯,需要修改幾個地方:
左邊選中工程,中間選中target,右面選中Build settings,在Architectures選項卡里面選擇Architetures為Optimized(armv7),Base SDK為Latest iOS(iOS 4.3) Valid Architectures填寫armv7.
編譯目標選擇iOS Device,當然,如果有連接電腦的設備,可以選擇設備.
編譯,提示:
Undefined symbols for architecture armv7:
"_BZ2_bzDecompressInit", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_BZ2_bzDecompressEnd", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_BZ2_bzDecompress", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
添加庫libbz2.1.0.dylib,再次編譯,OK通過
在ios5.0中編譯ffmpeg。 到官網下載ffmpeg,然后在終端進入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
make進行編譯。
然后將各個.a文件拷貝出來。
===========================================
在Xcode4.3環境下有些變化,需要注意isysroot
這是我最后調通的參數。。。
./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/iPhoneOS4.3.sdk --enable-cross-compile --target-os=darwin --cpu=arm1176jzf-s --arch=arm --extra-cflags='-arch armv6 --sysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk' --extra-ldflags='-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk'
===========================================
1. 下載:
在終端中輸入:git clone git://github.com/lajos/iFrameExtractor.git
注:該文件包中包含ffmpeg庫以及demo。
2.編輯:
打開iFrameExtractor文件夾下ffmpeg中的 build_armv6和build_armv7,修改./configure后面的參數,主要是SDK版本.我的是4.3,修改為:
./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=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. 重新修改build_armv7中的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. 編譯:
build_armv7
最后生成靜態庫,在lib目錄和armv7目錄.
注:build_armv7不能運行,則將該文件的每個命令直接在終端中運行。
6.用xcode(我的是4.0版本)打開iFrameExtractor.xcodeproj,現在編譯會出錯,需要修改幾個地方:
左邊選中工程,中間選中target,右面選中Build settings,在Architectures選項卡里面選擇Architetures為Optimized(armv7),Base SDK為Latest iOS(iOS 4.3) Valid Architectures填寫armv7.
編譯目標選擇iOS Device,當然,如果有連接電腦的設備,可以選擇設備.
編譯,提示:
Undefined symbols for architecture armv7:
"_BZ2_bzDecompressInit", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_BZ2_bzDecompressEnd", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_BZ2_bzDecompress", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
添加庫libbz2.1.0.dylib,再次編譯,OK通過.
以下步驟可以忽略:
7. 修改了ffmpeg版本到最新版(0.7),編譯的時候需要把common.mak復制到新版本目錄.
編譯的時候遇到錯誤:
ERROR: .endm without .macro at /usr/local/bin/gas-preprocessor.pl line 83, <ASMFILE> line 55
用老版本的libavcodec/arm/asm.S和libavcoec/arm/dsputil_arm.S覆蓋新版本(實際上我懷疑只覆蓋asm.S即可),重新編譯即可.
原文地址:http://blog.csdn.net/tsingien/article/details/6457246
ARM6如果遇到錯誤不如試試下面的config
./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/iPhoneOS4.3.sdk --extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/system --target-os=darwin --arch=arm --cpu=arm1176jzf-s --extra-cflags='-arch armv6' --extra-ldflags='-arch armv6' --enable-pic --enable-cross-compile --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-doc --disable-ffprobe
我的FFMPeg版本:"SVN-r4"
===========================================
傾情奉獻ios5.0編譯ffmpeg,真機ok!
我不是蛋疼弄這個哈~搞這個是因為之前我的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
也可以用下面這個配置,優化一下,我都是真機器測試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

//編譯日志
在加個 i386的 錯誤
If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first
解決:
before this cleanAll build then
In xcode go to Project > set active executable > appname - Iphone 4.0 simulator
then open simulator then go to Hardware > version > 4.0.2
then double click urapptarget and in build tab change "ios deployment target = 4.0"
now run in simulator it will work
//////////////////////////
iPhone3需要支持arm6哦,我現在也在用ffmpeg解碼,支持arm6的,我把我的編譯選項發來,你參考下(ffmpeg版本0.9.0)
./configure --enable-cross-compile --cross-prefix=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2 --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2' --prefix=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr --extra-cflags="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" --extra-ldflags="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -Wl,-syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" --target-os=darwin --arch=armv6 --enable-gpl --enable-static --disable-shared --enable-zlib --enable-bzlib --disable-debug --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-asm --disable-debug