歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> Linux編程

使用NDK交叉編譯ffmpeg+libx264找不到libx264的解決方法

使用NDK交叉編譯ffmpeg+libx264
 
1,編譯libx264
 
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
 
tar xjvf last_x264.tar.bz2
 
cd x264-snapshot*
 
使用如下confiure
 
export ARM_ROOT=/home/zangcf/cross_compile/Android-ndk-r9b
 
export ARM_INC=$ARM_ROOT/platforms/android-8/arch-arm/usr/include/
 
export ARM_LIB=$ARM_ROOT/platforms/android-8/arch-arm/usr/lib/
 
export ARM_TOOL=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
 
export ARM_LIBO=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8
 
export PATH=$ARM_TOOL/bin:$PATH
 
export ARM_PRE=arm-linux-androideabi
 
 
 
 
 
./configure --prefix=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build \
 
        --extra-cflags=" -I$ARM_INC -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID  -Wa,--noexecstack -MMD -MP " \
 
        --extra-ldflags="  -nostdlib -Bdynamic  -Wl,--no-undefined -Wl,-z,noexecstack  -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o -lc -lm -ldl -lgcc " \
 
        --cross-prefix=${ARM_PRE}- --disable-asm --host=arm-linux
 
 
 
make
 
make install
 
make distclean
 
 
 
2,下載編譯ffmpeg
 
 
 
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
 
tar xjvf ffmpeg-snapshot.tar.bz2
 
cd ffmpeg
 
使用如下configure
 
export ARM_ROOT=/home/zangcf/cross_compile/android-ndk-r9b
 
export ARM_INC=$ARM_ROOT/platforms/android-8/arch-arm/usr/include/
 
export ARM_LIB=$ARM_ROOT/platforms/android-8/arch-arm/usr/lib/
 
export ARM_TOOL=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
 
export ARM_LIBO=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8
 
export PATH=$ARM_TOOL/bin:$PATH
 
export ARM_PRE=arm-linux-androideabi
 
export LIB_INC=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/include
 
export LIB_LIB=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/lib
 
 
 
 
 
./configure --target-os=linux \
 
--arch=armv5te \
 
--enable-cross-compile \
 
--cc=$ARM_TOOL/bin/${ARM_PRE}-gcc \
 
--cross-prefix=$ARM_TOOL/bin/${ARM_PRE}- \
 
--extra-cflags=" -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -D
 
ANDROID  -Wa,--noexecstack -MMD -MP " \
 
--enable-static \
 
--disable-shared --enable-libx264 --enable-gpl \
 
--disable-asm --disable-yasm  \
 
--prefix=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build \
 
--disable-amd3dnow --disable-amd3dnowext --disable-mmx --disable-sse --disable-ssse3 \
 
--extra-cflags="-I$ARM_INC -std=gnu99 -I$LIB_INC " \
 
--extra-libs="-lc -lm -ldl -lgcc -lz -lx264 " \
 
--extra-ldflags=" -L$LIB_LIB -Wl,-rpath-link=$LIB_LIB -nostdlib -Bdynamic  -Wl,--no-undefined -Wl,-z,noexecstack  -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so
 
 -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o "
 
/////////////////////////////////////////////////////////////////////
 
執行configure的時候,怎麼都提示找不到h264,經過仔細分析研讀,分析configure文件,發現是x264的編譯選項有問題,少了一個--enable-static
 
加上這個選項,重新編譯x264,呵呵ffmpeg的配置編譯都通過了。
 
make
 
make install
 
make distclean
 
hash -r

FFmpeg 的詳細介紹:請點這裡
FFmpeg 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved