Reputation: 14581
I finally managed to build ffmpeg as detailed in here: https://enoent.fr/blog/2014/06/20/compile-ffmpeg-for-android/ and in the end, I have a ffmpeg library which accepts command arguments.
I am ONLY applying a watermark image over the video so for it I am using this ffmpeg command:
ffmpeg -i input.avi -i logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.avi
Basic config:
./configure \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-doc \
--disable-symver \
--enable-protocol=concat \
--enable-protocol=file \
--enable-muxer=mp4 \
--enable-demuxer=mpegts \
--enable-memalign-hack \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic -marm $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS"
No other commands needed from ffmpeg.
When compiling ffmpeg I get these files:
I want to reduce the size of the library to as small as possible, so given the above command, are there any files that I can remove from final build ?
ALSO which is the most common CPU found in current devices ? arm v7vfpv3, arm v7vfp, arm v7n ? I want to cover as many devices as possible.
#arm v6
#CPU=armv6
#OPTIMIZE_CFLAGS="-marm -march=$CPU"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one
#arm v7vfp
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
#PREFIX=./android/$CPU-vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
#arm v7n
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon
#build_one
#arm v6+vfp
#CPU=armv6
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
#PREFIX=./android/${CPU}_vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
Upvotes: 6
Views: 4172
Reputation: 4400
You could use link-time optimization (LTO) if your compiler supports it. I have had very good results with GCC and LTO optimizing out stuff that is never called. I would start with what LordNeckbeard suggest and configure only the sections you need and then use LTO with your static linking.
Other options to reduce code size include things like the size optimization (-Os) that most compilers support in one form or another. You can also strip unneeded symbols using something like strip --strip-all ./your_binary
.
If all of that isn't enough to get you to your target size, look into executable packers like UPX. These programs will make a cpu/memory trade-off to decompress binary files on the fly. On some architectures this can be a significant space saver.
Upvotes: 1