xcode5下ffmpeg靜態庫配置

來源:互聯網
上載者:User

標籤:ios   ffmpeg   

1、要安裝xcode命令列工具

       1).xcode5安裝命令列工具方法:

             在終端執行命令Using xcode-select --install 

       2).xcode5之前安裝命令列工具方法:

2、xcode5以前都是gcc編譯的,在xcode5以後都是clang編譯,在指令碼中有所體現

3、xcode5以前還要下載gas-preprocessor.pl指令碼包,然後使用cp命令拷貝到usr/bin下面,

     在xcode5以後不需要下載這個gas-preprocessor.pl指令碼

4、下載ffmpeg源碼,然後放放置源碼至/usr/bin/build/src/檔案下

       在終端執行 cd /usr/bin/build/src/ffmpeg-2.2.3進入ffmpeg檔案夾


5、arm7指令碼(產生arm7下.a檔案)

1) sudo ./configure --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk" --target-os=darwin --cc="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" --extra-cflags="-arch armv7" --extra-ldflags="-arch armv7" --extra-ldflags=-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/lib/system --arch=arm --cpu=cortex-a8 --enable-pic  --disable-asm --disable-everything --enable-decoder=h264 --enable-decoder=rv40 --enable-decoder=aac

2) make clean

3) make 

4) make install 如果執行失敗,執行 sudo make install

5) make clean

6) 執行所得.a檔案剪下到案頭ffmpeg檔案夾下arm7子檔案夾下


6、arm7s指令碼(產生arm7s下.a檔案)

1) sudo ./configure --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk" --target-os=darwin --cc="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" --extra-cflags="-arch armv7s -mfpu=neon -miphoneos-version-min=7.1” --extra-ldflags="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -miphoneos-version-min=7.1" --arch=arm --cpu=cortex-a9 --enable-pic  --disable-asm --disable-everything --enable-decoder=h264 --enable-decoder=rv40 --enable-decoder=aac

2) make clean

3) make 

4) make install 如果執行失敗,執行 sudo make install

5) make clean

6) 執行所得.a檔案剪下到案頭ffmpeg檔案夾下arm7s子檔案夾下


7、i386的編譯:(產生i386下.a檔案)

1) sudo ./configure --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk" --target-os=darwin --cc="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" --extra-cflags="-arch i386 -mfpu=neon -miphoneos-version-min=7.0" --extra-ldflags="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -miphoneos-version-min=7.0" --arch=i386 --cpu=i386 --enable-decoder=h264 --enable-decoder=rv40

2) make clean

3) make 

4) make install 如果執行失敗,執行 sudo make install

5) make clean

6) 執行所得.a檔案剪下到案頭ffmpeg檔案夾下sim子檔案夾下

注:不用配置這個--enable-pic  --disable-asm

--enable-pic  //build position-independent code

--disable-asm  //disable all assembler optimizations

指令碼中的黃色字型顯示編譯器的路徑,這個和xcode5以前是不一樣的



8、i386,arm7,arm7s檔案夾下的相同名字檔案合并到ios檔案下一個檔案

1)、三個libswscale.a檔案合成一個檔案libswscale.a

lipo -create /Users/chang/Desktop/ffmpeg/sim/libswscale.a /Users/chang/Desktop/ffmpeg/arm7/libswscale.a /Users/chang/Desktop/ffmpeg/arm7s/libswscale.a -output /Users/chang/Desktop/ffmpeg/ios/libswscale.a

2)、三個libswresample.a檔案合成一個檔案libswresample.a

lipo -create /Users/chang/Desktop/ffmpeg/sim/libswresample.a /Users/chang/Desktop/ffmpeg/arm7/libswresample.a /Users/chang/Desktop/ffmpeg/arm7s/libswresample.a -output /Users/chang/Desktop/ffmpeg/ios/libswresample.a

3)、三個libavutil.a檔案合成一個檔案libavutil.a

lipo -create /Users/chang/Desktop/ffmpeg/sim/libavutil.a /Users/chang/Desktop/ffmpeg/arm7/libavutil.a /Users/chang/Desktop/ffmpeg/arm7s/libavutil.a -output /Users/chang/Desktop/ffmpeg/ios/libavutil.a

4)、三個libavformat.a檔案合成一個檔案libavformat.a

lipo -create /Users/chang/Desktop/ffmpeg/sim/libavformat.a /Users/chang/Desktop/ffmpeg/arm7/libavformat.a /Users/chang/Desktop/ffmpeg/arm7s/libavformat.a -output /Users/chang/Desktop/ffmpeg/ios/libavformat.a

5)、三個libavfilter.a檔案合成一個檔案libavfilter.a

lipo -create /Users/chang/Desktop/ffmpeg/sim/libavfilter.a /Users/chang/Desktop/ffmpeg/arm7/libavfilter.a /Users/chang/Desktop/ffmpeg/arm7s/libavfilter.a -output /Users/chang/Desktop/ffmpeg/ios/libavfilter.a

6)、三個libavdevice.a檔案合成一個檔案libavdevice.a

lipo -create /Users/chang/Desktop/ffmpeg/sim/libavdevice.a /Users/chang/Desktop/ffmpeg/arm7/libavdevice.a /Users/chang/Desktop/ffmpeg/arm7s/libavdevice.a -output /Users/chang/Desktop/ffmpeg/ios/libavdevice.a

7)、三個libavcodec.a檔案合成一個檔案libavcodec.a

lipo -create /Users/chang/Desktop/ffmpeg/sim/libavcodec.a /Users/chang/Desktop/ffmpeg/arm7/libavcodec.a /Users/chang/Desktop/ffmpeg/arm7s/libavcodec.a -output /Users/chang/Desktop/ffmpeg/ios/libavcodec.a


注:i386,arm7檔案夾下各有8個.a檔案,arm7s檔案夾下卻只有7個,不明原理。

測試中,我在案頭建了一個檔案夾ffmpeg,下面有三個子檔案夾sim(即i386編譯所得.a檔案,用於模擬器調試)、arm7(即arm7環境下編譯所得檔案)、arm7s(即arm7s環境下編譯所得檔案)。經過上面命令操作後,在ios檔案夾下會得到合成後的.a檔案,這樣就可以在真機及模擬器下正常使用了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.