Skip to content

Instantly share code, notes, and snippets.

@rafaelbiriba
Last active July 25, 2024 03:04
Show Gist options
  • Save rafaelbiriba/7f2d7c6f6c3d6ae2a5cb to your computer and use it in GitHub Desktop.
Save rafaelbiriba/7f2d7c6f6c3d6ae2a5cb to your computer and use it in GitHub Desktop.
Install FFmpeg with libfdk_aac support (For Ubuntu)
# Criando um script .sh para executar todos os comandos:
#root@servidor:~# vi script.sh
#root@servidor:~# chmod +x script.sh
#root@servidor:~# ./script.sh
apt-get update
apt-get -y install autoconf automake build-essential git-core libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev libmp3lame-dev nasm gcc yasm && true
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make -j8
make install
make distclean
cd ~/ffmpeg_sources
wget https://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make -j8
make install
make distclean
cd ~/ffmpeg_sources
wget https://ffmpeg.org/releases/ffmpeg-4.2.1.tar.gz
tar xzvf ffmpeg-4.2.1.tar.gz
cd ffmpeg-4.2.1
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-libass --enable-libfdk-aac \
--enable-libmp3lame --enable-nonfree
make -j8
make install
cp ffmpeg /usr/bin/
make distclean
hash -r
ffmpeg 2>&1 | head -n1
@j8lud
Copy link

j8lud commented Mar 22, 2018

I must add the library libfaac where I must change your script ?

@penseurtank
Copy link

i follow above steps but after executing all the commands getting same error.
Error: ffmpeg_fdk_acc

@gilgongo
Copy link

@rafaelbiriba
Copy link
Author

done @gilgongo! Thanks.

@chrisvaughn
Copy link

thanks for the script! I had some issues build failures from ffmpeg master so I updated a fork to use the latest released version 4.2.1. https://gist.github.com/chrisvaughn/469312639631a65798c70acef36a108e

@Simanas
Copy link

Simanas commented Oct 3, 2019

Thanks @chrisvaughn! Your version worked for me, while original was broken. @rafaelbiriba please update this to keep it fresh! :)

@rafaelbiriba
Copy link
Author

Updated! Thanks @chrisvaughn !

@orhanar
Copy link

orhanar commented Jan 16, 2020

Got fatal error: syslib_channelMapDescr.h: No such file or directory
#include "syslib_channelMapDescr.h" when it comes to compile part. I think it needs another revision?

@ajaykt665
Copy link

Hi rafaelbiriba,
i wanted to know if the ffmpeg that is built with the script you provided has the support to inject spatial Audio metadata(Ambisonics).I am working on a project for Android where in i am using ffmpeg library to trim the 4k video . After trimming the video, the video loses the spatial properties(Video and audio). I am able to inject the Video meta data but not able to inject Audio(ambisonics)metadata.Please help me with the same.

@dustball
Copy link

dustball commented Jul 30, 2020

This is really great BUT it's missing most of the codecs that come with the default debian FFMPEG.

It's great to add libfdk-aac .. but why remove support for all the good stuff?

I fetched additional packages and configured more stuff ..

sudo apt-get -y install build-essential autoconf automake cmake libtool git checkinstall nasm yasm libass-dev libfreetype6-dev libsdl2-dev p11-kit libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev libchromaprint-dev frei0r-plugins-dev gnutls-dev ladspa-sdk libcaca-dev libcdio-paranoia-dev libcodec2-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgme-dev libgsm1-dev libjack-dev libmodplug-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenjp2-7-dev libopenmpt-dev libopus-dev libpulse-dev librsvg2-dev librubberband-dev librtmp-dev libshine-dev libsmbclient-dev libsnappy-dev libsoxr-dev libspeex-dev libssh-dev libtesseract-dev libtheora-dev libtwolame-dev libv4l-dev libvo-amrwbenc-dev libvorbis-dev libvpx-dev libwavpack-dev libwebp-dev libx264-dev libx265-dev libxvidcore-dev libxml2-dev libzmq3-dev libzvbi-dev liblilv-dev libopenal-dev opencl-dev libjack-dev libavc1394-0 libavc1394-dev libiec61883-0 libiec61883-dev libbluray-dev libfdk-aac-dev libbs2b-dev libbs2b0 libdc1394-22 libdc1394-22-dev 

./configure --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-chromaprint --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdc1394 --enable-libdrm --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-nonfree --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-shared --enable-small --enable-version3 --extra-version=0ubuntu0.2 --incdir=/usr/include/x86_64-linux-gnu --libdir=/usr/lib/x86_64-linux-gnu --toolchain=hardened`

@meaje
Copy link

meaje commented Jan 18, 2021

This is really great BUT it's missing most of the codecs that come with the default debian FFMPEG.

It's great to add libfdk-aac .. but why remove support for all the good stuff?

I fetched additional packages and configured more stuff ..

sudo apt-get -y install build-essential autoconf automake cmake libtool git checkinstall nasm yasm libass-dev libfreetype6-dev libsdl2-dev p11-kit libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev libchromaprint-dev frei0r-plugins-dev gnutls-dev ladspa-sdk libcaca-dev libcdio-paranoia-dev libcodec2-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgme-dev libgsm1-dev libjack-dev libmodplug-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenjp2-7-dev libopenmpt-dev libopus-dev libpulse-dev librsvg2-dev librubberband-dev librtmp-dev libshine-dev libsmbclient-dev libsnappy-dev libsoxr-dev libspeex-dev libssh-dev libtesseract-dev libtheora-dev libtwolame-dev libv4l-dev libvo-amrwbenc-dev libvorbis-dev libvpx-dev libwavpack-dev libwebp-dev libx264-dev libx265-dev libxvidcore-dev libxml2-dev libzmq3-dev libzvbi-dev liblilv-dev libopenal-dev opencl-dev libjack-dev libavc1394-0 libavc1394-dev libiec61883-0 libiec61883-dev libbluray-dev libfdk-aac-dev libbs2b-dev libbs2b0 libdc1394-22 libdc1394-22-dev 

./configure --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-chromaprint --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdc1394 --enable-libdrm --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-nonfree --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-shared --enable-small --enable-version3 --extra-version=0ubuntu0.2 --incdir=/usr/include/x86_64-linux-gnu --libdir=/usr/lib/x86_64-linux-gnu --toolchain=hardened`

BTW: the libraries that are built before this are SHARED libraies, so to use the above script you must either change the configure/compile lines for fdk-aac and lame to both read:

  • fdk-aac: ./configure --prefix="$HOME/ffmpeg_build" --enable-shared
  • lame: ./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --enable-shared
    OR the last configure line to read:
  • ./configure --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-chromaprint --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdc1394 --enable-libdrm --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-nonfree --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-shared --enable-static --enable-small --enable-version3 --extra-version=0ubuntu0.2 --incdir=/usr/include/x86_64-linux-gnu --libdir=/usr/lib/x86_64-linux-gnu --toolchain=hardened

BTW Also get rid of the final character at the end of the configure command line the "`" at the end it just messes things up...

@arbitrary-dev
Copy link

😎

sudo apt build-dep <package>
apt source <package>
cd <package>
vim debian/rules
dpkg-buildpackage -uc -us -b -j8
sudo dpkg --install ../<package>.deb

@gianght90
Copy link

This is really great BUT it's missing most of the codecs that come with the default debian FFMPEG.
It's great to add libfdk-aac .. but why remove support for all the good stuff?
I fetched additional packages and configured more stuff ..

sudo apt-get -y install build-essential autoconf automake cmake libtool git checkinstall nasm yasm libass-dev libfreetype6-dev libsdl2-dev p11-kit libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev libchromaprint-dev frei0r-plugins-dev gnutls-dev ladspa-sdk libcaca-dev libcdio-paranoia-dev libcodec2-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgme-dev libgsm1-dev libjack-dev libmodplug-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenjp2-7-dev libopenmpt-dev libopus-dev libpulse-dev librsvg2-dev librubberband-dev librtmp-dev libshine-dev libsmbclient-dev libsnappy-dev libsoxr-dev libspeex-dev libssh-dev libtesseract-dev libtheora-dev libtwolame-dev libv4l-dev libvo-amrwbenc-dev libvorbis-dev libvpx-dev libwavpack-dev libwebp-dev libx264-dev libx265-dev libxvidcore-dev libxml2-dev libzmq3-dev libzvbi-dev liblilv-dev libopenal-dev opencl-dev libjack-dev libavc1394-0 libavc1394-dev libiec61883-0 libiec61883-dev libbluray-dev libfdk-aac-dev libbs2b-dev libbs2b0 libdc1394-22 libdc1394-22-dev 

./configure --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-chromaprint --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdc1394 --enable-libdrm --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-nonfree --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-shared --enable-small --enable-version3 --extra-version=0ubuntu0.2 --incdir=/usr/include/x86_64-linux-gnu --libdir=/usr/lib/x86_64-linux-gnu --toolchain=hardened`

BTW: the libraries that are built before this are SHARED libraies, so to use the above script you must either change the configure/compile lines for fdk-aac and lame to both read:

  • fdk-aac: ./configure --prefix="$HOME/ffmpeg_build" --enable-shared
  • lame: ./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --enable-shared
    OR the last configure line to read:
  • ./configure --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-chromaprint --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdc1394 --enable-libdrm --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-nonfree --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-shared --enable-static --enable-small --enable-version3 --extra-version=0ubuntu0.2 --incdir=/usr/include/x86_64-linux-gnu --libdir=/usr/lib/x86_64-linux-gnu --toolchain=hardened

BTW Also get rid of the final character at the end of the configure command line the "`" at the end it just messes things up...

i did as your instructions, but got error ffmpeg: error while loading shared libraries: libfdk-aac.so.2: cannot open shared object file: No such file or directory
can you write a complete bash file for this, thanks.

Copy link

ghost commented Mar 21, 2022

please make for support ffmpeg 5.0

@TalkLounge
Copy link

please make for support ffmpeg 5.0

Just use https://github.com/markus-perl/ffmpeg-build-script

@drscotthawley
Copy link

drscotthawley commented May 11, 2024

I'm getting ERROR: libfdk_aac not found after it runs through a bunch of ffmpeg-4.2.1 files:

...
ffmpeg-4.2.1/tests/checkasm/vf_nlmeans.c
ffmpeg-4.2.1/tests/tiny_psnr.c
ffmpeg-4.2.1/COPYING.LGPLv2.1
ffmpeg-4.2.1/README.md
ffmpeg-4.2.1/CONTRIBUTING.md
ERROR: libfdk_aac not found

I don't notice any prior errors or issues with the build process before that.
Any suggestions?
(e.g., if it's a package we need, how come it's not included in the apt-get line that installs the other packages?)

@rafaelbiriba
Copy link
Author

@drscotthawley this script is quite old and no longer maintained.

In any case, did you have libfdk_aac?
It seems you may be skipping the clone part from the libfdk_aac repository.

@CRC-Mismatch
Copy link

CRC-Mismatch commented Jun 4, 2024

@rafaelbiriba this happens if you run the script without root permissions in a copy-paste multi-line command (at least in my zsh setup it did), since for multi-line commands it behaves as if split by ; and doesn't quit at the first failure...

For that, I'd recommend adding a set -e before everything else, since that should make most current shells quit after the first failed command (but that would still lead to problems with the mkdir commands when trying again after the first attempt).

About the problem @drscotthawley mentions, I think I faced it myself here... I'm not one to vouch for sudo usage "for everyone", but I would certainly recommend (in this specific case) to prefix all apt-get, make install and cp ffmpeg /usr/bin/ commands with sudo if one's willing to try it without root access, since (together with the aforementioned problem) the script tries to move on with undefined results even if any of the dependencies' installations fails...

But I'd guess the right way forward would be to work on a CMake (or something alike) script, that handles dependencies Git (sub)modules cloning (compilation and installation, if required) altogether, also properly handling errors (and by saying that, I think I know why you left this gist as-was 😏 )

@rafaelbiriba
Copy link
Author

@CRC-Mismatch thanks for the detailed analysis.
This script was originally intended to be used for myself, I used a couple of times in 2019 and has been deprecated by me since then.
Feel free to take over and make a smarter version out of it. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment