x264 、 faac、rtmpdump 静态库编译

1、下载 x264的源代码 (http://www.videolan.org/developers/x264.html)

git clone git://git.videolan.org/x264.git

2、编写编译脚本

NDK_ROOT=/root/android/android-ndk-r15b
SYSROOT=$NDK_ROOT/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
function build_one
{
    ./configure \
    --prefix=$PREFIX \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --sysroot=$SYSROOT \
    --host=arm-linux \
    --enable-pic \
    --enable-static \
    --disable-asm \
    --disable-shared \
    --disable-cli
    make clean
    make
    make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU  
build_one

3、编译

cd x264
chmod u+x build_android.sh
./build_android.sh

4、下载 faac 的源代码 (http://www.audiocoding.com/downloads.html)

wget https://nchc.dl.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz

5、编写编译脚本

#!/bash/bin

CPU=arm
NDK_ROOT=/root/android/android-ndk-r15b
export PLATFORM=$NDK_ROOT/platforms/android-9/arch-arm 
export PREBUILT=$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
export PREFIX="$(pwd)/android/arm"
export CROSS_COMPILE=$PREBUILT/arm-linux-androideabi-

export CFLAGS="-DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300"

export CPPFLAGS="$CFLAGS"
export CFLAGS="$CFLAGS"
export CXXFLAGS="$CFLAGS"
export CXX="${CROSS_COMPILE}g++ --sysroot=${PLATFORM}"
export LDFLAGS="$LDFLAGS"
export CC="${CROSS_COMPILE}gcc --sysroot=${PLATFORM}"
export NM="${CROSS_COMPILE}nm"
export STRIP="${CROSS_COMPILE}strip"
export RANLIB="${CROSS_COMPILE}ranlib"
export AR="${CROSS_COMPILE}ar"

./configure --program-prefix=$PREFIX --without-mp4v2 --host=arm-linux
mkdir -p $PREFIX/lib
cp ./libfaac/.libs/*.a $PREFIX/lib
cp ./libfaac/.libs/*.so $PREFIX/lib
mkdir -p $PREFIX/include
cp ./include/*.h $PREFIX/include

6、编译

chmod u+x build_android.sh
./build_android.sh

7、rtmpdump 源代码下载

wget http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.3.tgz

8、直接使用 as 编译 rtmpdump
拷贝解压后的 librtmp 到 cpp 文件夹,在librtmp中新建 CMakeLists.txt

cmake_minimum_required(VERSION 3.4.1)
# close openssl
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_CRYPTO")

file(GLOB RTMP_SRC *.c)

add_library(rtmp
            STATIC
            ${RTMP_SRC}
)

9、在 app 目录下的 CMakeLists.txt 关联 librtmp/CMakeLists.txt

add_subdirectory(src/main/cpp/librtmp)

你可能感兴趣的:(x264 、 faac、rtmpdump 静态库编译)