编译ijkplayer-android

2022-04-17  本文已影响0人  _好好学习

环境准备

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    brew install git
    brew install yasm

无论是Windows还是MacOS都需要配置Android工程的编译环境,Windows需要在Cygwin终端中的~/.bash_profile或~/.profile上进行配置,MacOS则需要在~/.bash_profile或~/.profile进行配置。

export ANDROID_SDK=/Users/xxx/Library/Android/sdk   //sdk所在的路径
export ANDROID_NDK=/Users/xxx/Library/Android/sdk/ndk/android-ndk-r12b  //ndk所在的路径,这里使用r12b的ndk进行编译,高版本的ndk会编不过

踩坑遍译

  1. 拉取代码
git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android  //拉取仓库代码
cd ijkplayer-android  //进入工程目录
git checkout -B latest k0.8.8  //切换到最新分支
  1. 预处理
//根据需要选择编译颗粒度
//lite版
cd config
rm module.sh
ln -s module-lite.sh module.sh

//lite版支持hevc
cd config
rm module.sh
ln -s module-lite-hevc.sh module.sh

//默认,支持复杂的多种格式
cd config
rm module.sh
ln -s module-default.sh module.sh
  1. 编译ffmpeg
cd ..
./init-android.sh  //此处下载ffmpeg相关资源,需要保证网络条件良好,不然会影响后续的编译
cd android/contrib
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all  //编译ffmpeg

如报错fatal error: linux/perf_event.h: No such file or directory,去module.sh脚本中加上export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-linux-perf" 即可

  1. 编译ijkplayer
cd ..
sh compile-ijk.sh all

编译完成后可以看到android工程中的各个library中已经有so文件了。


WechatIMG58.jpeg

运行demo

把ijkplayer-example build.gradle中的所有all32相关的都注释掉

高版本的Android Studio需要在ijkplayer-example build.gradle中的default config中添加flavorDimensions "versionCode"

然后进行项目构建运行就可以了。

上一篇下一篇

猜你喜欢

热点阅读