VLC的全名是Video Lan Client,是一个开源的、跨平台的视频播放器。VLC支持大量的音视频传输、封装和编码格式。最近要做流媒体平台,需要深入研究VLC。由于比较熟悉android开发,所以先从VLC for Android的编译出AAR文件开始。
参考的文章:
官方编译文档(https://wiki.videolan.org/AndroidCompile/)
VLC for Android编译出AAR文件(最新vlc代码)(https://blog.csdn.net/u010735007/article/details/108141213)
基于libvlc aar的android播放器实例(https://blog.csdn.net/u010735007/article/details/108168267)
基于libvlc aar的android播放器(点播与本地播放)(https://blog.csdn.net/u010735007/article/details/108424493)
基于libvlc aar的android截屏和录制视频功能(https://blog.csdn.net/u010735007/article/details/108517985)
android,ios,linux多平台libvlc api文档说明笔记(不断更新)(https://blog.csdn.net/u010735007/article/details/108198711)
VLC-3.0全部详细参数(https://blog.csdn.net/avsuper/article/details/80145439)
1.编译环境
(1)编译系统:Ubuntu18.04 Ubuntu20.04(CPU:2核,4G内存,60G硬盘,阿里云香港节点)
(2)Android SDK:android-sdk_r24.4.1-linux 下载地址:http://tools.android-studio.org/index.php/sdk/
(3)Android NDK:android-ndk-r18b-linux-x86_64 android-ndk-r21b-linux-x86_64 下载地址:https://developer.android.google.cn/ndk/downloads/older_releases
(4)JDK:jdk-8u261-linux-x64 下载地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
备注:用香港节点是因为VLC的源代码和中间编译使用的插件都在国外,速度很慢,会下载不成功导致编译失败。而使用r18版本的ndk,是因为最新的vlc代码编译出现问题,把vlc源代码低版本而使用低版本的ndk,后面会提到 用Ubuntu20.04能编译出最新版本的vlc。
2.编译过程
(1)下载必要的软件包,如果不成功先apt-get update
sudo apt-get install automake ant autopoint cmake build-essential libtool-bin \
patch pkg-config protobuf-compiler ragel subversion unzip git \
openjdk-8-jre openjdk-8-jdk flex python wget vim
(2)配置Android ndk,Android sdk,JDK
修改配置文件
vim /etc/profile
把下面配置信息放到profile文件里面,/var/www/bak/backup是我存放这几个平台的路径
export ANDROID_SDK=/var/www/bak/backup/android-sdk-linux
export ANDROID_NDK=/var/www/bak/backup/android-ndk-r21b
export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools
export JAVA_HOME=/var/www/bak/backup/jdk1.8.0_261
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
最后执行
source /etc/profile
(3)下载代码并编译
下载代码
git clone https://code.videolan.org/videolan/vlc-android.git
由于最新代码我尝试过编译不过,出现error: possibly undefined macro: AM_PROG_LIBTOOL,因此我暂时降VLC源代码的版本去编译,最后稳定的版本是3.2.12
切换成3.2.12,命令:git checkout 3.2.12
cd vlc-android
编译,需要经过漫长的等待
sh buildsystem/compile.sh
出现下面提示,编译完成
BUILD SUCCESSFUL in 4m 13s
141 actionable tasks: 141 executed
编译完成后,使用下面命令,又需要经过漫长的等待,编译出aar文件
sh buildsystem/compile.sh -l -a all -r
cd libvlc/build/outputs/aar
出现libvlc-all-3.2.6.aar libvlc-all-3.3.0-eap17.aar文件,不过有点大,70多M,下一步就是在基于libvlc arr制作自己的android流媒体播放器
编译过程中的错误解决
(1)编译过程中出现补丁打不上错误
NOTE: checks can be bypass by adding '-b' option to this script.
Checking presence of patch ../libvlc/patches/vlc3/0001-compat-Workaround-sendmsg-bug-on-android.patch
Cannot find patch ../libvlc/patches/vlc3/0001-compat-Workaround-sendmsg-bug-on-android.patch in tree, aborting.
There can be two reasons for that:
- you forgot to apply the patch on this tree, or
- you applied the patch without the 'git am --message-id ...' option.
执行下面命令,即可
sh buildsystem/compile.sh -b
(2)出现下面git错
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address
执行下面命令,即可
git config --global user.email 你的邮箱
git config --global user.name 你的名字
(3)出现bison错误
lib/fseterr.c:77:3: error: #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
77 | #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
| ^~~~~
更新一下bison即可
apt-get install bison
如有用到此功能的朋友,可以留言交流和点赞