使用工具:
- Mac 10.10.5 (14F2511)
- (android-ndk-r14b)[https://developer.android.google.cn/ndk/downloads/index.html]
- android-sdk
1. 打開(kāi)終端,安裝homebrew, git, yasm
# 安裝homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 安裝git
brew install git
# 安裝yasm
brew install yasm
2. 配置NDK與SDK
# add these lines to your ~/.bash_profile or ~/.profile
export ANDROID_SDK=<your sdk path>
export ANDROID_NDK=<your ndk path>
命令行
vim ~/.bash_profile
# 或者
vim ~/.profile
配置后如下圖:

圖1.png
注:等號(hào)兩邊不要填空格
3. 克隆項(xiàng)目
git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android
4. 下載并編譯ffmpeg
# 進(jìn)入ijkplay-android目錄
cd ijkplayer-android
# 安裝ffmpeg,此處等待,如果中途出現(xiàn)異常,可以重復(fù)執(zhí)行此命令
./init-android.sh
# 進(jìn)入config文件夾
cd config
# 移除默認(rèn)的配置
rm module.sh
#拷貝module-default.sh為module.sh
ln -s module-default.sh module.sh
# 進(jìn)入android/contrib目錄
cd ..
cd android/contrib
# 清楚ffmpeg的編譯文件
./compile-ffmpeg.sh clean
# 編譯ffmpeg的所有架構(gòu)
./compile-ffmpeg.sh all
編譯完成后,在contrib/build/文件夾下生成ffmpeg的對(duì)應(yīng)的架構(gòu)文件夾,在每個(gè)架構(gòu)對(duì)應(yīng)的文件夾下的output目錄下會(huì)生成一個(gè)libijkffmpeg.so文件。

圖2.png
5. 編譯ijkplayer
cd ..
./compile-ijk.sh all
編譯完成之后,在android/ijkpleyer文件夾的對(duì)應(yīng)架構(gòu)下,在路徑("/src/main/libs/架構(gòu)名/")下生成libijkplayer.so、libijkffmpeg.so、libijksdl.so三個(gè)文件。

圖3.png