使用工具:
- Mac 10.10.5 (14F2511)
- (android-ndk-r14b)[https://developer.android.google.cn/ndk/downloads/index.html]
- android-sdk
1. 打開終端缀旁,安裝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
注:等號兩邊不要填空格
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的對應(yīng)的架構(gòu)文件夾御板,在每個架構(gòu)對應(yīng)的文件夾下的output目錄下會生成一個libijkffmpeg.so文件魁亦。
圖2.png
5. 編譯ijkplayer
cd ..
./compile-ijk.sh all
編譯完成之后喉誊,在android/ijkpleyer文件夾的對應(yīng)架構(gòu)下邀摆,在路徑("/src/main/libs/架構(gòu)名/")下生成libijkplayer.so、libijkffmpeg.so伍茄、libijksdl.so三個文件栋盹。
圖3.png