我正在尝试构建FFmpeg,因为我意识到我的应用程序在x86设备中不适用于android 6.0之前我已经发布了我的应用程序与targetsdkversion 23(它有文本重定位),现在我无法发布我的应用程序使用targetsdkversion 22(这是我可以解决问题的方法)。所以我读了很多关于这个问题的看法似乎没有解决方案。有人说我可以使用--disable-asm标志编译ffmpeg,我可以解决问题。我想生成一个libffmeg.so for vitamio,适用于x86 android 6.0。
我正在使用
Ubuntu 14.04 LTS
Android NDK r12b
我的示例项目是来自Download
的Vitamio-5.0.2所以我正在研究这个tutorial
这是我的FFmpeg-Android.sh文件
#!/bin/bash
export ANDROID_NDK=/home/myuser/Downloads/android-ndk-r12b
DEST=`pwd`/build/ffmpeg && rm -rf $DEST
SOURCE=`pwd`/ffmpeg
if [ -d ffmpeg ]; then
cd ffmpeg
else
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
fi
git reset --hard
git clean -f -d
git checkout `cat ../ffmpeg-version`
patch -p1 <../FFmpeg-VPlayer.patch
[ $PIPESTATUS == 0 ] || exit 1
git log --pretty=format:%H -1 > ../ffmpeg-version
TOOLCHAIN=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86
SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm/
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=$TOOLCHAIN
export PATH=$TOOLCHAIN/bin:$PATH
export CC="ccache 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"
FFMPEG_FLAGS="--target-os=linux \
--arch=arm \
--enable-cross-compile \
--cross-prefix=arm-linux-androideabi- \
--enable-shared \
--enable-static \
--disable-symver \
--disable-doc \
--disable-ffplay \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-encoders \
--disable-muxers \
--disable-filters \
--disable-devices \
--disable-everything \
--enable-protocols \
--enable-parsers \
--enable-demuxers \
--enable-decoders \
--enable-bsfs \
--enable-network \
--enable-swscale \
--disable-demuxer=sbg \
--disable-demuxer=dts \
--disable-parser=dca \
--disable-decoder=dca \
--disable-asm \
--enable-version3"
for version in neon armv7 vfp armv6; do
cd $SOURCE
case $version in
neon)
EXTRA_CFLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-quad"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"
;;
armv7)
EXTRA_CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"
;;
vfp)
EXTRA_CFLAGS="-march=armv6 -mfpu=vfp -mfloat-abi=softfp"
EXTRA_LDFLAGS=""
;;
armv6)
EXTRA_CFLAGS="-march=armv6"
EXTRA_LDFLAGS=""
;;
*)
EXTRA_CFLAGS=""
EXTRA_LDFLAGS=""
;;
esac
PREFIX="$DEST/$version" && mkdir -p $PREFIX
FFMPEG_FLAGS="$FFMPEG_FLAGS --prefix=$PREFIX"
./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" | tee $PREFIX/configuration.txt
cp config.* $PREFIX
[ $PIPESTATUS == 0 ] || exit 1
make clean
make -j4 || exit 1
make install || exit 1
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
cp $PREFIX/libffmpeg.so $PREFIX/libffmpeg-debug.so
arm-linux-androideabi-strip --strip-unneeded $PREFIX/libffmpeg.so
done
https://www.vitamio.org/en/2013/Tutorial_0509/13.html
其他文件与url提供的文件相同
然后结果是
我从CFLAGS中删除了-Werror = strict-aliasing,它生成了其他.so文件,而不是libffmpeg.so
错误在此代码行中
$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
我已从导出CC =“ccache arm-linux-androideabi-gcc”中删除了ccache 我有一个错误
我已将--disable-asm更改为--enable-asm并且我已正确编译FFmpeg-Android.sh
我在我的android studio项目中复制了armv6,armv7,neon和vfp文件中生成的libffmpeg.so。
我不知道我是否将libffmpeg.so文件复制到了正确的位置
armv6 -> arm64-v8a
armv7 -> armeabi-v7a
neon -> x86
Android Studio中的结果
I/Vitamio[5.0.2][Player]: Copyright (c) YIXIA (http://yixia.com).
THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
I/Vitamio[5.0.2][Player]: LOAD FFMPEG START: libffmpeg.so
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, av_copy_packet
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_register_all
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_uninit
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_get_by_name
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_inout_alloc
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_inout_free
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_graph_alloc
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_graph_create_filter
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_graph_parse
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_graph_parse2
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_graph_parse_ptr
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_graph_config
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, av_buffersrc_add_frame
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, av_buffersink_get_buffer_ref
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_unref_bufferp
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, avfilter_graph_free
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ffmpeg, av_abuffersink_params_alloc
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_shutdown
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_free
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_CTX_free
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_load_error_strings
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_library_init
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_CTX_new
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, TLS_client_method
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_new
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_set_fd
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_connect
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_read
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, SSL_write
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM ssl, ERR_print_errors_fp
I/Vitamio[5.0.2][Player]: LOAD FFMPEG END: libffmpeg.so
I/Vitamio[5.0.2][Player]: LOAD VVO START: libvvo.9.so
E/Vitamio[5.0.2][Player]: FIND_NAME_SYM vvo, render_yuv
I/Vitamio[5.0.2][Player]: LOAD VVO END: libvvo.9.so
I/Vitamio[5.0.2][Player]: LOAD VAO START: libvao.0.so
I/Vitamio[5.0.2][Player]: LOAD VAO END: libvao.0.so
I/Vitamio[5.0.2][Player]: VPLAYER INIT BEGIN
I/Vitamio[5.0.2][Player]: Application package name: **.*******.******************.*********
--------- beginning of crash
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 3334 (ez.**********
Application terminated.