2項依賴:
- gas-preprocessor(見附錄:gas-preprocessor簡介)
- yasm 1.2.0
若是要集成x264和fdk_aac,須要先編譯x264和fdk_aac。
Usage(
用root執行
)
./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中有個
執行到這一句說明沒有安裝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簡介
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.
Perl script that implements a subset of the GNU as preprocessor that Apple's as doesn't
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解碼:
藝搜參考: