android - 编译 FFmpeg : libx264 not found

标签 android ffmpeg android-ndk libx264

我希望有人能帮助我解决这个问题。我试图按照本教程使用 android ndk r10e 在 ubuntu 12.04LTS 下为 android 编译 FFmpeg 2.2.3 库:

Tutorial1

Tutorial2

这是我的 build_android.sh 文件:

#!/bin/bash
NDK=/home/rango/Desktop/android-ndk-r10e
SYSROOT=$NDK/platforms/android-19/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86

#ADDI_LDFLAGS="-L /usr/local/lib"
#ADDI_CFLAGS="-I /usr/include"

function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--enable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-doc \
--disable-symver \
--enable-protocol=concat \
--enable-protocol=file \
--enable-muxer=mp4 \
--enable-demuxer=mpegts \
--enable-memalign-hack \
--enable-gpl \
--enable-libx264 \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic -marm $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \

make clean
make -j4
make install
}

CPU=arm
PREFIX=$(pwd)/android/$CPU

build_one

当我在没有 --enable-libx264\行的情况下执行 buid_android.sh 脚本时,一切进展顺利,我可以在 android/arm/文件夹中获取 .a 文件。但是这一行失败并在控制台中显示以下错误:

ERROR: libx264 not found

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 "config.log" produced by configure as this will help

它似乎无法找到库的位置,因为我在 config.log 文件中发现了很多以下错误:

"LIBNAME".h: No such file or directory newlib.h: No such file or directory mingw.h: No such file or directory x264.h: No such file or directory

这是 config.log 文件的尾部:

check_mathfunc truncf 1
check_ld cc
check_cc
BEGIN /tmp/ffconf.zGKqGin6.c
    1   #include <math.h>
    2   float foo(float f, float g) { return truncf(f); }
    3   int main(void){ return (int) foo; }
END /tmp/ffconf.zGKqGin6.c
/home/rango/Desktop/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=/home/rango/Desktop/android-ndk-r10e/platforms/android-19/arch-arm/ -isysroot /home/rango/Desktop/android-ndk-r10e/platforms/android-19/arch-arm/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -Os -fpic -marm -march=armv5te -std=c99 -fomit-frame-pointer -fPIC -marm -pthread -c -o /tmp/ffconf.8Q9ke3aO.o /tmp/ffconf.zGKqGin6.c
/home/rango/Desktop/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=/home/rango/Desktop/android-ndk-r10e/platforms/android-19/arch-arm/ -isysroot /home/rango/Desktop/android-ndk-r10e/platforms/android-19/arch-arm/ -Wl,--as-needed -o /tmp/ffconf.3sjTkc5z /tmp/ffconf.8Q9ke3aO.o -lm -lz -pthread
check_lib x264.h x264_encoder_encode -lx264
check_header x264.h
check_cpp
BEGIN /tmp/ffconf.zGKqGin6.c
    1   #include <x264.h>
    2   int x;
END /tmp/ffconf.zGKqGin6.c
/home/rango/Desktop/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=/home/rango/Desktop/android-ndk-r10e/platforms/android-19/arch-arm/ -isysroot /home/rango/Desktop/android-ndk-r10e/platforms/android-19/arch-arm/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -Os -fpic -marm -march=armv5te -std=c99 -fomit-frame-pointer -fPIC -marm -pthread -E -o /tmp/ffconf.8Q9ke3aO.o /tmp/ffconf.zGKqGin6.c
/tmp/ffconf.zGKqGin6.c:1:18: fatal error: x264.h: No such file or directory
 #include <x264.h>
                  ^
compilation terminated.
ERROR: libx264 not found

最佳答案

理论上,要为 Android 构建支持 libx264FFmpeg,您需要完成以下步骤:

1) 为 Android 构建 libx264。现在您还没有构建任何libx264,这就是您遇到上述错误的原因。

2) 更改您的 buid_android.sh 并向 configure 添加其他选项(--extra-cflags--extra -ldflags) 以指定 includelib 目录的路径,libx264 是在步骤 1 中构建的。

3) 运行修改后的 build_android.sh

很遗憾,我还没有为 Android 构建 libx264。但我认为有办法做到这一点......

关于android - 编译 FFmpeg : libx264 not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35960371/

相关文章:

android - NDK 构建错误

android - 如何在 Gradle 中设置预处理器定义

ffmpeg - cuda 编码 - OpenEncodeSessionEx 失败 : out of memory

android - arm-linux-androideabi-gcc : Internal error: Killed (program cc1) from Android NDK r8

java - 将窗口覆盖上的触摸事件传递给它后面的 Activity

android - 如何在 QtCreator 项目树(CMake-项目)中显示额外文件?

android - TextInputLayout 错误信息大小

Android 小部件在一段时间后停止工作?

c++ - 将 QUdpSocket 用于自定义 FFMPEG I/O(原始 H.264)

php - ffmpeg-php 静默设置