剛接觸ffmpeg麻裁,找了好多資料箍镜,都沒有編譯成功,現(xiàn)在奉上github上的腳本鏈接:https://github.com/kewlbear/FFmpeg-iOS-build-script
大體步驟:
- 先下載文件:https://github.com/libav/gas-preprocessor煎源,
復(fù)制gas-preprocessor.pl
到/usr/sbin
下色迂,
修改文件權(quán)限:chmod 777 /usr/local/bin/gas-preprocessor.pl
- 安裝
yams
具體步驟如下:
- 下載腳本:https://github.com/kewlbear/FFmpeg-iOS-build-script
- 解壓,找到文件
build-ffmpeg.sh
- 執(zhí)行服本文件:
./build-ffmpeg.sh
, 由于本人沒有事先安裝Yasm
執(zhí)行腳本文件會(huì)出錯(cuò)手销,
如下:
VeradeMacBook-Pro:~ a1$ ./build-ffmpeg.sh Yasm not found Homebrew not found. Trying to install... Whoops, the Homebrew installer has moved! Please instead run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Also, please ask wherever you got this link from to update it to the above. Trying to install Yasm... ./build-ffmpeg.sh: line 67: brew: command not found
That's歇僧,沒有yasm, 看到提示執(zhí)行 :ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"安裝 - 編譯完成后,終端進(jìn)入
FFmpeg-iOS-build-script
目錄锋拖,然后輸入./build-ffmpeg.sh lipo
诈悍,這個(gè)命令是把.a
文件合并為一個(gè) - 把
ffmpeg-iOS
文件加入到工程中 - 添加一個(gè)頭文件引用
#include "avformat.h"
添加一個(gè)api語句:av_register_all();
給一個(gè)類文件.m
后綴改為.mm
,開啟混編模式兽埃。
運(yùn)行工程侥钳,如果沒有報(bào)錯(cuò),則表明編譯成功 - **注意 **
編譯的時(shí)候報(bào)錯(cuò):'libavcodec/avcodec.h' file not found
讲仰,修改Header search paths 里的路徑:$(PROJECT_DIR)/FFmpeg-iOS/include
加入External libraries
:
libz.dylib
libbz2.dylib
``libiconv.dylib