ExoPlayer+FFMpeg软解
概述
ExoPlayer是Google开源的Android平台媒体播放器。 它是Android的MediaPlayer API的替代品。
相⽐于IJKPlayer,EXOPlayer更易于拓展,功能更多,bug更少。ExoPlayer虽然不⽀持软解但是为开发者扩展软解预留了接⼝。⽹上竟然搜不到ExoPlayer+软解的扩展实现,那就有必要来⼀篇了hhh。
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 \
-
-enable-decoder=alac \
--enable-decoder=pcm_mulaw \
--enable-decoder=pcm_alaw \
--enable-decoder=mp3 \
--enable-decoder=amrnb \
--enable-decoder=amrwb \
--enable-decoder=aac \
--enable-decoder=ac3 \
--enable-decoder=eac3 \
decoder--enable-decoder=dca \
--enable-decoder=mlp \
-
-enable-decoder=truehd \
4.根据要编译的架构编写编译脚本
ANDROID_NDK=/Users/hawkswang/ndk/android-ndk-r15c
HOST_PLATFORM=darwin-x86_64
./configure \
--libdir=android-libs/armeabi-v7a \
--arch=arm \
--cpu=armv7-a \
--cross-prefix="${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/${HOST_PLATFORM}/bin/arm-linux-androideabi-" \
--sysroot="${ANDROID_NDK}/platforms/android-9/arch-arm/" \
--extra-cflags="-march=armv7-a -mfloat-abi=softfp" \
--extra-ldflags="-Wl,--fix-cortex-a8" \
--extra-ldexeflags=-pie \
${COMMON_OPTIONS} \
5.开始编译
make -j4 && make install-libs
6.编写JNI(如果想要扩展更多功能的话)
7.交叉编译JNI接⼝
在⽬录下ExoPlayer/extensions/ffmpeg/src/main/jni
执⾏
ANDROID_NDK=/Users/hawkswang/ndk/android-ndk-r15c
HOST_PLATFORM=darwin-x86_64
${ANDROID_NDK}/ndk-build APP_ABI="armeabi armeabi-v7a arm64-v8a" -j4
下⾯是把第1~5部整合到⼀块的脚本;
#!/bin/bash
ANDROID_NDK=/Users/hawkswang/ndk/android-ndk-r15c
HOST_PLATFORM=darwin-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 \
--enable-decoder=alac \
--enable-decoder=pcm_mulaw \
--enable-decoder=pcm_alaw \
--enable-decoder=mp3 \
--enable-decoder=amrnb \
--enable-decoder=amrwb \
--enable-decoder=aac \
--enable-decoder=ac3 \
--enable-decoder=eac3 \
--enable-decoder=dca \
-
-enable-decoder=mlp \
--enable-decoder=truehd \
"&& \
#(git -C ffmpeg pull || git clone /ffmpeg.git ffmpeg) && \
cd ffmpeg &&git checkout release/4.0 && \
./configure \
--libdir=android-libs/armeabi-v7a \
--arch=arm \
--cpu=armv7-a \
--cross-prefix="${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/${HOST_PLATFORM}/bin/arm-linux-androideabi-" \ --sysroot="${ANDROID_NDK}/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="${ANDROID_NDK}/toolchains/aarch64-linux-android-4.9/prebuilt/${HOST_PLATFOR
M}/bin/aarch64-linux-android-" \ --sysroot="${ANDROID_NDK}/platforms/android-21/arch-arm64/" \
--extra-ldexeflags=-pie \
${COMMON_OPTIONS} \
&& \
make -j4 &&make install-libs && \
make clean && ./configure \
--libdir=android-libs/armeabi \
--arch=arm \
--cpu=armv5 \
--cross-prefix="${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/${HOST_PLATFORM}/bin/arm-linux-androideabi-" \ --sysroot="${ANDROID_NDK}/platforms/android-9/arch-arm/" \
--extra-cflags="-march=armv5 -mfloat-abi=softfp" \
--extra-cflags="-march=armv5 -mfloat-abi=softfp" \ --extra-ldflags="-Wl,--fix-cortex-a8" \
--extra-ldexeflags=-pie \
${COMMON_OPTIONS} \
&& \
make -j4 &&make install-libs && \
make clean
echo"Success !"
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论