1.下载WMware虚拟机并安装激活
2.下载ubuntu系统并在WMware中新建虚拟机安装该系统,开机在HOME目录下新建environment文件夹
3.通过浏览器下载JDK1.8并解压到environment文件夹中
4.通过浏览器下载SDK并解压到environment文件夹中
5.执行命令下载NDK包:wget -c http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin;复制到environment后通过授权chmod a+x android-ndk-r10c-linux-x86_64.bin并./android-ndk-r10c-linux-x86_64.bin安装NDK
6.Ctrl+Alt+T打开命令窗口执行sudo su进入root模式,通过命令 gedit /etc/profile打开配置文件配置环境变量,在末尾添加如下内容:
export JAVA_HOME=/home/case/environment/jdk1.8.0_121/
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export ANDROID_NDK=/home/case/environment/android-ndk-r10e
export PATH=$PATH:$ANDROID_NDK
export ANDROID_SDK=/home/case/environment/android-sdk-linux
export PATH=${PATH}:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
7.每次重新打开命令窗口需要用到NDK时需要先执行source /etc/profile
8.执行命令apt install git和apt install yasm
9.正式编译ijkplayer:
①git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android
②cd ijkplayer-android
③git checkout -B latest k0.7.7.1
④cd config
rm module.sh
ln -s module-default.sh module.sh
cd ..
cd android/contrib
./compile-ffmpeg.sh clean
⑤sudo dpkg-reconfigure dash (注:在弹出的选项中选择NO)
⑥cd ~/ijkplayer-android
./init-android.sh
⑦cd android/contrib
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all(注:测试时为了方便,可以先编译一个包./compile-ffmpeg.sh armv7a)
⑧cd ..
./compile-ijk.sh all(注:对应上面执行./compile-ijk.sh armv7a)
10.默认ijkplayer不支持rtsp的格式播放,需要修改文件ijkplayer-android/config/module-lite.sh如下:
在# ./configure --list-protocols配置中添加(或修改)
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-protocol=rtp"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-protocol=tcp" //需要使用tcp才添加
在# ./configure --list-demuxers配置中添加(或修改)
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-demuxer=rtsp"
修改完成后进入ijkplayer-android/config目录执行以下命令:
rm module.sh
ln -s module-lite.sh module.sh
cd ..
cd android/contrib
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all(或者./compile-ffmpeg.sh armv7a)
11.修改ffmpeg的tcp播放问题,进入ijkplayer-android/ijkmedia/ijkplayer/打开ff_ffplay.c文件,注释两行如下代码:
将下面三行代码的中间一行注释掉
SDL_LockMutex(wait_mutex);
//SDL_CondWaitTimeout(is->continue_read_thread, wait_mutex, 10);
SDL_UnlockMutex(wait_mutex);
再将packet_queue_get_or_buffering函数中的ffp_toggle_buffering(ffp, 1);注释掉
最后进入ijkplayer-android/android/执行./compile-ijk.sh all(或./compile-ijk.sh armv7a)