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

I finally managed to build ffmpeg as described here: 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" \


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
#OPTIMIZE_CFLAGS="-marm -march=$CPU"

#arm v7vfpv3
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "

#arm v7vfp
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "

#arm v7n
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"

#arm v6+vfp
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"



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.



All Articles