Ubuntu下编译支持RTSP流协议的ijkplayer
程序员文章站
2023-12-31 14:03:22
I. 前置条件A. Android SDK与NDKSDK:https://developer.android.com/studio#downloadsNDK:https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zipB. 编译环境sudo apt-get install yasm gitC. 代码下载git clone https://github.com/Bilibili/ijk...
I. 前置条件
A. Android SDK与NDK
SDK:
https://developer.android.com/studio#downloads
NDK:
https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip
B. 编译环境
sudo apt-get install yasm git
C. 代码下载
git clone https://github.com/Bilibili/ijkplayer.git
注意:截至目前,master分支的ijkplayer仅支持最新到r14的Android NDK,更新的则无法识别;
这里有一份从官网下载的R14 NDK,需要的自取:百度网盘 提取码:vtfs
II. 编译步骤
A. 解压Android SDK/NDK,并将其路径添加至环境变量
假设我的Android SDK与NDK分别存放在~/dev_tools/android-sdk/与~/dev_tools/android-ndk-r14b/,那么在终端中执行如下指令:
export ANDROID_SDK=~/dev_tools/android-sdk/
export ANDROID_NDK=~/dev_tools/android-ndk-r14b/
B. 修改编译选项,增加对RTSP的支持
配置文件在config/module.sh中(默认软连接到module-lite.sh)
在文件末尾添加如下配置:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-protocol=rtp"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-demuxer=rtsp"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-decoder=mjpeg"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-demuxer=mjpeg"
C. 编译ffmpeg
在ijkplayer git库根目录依次执行如下指令:
./init-android.sh
cd android/contrib/
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all
D. 编译ijkplayer
cd ../
./compile-ijk.sh all
至此,ijkplayer的so库已经编译完成了,存放在ijkplayer/ijkplayer-*/src/main/libs/下,*表示编译时选择的架构,我们选择的时all,所以有如下这么几个:
$ ls ijkplayer/*/src/main/libs
ijkplayer/ijkplayer-arm64/src/main/libs:
arm64-v8a
ijkplayer/ijkplayer-armv5/src/main/libs:
armeabi
ijkplayer/ijkplayer-armv7a/src/main/libs:
armeabi-v7a
ijkplayer/ijkplayer-x86_64/src/main/libs:
x86_64
ijkplayer/ijkplayer-x86/src/main/libs:
x86
分散在这几个目录下,要用的时候还是略微优点麻烦,因此shell指令将so库拷贝到同一目录下,方便移植;
E. 批量拷贝到统一目录:
mkdir output
for dir in `find ijkplayer/ -name 'libs' `;do cp $dir/* -rf output/;done
然后直接查看output这个目录下的内容即可:
$ ls output/*
output/arm64-v8a:
libijkffmpeg.so libijkplayer.so libijksdl.so
output/armeabi:
libijkffmpeg.so libijkplayer.so libijksdl.so
output/armeabi-v7a:
libijkffmpeg.so libijkplayer.so libijksdl.so
output/x86:
libijkffmpeg.so libijkplayer.so libijksdl.so
output/x86_64:
libijkffmpeg.so libijkplayer.so libijksdl.so
本文地址:https://blog.csdn.net/u014175785/article/details/107121739