The original article was first published in the wechat public number: Practice, welcome to pay attention to communication!

Recently, the project may need video playback, and the later may also support the playback of RTSP protocol video, weighing the compiler of the open source IjkPlayer B station. Ijkplayer is a lightweight cross-platform player based on FFMPEG that can be used on Android and Ios. It can be compiled to support more formats, as long as FFMPEG supports ijkPlayer.

I started compiling ijkPlayer using Cygwin, but there were always errors when generating so files. Of course, there were a lot of holes in the process. So I decided to use Ubuntu to compile ijkPlayer.

  1. To prepare
  2. Configuring environment Variables
  3. Install required Components
  4. Officially compiled
  5. Run ijkplayer

To prepare

Install the VMware VM and Ubuntu system. After installing VMware, create the VM and select the typical installation mode, as shown in the following figure:

Then click Next and select the downloaded system image, as shown below:

The correct selection will display the image information, such as Ubuntu 64-bit 18.04, and proceed to the next step, as shown below:

Fill in the user name, password and other information, click Next, as shown below:

Enter the VM name and the location to install the VM, and click Next:

Set the vm disk size, save the disk as a single file so as not to degrade the disk performance, and then click Next, as shown below:

After the Ubuntu VIRTUAL machine is created, click Finish, wait for the Ubuntu installation to complete, and enter the password to enter the Ubuntu system, as shown below:

In addition, you need to download the Linux version of Android SDK and NDK, here choose android-sdk_R24.4.1-linux. TGZ and Android-ndk-r10e-linux-x86_64. zip respectively. You can run the following command to decompress the file:

unzip xxx.zip
tar -xvf xxx.tgz
Copy the code

Do not place the NDK directory in the shared directory of the VIRTUAL machine. To ensure smooth compilation, place the NDK directory in the Ubuntu system directory under the /home/username.

Configuring environment Variables

In Ubuntu, press Ctrl+ H to view the.bashrc file and configure the SDK and NDK environment variables as follows:

NDK=/home/jzman/android/android-ndk-r10e export NDK ADB=/home/jzman/android/android-sdk-linux/platform-tools export ADB # ANDROID_NDK and ANDROID_SDK ANDROID_NDK path = / home/jzman/android/android - the NDK - r10e export ANDROID_NDK ANDROID_SDK = / home/jzman/android/android SDK - Linux export ANDROID_SDK # joining PATH PATH PATH=${PATH}:${NDK}:${ADB}:${ANDROID_NDK}:${ANDROID_SDK}Copy the code

Bashrc, run the Terminal command to check whether the NDK is successfully configured. If the run log is as follows, the NDK is successfully configured.

jzman@ubuntu:~$ ndk-build -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu
Copy the code

Install required Components

Enter the following commands to update and install git, yasm, and make

sudo apt-get update
sudo apt install git
sudo apt install yasm
sudo apt install make
Copy the code

Run git –version and make -v to check whether the git and make tools are installed successfully. If the installation is successful, the corresponding version is displayed as follows:

jzman@ubuntu:~$ git --version
git version 2.171.
jzman@ubuntu:~$ make -v
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
jzman@ubuntu:~$
Copy the code

Officially compiled

/ / clone ijkplayer source code
git clone https://github.com/Bilibili/ijkplayer.git ijkplayer
cd ijkplayer
git checkout -B latest k08.8.
// Use the lighter module-lite.sh
cd ijkplayer/config
rm module.sh
ln -s module-lite module.sh
// Download ffMPEG source code
cd ijkplayer
./init-android
/ / build ffmpeg
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all
// Build ijkplayer to generate so file
cd ijkplayer/android
./compile-ijk.sh all
Copy the code

To support HTTPS, run the following command at compile time:

CD ijkplayer. / init - android - openssl. Sh support (HTTPS) CD ijkplayer/android/contrib/compile - openssl. Sh clean ./compile-openssl.sh allCopy the code

After successful compilation, the corresponding Android project will be generated under ijkPlayer/Android, as shown below:

See the abi in the library, such as ijkplayer/android/ijkplayer/ijkplayer arm64 / SRC/main/libs is generated under the corresponding so file, arm64, for example, as shown in the figure below:

Run ijkplayer

Use Android Studio to open the compiled Android project, running screenshots are as follows:

Personal wechat public number: practice, you can pay attention to exchange and study together.