ffmpeg 编译安装android和linux
下载:https://github.com/FFmpeg/FFmpeg
https://www.ffmpeg.org/download.html
envirenment
ndk: https://github.com/android/ndk/wiki/Unsupported-Downloads
sudo apt-get install build-essential pkg-config
sudo apt-get intall libx264-dev libspeex-dev libfdk-aac-dev
编译安装脚本
#!/bin/bash
# 清空上次的编译
make clean
#你自己的NDK路径.
#export NDK=/home/anjoiner/Android/Sdk/ndk-bundle
#export NDK=/home/light/Android/Sdk/ndk/25.1.8937393
export NDK=/mnt/light-link/DevTools/android-ndk-r21d
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/
API=30
function build_android
{
echo "Compiling FFmpeg for $CPU"
./configure \
--prefix=$PREFIX \
--enable-neon \
--enable-hwaccels \
--enable-gpl \
--enable-postproc \
--enable-shared \
--enable-jni \
--enable-mediacodec \
--enable-decoder=h264_mediacodec \
--disable-static \
--disable-doc \
--enable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--enable-avdevice \
--disable-doc \
--disable-symver \
--cross-prefix=$CROSS_PREFIX \
--target-os=android \
--arch=$ARCH \
--cpu=$CPU \
--cc=$CC
--cxx=$CXX
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $OPTIMIZE_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make -j20
make install
echo "The Compilation of FFmpeg for $CPU is completed"
}
export target_arch=$1
if [ "${target_arch}" = "" ]; then
target_arch=armv8a
fi;
echo ${target_arch}
if [ "${target_arch}" = "armv8a" ]; then
echo ${target_arch} is armv8a
#armv8-a
ARCH=arm64
CPU=armv8-a
CC=$TOOLCHAIN/bin/aarch64-linux-android$API-clang
CXX=$TOOLCHAIN/bin/aarch64-linux-android$API-clang++
SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
CROSS_PREFIX=$TOOLCHAIN/bin/aarch64-linux-android-
PREFIX=$(pwd)/build/$CPU
OPTIMIZE_CFLAGS="-march=$CPU"
build_android
elif [ ${target_arch} = "armv7a" ]; then
echo ${target_arch} is armv7a
#armv7-a
ARCH=arm
CPU=armv7-a
CC=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang
CXX=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang++
SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
CROSS_PREFIX=$TOOLCHAIN/bin/arm-linux-androideabi-
PREFIX=$(pwd)/build/$CPU
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
build_android
elif [ ${target_arch} = "x86" ]; then
echo ${target_arch} is x86
#x86
ARCH=x86
CPU=x86
CC=$TOOLCHAIN/bin/i686-linux-android$API-clang
CXX=$TOOLCHAIN/bin/i686-linux-android$API-clang++
SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
CROSS_PREFIX=$TOOLCHAIN/bin/i686-linux-android-
PREFIX=$(pwd)/build/$CPU
OPTIMIZE_CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32"
build_android
else
echo ${target_arch} is default x86_64
#x86_64
ARCH=x86_64
CPU=x86-64
CC=$TOOLCHAIN/bin/x86_64-linux-android$API-clang
CXX=$TOOLCHAIN/bin/x86_64-linux-android$API-clang++
SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
CROSS_PREFIX=$TOOLCHAIN/bin/x86_64-linux-android-
PREFIX=$(pwd)/build/$CPU
OPTIMIZE_CFLAGS="-march=$CPU -msse4.2 -mpopcnt -m64 -mtune=intel"
build_android
fi;
标签:bin,ffmpeg,--,linux,android,CPU,x86
From: https://www.cnblogs.com/minding/p/17589386.html