1.下載WMware虛擬機(jī)并安裝激活
2.下載ubuntu系統(tǒng)并在WMware中新建虛擬機(jī)安裝該系統(tǒng)闽烙,開(kāi)機(jī)在HOME目錄下新建environment文件夾
3.通過(guò)瀏覽器下載JDK1.8并解壓到environment文件夾中
4.通過(guò)瀏覽器下載SDK并解壓到environment文件夾中
5.執(zhí)行命令下載NDK包:wget -c http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin诈乒;復(fù)制到environment后通過(guò)授權(quán)chmod? a+x? android-ndk-r10c-linux-x86_64.bin并./android-ndk-r10c-linux-x86_64.bin安裝NDK
6.Ctrl+Alt+T打開(kāi)命令窗口執(zhí)行sudo su進(jìn)入root模式叮喳,通過(guò)命令 gedit /etc/profile打開(kāi)配置文件配置環(huán)境變量砰诵,在末尾添加如下內(nèi)容:
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.每次重新打開(kāi)命令窗口需要用到NDK時(shí)需要先執(zhí)行source /etc/profile
8.執(zhí)行命令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 (注:在彈出的選項(xiàng)中選擇NO)
⑥cd ~/ijkplayer-android
./init-android.sh
⑦cd android/contrib
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all(注:測(cè)試時(shí)為了方便瞎暑,可以先編譯一個(gè)包./compile-ffmpeg.sh ?armv7a)?
⑧cd ..
./compile-ijk.sh all(注:對(duì)應(yīng)上面執(zhí)行./compile-ijk.sh? armv7a)
10.默認(rèn)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"
修改完成后進(jìn)入ijkplayer-android/config目錄執(zhí)行以下命令:
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播放問(wèn)題束昵,進(jìn)入ijkplayer-android/ijkmedia/ijkplayer/打開(kāi)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函數(shù)中的ffp_toggle_buffering(ffp, 1);注釋掉
最后進(jìn)入ijkplayer-android/android/執(zhí)行./compile-ijk.sh all(或./compile-ijk.sh armv7a)