Summary of Live Technology (II) Ijkplayer compilation to Android platform and Test decoding library

Source: Internet
Author: User

Reprint please the head source link and the tail two-dimensional code together reprint, this article from countercurrent fish yuiop:http://blog.csdn.net/hejjunlin/article/details/55670380

Preface: Ijkplayer, is the B station engineer Open-source player frame, based on ffmpeg and MEDIACODEC, the internal realization of soft and hard solution of the function, for the company without self-developed bottom player, with it is really more appropriate. About the introduction can be seen directly: Https://github.com/Bilibili/ijkplayer, today is mainly for Ijkplayer to compile on the Android platform to run.

First look at the following:
GIF graphs are as follows:




Compilation process: Compiling this library on a Mac
Clone a copy of the source code to the Local:

clone https://github.com/Bilibili/ijkplayer.git ijkplayer-androidcd ijkplayer-androidgit checkout -B latest k0.7.7.1#最新分支

Compiling ffmpeg

./init-android.sh  # 初始化ijkplayer中和android相关,如果是在iOS,这是就是./init-ios.shcd android/contrib./compile-ffmpeg.sh clean./compile-ffmpeg.sh#编译ffmpeg

found that the NDK environment is not configured on Pro.

Download NDK, fortunately, in the "hand-written illustrations you use Android Studio compiled FFmpeg library and porting", I put ndk-10e into the cloud disk.

    • For reference, see the bottom of this article, you can download it yourself.
    • With the command./android-ndk-r10e-mac-x86_64.bin, it can be decompressed, such as:

But not so smooth, in the decompression process appeared permission denied.
At this time to change the permissions, execute the command chmod a+x./android-ndk-r10e-mac-x86_64.bin

Configuring the NDK Environment

    • Start Terminal terminal
    • Go to the home directory of the current user
      • Enter CD ~ or/users/yourusername
    • Create the. Bash_profile
    • Enter Touch. Bash_profile
    • Edit. bash_profile file

    • Enter OPEN-E. bash_profile
      Because it is to configure the NDK development environment, enter the Android NDK under the directory, front of the Android SDK, you can not move it, the final. bash_profile file is as follows:

    • Save the file, close the. bash_profile
    • Update the environment variables you just configured
      • Enter source. Bash_profile, let the just-length configuration take effect

Ndk-build Test

    • Locate the ndk-10e in the sample directory, CD hello-jni, and Sweep command ndk-build. It will appear as shown below:

Back to the process of compiling ffmpeg:
Still executed:./compile-ffmpeg.sh all, get as follows

This article is derived from the countercurrent fish yuiop:http://blog.csdn.net/hejjunlin/article/details/55670380

Compile at the end of the following:

Finally, in the Crontrib directory, the various platform files needed to compile so, such as Arm,x86, will appear. You can also specify the platform, compile.

Finally execute the following command, let Ijkplayer and ffmpeg to play so Library and demo project:

.../compile-ijk.all

After execution, a Ijkplayer folder will appear for studio project, which contains the platform so library. When you import Android Studio, you can run the demo project.

Import Android Studio,example project run to emulator:

Click Sample to enter the play test

Finally we compile it, not to see the demo is finished. We can change the C code and recompile the so library as above if it is to be used in other projects. The following are referenced in the XML:

<tv.danmaku.ijk.media.example.widget.media.IjkVideoView            android:id="@+id/video_view"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:layout_gravity="center"/>

Add some of the following initialization criteria to your Java code.

Videoview = (Ijkvideoview) Findviewbyid (R. ID. Videoview);Init Playerijkmediaplayer. Loadlibrariesonce(NULL);Ijkmediaplayer. Native_profilebegin ("Libijkplayer.so");Videoview. Setvideouri(Uri. Parse(Murl));Videoview. Setonpreparedlistener(New Imediaplayer. Onpreparedlistener() {@Override public void onprepared (Imediaplayer MP) {Videoview. Start();}});

The first time to get blog update reminders, as well as more Android dry, source code Analysis , Welcome to follow my public number, sweep the bottom QR code or long press to identify two-dimensional code, you can pay attention to.

If you feel good, easy to praise, but also to the author's affirmation, can also share this public number to you more people, original not easy

Summary of Live Technology (II) Ijkplayer compilation to Android platform and Test decoding library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.