
It's currently difficult to use ExoPlayer modules in other gradle projects because they rely on constants and dependencies defined in our own top level gradle file. This change moves the constants into a separate file referenced directly from each module. It also removes the need for the top level gradle file to declare a dependency on com.novoda:bintray-release. This is now only needed if "exoplayerPublishEnabled = true" is specified. Issue: #2851 Issue: #2974 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160272072
FfmpegAudioRenderer
Description
The FFmpeg extension is a Renderer implementation that uses FFmpeg to decode audio.
Build instructions
- Checkout ExoPlayer along with Extensions
git clone https://github.com/google/ExoPlayer.git
- Set the following environment variables:
cd "<path to exoplayer checkout>"
EXOPLAYER_ROOT="$(pwd)"
FFMPEG_EXT_PATH="${EXOPLAYER_ROOT}/extensions/ffmpeg/src/main"
- Download the Android NDK and set its location in an environment variable:
NDK_PATH="<path to Android NDK>"
- Set up host platform ("darwin-x86_64" for Mac OS X):
HOST_PLATFORM="linux-x86_64"
- Fetch and build FFmpeg. For example, to fetch and build for armeabi-v7a, arm64-v8a and x86 on Linux x86_64:
COMMON_OPTIONS="\
--target-os=android \
--disable-static \
--enable-shared \
--disable-doc \
--disable-programs \
--disable-everything \
--disable-avdevice \
--disable-avformat \
--disable-swscale \
--disable-postproc \
--disable-avfilter \
--disable-symver \
--disable-swresample \
--enable-avresample \
--enable-decoder=vorbis \
--enable-decoder=opus \
--enable-decoder=flac \
" && \
cd "${FFMPEG_EXT_PATH}/jni" && \
git clone git://source.ffmpeg.org/ffmpeg ffmpeg && cd ffmpeg && \
./configure \
--libdir=android-libs/armeabi-v7a \
--arch=arm \
--cpu=armv7-a \
--cross-prefix="${NDK_PATH}/toolchains/arm-linux-androideabi-4.9/prebuilt/${HOST_PLATFORM}/bin/arm-linux-androideabi-" \
--sysroot="${NDK_PATH}/platforms/android-9/arch-arm/" \
--extra-cflags="-march=armv7-a -mfloat-abi=softfp" \
--extra-ldflags="-Wl,--fix-cortex-a8" \
--extra-ldexeflags=-pie \
${COMMON_OPTIONS} \
&& \
make -j4 && make install-libs && \
make clean && ./configure \
--libdir=android-libs/arm64-v8a \
--arch=aarch64 \
--cpu=armv8-a \
--cross-prefix="${NDK_PATH}/toolchains/aarch64-linux-android-4.9/prebuilt/${HOST_PLATFORM}/bin/aarch64-linux-android-" \
--sysroot="${NDK_PATH}/platforms/android-21/arch-arm64/" \
--extra-ldexeflags=-pie \
${COMMON_OPTIONS} \
&& \
make -j4 && make install-libs && \
make clean && ./configure \
--libdir=android-libs/x86 \
--arch=x86 \
--cpu=i686 \
--cross-prefix="${NDK_PATH}/toolchains/x86-4.9/prebuilt/${HOST_PLATFORM}/bin/i686-linux-android-" \
--sysroot="${NDK_PATH}/platforms/android-9/arch-x86/" \
--extra-ldexeflags=-pie \
--disable-asm \
${COMMON_OPTIONS} \
&& \
make -j4 && make install-libs && \
make clean
- Build the JNI native libraries, setting
APP_ABI
to include the architectures built in the previous step. For example:
cd "${FFMPEG_EXT_PATH}"/jni && \
${NDK_PATH}/ndk-build APP_ABI="armeabi-v7a arm64-v8a x86" -j4
- In your project, you can add a dependency on the extension by using a rule like this:
// in settings.gradle
include ':..:ExoPlayer:library'
include ':..:ExoPlayer:extension-ffmpeg'
// in build.gradle
dependencies {
compile project(':..:ExoPlayer:library')
compile project(':..:ExoPlayer:extension-ffmpeg')
}
- Now, when you build your app, the extension will be built and the native libraries will be packaged along with the APK.