ffmpeg_video 发表于 2013-11-4 18:50:31

ffmpeg libx264编译出错

本帖最后由 ffmpeg_video 于 2013-11-4 18:56 编辑

我的编译过程如下:

1. 下载libx264
git clone git://git.videolan.org/x264.git

./configure--enable-shared--enable-static
make
make install

2.下载ffmpeg源码
git clone git://source.ffmpeg.org/ffmpeg.git
编写了一个 shell.sh 脚本
如果一开始执行shell.sh的话会报错:找不到 config.mak 等一系列的.mak文件
所以
./configure
make
make install

然后再执行
./shell.sh
这里报错,找不到libx264

shell.sh如下:
export ANDROID_NDK=/home/cjc/android_/android-ndk-r9
export TOOLCHAIN=/tmp/ffmpeg2
export SYSROOT=$TOOLCHAIN/sysroot/
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=$TOOLCHAIN

export PATH=$TOOLCHAIN/bin:$PATH
export CC=arm-linux-androideabi-gcc
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar

CFLAGS="-O3 -Wall -mthumb -pipe -fpic -fasm \
      -finline-limit=300 -ffast-math \
      -fstrict-aliasing -Werror=strict-aliasing \
      -fmodulo-sched -fmodulo-sched-allow-regmoves \
      -Wno-psabi -Wa,--noexecstack \
      -D__ARM_ARCH_5__ -D__ARM_ARCH_5E__ \
      -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ \
      -DANDROID -DNDEBUG"

EXTRA_CFLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-quad -I/usr/local/include"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8 -L/usr/local/lib"

FFMPEG_FLAGS="--prefix=/home/cjc/android_/tmp/ffmpeg2/build \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--cross-prefix=arm-linux-androideabi- \
--enable-shared \
--disable-symver \
--disable-doc \
--disable-ffplay \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-encoders \
--disable-muxers \
--disable-bsfs \
--disable-filters \
--disable-devices \
--disable-everything \
--enable-protocols\
--enable-parsers \
--enable-demuxers \
--disable-demuxer=sbg \
--enable-decoders \
--enable-encoders \
--enable-gpl \
--enable-libx264 \
--enable-network \
--enable-swscale\
--enable-asm \
--enable-version3"

./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS"
make clean
make -j4
make install

rm libavcodec/inverse.o
$CC -lm -lz -shared --sysroot=$SYSROOT -Wl,--no-undefined -Wl,-z,noexecstack $EXTRA_LDFLAGS libavutil/*.o libavutil/arm/*.o libavcodec/*.o libavcodec/arm/*.o libavformat/*.o libswresample/*.o libswscale/*.o -o $PREFIX/libffmpeg.so

请高手指点一下,谢谢.......

James.DF 发表于 2013-11-5 09:35:45

1、x264要用NDK编译
2、编译好的x264库文件和头文件要安装到NDK中你用的platform对应的$sysroot目录下

T-Bagwell 发表于 2013-11-4 18:56:28

能否将错误整体贴出来,或者将config.log贴上来

ffmpeg_video 发表于 2013-11-4 18:58:23

BEGIN /tmp/ffconf.92AhT9um.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.92AhT9um.c
arm-linux-androideabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -Wall -mthumb -pipe -fpic -fasm -finline-limit=300 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -fmodulo-sched -fmodulo-sched-allow-regmoves -Wno-psabi -Wa,--noexecstack -D__ARM_ARCH_5__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ -DANDROID -DNDEBUG -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -march=armv5 -std=c99 -fomit-frame-pointer -fPIC -marm -c -o /tmp/ffconf.Ko2jdmll.o /tmp/ffconf.92AhT9um.c
arm-linux-androideabi-gcc -Wl,--fix-cortex-a8 -Wl,--as-needed -o /tmp/ffconf.dwIPk9ds /tmp/ffconf.Ko2jdmll.o -lm -lz
check_lib x264.h x264_encoder_encode -lx264
check_header x264.h
check_cpp
BEGIN /tmp/ffconf.92AhT9um.c
    1        #include <x264.h>
    2        int x;
END /tmp/ffconf.92AhT9um.c
arm-linux-androideabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -Wall -mthumb -pipe -fpic -fasm -finline-limit=300 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -fmodulo-sched -fmodulo-sched-allow-regmoves -Wno-psabi -Wa,--noexecstack -D__ARM_ARCH_5__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ -DANDROID -DNDEBUG -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -march=armv5 -std=c99 -fomit-frame-pointer -fPIC -marm -E -o /tmp/ffconf.Ko2jdmll.o /tmp/ffconf.92AhT9um.c
/tmp/ffconf.92AhT9um.c:1:18: fatal error: x264.h: No such file or directory
compilation terminated.
ERROR: libx264 not found

孙悟空 发表于 2013-11-4 19:15:16

编译x264的时候,需要确定一下安装目录,你的系统是什么的?
centos?ubuntu?

ffmpeg_video 发表于 2013-11-4 19:24:06

ubuntu

T-Bagwell 发表于 2013-11-4 19:25:41

装x264的时候可能遇到问题了
你可以试试
./configure --prefix=/usr --enable-shared --enable-static

ffmpeg_video 发表于 2013-11-4 19:26:33

好,我再试试

ffmpeg_video 发表于 2013-11-4 19:32:05

我粘帖数据过来,并发表之后,怎么突然不见了?

孙悟空 发表于 2013-11-4 19:33:52

还没解决是吗?

ffmpeg_video 发表于 2013-11-4 19:34:55

cjc@cjc-K55VD:~/android_/ffmpeg$ ./shell.sh
Auto-config: --toolchain=arm-linux-androideabi-4.6
Copying prebuilt binaries...
Copying sysroot headers and libraries...
Copying libstdc++ headers and libraries...
Copying files to: /tmp/ffmpeg2
Cleaning up...
Done.
ERROR: libx264 not found
页: [1] 2
查看完整版本: ffmpeg libx264编译出错