Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why my ffmpeg libs are so large? [closed]

Tags:

ffmpeg

size

libs

I compiled ffmpeg libs on my Ubuntu 64-bits using the following script:

   mkdir ~/ffmpeg_sources

#x264

cd ~/ffmpeg_sources
   wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
   tar xjvf last_x264.tar.bz2
   cd x264-snapshot*
   ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static --disable-asm
   make
   make install
   make distclean

#FFmpeg

cd ~/ffmpeg_sources
   wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
   tar xjvf ffmpeg-snapshot.tar.bz2
   cd ffmpeg
   PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
   export PKG_CONFIG_PATH
   ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" \
   --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --extra-libs="-ldl" --   enable-gpl \
  --enable-libx264 --enable-x11grab --disable-yasm                                                                                                                               
   make
   make install
   make distclean
   hash -r

But the final libs are really large (For example, libavcodec.a > 140 Mb). Anybody know why my libs are so large ?

EDIT

My Solutions:

  • add the option "--disable-debug" to the ./configure. The size of my libavcodec fell from 150Mb to 12Mb!
  • Remove all unnecessary codecs: Add the options -disable-encoders, --disable-decoders and then add only codecs you want with --enable-encoder=NAME and --enable-decoder=NAME. Print the list using ./configure --list-encoders --list-decoders. see ./configure --help for more information. (My final libavcodec has a size of 4Mo)
like image 553
user3504221 Avatar asked Apr 06 '14 18:04

user3504221


People also ask

Why is FFmpeg so big?

ffmpeg is a very large library with a lot of functionality (many different codecs, etc) so it's not surprising for the output files to be large.

Where do I put FFmpeg?

Add the FFmpeg binary directory to the path. Here's how: Click the New button to open a new blank line below the bottom-most path. Type C:\ffmpeg\bin . Or, if you placed the FFmpeg folder on a different drive or in a different folder, replace this path with that location instead (remember to leave \bin at the end).


1 Answers

Note that the static libs (such as libavcodec.a) contain all kinds of extra data that will be stripped off by linker.

But even after that you can add --enable-small to ./configure parameters. About a year ago this parameter reduced the size of libavcodec.so from 14 to ~3 MByte.

like image 171
Alex Cohn Avatar answered Nov 20 '22 05:11

Alex Cohn