我试图用
android ndk r8b编译ffmpeg的最后一个版本,但我总是有错误,我不知道如何解决它们.我正在阅读本教程
http://www.roman10.net/how-to-build-ffmpeg-for-android/,但脚本不适用于我的环境,我使用这个:
-Ubuntu 12.04 LTS.
-Intel Core i7.
-Android ndk r8b
– 最新版本ffmeg(1.0)
基本上我想将电影从一种格式编码到另一种格式.
这就是我使用的脚本:
NDK=../android-ndk-r8b
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
function build_r8b
{
bash configure \
--disable-shared \
--enable-static \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-postproc \
--enable-small \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--enable-cross-compile \
--target-os=linux \
--extra-cflags="-I$PLATFORM/usr/include" \
--extra-ldflags="-L$PLATFORM/usr/lib -nostdlib" \
--arch=arm \
--disable-symver \
--disable-debug \
--disable-stripping \
$ADDITIONAL_CONFIGURE_FLAG
sed -i 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h
sed -i 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h
sed -i 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h
sed -i 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h
sed -i 's/HAVE_TRUNC 0/HAVE_TRUNC 1/g' config.h
sed -i 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h
make clean
make -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}
#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
#build_one
build_r8b
这是最终结果
jllarraz@ubuntu:~/Descargas/ffmpeg$bash build_android.sh
/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc 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 "config.log" produced by configure as this will help
solving the problem.
make: execvp: ./version.sh: Permiso denegado
make: execvp: ./version.sh: Permiso denegado
HOSTCC doc/print_options.o
CC cmdutils.o
CC libavdevice/alldevices.o
CC libavdevice/avdevice.o
In file included from doc/print_options.c:104:0:
./libavcodec/options_table.h: En la función ‘show_codec_opts’:
./libavcodec/options_table.h:85:1: aviso: ‘sub_id’ es obsoleto (declarado en ./libavcodec/avcodec.h:1505) [-Wdeprecated-declarations]
./libavcodec/options_table.h:149:1: aviso: ‘luma_elim_threshold’ es obsoleto (declarado en ./libavcodec/avcodec.h:1740) [-Wdeprecated-declarations]
./libavcodec/options_table.h:150:1: aviso: ‘chroma_elim_threshold’ es obsoleto (declarado en ./libavcodec/avcodec.h:1747) [-Wdeprecated-declarations]
./libavcodec/options_table.h:284:1: aviso: ‘color_table_id’ es obsoleto (declarado en ./libavcodec/avcodec.h:1986) [-Wdeprecated-declarations]
./libavcodec/options_table.h:307:1: aviso: ‘inter_threshold’ es obsoleto (declarado en ./libavcodec/avcodec.h:2049) [-Wdeprecated-declarations]
./libavcodec/options_table.h:312:1: aviso: ‘quantizer_noise_shaping’ es obsoleto (declarado en ./libavcodec/avcodec.h:2056) [-Wdeprecated-declarations]
cmdutils.c:52:21: error fatal: version.h: No existe el archivo o el directorio
compilación terminada.
make: *** [cmdutils.o] Error 1
make: *** Se espera a que terminen otras tareas....
build_android.sh: línea 59: ../android-ndk-r8b/toolchains/arm-linux-androideabi- 4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar: Permiso denegado
build_android.sh: línea 60: ../android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld: Permiso denegado
最佳答案 经过几个小时的工作,我找到了一种方法来编译它:
1)在我的情况下在包含android-ndk和ffmpeg的文件夹中给予权限“chmod 777 ./* -R”(一定要使用’./’而不是’/’!)
2)在我的环境中安装我需要的东西.
3)这是我的新.sh文件
function build_r8b_test
{
bash configure --target-os=linux \
--prefix=$PREFIX \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
--disable-shared \
--enable-static \
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
--disable-everything \
--enable-demuxer=mov \
--enable-demuxer=h264 \
--disable-ffplay \
--enable-protocol=file \
--enable-avformat \
--enable-avcodec \
--enable-decoder=rawvideo \
--enable-decoder=mjpeg \
--enable-decoder=h263 \
--enable-decoder=mpeg4 \
--enable-decoder=h264 \
--enable-parser=h264 \
--enable-encoder=mpeg4 \
--enable-encoder=mpeg \
--disable-network \
--enable-zlib \
--disable-avfilter \
--disable-avdevice \
$ADDITIONAL_CONFIGURE_FLAG
sed -i 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h
sed -i 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h
sed -i 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h
sed -i 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h
sed -i 's/HAVE_TRUNC 0/HAVE_TRUNC 1/g' config.h
sed -i 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h
make clean
make -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}
#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_r8b_test