此片文章记录了怎么源码编译出vlcplayer aar。vlcplayer aar包可以集成到自己app包中,让自己app拥有播放视频的功能,源码编译vlc player 可以根据需要裁减功能,或直接修改vlc源码。
1编译要求
您必须在Linux(或者OSX,如果您知道自己在做什么的话)上进行构建。
必须安装以下软件包:
GNU自动工具:autoconf、libtool、automake和make(又称gmake和它们的依赖关系:m4和gawk,mawk或nawk,
GNU C和C++编译器又称为gcc和g++,
一些GNU构建实用程序:pkg配置和补丁,
以下其他构建实用程序:ApacheAnt(或Ant)、cmake、protobuf、ragel、,
Subversion和Git版本控制系统
解压缩和curl或wget用于检索源。
可能需要其中一些工具的最新版本。在编写时,特别需要gettext 0.19.3或更高版本。
如果缺少以上任何一项,预计构建会在某个时候失败。
如果目标是Android-x86设备,也必须安装yasm。
Ubuntu上按照以下步骤安装软件包:
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
编译32位需要安装:
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install zlib1g:i386 libstdc++6:i386 libc6:i386
2获取VLC源
从VLC git克隆源,拉取完源码以后千万不能更改源码所在路径,否则编译不过。
在你的android源文件夹中,运行: git clone https://code.videolan.org/videolan/vlc-android.git
3环境设置
Set $ANDROID_SDK to point to your Android SDK directory
export ANDROID_SDK=/path/to/android-sdk
Set $ANDROID_NDK to point to your Android NDK directory
export ANDROID_NDK=/path/to/android-ndk
Add some useful binaries to your $PATH
export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools
在buildsystem/compile.sh编译脚本中添加如下环境配置,主要配置SDK、NDK、Java8的路径。
export ANDROID_SDK=/media/trchen/Android/programs/Sdk
export ANDROID_NDK=/media/trchen/Android2/Programes/android-ndk-r21-linux/21.4.7075529
export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
4构建
在使用Android studio编译应用程序之前,必须运行compile.sh一次才能设置gradle构建系统。
它应该使用以下内容自动填充强制性的local.properties和gradle.properties文件:
local.properties(本地属性)
sdk.dir=< A N D R O I D s d k 的 s d k 路径 > n d k . d i r = < ANDROID_sdk的sdk路径> ndk.dir=< ANDROIDsdk的sdk路径>ndk.dir=<ANDROID_ndk的ndk路径>
这设置了gradle以使用正确的SDK/NDK进行构建。
一旦第一次编译成功,您就可以使用Run命令从Android Studio进行构建。
为了提高gradle的执行时间,请尝试在vlc-android项目的gradle.properties中编写这些选项。或者直接在~/.gradle/gradle.properties中
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048M
4.1构建apk
请先阅读compile.sh,因为它包含一些非常有用和重要的信息。然后运行它:
buildsystem/compile.sh-a<ABI>
sudo buildsystem/compile.sh -a armeabi-v7a
注意:此时,您将在vlc-android/build/outputs/APK文件夹中获得一个自动生成的调试APK,并用调试密钥签名。
为了构建非调试(发布和未签名)包:
buildsystem/compaile.sh版本
注意:此时,您将在同一文件夹中获得一个发布APK。
4.2构建LibVLC aar
要构建LibVLC,只需传递-l选项:
buildsystem/compile.sh-l-a<ABI>-r
编译命令如下:
sudo buildsystem/compile.sh -l -a armeabi-v7a -r
.aar档案将位于libvlc/build/outputs/aar中
4.3 vlcplayer 启用功能或直接修改vlc代码满足自己需求
构建成功后,修改vlc配置参数,启用特殊功能,在重新构建:
libvlcjni/buildsystem/compile-libvlc.sh
VLC_CONFIGURE_ARGS=--enable-a52 \--enable-x264 \
构建模块配置说明如下,比如支持v4l2输入,支持mp3编码等,需要启用配置
Input plugins:--enable-libproxy support libproxy (default auto)--enable-live555 enable RTSP input through live555 (default enabled)--enable-dc1394 IIDC FireWire input module [default=auto]--enable-dv1394 DV FireWire input module [default=auto]--enable-linsys Linux Linear Systems Ltd. SDI and HD-SDI input cards(default enabled)--enable-dvdread dvdread input module [default=auto]--disable-dvdnav disable DVD navigation with libdvdnav (default auto)--disable-dshow support DirectShow (default auto)--enable-bluray (libbluray for Blu-ray disc support ) [default=auto]--enable-opencv (OpenCV (computer vision) filter) [default=off]--disable-smb disable SMB/CIFS support (default auto)--enable-sftp support SFTP file transfer via libssh2 (defaultdisabled)--disable-v4l2 disable Video4Linux version 2 (default auto)--enable-pvr support PVR V4L2 cards (default disabled)--disable-decklink disable Blackmagic DeckLink SDI input (default auto)--with-decklink-sdk=DIR,location of Blackmagic DeckLink SDI SDK)--enable-gnomevfs GnomeVFS access module [default=auto]--enable-vcdx navigate VCD with libvcdinfo (default disabled)--disable-vcd disable built-in VCD and CD-DA support (defaultenabled)--disable-libcddb disable CDDB for Audio CD (default enabled)--enable-screen disable screen capture (default enabled)--enable-realrtsp Real RTSP module (default disabled)--enable-macosx-eyetv Mac OS X EyeTV (TNT Tuner) module (default enabled on Mac OS X)--enable-macosx-qtkit Mac OS X qtcapture (video) and qtsound (audio) module (default enabled on Mac OS X)
Mux/Demux plugins:--enable-dvbpsi build with dvbpsi support enabled [default=auto]--enable-gme use Game Music Emu (default auto)--enable-sid C64 sid demux support (default auto)--enable-ogg Ogg demux support [default=auto]--enable-mux_ogg Ogg mux support [default=auto]--enable-shout libshout output plugin [default=auto]--disable-mkv do not use libmatroska (default auto)--disable-mod do not use libmodplug (default auto)--disable-mpc do not use libmpcdec (default auto)Codec plugins:--enable-wma-fixed libwma-fixed module (default disabled)--enable-shine shine mp3 encoding module (default disabled)--enable-omxil openmax il codec module (default disabled)--enable-iomx iomx codec module (default disabled)--enable-crystalhd crystalhd codec plugin (default auto)--enable-mad libmad module (default enabled)--with-mad=PATH path to libmad--with-mad-tree=PATH mad tree for static linking--enable-merge-ffmpeg merge FFmpeg-based plugins (default disabled)--enable-avcodec libavcodec codec (default enabled)--enable-libva VAAPI GPU decoding support (libVA) (default auto)--enable-dxva2 DxVA2 GPU decoding support (default auto)--enable-switcher Stream-out switcher plugin (default disabled)--enable-avformat libavformat containers (default enabled)--enable-swscale libswscale image scaling and conversion (defaultenabled)--enable-postproc libpostproc image post-processing (default enabled)--enable-faad faad codec (default auto)--with-faad-tree=PATH faad tree for static linking--enable-twolame MPEG Audio Layer 2 encoder [default=auto]--enable-quicktime QuickTime module (deprecated)--enable-a52 A/52 support with liba52 (default enabled)--with-a52=PATH a52 headers and libraries--with-a52-tree=PATH a52dec tree for static linking--with-a52-fixed specify if liba52 has been compiled with fixed point support--enable-dca DTS Coherent Acoustics support with libdca[default=auto]--enable-flac libflac decoder/encoder support [default=auto]--enable-libmpeg2 libmpeg2 decoder support [default=auto]--enable-vorbis Vorbis decoder and encoder [default=auto]--enable-tremor Tremor decoder support (default disabled)--enable-speex Speex support [default=auto]--enable-theora experimental theora codec [default=auto]--enable-dirac dirac encoder [default=auto]--enable-schroedinger dirac decoder and encoder using schroedinger[default=auto]--enable-png PNG support (default enabled)--enable-x26410b H264 10-bit encoding support with static libx264 (default disabled)--with-x26410b-tree=PATH H264 10-bit encoding module with libx264 (static linking)--enable-x264 H264 encoding support with libx264 (default enabled)--with-x264-tree=PATH x264 tree for static linking--enable-fluidsynth MIDI synthetiser with libfluidsynth [default=auto]--enable-zvbi VBI (inc. Teletext) decoding support with libzvbi(default enabled)--enable-telx Teletext decoding module (conflicting with zvbi)(default enabled if zvbi is absent)--enable-libass Subtitle support using libass (default enabled)--enable-kate kate codec [default=auto]--enable-tiger Tiger rendering library for Kate streams (default auto)
模块配置参考: https://wiki.videolan.org/VLC_configure_help/
编译参考:https://wiki.videolan.org/AndroidCompile#Get_VLC_Source