Reduce the compiled size of the ffmpeg library based on what I need

I finally managed to build ffmpeg as described here: https://enoent.fr/blog/2014/06/20/compile-ffmpeg-for-android/ and eventually I have a ffmpeg library that accepts the command arguments.

I am ONLY applying the watermark image over the video, so I use this ffmpeg command to do this:

ffmpeg -i input.avi -i logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.avi

      

Basic configuration:

  ./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 required from ffmpeg.

When compiling ffmpeg, I get these files:

enter image description here

I want to reduce the size of the library as small as possible, so given the command above, are there any files that I can remove from the final build?

ALSO, which is the most common processor 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

      

+3


source to share


1 answer


You can use connection time optimization (LTO) if your compiler supports it. I have had very good results with GCC and LTO optimizing things that are never called. I'll start with what LordNeckbeard suggests and only set up the partitions you need, then use LTO with your static link.

Other options for reducing code size include features such as optimization for size (-Os), which most compilers support in one form or another. You can also remove unneeded characters using something like strip --strip-all ./your_binary

.



If that's not enough to get your target size, look at executable packages like UPX . These programs will do cpu / memory compilation to quickly decompress binaries. On some architectures, this can be a significant space saving.

+1


source







All Articles