3

I am trying to build FFmpeg because I realized that my app doesn't work for android 6.0 in x86 devices before that I have published my app with targetsdkversion 23 (It has text relocations) and now I can't publish my app using targetsdkversion 22 (This is the way that I could fix the problem). So I read a lot about this problem It seems there isn't a solution. Some people say that I can compile ffmpeg using --disable-asm flag and I can solve the problem. I want to generate a libffmeg.so for vitamio that works on x86 android 6.0.

I am using

Ubuntu 14.04 LTS

Android NDK r12b

And my example project is Vitamio-5.0.2 from Download

So I am working on this tutorial

This is my FFmpeg-Android.sh file

#!/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

The other files are the same as url provides

Then the result is

enter image description here

I have deleted -Werror=strict-aliasing from CFLAGS and it generates the other .so files less libffmpeg.so

enter image description here

The error is in this code line

$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

I have removed ccache from export CC="ccache arm-linux-androideabi-gcc" and I have an error

enter image description here

I have changed --disable-asm to --enable-asm and I have compiled FFmpeg-Android.sh correctly

enter image description here

I copied the libffmpeg.so generated in armv6, armv7, neon and vfp files in my android studio project.

I don't know if I copied libffmpeg.so files in the correct place

armv6 -> arm64-v8a
armv7 -> armeabi-v7a
neon  -> x86

enter image description here

And the result in 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.
EduardoUstarez
  • 603
  • 11
  • 22

0 Answers0