Bilibili ijkplayer 編譯出so文件?;ㄙM(fèi)了我2天的時間不斷的研究,得出結(jié)果
我用的mac電腦,所以blablabla...
1.準(zhǔn)備
下載ijkPlayer源碼,下載地址:https://github.com/Bilibili/ijkplayer
編譯之前 首先查看一下是否安裝了NDK,沒有的請自行安裝,下載地址:
https://developer.android.com/ndk/downloads/index.html?hl=zh-cn
編譯需要的 NDK 最小版本支持 10e,另外作者貌似還沒有對NDK15支持 所以 最好是 14e
安裝NDK之后,要記得在.bash_profile配置
export ANDROID_SDK="SDK路徑"
export ANDROID_NDK="NDK路徑"
(使用open .bash_profile 打開 配置文件)
2.安裝前需要準(zhǔn)備的工具
homebrew git 和yasm
可自行百度 mac 如何安裝 homebrew
3.配置文件(終端進(jìn)入ijkPlayer工程根目錄)
有三種文件可供選擇
? If you prefer more codec/format
cd config
rm module.sh
ln -s module-default.sh module.sh
? If you prefer less codec/format for smaller binary size (include hevc function)
cd config
rm module.sh
ln -s module-lite-hevc.sh module.sh
? If you prefer less codec/format for smaller binary size (by default)
cd config
rm module.sh
ln -s module-lite.sh module.sh
本來想使用第一種配置文件,支持的類型還多一些,但打出來的so文件11M多,太大了,最后選擇了第三種配置文件,打出來so 4M左右.
4.初始化openssl、ffmpeg(根目錄)
./init-android.sh
按照 github的步驟走
5.編譯
切換到android/contrib目錄下(cd android/contrib),執(zhí)行如下命令 編譯so文件
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all
其中all 代表所有平臺,如果只想編譯指定的平臺,比如編譯armv5 ,則將all改為armv5 (本人使用的是armv7a)
6.生成 so文件
切換到android目錄下(cd ..),執(zhí)行如下命令 生成so文件
./compile-ijk.sh all
上面使用的是armv7a,這里的all 也要使用 armv7a
生成的so文件在android /ijkplayer /ijkplayer-armv7a/src/main/libs 里面
-
遇到的問題
1、android NDK = 空 你需要打開你的.bash_profile 配置文件 cd ~ 進(jìn)入根目錄 在 open .bash_profile 命令打開。設(shè)置你的 ndk路徑,最好從google上下載 14e。目前的16 不支持,15 沒試過。 2、IJK_NDK_REL=空 打開 do-detect-env.sh 文件 添加 IJK_NDK_REL增加 14* 簡單看一下code 可以找到,詳情看github中的issue 3、ERROR: Failed to create toolchain 有些code比較老了,版本不支持,所以本人當(dāng)時退回到使用 ndk14e。并且只生成了armv7a的so文件
編譯之后的demo地址鏈接 :https://github.com/bushe-coffee/dkplayer
此鏈接是具體的使用的例子。學(xué)習(xí)的話可以看看。