Full compilation of ijkplayer for Mac to generate Android Library

ijkplayer compilation

GitHub address: https://github.com/Bilibili/ijkplayer

Recently, I did a new training and talked about the compilation process. I found that many people can't pull the code and compile it. I use a new computer to sort out the pits that will be encountered in a new environment. Here, I simply record the complete content and the pits I stepped on.

1. Environmental preparation

# install homebrew, git, yasm
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install git
brew install yasm

2. Setting environment

Add a path to your environment variable

open .bash_profile

After editing, save and take effect, use the following command, which is aimed at the context of the current window
source .bash_profile

The environment variable is very simple. If you can't search at will, you can find the answer.

3. Download ijk code

This needs to install GIT. You can refer to various online tutorials, which is relatively simple. Because the desktop client of GIT has been installed in my mac before, there is a git environment and no additional configuration is required.

# Clone to ijkplayer Android directory
git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android

# Enter ijkplayer Android directory
cd ijkplayer-android
# Check out the latest version
git checkout -B latest k0.8.8

4. Select your configuration before compiling, that is, some configuration options during automatic compilation, such as what protocols are supported, what audio and video types are supported, etc,

There are three official templates for us to use:

  • module-default.sh: by default, you can use this if you like more types;
  • module-lite-hevc.sh: if you prefer a smaller binary CODEC / format (including hevc function)
  • module-lite.sh: if you prefer a smaller binary size CODEC / format (by default)

The use is as follows:

cd config
rm module.sh
ln -s module-default.sh module.sh

5. Initialize FFMPEG

./init-android.sh

This is the source code for downloading FFMPEG. The download process will be very slow. The contents of the extra\ffmpeg folder will change during the download process.

If the video playback needs to support Https protocol, you also need to execute the following commands:

./init-android-openssl.sh

If the terminal is not configured with an agent, it will be very slow. The computer turns on VPN and the terminal are two different things. The terminal still does not take the agent traffic, unless it is the agent of all traffic.

# Open terminal input: the agent that can take the computer VPN.

# For example, this is just an example. IP and ports use their own.

export http_proxy=http://127.0.0.1:50122

export https_proxy=http://127.0.0.1:50122 

export ALL_PROXY=socks5://127.0.0.1:50121

6. Compilation

cd android/contrib

Execute the clear command, and then compile the required so. All here generates all versions. If you only need the corresponding version, you can replace all with the version you need, such as armv7a. Compilation takes a long time.

Compiling openssl

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

Compile ffmpeg

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

Compile version 0.8.8 of ijk/ compile-ffmpeg.sh all, Linux / perf appears_ event. h: No such file or directory

# In moule SH file can be added with the following two sentences:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-linux-perf"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-bzlib"

# Then clean and compile.
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all

7. At this point, the compilation is complete. You can find the ikplayer directory and open it with Android.

About how to run android studio integrated ijkplayer

  • 1. Import into your project

android studio opens your project, file import module... Select the Android / ijkplayer directory of ijkplayer. Ijk example depends on all libraries, so all projects will be imported into your project after import.

  • 2. Copy the tools folder in the android/ijkplayer directory to the root directory of your project.
  • 3. Create a new folder named jniLibs under the ijkplayer Java \ SRC \ main \ directory, and copy the folders under the \ src\main\libs directory in each ijkplayer XXX directory to the jniLibs folder. For example, the directory of ijkplayer – armv7a contains the folder armeabi-v7a, which contains the corresponding files of the platform so file. If you want to include all platforms, copy all the files under ijkplayer XXX. If you only want some platforms, copy only their files.
  • 4. Delete all the directories of ijkplayer xxx from the project, and only keep the ijkplayer example, ijkplayer Java, ijkplayer exo and tools folders, where ijkplayer example depends on the following.

 

  • 5. Change the ijkplayer example to the form of Module. Because ijkplayer example itself is an application project, it does not generate aar files by default, and the resources in it depend on each other, so it is difficult to use it in the same way as the old version by copying several required java files into its own project. Therefore, it is better to convert the whole ijkplayer example into a Module of our project. The specific methods are:
Modify first ijkplayer-example Directory build.gradle Documents, as follows:


apply plugin: 'com.android.library'


android {

  // http://tools.android.com/tech-docs/new-build-system/tips

  //noinspection GroovyAssignabilityCheck

  compileSdkVersion rootProject.ext.compileSdkVersion

  //noinspection GroovyAssignabilityCheck

  buildToolsVersion rootProject.ext.buildToolsVersion

  buildToolsVersion '25.0.0'


  lintOptions {

    abortOnError false

  }

  defaultConfig {

    minSdkVersion 9

    targetSdkVersion rootProject.ext.targetSdkVersion

    versionCode rootProject.ext.versionCode

    versionName rootProject.ext.versionName

  }

  buildTypes {

    release {

      minifyEnabled false

      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

    }

  }

}


dependencies {

  compile fileTree(include: ['*.jar'], dir: 'libs')

  compile 'com.android.support:appcompat-v7:25.0.0'

  compile 'com.android.support:preference-v7:23.0.1'

  compile 'com.android.support:support-annotations:23.0.1'


  compile 'com.squareup:otto:1.3.8'


  compile project(':ijkplayer-java')

  compile project(':ijkplayer-exo')

}

be careful:

  1. apply plugin: ‘com.android.application 'should be changed to apply plugin:' com android. library’
  2. The sentence of applicationId "tv.danmaku.ijk.media.example" should be removed
  3. compile 'com.android.support:appcompat-v7:25.0.0'
    1. compile 'com.android.support:preference-v7:23.0.1'
    2. compile 'com.android.support:support-annotations:23.0.1'
    3. compile 'com.squareup:otto:1.3.8'

These modifications are the versions installed for yourself.

  • 6. Add a gradle in the ijkplayer example root directory Properties file, as follows:
POM_NAME=ijkplayer-example

POM_ARTIFACT_ID=ijkplayer-example

POM_PACKAGING=aar
  • 7. Add dependencies to your project, complete the above operations, and click async gradle.

Other errors:

If appear

Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

The above similar errors are caused by different sdk versions of several projects. Four projects include your own project's compileSdkVersion

buildToolsVersion, targetSdkVersion and compile 'com android. Support: appcompat-v7: 25.0.0 'versions must be unified. If they are not unified, various problems will occur.

The above is the whole content of this article. I hope it will be helpful to your study.

Keywords: Android kotlin ijkPlayer

Added by adige72 on Wed, 09 Mar 2022 11:56:04 +0200