美文网首页
macOS上为Android编译ffmpeg so库

macOS上为Android编译ffmpeg so库

作者: IOXusu | 来源:发表于2020-05-12 00:17 被阅读0次

    1.下载
    http://www.ffmpeg.org/download.html
    tar -xzf [解压下载的文件]

    2.配置并编写编译指令
    (1)安装 yasm
    brew install yasm
    (2)编辑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)'
    

    安装完毕后执行./configure
    (3)新建android_build.sh文件,编辑android_build.sh

    #!/bin/bash
    make clean
    export NDK=/Users/xusu/Library/Android/sdk/ndk/21.1.6352462
    export SYSROOT=$NDK/platforms/android-29/arch-arm/
    export TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64
    export CPU=arm
    export PREFIX=$(pwd)/android/$CPU
    export ADDI_CFLAGS="-marm"
    ./configure --target-os=linux \
    --prefix=$PREFIX --arch=arm \
    --disable-doc \
    --enable-shared \
    --disable-static \
    --disable-yasm \
    --disable-symver \
    --enable-gpl \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG
    make clean
    make
    make install
    

    其中NDK是你自己刚刚配置的ndk路径,SYSROOT为platforms中的路径,TOOLCHAIN为toolchains里面中的路径,依次配置好过后保存并退出。
    3.开始编译
    chmod 777 android_build.sh
    ./android_build.sh

    相关文章

      网友评论

          本文标题:macOS上为Android编译ffmpeg so库

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