Kepler for Android: corresponding source for FFmpeg
====================================================

Kepler for Android (com.keplerplayer.app) decodes some audio formats (AC-3, E-AC-3, DTS, TrueHD,
MPEG audio and others) with FFmpeg, through the FFmpeg decoder extension of Google's Media3
library. FFmpeg is licensed under the GNU Lesser General Public License, version 2.1 or later.
This archive is the complete corresponding source for the FFmpeg code in the app, and everything
needed to rebuild it.

Applies to: Kepler for Android, version 1.0 (version code 4) and later builds, until this page
names a newer FFmpeg.


What is in this archive
-----------------------

ffmpeg/
    FFmpeg 6.0.2, release/6.0 branch at commit b4a62c32549b8295691a8e0ff2c9b82188923159,
    unmodified. Upstream: https://git.ffmpeg.org/ffmpeg.git
    Licence: ffmpeg/COPYING.LGPLv2.1 (see ffmpeg/LICENSE.md).

media3/libraries/decoder_ffmpeg/
    Media3 1.10.1's FFmpeg decoder extension, unmodified: the Java classes, the JNI glue
    (src/main/jni/ffmpeg_jni.cc), CMakeLists.txt and build_ffmpeg.sh, which runs FFmpeg's
    configure. Upstream: https://github.com/androidx/media, tag 1.10.1.
    Licence: Apache License 2.0 (media3/LICENSE).

build_media3_ffmpeg.sh
    The script Kepler's own build uses to produce the extension: it fetches the two trees above,
    configures FFmpeg and builds the Android library. It names every pin below.


How the app's library was built
-------------------------------

FFmpeg is compiled as static libraries and linked into libffmpegJNI.so, a separate shared
library inside the app (lib/<abi>/libffmpegJNI.so in the APK), which the app loads at run time.

    Android NDK r26b (26.1.10909125), API level 24, ABIs armeabi-v7a, arm64-v8a, x86, x86_64.

    configure options (from media3/.../jni/build_ffmpeg.sh), for every ABI:
        --target-os=android --enable-static --disable-shared --disable-doc --disable-programs
        --disable-everything --disable-avdevice --disable-avformat --disable-swscale
        --disable-postproc --disable-avfilter --disable-symver --enable-swresample
        --extra-ldexeflags=-pie --disable-v4l2-m2m --disable-vulkan
        plus the per-ABI --arch, --cpu and toolchain options in build_ffmpeg.sh.

    Enabled decoders:
        vorbis opus flac alac pcm_mulaw pcm_alaw mp3 amrnb amrwb aac ac3 eac3 dca mlp truehd

    FFmpeg was configured without --enable-gpl and without --enable-nonfree; its own config.h
    reports: FFMPEG_LICENSE "LGPL version 2.1 or later".


Rebuilding it
-------------

1. Install the Android SDK and NDK r26b, and a JDK 17 or 21.
2. Run:  ./build_media3_ffmpeg.sh /path/to/a/work/dir
   (it clones the same two trees; to build from this archive instead, put ffmpeg/ at
   media3/libraries/decoder_ffmpeg/src/main/jni/ffmpeg inside a Media3 1.10.1 checkout and run
   jni/build_ffmpeg.sh, then ./gradlew :lib-decoder-ffmpeg:assembleRelease from Media3's root.)
3. The library is in the AAR it produces, at jni/<abi>/libffmpegJNI.so.


Questions
---------

contact@keplerplayer.com
https://keplerplayer.com/opensource
