Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

How to decrease binary size

Taner Sener edited this page Jul 4, 2019 · 4 revisions

The size of MobileFFmpeg binaries is determined by the following two factors:

  1. External libraries enabled
  2. FFmpeg components enabled

MobileFFmpeg already defines eight packages with different external libraries enabled. You can use a similar approach and create your own package by enabling only external libraries you need. If you don't enable any of them, your package will have the minimum size, just as the current min package.

Sometimes, not enabling unused external libraries is not enough and you may need to decrease binary size further. You can achieve that by modifying FFmpeg components enabled.

Two files, android-ffmpeg.sh for Android and ios-ffmpeg.sh for both iOS and tvOS, under the build folder defines which FFmpeg components are enabled for each platform. Current versions of these scripts do not modify default components and only disable features/devices not available on mobile platforms.

configure line located in the lower part of the files is responsible of enabling/disabling FFmpeg components.

./configure \
    --sysroot=${SDK_PATH} \
    --prefix=${BASEDIR}/prebuilt/ios-$(get_target_build_directory)/${LIB_NAME} \
    --enable-version3 \
    --arch="${TARGET_ARCH}" \
    --cpu="${TARGET_CPU}" \
    --target-os=darwin \
    --ar="${AR}" \
    ...

Enabling/disabling a component can be done by appending options to configure line. Options starting with --enable- prefix are used to enable a component and options starting with --disable- prefix are used to disable it.

In order to build the smallest possible binary, you need to disable all FFmpeg components and enable only required ones.

For example, if you are using MobileFFmpeg to read JPEG files and create an mpeg4 video, you can use the following options to disable all FFmpeg components and enable only necessary ones.

    --disable-everything \
    --enable-decoder=bmp,jpeg2000,jpegls,mjpeg,mjpegb,smvjpeg \
    --enable-demuxer=bmp,jpeg2000,jpegls,mjpeg,mjpegb,smvjpeg \
    --enable-muxer=mp4 \
    --enable-protocol=file \
    --enable-encoder=mpeg4 \
Clone this wiki locally