Optimize ffmpeg build scripts

master
Kemp Xu 3 years ago
parent aa3e7db12f
commit 75efdbaea1
  1. 1
      .gitignore
  2. 30
      build_ffmpeg.sh
  3. 7
      copy_ffmpeg_so.sh

1
.gitignore vendored

@ -8,3 +8,4 @@
.externalNativeBuild .externalNativeBuild
.cxx .cxx
/ffmpeg /ffmpeg
/ffmpeg-libs

@ -14,13 +14,19 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
FFMPEG_PATH=./ffmpeg
FFMPEG_LIB_PATH="$(pwd)/ffmpeg-libs"
FFMPEG_PATH=. USER_HOME=$(eval echo ~$user)
NDK_PATH=/Users/xch/Library/Android/sdk/ndk/21.0.5935234 NDK_PATH="$USER_HOME/Library/Android/sdk/ndk/21.0.6113669"
HOST_PLATFORM="darwin-x86_64" HOST_PLATFORM="darwin-x86_64"
TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin" TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
GCC_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc" GCC_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/lib/gcc"
git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg
cd ${FFMPEG_PATH}
git checkout release/4.2
ENABLED_ENCODERS=(png) ENABLED_ENCODERS=(png)
ENABLED_DECODERS=(h264 png) ENABLED_DECODERS=(h264 png)
ENABLED_MUXERS=(h264 mp4 matroska image2) ENABLED_MUXERS=(h264 mp4 matroska image2)
@ -80,14 +86,10 @@ COMMON_MERGE_OPTIONS="
-lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker -lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker
" "
cd "${FFMPEG_PATH}"
# (git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg)
cd ffmpeg
git checkout release/4.2
# armeabi-v7a # armeabi-v7a
SYSROOT="${NDK_PATH}/platforms/android-16/arch-arm" SYSROOT="${NDK_PATH}/platforms/android-16/arch-arm"
PREFIX="android-libs/armeabi-v7a" PREFIX="${FFMPEG_LIB_PATH}/armeabi-v7a"
./configure \ ./configure \
--prefix=$PREFIX \ --prefix=$PREFIX \
--arch=arm \ --arch=arm \
@ -114,7 +116,7 @@ make clean
# arm64-v8a # arm64-v8a
SYSROOT="${NDK_PATH}/platforms/android-21/arch-arm64" SYSROOT="${NDK_PATH}/platforms/android-21/arch-arm64"
PREFIX="android-libs/arm64-v8a" PREFIX="${FFMPEG_LIB_PATH}/arm64-v8a"
./configure \ ./configure \
--prefix=$PREFIX \ --prefix=$PREFIX \
--arch=aarch64 \ --arch=aarch64 \
@ -139,7 +141,7 @@ make clean
# x86 # x86
SYSROOT="${NDK_PATH}/platforms/android-16/arch-x86" SYSROOT="${NDK_PATH}/platforms/android-16/arch-x86"
PREFIX="android-libs/x86" PREFIX="${FFMPEG_LIB_PATH}/x86"
./configure \ ./configure \
--prefix=$PREFIX \ --prefix=$PREFIX \
--arch=x86 \ --arch=x86 \
@ -162,3 +164,11 @@ ${TOOLCHAIN_PREFIX}/i686-linux-android-ld \
${GCC_PREFIX}/i686-linux-android/4.9.x/libgcc_real.a ${GCC_PREFIX}/i686-linux-android/4.9.x/libgcc_real.a
${TOOLCHAIN_PREFIX}/i686-linux-android-strip $PREFIX/libffmpeg.so ${TOOLCHAIN_PREFIX}/i686-linux-android-strip $PREFIX/libffmpeg.so
make clean make clean
# Copy libffmpeg.so to library/libs
echo "Start copy"
LIBRARY_LIBS_PATH=../library/libs
cp ${FFMPEG_LIB_PATH}/arm64-v8a/libffmpeg.so ${LIBRARY_LIBS_PATH}/arm64-v8a/libffmpeg.so
cp ${FFMPEG_LIB_PATH}/armeabi-v7a/libffmpeg.so ${LIBRARY_LIBS_PATH}/armeabi-v7a/libffmpeg.so
cp ${FFMPEG_LIB_PATH}/x86/libffmpeg.so ${LIBRARY_LIBS_PATH}/x86/libffmpeg.so
echo "End copy"

@ -1,7 +0,0 @@
#!/bin/bash
FFMPEG_PATH=./ffmpeg
cp ${FFMPEG_PATH}/android-libs/arm64-v8a/libffmpeg.so ./library/libs/arm64-v8a/libffmpeg.so
cp ${FFMPEG_PATH}/android-libs/armeabi-v7a/libffmpeg.so ./library/libs/armeabi-v7a/libffmpeg.so
cp ${FFMPEG_PATH}/android-libs/x86/libffmpeg.so ./library/libs/x86/libffmpeg.so
Loading…
Cancel
Save