最近在研究IOS視頻播放器,需要使用到ffmpeg4ios,所以整理編譯過程。
需要使用到Git,Linux Shell指令碼執行install-ffmpeg.sh即可。
下述Linux Shell指令碼:http://ishare.iask.sina.com.cn/f/37135883.html
install-ffmpeg.sh
SRCDIR==/install- - [ ! -e ffmpeg--O http:-/compile-*.sh [ -/ffmpeg-${VERSION}//compile-/compile-/compile-/compile-universal.sh
install-gas.sh
echo -f gas-preprocessor/gas-preprocessor.pl /usr/sbin/+x /usr/sbin/gas-
compile-armv7s.sh
SRCDIR==/=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin//--host=arm-apple---sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/--prefix=build/--extra-cflags=--extra-ldflags=--enable-pic --disable-shared --enable-&&/--prefix=--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/--=--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/--extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/--target-os=--arch=--cpu=cortex---extra-cflags=--extra-ldflags=--enable---enable-cross---enable---enable---disable---disable---disable---disable--p ./build/-f ./libavcodec/libavcodec.a ./build/armv7s/-f ./libavdevice/libavdevice.a ./build/armv7s/-f ./libavfilter/libavfilter.a ./build/armv7s/-f ./libavformat/libavformat.a ./build/armv7s/-f ./libavutil/libavutil.a ./build/armv7s/-f ./libswscale/libswscale.a ./build/armv7s/libswscale.a
compile-armv7.sh
SRCDIR==/=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin//--host=arm-apple---sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/--prefix=build/--extra-cflags=--extra-ldflags=--enable-pic --disable-shared --enable-&&/--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/--=--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/--extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVERSION}.sdk/usr/lib/--target-os=--arch=--cpu=cortex---extra-cflags=--extra-ldflags=--enable---enable-cross---enable---enable---disable---disable---disable---disable--p ./build/-f ./libavcodec/libavcodec.a ./build/armv7/-f ./libavdevice/libavdevice.a ./build/armv7/-f ./libavfilter/libavfilter.a ./build/armv7/-f ./libavformat/libavformat.a ./build/armv7/-f ./libavutil/libavutil.a ./build/armv7/-f ./libswscale/libswscale.a ./build/armv7/libswscale.a
compile-i386.sh
SRCDIR==/=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin//--host=i386-apple---sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/--prefix=build/--extra-cflags=--extra-ldflags=--enable-pic --disable-shared --enable- --disable-&&/--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/--=--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/--extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk/usr/lib/--target-os=--arch=--cpu=--extra-cflags=--extra-ldflags=--enable---enable-cross---enable---enable---disable---disable---disable---disable---disable--p ./build/-f ./libavcodec/libavcodec.a ./build/i386/-f ./libavdevice/libavdevice.a ./build/i386/-f ./libavfilter/libavfilter.a ./build/i386/-f ./libavformat/libavformat.a ./build/i386/-f ./libavutil/libavutil.a ./build/i386/-f ./libswscale/libswscale.a ./build/i386/libswscale.a
compile-universal.sh
-sdk iphoneos lipo -output ./build/--arch armv7s ./build/armv7s/-arch armv7 ./build/armv7/-arch i386 ./build/i386/-sdk iphoneos lipo -output ./build/--arch armv7s ./build/armv7s/-arch armv7 ./build/armv7/-arch i386 ./build/i386/-sdk iphoneos lipo -output ./build/--arch armv7s ./build/armv7s/-arch armv7 ./build/armv7/-arch i386 ./build/i386/-sdk iphoneos lipo -output ./build/--arch armv7s ./build/armv7s/-arch armv7 ./build/armv7/-arch i386 ./build/i386/-sdk iphoneos lipo -output ./build/--arch armv7s ./build/armv7s/-arch armv7 ./build/armv7/-arch i386 ./build/i386/-sdk iphoneos lipo -output ./build/--arch armv7s ./build/armv7s/-arch armv7 ./build/armv7/-arch i386 ./build/i386/-sdk iphoneos lipo -output ./x264/build/--arch armv7s ./x264/build/armv7s/lib/-arch armv7 ./x264/build/armv7/lib/-arch i386 ./x264/build/i386/lib/libx264.a
編譯出來的檔案為:
libavcodec.a
用於各種類型聲音/映像編解碼;
libavdevice.a
libavfilter.a
libavformat.a
用於各種音視頻封裝格式的產生和解析,包括擷取解碼所需資訊以產生解碼上下文結構和讀取音視訊框架等功能;
libavutil.a
包含一些公用的工具函數;
libswscale.a
用於視頻情境比例縮放、色彩映射轉換;
libx264.a
開源樣本iFrameExtractor
git clone git://github.com/lajos/iFrameExtractor.git
這是一個iOS下利用ffmpeg解碼播放的例子。不過這個例子是利用貼圖的方式來顯示,效果不是很好,而且沒有加入聲音解碼。
要想項目順利運行需要添加支援庫
Project References -> Targets -> Build Phases -> Link Binary With Librarys
- libbz.dylib
- libz.dylib
- libiconv.2.4.0.dylib
修改標頭檔搜尋路徑(標頭檔:http://www.ffmpeg4ios.org/releases/ffmpeg4ios-1.0-include.zip)
Project References -> Targets -> Build Settings -> Header Search Paths
修改庫檔案搜尋路徑(編譯出來.a檔案的路徑)
Project References -> Targets -> Build Settings -> Library Search Paths
有疑問者可以留言