ubuntu 編譯ffmpeg 小記
阿新 • • 發佈:2021-07-08
使用ndk 14 和ffmpeg 3.3.9
https://developer.android.google.cn/ndk/downloads/older_releases
http://ffmpeg.org/olddownload.html
1.修改configure
# SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)' # LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' # SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)' # SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)' # # 將上面四個變數的值改成如下: SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' LIB_INSTALL_EXTRA_CMD='$$(RANLIB)"$(LIBDIR)/$(LIBNAME)"' SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' SLIB_INSTALL_LINKS='$(SLIBNAME)'
2.編寫編譯用的sh檔案,名字隨便,在ffmpeg目錄下
linux是linux-x86_64,蘋果的是darwin-x86_64
#!/bin/bash # ndk環境 export NDK=/home/ma/sss/NDK/android-ndk-r14b export SYSROOT=$NDK/platforms/android-21/arch-arm export TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 CPU=armv7-a # 要儲存動態庫的目錄,這裡儲存在原始碼根目錄下的android/armv7-a export PREFIX=$(pwd)/android/$CPU ADDI_CFLAGS="-marm" function build_android { echo"開始編譯ffmpeg" ./configure \ --target-os=linux \ --prefix=$PREFIX \ --enable-cross-compile \ --enable-shared \ --disable-static \ --disable-doc \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-avdevice \ --disable-doc \ --disable-symver \ --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \ --arch=arm \ --sysroot=$SYSROOT \ --extra-cflags="-Os -fpic $ADDI_CFLAGS" \ --extra-ldflags="$ADDI_LDFLAGS" \ $ADDITIONAL_CONFIGURE_FLAG make clean make -j16 make install echo "編譯結束!" } build_android