Analysis of ijkplayer player (1) Let ijkplayer play

1. Introduction:
ijkplayer is a third-party open source player that encapsulates FFmpeg very well. Unfortunately, ijkplayer2.0 does not seem to be open source, and the update of version 1.0 has basically stopped. Many companies will use ijkplayer as their playback application Kernel, this player that integrates software and hardware codec functions is indeed very popular. Starting from this article, I will analyze the ijkplayer player. I hope it will be helpful for everyone to understand ijkplayer. Correct me.

2. Environment construction and compilation:
1. Environment construction:
The address of ijkplayer GitHubis as follows:

https://github.com/bilibili/ijkplayer

By reading the project, readmewe can help us quickly build the ijkplayer environment. If we want to use ijkplayer in our own project, we need java layer dependencies and underlying libraries. The former directly adds the following dependencies gradle:

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'
}

NDK and SDK are required to correctly compile the jni library of ijkplayer, and the NDK toolkit can be downloaded from the official website of Android. From my actual experience, r14e~r10ethe version of . The virtual machine environment imports environment variables containing NDK and SDK paths as follows:

export ANDROID_NDK=/home/xxx/android-ndk-r10e
export PATH=$PATH:ANDROID_NDK
export ANDROID_SDK=/home/xxx/android-sdk-linux
export PATH=${PATH}:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools

2. Compilation:
To compile the JNI library, we can execute the following instructions in sequence:

./init-android.sh
cd android/contrib
./compile_ffmpeg.sh clean
./compile_ffmpeg.sh all (默认是只编译armv7)  armv5 armv7a arm64 x86 x86_64
cd ..
./compile_ijk.sh all

Here you need to pay attention to the following issues. The first step is to download the source code of FFmpeg through the script of ijkplayer. There are 5 source codes of the architecture, so there will be a long delay here. The next step is to compile the FFmpeg library of the corresponding architecture. The script is followed by allIt is to compile all architectures. Of course, you can also choose to compile the architectures of your own known platforms. The commonly used architectures are armv7aand arm64. The last step is to compile the ijkplayer library, and you can also choose the architecture you need. When the compilation is completed, the following three dynamic libraries will be generated:
libijkffmpeg.so
libijkplayer.so
libijksdl.so

3. Run the demo:
Open the project in the ijkplayer source code through Android studio ijkplayer-example, you can actively create the lib folder to package the three libraries generated above into it, or push it to the system/libbottom of the board through adb, and then compile the demo After installing it on your own platform, you can play the code stream. It should be noted that if the playback test code stream crashes, it is most likely caused by the lack of three libraries.

4. Introduction to the source code path:
The source code path of ijkplayer is a bit complicated. Many people don't know what should be modified when debugging. Let me focus on it here.
Enter the root directory, we focus on the following path:
insert image description here
android/ioscorresponding to different OS platforms;
configunder the folder are several scripts for configuring our ijkplayer and FFmpeg, if it is necessary to cut the library in the project, please pay attention here;
extrafile The following is the third-party software used by ijkplayer. Please note that modifying the FFmpeg source code here has no effect;
ijkmediahere is the source code of ijkplayer, including the implementation of jni and sdl source code of ijkplayer. This folder is very important;
because I use It is the Android platform, and then enter androidthe directory:
insert image description here
contribthe source code of FFmpeg of each architecture is under the directory, and the source code here will be modified, and the push libijkffmpeg.sowill have an effect;
ijkplayerthe directory is where the java project is located, ijkplayer-exampleand it is under this directory;

5. Summary:
This article is relatively easy. It briefly introduces the compilation and use of ijkplayer. The next article will start from the official demo to see how ijkplayer is transferred into the jni library.

Guess you like

Origin blog.csdn.net/achina2011jy/article/details/115667718