Ijkplayer android https 编译支持 - bei1999/work GitHub Wiki

前言

ijkplayer 官网的项目没有对https格式文件进行支持,项目遇到https 类型文件,于是进行一次源码编译

准备

开发环境

  • 系统:mac os 10.11.6
  • NDK:android-ndk-r14b(建议使用 r10e 以上版本)不推荐使用更高版本

NDK环境变量配置

//编辑配置文件
open .bash_profile
//添加
export PATH=${PATH}:ndk绝对路径
ANDROID_NDK=ndk绝对路径
//更改生效
source ~/.bash_profile 

编译

git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android
cd ijkplayer-android
git checkout -B latest k0.8.4

// checkout ffmpeg 源码
./init-android.sh 

//checkout openssl源码
./init-android-openssl.sh

cd android/contrib

// 编译 openssl
./compile-openssl.sh clean
./compile-openssl.sh all

./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all

cd ..
./compile-ijk.sh all

# Android Studio:
#     Open an existing Android Studio project
#     Select android/ijkplayer/ and import
#
#     define ext block in your root build.gradle
#     ext {
#       compileSdkVersion = 23       // depending on your sdk version
#       buildToolsVersion = "23.0.0" // depending on your build tools version
#
#       targetSdkVersion = 23        // depending on your sdk version
#     }
#
# If you want to enable debugging ijkplayer(native modules) on Android Studio 2.2+: (experimental)
#     sh android/patch-debugging-with-lldb.sh armv7a
#     Install Android Studio 2.2(+)
#     Preference -> Android SDK -> SDK Tools
#     Select (LLDB, NDK, Android SDK Build-tools,Cmake) and install
#     Open an existing Android Studio project
#     Select android/ijkplayer
#     Sync Project with Gradle Files
#     Run -> Edit Configurations -> Debugger -> Symbol Directories
#     Add "ijkplayer-armv7a/.externalNativeBuild/ndkBuild/release/obj/local/armeabi-v7a" to Symbol Directories
#     Run -> Debug 'ijkplayer-example'
#     if you want to reverse patches:
#     sh patch-debugging-with-lldb.sh reverse armv7a
#
# Eclipse: (obselete)
#     File -> New -> Project -> Android Project from Existing Code
#     Select android/ and import all project
#     Import appcompat-v7
#     Import preference-v7
#
# Gradle
#     cd ijkplayer
#     gradle

运行

上面的编译后会生成对于目录jkplayer/android/ijkplayer/ijkplayer-xxx/src/main/libs 的so库文件,引入as 工程运行如下:

问题汇总

  1. make NDK standalone toolchain

    解决: 使用旧版本ndk r14

  2. make: *** No rule to make target/sources//android/cpufeatures/cpu-features.c',needed by obj/local/armeabi/objs-debug/cpu-features.o

    解决: 删除输出文件夹“obj” 重新build

文献

NDK 官网下载链接

Bilibili ijkplayer