Skip to content

Instantly share code, notes, and snippets.

@quink-black
Created February 4, 2021 17:26
Show Gist options
  • Save quink-black/59b244b0f6828c7c597f44c98ca903ae to your computer and use it in GitHub Desktop.
Save quink-black/59b244b0f6828c7c597f44c98ca903ae to your computer and use it in GitHub Desktop.
How to build VLC on Android

How to build VLC on Android

  • This is an introduction about build VLC on Android natively, not cross build VLC for Android
  • It's pretty useless, just for fun.

Prepare

  1. Install termux from F-Droid or Google play on Android device

Termux is an Android terminal emulator and Linux environment app that works directly with no rooting or setup required. A minimal base system is installed automatically - additional packages are available using the APT package manager.

https://termux.com/

  1. Setup remote login

    https://wiki.termux.com/wiki/Remote_Access

    This is not necessary if you can connect a monitor and keyboard to your Android device.

  2. Install the required package and tools to download and build VLC. The following is an incomplete list of package what I installed:

    cmake clang lldb vim tmux bash-completion make man ninja htop tree ctags mediainfo ffmpeg libx264 libx265 pkg-config flex bison libtool gettext autoconf automake m4 ndk-sysroot ndk-multilib
    

Build

  1. Get the source code from https://code.videolan.org/ or https://github.com/videolan/vlc.git

    git clone https://github.com/videolan/vlc.git
  2. Since there is no JVM environment, some code doesn't work as expected. Patch the source code

    diff --git a/src/android/specific.c b/src/android/specific.c
    index 1b74f522a3..d83b193b02 100644
    --- a/src/android/specific.c
    +++ b/src/android/specific.c
    @@ -172,7 +172,7 @@ void
     system_Configure(libvlc_int_t *p_libvlc, int i_argc, const char *const pp_argv[])
     {
         (void)i_argc; (void)pp_argv;
    -    assert(s_jvm != NULL);
    +    //assert(s_jvm != NULL);
         var_Create(p_libvlc, "android-jvm", VLC_VAR_ADDRESS);
         var_SetAddress(p_libvlc, "android-jvm", s_jvm);
     }
  3. Run bootstrap and configure

    This is the configure options what I used

    CC=clang \
        CXX=clang++ \
        BUILDCC=clang \
        EGL_LIBS="-L/system/lib64 -lEGL" \
        GLES2_LIBS="-L/system/lib64 -lGLESv2" \
        ac_cv_header_sys_shm_h=no \
    ../configure --enable-debug \
        --disable-lua \
        --disable-a52 \
        --disable-alsa \
        --disable-qt \
        --disable-v4l2 \
        --prefix=$HOME/local \
        --disable-xcb # --enable-xcb if you want x11 output
  4. Then run make. That's all! After build success, you can run VLC on command line to playback.

Note

Audio output

AudioTrack doesn't work. OpenSLES works out of box. So there is no problem to get audio output.

Video output

The standard Android video output doesn't work since there is no SurfaceView. You can get X11 output, but don't expect good performance.

  1. Install X11 libs in termux. I can't figure out a minimum package list, so just install openbox and all of the dependencies.

    apt-get install libx11-static xorgproto libxrandr openbox
  2. Install the XServer XSDL app via Google play

  3. --enable-xcb and rebuild VLC

  4. open XServer XSDL

  5. export DISPLAY=:0 in termux and run VLC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment