Record an ijkplayer compilation trip

Keywords: Android git OpenSSL SDK

Preface

With the rise of the media and audio-video industry, as well as the product demand for cross-platform mobile business, there has been an increase in the workload of developers and the difficulty of the work. For example, audio-video playback needs to support 95% of audio-video formats on the market, so native Android players can not be satisfied, at this time we can consider ijkplayer.
Let's start by introducing what ijkplayer is. ijkplayer is an open source, FFMPEG-based, lightweight Android/Ios audio and video player developed by bilibili. It is favored by developers for its easy integration, tailorable editing configuration, highly customizable development, and is therefore intimately called by developers and users.Station B.

How to use ijkplayer

Official address of ijkplayer:https://github.com/bilibili/ijkplayer

  • Android
  • Gradle
# required
allprojects {
    repositories {
        jcenter()
    }
}

dependencies {
    # required, enough for most devices.
    compile 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
    compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'

    # Other ABIs: optional
    compile 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
    compile 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
    compile 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
    compile 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'

    # ExoPlayer as IMediaPlayer: optional, experimental
    compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
}

Now that a popular ijkplayer library has been added, just use it without special requirements!Then there's a big difference between using MediaPlayer and using it. There's no telling you how to use it. There's a lot of Google right away.

ijkplayer Compile so Library

First of all, my compilation environment is Ubuntu-16.04.6-server-amd64

  • Step 1: Download, configure SDK and NDK
    SDK download:http://tools.android-studio.org/index.php/sdk
    Recommended use: Android-sdk_r24.4.1-linux
    NDK Official Download:https://developer.android.google.cn/ndk/downloads/older_releases
    NDK version recommended: NDK r10e

Next, configure environment variables:

1. $ sudo vim /etc/profile,Add the following at the end of the file:
2. export ANDROID_SDK=/home/yh/android-sdk-linux
3. export PATH=$ANDROID_SDK/tools:$PATH
4. export ANDROID_NDK=/home/yh/ndk/android-ndk-r10e/
5. export PATH=$ANDROID_NDK:$PATH
6. Save and Exit
7. $ source .bashrc // Make the configured environment variables valid

Verify that the configuration is valid: ndk-build-v

The console prints the log above and the android NDK installation is now configured.

  • Step 2: Install git, make, and yasm
sudo apt-get install git
sudo apt-get install make
sudo apt-get install yasm

  • Step 3: Pull ijkplayer source
1. git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android // Pull ijkplayer source
2. cd ijkplayer-android // Enter Source Directory
3. git checkout -B latest k0.8.8 // Create a new branch

  • Step 4: Initialize android
./init-android.sh // Initialize Android script
  • Step 5: Compile script configuration
1.If you like more codecs/format
cd config // Enter config directory
rm module.sh // deleteModule.shScript
ln -s module-default.sh module.sh // Specify default script soft connectionModule.sh
source module.sh // Re-execute the newly modified file initialization for immediate effect

2.If you want to use a smaller codec/Format to obtain smaller binary sizes (including hevc Function)
cd config
rm module.sh
ln -s module-lite-hevc.sh module.sh
source module.sh

3.If you want to use a smaller codec/Format to get a smaller binary size (by default)
cd config
rm module.sh
ln -s module-lite.sh module.sh
source module.sh

//Here we choose the1Yes, don't ask me why, children know as much as possible
//Then modify the module-default.sh,Append the following two lines to the end of the file
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-linux-perf"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-bzlib"
  • Step 6: Initialize android support for accessing Https
1. cd .. // Return to the previous directory
2. ./init-android-openssl.sh // Execute Initialization Support https Scripts
  • Step 7:clear
1. cd android/contrib // Enter contrib directory
2. ./compile-openssl.sh clean
3. ./compile-ffmpeg.sh clean
  • Step 8: Compile openssl
1. ./compile-openssl.sh all //About 5 minutes (see server configuration)
  • Step 9: Compile ffmpeg
./compile-ffmpeg.sh all

Note: If you want to compile all versions of the so library, follow all if you only want to compile specific
The CPU schema is directly followed by the CPU schema name, for example:. /compile-Ffmpeg.shArmv7a is fine!

  • Step 10: Compile ijkplayer
cd .. 
./compile-ijk.sh armv7a
Wait a moment... After successful compilation, the libraries and files in ijkplayer in the current directory are updated.Export ing the ijkplayer project as a library dependency is OK.


Finally, how to use compiled library files:

  • Import the corresponding library file into your own project, and you can tell it by the suffix name of the folder!Unexpectedly, there will be error information, which is basically a problem with gradle configuration. Just modify the error location based on the error information.
  • After modifying the above configuration error information, we can package the above libraries into aar s, so that we can use AARS directly as dependent packages for projects in the future. Is it convenient?
  • You can customize your own ijkplayer based on what's inside the example!
Finally, thank you for your reading. Your attention and forwarding are my endless power.

Posted by chriskiely on Sun, 07 Jun 2020 18:17:49 -0700