Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Simple Analysis of Ijkplayer

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

1. Get the code:

Git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android

Cd ijkplayer-android

Git checkout-B latest k0.8.8

2. Before Build:

# install homebrew, git, yasm

Ruby-e "$(curl-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Brew install git

Brew install yasm# add these lines to your / .bash_profile or ~ / .profile

# export ANDROID_SDK=

# export ANDROID_NDK=

# on Cygwin (unmaintained)

# install git, make, yasm

3. Get dependent open source libraries

. / init-android.sh

Get FFmpeg different armabi libraries

Get the libyuv and libtouchsound lib libraries:

Introduction to several open source libraries:

1. Jni4android is a jni generation tool, which can automatically generate * .c files and * .h header files for the corresponding jni layer according to the java class provided.

2. SoundTouch is an open source audio library with the following features:

Variable speed constant tone (TSM,Time Scale Modification), change the audio playback speed (fast or slow) without affecting the audio tone (Pitch).

Variable tone and constant speed Pitch Shifting, change the audio tone while keeping the audio playback speed unchanged

Change the tone and speed of the audio at the same time

3. Libyuv is Google's open source library that converts, rotates and scales all kinds of YUV and RGB. It is cross-platform, can be compiled and run on Windows, Linux, Mac, Android and x86, x64, arm architecture, and supports acceleration of SIMD instructions such as SSE, AVX, NEON, etc.

4. Compile the Android FFmpeg library:

Cd android/contrib./compile-ffmpeg.sh clean./compile-ffmpeg.sh all

FFmpeg Git Warehouse:

Ffmpeg libraries corresponding to different armabi:

FFmpeg compilation script:

Compile target files such as libavfiter:

5. Compile ijk:

Cd... / compile-ijk.sh all

Compile the JNI folder in the ijkplayer directory through NDK

Package to generate so such as ijkffmpeg.

Compile ijkplayer

6. Import AS (3.2):

File- > Open, click to select android- > ijkplayer

AS configuration considerations:

1. Switch the Gradle version. Manually download the gradle version such as gradle-4.6-all.zip and put it in the gradle file.

2. Jcenter download timeout, replace it with aliyun.

two。 Ijk Code Analysis:

In addition to providing ijkPlayer API, IjkPlayer also provides Android's native MediaPlayer and google's own exoPlayer API. IjkPlayer in VideoView through Player factory mode Create

The overall architecture of IjkDemo:

Demo is not drawn with sdl. For more information on android, please see:

Https://github.com/wanliyang1990/SDL2ForAndroid

Ijkplayer playback sequence diagram:

. / android/ijkplayer_jni.c

IjkMediaPlayer_native_setup

Ijkplayer_android.c

Ijkmp_android_create

Ffpipeline_android.c

Ffpipeline_create_from_android

Basic block diagram of the player:

The main code call process in ffplay.c is shown in the following figure:

1. Data reading

Stream_open mainly does the following things:

Create a videoq/audioq that stores data before video/audio decoding

Create a pictq/sampq to store video/audio decoded data

Create a read data thread read_thread

Create a video rendering thread video_refresh_thread

two。 Audio and video decoding:

Selection of video decoding mode

If ffp- > mediacodec is configured, it will give priority to try to open the hardware × ×. If hardware decoding is not supported, the soft solution will be switched.

Video_thread/audio_thread .

3. Audio and video rendering

Initialize player and build vout object: ijksdl-> S4a

Mp- > ffplayer- > vout = SDL_VoutAndroid_CreateForAndroidSurface ()

Call SDL_VoutDisplayYUVOverlay for drawing

SDL_VoutDisplayYUVOverlay (ffp- > vout, vp- > bmp)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report