ndk-r22编译ffmpeg4.4支持openssl,rtsp,x264
openssl脚本:#!/bin/bashAPI=21export ANDROID_NDK_HOME=/home/xxx/ndkCC=clangCPU=arm64PLATFORM=aarch64-linux-androidCPU_ARCH="arm64-v8a"echo "\n=============================================================
·
openssl脚本:
#!/bin/bash
API=21
export ANDROID_NDK_HOME=/home/xxx/ndk
CC=clang
CPU=arm64
PLATFORM=aarch64-linux-android
CPU_ARCH="arm64-v8a"
echo "\n======================================================================"
echo "[*] start compile openssl for android $CPU_ARCH ..."
echo "======================================================================\n"
echo "\n======================================================================"
echo "[*] make clean ..."
echo "======================================================================\n"
make clean
rm -rf $(pwd)/android/$CPU_ARCH
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
echo "\n======================================================================"
echo "[*] configure ..."
echo "======================================================================\n"
./Configure \
android-$CPU \
-D__ANDROID_API__=$API \
--prefix=$(pwd)/android/$CPU_ARCH \
--openssldir=$(pwd)/android/$CPU_ARCH \
no-shared no-ssl2 no-ssl3 no-comp no-hw no-engine
make
make install
x264脚本:
#!/bin/bash
export ANDROID_NDK_HOME=/home/xxx/ndk
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
NDK=/home/xxx/ndk
HOST_TAG=linux-x86_64
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
CPU=armv8-a
HOST=aarch64-linux-android
ANDROID_LIB_PATH="$(pwd)/android"
API=21
export CC=$TOOLCHAIN/bin/aarch64-linux-android$API-clang
export CXX=$TOOLCHAIN/bin/aarch64-linux-android$API-clang++
echo "build for android $CPU"
./configure \
--host=$HOST \
--disable-shared \
--enable-static \
--prefix="$ANDROID_LIB_PATH/$CPU" \
--enable-pic \
--enable-strip \
--extra-cflags="-fPIC"
make clean
make -j8
make install
#export AR=$TOOLCHAIN/bin/aarch64-linux-android-ar
#export AS=$TOOLCHAIN/bin/aarch64-linux-android-a
#export LD=$TOOLCHAIN/bin/aarch64-linux-android-ld
#export RANLIB=$TOOLCHAIN/bin/aarch64-linux-android-ranlib
#export STRIP=$TOOLCHAIN/bin/aarch64-linux-android-strip
ffmpeg脚本:
#!/bin/bash
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
NDK=/home/xxx/ndk
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/
API=21
#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)/android/$CPU
OPTIMIZE_CFLAGS="-march=$CPU"
#第三方库
OPENSSL_INCLUDE=/home/xxx/openssl/android/arm64-v8a/include
OPENSSL_LIB=/home/xxx/openssl/android/arm64-v8a/lib
X264_INCLUDE=/home/xxx/x264/android/armv8-a/include
X264_LIB=/home/xxx/x264/android/armv8-a/lib
echo "Compiling FFmpeg for $CPU"
./configure \
--prefix=$PREFIX \
--disable-neon \
--disable-hwaccels \
--disable-gpl \
--disable-postproc \
--enable-shared \
--enable-jni \
--disable-mediacodec \
--disable-decoder=h264_mediacodec \
--disable-decoder=hevc \
--disable-decoder=hevc_v4l2m2m \
--disable-encoder=hevc_v4l2m2m \
--disable-static \
--disable-doc \
--disable-symver \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-doc \
--disable-symver \
--extra-cflags="-I$X264_INCLUDE -I$OPENSSL_INCLUDE " \
--extra-ldflags="-L$OPENSSL_LIB -L$X264_LIB" \
--enable-nonfree \
--enable-gpl \
--enable-libx264 \
--enable-openssl \
--enable-protocols \
--enable-protocol=https \
--enable-protocol=http \
--enable-network \
--enable-demuxer=rtsp \
--enable-avresample \
--cross-prefix=$CROSS_PREFIX \
--target-os=android \
--arch=$ARCH \
--cpu=$CPU \
--cc=$CC \
--cxx=$CXX \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $OPTIMIZE_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
echo "The Compilation of FFmpeg for $CPU is completed"
编译好的ffmpeg文件(arm-v8a)放在:
https://gitee.com/ys1879615351/ndk22-ffmpeg
更多推荐
已为社区贡献1条内容
所有评论(0)