- IJKPlayer is the open source video playback framework of Bilibili. IJKPlayer is a lightweight Android/iOS video player based on FFMPEG. FFMPEG is the world’s leading multimedia framework. It can decod, encodes, transcodes, reuse, reuse, flow, flow, filter and play most video formats. It provides a complete solution for recording, conversion, and fluidized sound videos. It contains very advanced audio/video decoding library libavcodec. In order to ensure high transplantability and encoding quality, many CODEs in LibavCodec are developed from scratch.
- official document address:https://github.com/bilibili/ijkplayer
- Introduce the package, call its API to simply implement video playback
- But there are many formats that are not supported, such as M3U8, and videos of HTTPS links cannot be played (reporting Protocol Not Found). At this time, Ijkplayer needs to be compiled.
- First of the two official screenshots, basically follow the official steps.
- 1. Prepare environment
(1), prepare a Ubuntu system (the other Linux distributions have not been tried), and those who are not used in virtual machines will be done
(2), GCC, G ++, Make’s basic compilation environment may be available
(3), Android SDK, download address:https://developer.android.com/studio, Android SDK I usedhttps://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
(4), Android NDK download address:https://developer.android.com/ndk/downloads(Note to download the corresponding version, otherwise there will be pit), and the Android NDK I usehttps://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zip - 2. After ready, you can configure environment variables, install git and yasm
apt-get install git
,apt-get install yasm
and then open the environment variable configuration file editingvim /etc/profile
Add.
# Fill in your own path here
export Android_sdk =/Home/ZZQ/Software/Androidsdk
export android_ndk =/Home/ZZQ/Software/Android-NDK-R10e
export path = $ PATH: $ Android_sdk/Tools: $ Android_ndk
- Use after saving
source /etc/profile
Make it effective. - 4. Pull the IJKPlayer code to configure some attributes; the first solution (relatively common) selected here.
git clone https://github.com/Bilibili/ijkplayer ijkplayer-android
cd ijkplayer-android
git checkout -B latest k0.8.8
cd config
ln -s module-default.sh module.sh
- 5. Initialization and compilation. This step is mainly to pick up FFMPEG and compile code. It takes a few hours slowly, and it may fail to pick up FFMPEG midway and re -execute.
./init-android.sh
cd android/contrib
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all
cd ..
./compile-ijk.sh all
- Compilation complete
- After importing the above example, I found that I still ca n’t play HTTPS videos. After checking the information, I did n’t run the script about OpenSSL.
- 1. Initialize (I won’t go into details in the previous steps)
./init-android.sh
./init-android-openssl.sh
- 2. Clean up and compile
cd android/contrib
./compile-openssl.sh clean
./compile-openssl.sh all
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all
cd ..
./compile-ijk.sh all
- 1. Use Android Studio to open Android/IJKPlayer, wait for Android Studio to automatically configure it, run iJKPlayer-EXAMPLE, etc. After the program is successfully installed on the phone, it can be tested.
- 2. Use. The use of IJKPlayer is basically the same as the MediaPlayer usage with the system.
- Examples are basically like this.
- Error
You need the NDKr10e or later
; The solution is that NDK uses a low version, download address:https://developer.android.com/ndk/downloads/older_releases.html, it is best to download the corresponding R10E version (https://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zip) - ./libavutil/timer.h:38:31: Fatal error: linux/perf_event.h: no such file or directory; the solution is
module-default.sh
File last addexport COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-linux-perf"
, because the attribute is reset, the compilation steps must start after joining. - Report error Could not resolve com.android.support:appcompat-v7:23.0.1 or please install the Android support repository from the Android SDK Manager.
When I learned from API 26, SUPPORT LIBRARIES needs to be downloaded from Google’s Maven warehouse, so you need to add the following configuration in allProjects in the build.gradle
maven { url "https://maven.google.com" }
- Finally attached the compiled code:https://github.com/1030907690/ijkplayer-https, if there are any wrongs, please correct me.