请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

mac ffmpeg android 交叉编译 问题

问题

ffmpeg mac 编译没有问题, 但是Android交叉编译的时候,一直生成不了文件

本机环境

环境: mac 10.13.6
ffmpeg: 4.1.3
NDK: android-ndk-r10e

ffmpeg version 4.1.git Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.10.44.4)
  configuration: --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-videotoolbox --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --cc=clang --host-cflags= --host-ldflags=
  libavutil      56. 28.100 / 56. 28.100
  libavcodec     58. 52.102 / 58. 52.102
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 54.101 /  7. 54.101
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

问题

Android 交叉编译脚本和运行命令如下,我查看了我文件对应的目录都有对应的文件,但是就是编译后,没有生成文件夹

执行命令:

 sudo ./build_ffmpeg_for_android.sh

执行脚本:

PREFIX=android-build

#设置你自己的NDK位置
NDK_HOME=/Users/xxxx/Library/Android/sdk/android-ndk-r10e
#设置你自己的平台,这上Mac上的,linux换成linux-x86_64
NDK_HOST_PLATFORM=darwin-x86_64

COMMON_OPTIONS="\n    --target-os=android \n    --disable-static \n    --enable-shared \n    --enable-small \n    --disable-programs \n    --disable-ffmpeg \n    --disable-ffplay \n    --disable-ffprobe \n    --disable-doc \n    --disable-symver \n    --disable-asm \n    "

function build_android {
    ./configure \n    --libdir=${PREFIX}/libs/armeabi-v7a \n    --incdir=${PREFIX}/includes/armeabi-v7a \n    --pkgconfigdir=${PREFIX}/pkgconfig/armeabi-v7a \n    --arch=arm \n    --cpu=armv7-a \n    --cross-prefix="${NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/${NDK_HOST_PLATFORM}/bin/arm-linux-androideabi-" \n    --sysroot="${NDK_HOME}/platforms/android-19/arch-arm/" \n    --extra-cflags="-march=armv7-a -mfloat-abi=softfp -mfpu=neon" \n    --extra-ldexeflags=-pie \n    ${COMMON_OPTIONS}
    make clean
    make -j8 && make install

    # ./configure \n    # --libdir=${PREFIX}/libs/arm64-v8a \n    # --incdir=${PREFIX}/includes/arm64-v8a \n    # --pkgconfigdir=${PREFIX}/pkgconfig/arm64-v8a \n    # --arch=aarch64 \n    # --cpu=armv8-a \n    # --cross-prefix="${NDK_HOME}/toolchains/aarch64-linux-android-4.9/prebuilt/${NDK_HOST_PLATFORM}/bin/aarch64-linux-android-" \n    # --sysroot="${NDK_HOME}/platforms/android-21/arch-arm64/" \n    # --extra-ldexeflags=-pie \n    # ${COMMON_OPTIONS} 
    # make clean
    # make -j8 && make install

    # ./configure \n    # --libdir=${PREFIX}/libs/x86 \n    # --incdir=${PREFIX}/includes/x86 \n    # --pkgconfigdir=${PREFIX}/pkgconfig/x86 \n    # --arch=x86 \n    # --cpu=i686 \n    # --cross-prefix="${NDK_HOME}/toolchains/x86-4.9/prebuilt/${NDK_HOST_PLATFORM}/bin/i686-linux-android-" \n    # --sysroot="${NDK_HOME}/platforms/android-19/arch-x86/" \n    # --extra-ldexeflags=-pie \n    # ${COMMON_OPTIONS} 
    # make clean
    # make -j8 && make install

    # ./configure \n    # --libdir=${PREFIX}/libs/x86_64 \n    # --incdir=${PREFIX}/includes/x86_64 \n    # --pkgconfigdir=${PREFIX}/pkgconfig/x86_64 \n    # --arch=x86_64 \n    # --cpu=x86_64 \n    # --cross-prefix="${NDK_HOME}/toolchains/x86_64-4.9/prebuilt/${NDK_HOST_PLATFORM}/bin/x86_64-linux-android-" \n    # --sysroot="${NDK_HOME}/platforms/android-21/arch-x86_64/" \n    # --extra-ldexeflags=-pie \n    # ${COMMON_OPTIONS}
    # make clean
    # make -j8 && make install

};

build_android

w
错误日志:

/Users/xxxx/Library/Android/sdk/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-clang is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

······
省略部分日志
······

ld: warning: text-based stub file /System/Library/Frameworks//VideoToolbox.framework/VideoToolbox.tbd and library file /System/Library/Frameworks//VideoToolbox.framework/VideoToolbox are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//VideoToolbox.framework/VideoToolbox.tbd and library file 
INSTALL	libavutil/rational.h
INSTALL	libavutil/lzo.h
INSTALL	libavutil/avconfig.h
INSTALL	libavutil/ffversion.h
INSTALL	libavutil/libavutil.pc

尝试解决

  1. google 搜索了半天,大部分说路径配置有问题,我查看脚本对应 ndk 的 --cross-prefix 和 --sysroot= 都能找到对应文件夹

最终结果

  • 期望结果:脚本所在目录,生成 android-build 文件夹,里边包含对应的头文件和so 包
  • 最终结果: 脚本所在目录 和 /usr/local/ffmpeg 目录都没有文件

正在回答 回答被采纳积分+3

3回答

李超 2019-05-28 21:43:06

去咱们的QQ群里问吧,那里更方便回答

0 回复 有任何疑惑可以回复我~
提问者 平沙落雁式 2019-05-28 13:54:57

老师,一直编译不过。。。

0 回复 有任何疑惑可以回复我~
李超 2019-05-27 08:15:00

是用的我上传到git 上的脚本吗?

0 回复 有任何疑惑可以回复我~
  • 提问者 平沙落雁式 #1
    是的,用老师你上传的编译脚本
    回复 有任何疑惑可以回复我~ 2019-05-27 09:48:44
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信