2項依賴:
gas-preprocessor(見附錄:gas-preprocessor簡介)
yasm 1.2.0
如果要內建x264和fdk_aac,需要先編譯x264和fdk_aac。
Usage(用root執行)
To build everything:
./build-ffmpeg.sh
To build arm64 libraries:
./build-ffmpeg.sh arm64
To build fat libraries for armv7 and x86_64 (x86_64 是64-bit simulator 模拟器):
./build-ffmpeg.sh armv7 x86_64
To build fat libraries from separately built thin libraries:
./build-ffmpeg.sh lipo
You should link your app with
libz.dylib
libbz2.dylib
libiconv.dylib
最終輸出FFmpeg-iOS(我已改成fat-FFmpeg),可以在腳本裡指定需要的平台
#ARCHS="arm64 armv7 x86_64 i386"
問題:
1,編譯失敗,sh中有個
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 通路不了
執行到這一句說明沒有安裝yasm,而安裝yasm,需要用到homebrew,是以執行上面語句安裝homebrew時報錯了。
解決:安裝yasm,先安裝homebrew,參見附錄:homebrew的安裝與使用
2,xcrun -sdk iphoneos clang is unable to create an executable file
C compiler test failed.
解決:去掉bitcode,如下:
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET -fembed-bitcode"
3,如果內建了fdk_aac,需要添加:enable-nonfree
4,gas-preprocessor.pl的位置在usr/local/bin/,之前在/usr/bin下。不然會報GNU assembler not found gas-preprocessor
附錄:
一,homebrew的安裝與使用
套件管理器
安裝:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
不能用root執行
常用指令:
查找軟體包
brew search wget
安裝軟體包
brew install wget
删除軟體包
brew remove wget
檢視軟體包資訊
brew info wget
列出軟體包的依賴關系
brew deps wget
更新brew
brew update
二,gas-preprocessor簡介
https://github.com/libav/gas-preprocessor
Perl script that implements a subset of the GNU as preprocessor that Apple's as doesn't
To configure Libav for iOS: ./configure --enable-cross-compile --arch=arm --target-os=darwin --cc='clang -arch armv7' --sysroot=$(xcrun --sdk iphoneos --show-sdk-path) --cpu=cortex-a8 --enable-pic If deploying to all generations, it's recommended to do separate out-of-tree builds for each architecture, then lipo together the resulting libs. For instance, assuming separate builds in armv6 and armv7: lipo -create -arch armv6 armv6/libavcodec/libavcodec.a -arch armv7 armv7/libavcodec/libavcodec.a -output universal/libavcodec.a and similar for each library. Then in XCode, make sure to build for both armv6 and armv7. If you only care about one generation (since the armv6 devices are too slow for instance), then lipo is unnecessary of course.
還一個原始版本https://github.com/yuvi/gas-preprocessor
To configure ffmpeg for the iPhone 3gs and iPod touch 3g: ./configure --enable-cross-compile --arch=arm --target-os=darwin --cc='/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv7' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk --cpu=cortex-a8 --enable-pic To configure ffmpeg for all other iPhones and iPods: ./configure --enable-cross-compile --arch=arm --target-os=darwin --cc='/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk --cpu=arm1176jzf-s Make sure to replace the iPhone SDK version with the version that you're using. Pre-3.0 versions aren't supported and probably won't work. If deploying to all generations, it's recommended to do separate out-of-tree builds for each architecture, then lipo together the resulting libs. For instance, assuming separate builds in armv6 and armv7: lipo -create -arch armv6 armv6/libavcodec/libavcodec.a -arch armv7 armv7/libavcodec/libavcodec.a -output universal/libavcodec.a and similar for each library. Then in XCode, make sure to build for both armv6 and armv7. If you only care about one generation (since the armv6 devices are too slow for instance), then lipo is unnecessary of course.
我的腳本:
庫裁剪:支援libfdk_aac+libx264 編碼和aac+h264解碼:
藝搜參考:
腳本: https://github.com/kewlbear/FFmpeg-iOS-build-script
Homebrew:http://linfan.info/blog/2012/02/25/homebrew-installation-and-usage/
時間寶貴,隻能複制+粘貼,若圖檔無法顯示或排版混亂,請通路elesos.com查找原文