美文网首页
Android NDK 编译 ffmpeg + x264

Android NDK 编译 ffmpeg + x264

作者: FM_1ad7 | 来源:发表于2021-09-26 11:03 被阅读0次

    原文连接:https://blog.csdn.net/yu540135101/article/details/105183294/
    libx264源码下载地址
    http://www.videolan.org/developers/x264.html
    ffmpeg源码下载
    http://ffmpeg.org/download.html
    gcc编译Android的libx264
    libx264使用gcc进行编译,NDK版本android-ndk-r14b

    #!/bin/sh
    ANDROID_NDK="/home/zhangyu/ffmpeg/android-ndk-r14b"
    SDK_VERSION=21
    #ARCH=arm64
    ARCH=arm
    
    if [ "$ARCH" = "arm64" ]
    then
        PLATFORM_PREFIX="aarch64-linux-android-"
        HOST="aarch64"
        PLATFORM_VERSION=4.9
    else
        PLATFORM_PREFIX="arm-linux-androideabi-"
        HOST="arm"
        PLATFORM_VERSION=4.9
    fi
    
    PREFIX=$(pwd)/android/${ARCH}
    SYSROOT=$ANDROID_NDK/platforms/android-${SDK_VERSION}/arch-${ARCH}
    TOOLCHAIN=$ANDROID_NDK/toolchains/${PLATFORM_PREFIX}${PLATFORM_VERSION}/prebuilt/linux-x86_64
    CROSS_PREFIX=$TOOLCHAIN/bin/${PLATFORM_PREFIX}
    
    
    ./configure \
        --prefix=$PREFIX \
        --cross-prefix=$CROSS_PREFIX \
        --sysroot=$SYSROOT \
        --enable-static \
        --enable-pic \
        --disable-asm \
        --host=arm-linux \
    

    clang编译Android的FFmpeg-4.2.2
    clang编译ffmpeg-4.2.2,NDK版本android-ndk-r21
    其中要指定libx264.a的路径和include

    #!/bin/bash
    export NDK=../android-ndk-r20b
    # 当前系统
    export HOST_TAG=linux-x86_64
    # 支持的 Android CUP 架构
    # export ARCH=aarch64
    # export CPU=armv8-a
    export ARCH=armv7a
    export CPU=armv7-a
    # 支持的 Android 最低系统版本
    export MIN=21
    export ANDROID_NDK_PLATFORM=android-21
    
    export PREFIX=$(pwd)/android/$CPU
    
    export MIN_PLATFORM=$NDK/platforms/android-$MIN
    export SYSROOT=$NDK/sysroot
    export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
    export AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar
    export AS=$TOOLCHAIN/bin/arm-linux-androideabi-as
    export CC=$TOOLCHAIN/bin/$ARCH-linux-androideabi$MIN-clang
    echo "-----------------------------"
    echo $CC
    export CXX=$TOOLCHAIN/bin/$ARCH-linux-androideabi$MIN-clang++
    export LD=$TOOLCHAIN/bin/arm-linux-androideabi-ld
    export NM=$TOOLCHAIN/bin/arm-linux-androideabi-nm
    export RANLIB=$TOOLCHAIN/bin/arm-linux-androideabi-ranlib
    export STRIP=$TOOLCHAIN/bin/arm-linux-androideabi-strip
    
    OPTIMIZE_CFLAGS="-I/work/fuweicong/android/x264/android/arm/include -DANDROID -I$NDK/sysroot/usr/include/arm-linux-androideabi/"
    ADDI_LDFLAGS="-Wl,-rpath-link=$MIN_PLATFORM/arch-arm/usr/lib -L/work/fuweicong/android/x264/android/arm/lib -L$MIN_PLATFORM/arch-arm/usr/lib -nostdlib"
    
    
    export PKG_CONFIG_PATH=/work/fuweicong/android/x264/android/arm/lib/pkgconfig:$PKG_CONFIG_PATH
    
    ./configure \
        --prefix=$PREFIX \
        --ar=$AR \
        --as=$AS \
        --cc=$CC \
        --cxx=$CXX \
        --nm=$NM \
        --ranlib=$RANLIB \
        --strip=$STRIP \
        --arch=$ARCH \
        --target-os=android \
        --enable-cross-compile \
        --disable-asm \
        --enable-gpl \
        --enable-libx264 \
        --enable-jni \
        --enable-neon \
        --enable-mediacodec \
        --enable-shared \
        --disable-static \
        --disable-ffprobe \
        --disable-ffplay \
        --disable-ffmpeg \
        --disable-debug \
        --disable-symver \
        --disable-stripping \
        --extra-cflags="-I/work/fuweicong/android/x264/android/arm/include" \
        --extra-ldflags="-L/work/fuweicong/android/x264/android/arm/lib" \
    
    make -j8
    make install
    
    

    相关文章

      网友评论

          本文标题:Android NDK 编译 ffmpeg + x264

          本文链接:https://www.haomeiwen.com/subject/kxrqnltx.html