2018年2月13日 星期二

[Embedded] build tiny ffmpeg library

This article describe how to configure a tiny ffmpeg library for embedded system.


1. donwload source code
$ wget http://ffmpeg.org/releases/ffmpeg-3.4.2.tar.bz2
$ tar xvf ffmpeg-3.4.2.tar.bz2
$ cd ffmpeg-3.4.2
2. baseline configure with only one decoder (mp3)
$ ./configure \
 --enable-cross-compile \
 --arch=armv7-a \
 --target-os=linux \
 --cross-prefix=arm-linux-gnueabihf- \
 --enable-neon \
 --extra-cflags='-mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -std=c99 -fomit-frame-pointer -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize' \
 --disable-static \
 --enable-shared \
 --disable-debug \
 --disable-avdevice \
 --disable-avfilter \
 --disable-swscale \
 --disable-ffmpeg \
 --disable-ffplay \
 --disable-ffserver \
 --disable-doc \
 --disable-network \
 --disable-muxers \
 --disable-demuxers \
 --enable-rdft \
 --enable-demuxer=mp3 \
 --disable-bsfs \
 --disable-filters \
 --disable-parsers \
 --enable-parser=mpegaudio \
 --disable-protocols \
 --enable-protocol=file \
 --disable-indevs \
 --disable-outdevs \
 --disable-encoders \
 --disable-decoders \
 --enable-decoder=mp3
$ make install DESTDIR=~/test/baseline
3. Addition configuration may need
--enable-small
--enable-thumb
4. size comparision (baseline, enable-small, enable-thumb)
$ tree -h baseline/usr/local/lib/
├── [347K] libavcodec.so.57.107.100
├── [168K] libavformat.so.57.83.100
├── [344K] libavutil.so.55.78.100
└── [ 61K] libswresample.so.2.9.100 
$ tree -h withsmall/usr/local/lib/
├── [217K] libavcodec.so.57.107.100
├── [128K] libavformat.so.57.83.100
├── [220K] libavutil.so.55.78.100
└── [ 56K] libswresample.so.2.9.100 
$ tree -h withthumb/usr/local/lib/
├── [347K] libavcodec.so.57.107.100
├── [168K] libavformat.so.57.83.100
├── [344K] libavutil.so.55.78.100
└── [ 61K] libswresample.so.2.9.100

Conclusion: "--enable-small" will got a tiny ffmpeg library size.