Compile FFmpeg with libfdk_aac
Asked Answered
N

3

14

I been reading on how to convert mp3 to m4a, and found that I must compile FFmpeg if I'll use the AAC encoder, libfdk_aac.

But reading FFmpeg guide on how to compile FFmpeg with libfdk_aac makes no sense for a beginner like me.

To use libfdk_aac the encoding guide says:

Requires ffmpeg to be configured with --enable-libfdk_aac --enable-nonfree.

Where do I put those flags?

Do I put it here somewhere?:

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
make install
make distclean

Or maybe here somewhere?

cd ~/ffmpeg_sources
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
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-libass --enable-libfdk-aac \
  --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx \
  --enable-libx264 --enable-nonfree --enable-x11grab
make
make install
make distclean
hash -r

If I'm reading the compile guide right I guess that these two chunks of code is what I need to compile FFmpeg.

I'm using Ubuntu server 12.4

UPDATE

After upgrading my system to Ubuntu 16.04 I had to install ffmpeg again. I still needed libfdk-aac. Fortunately there's a good step-by-step guide at http://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu on how to compile ffmpeg.

I thought I would share how to compile if just interested in compiling ffmpeg with libfdk-aac and libmp3lame.

If you haven't already a bin in home directory:

mkdir ~/bin 

Install dependencies. Didn't need the non-server packages:

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libtheora-dev libtool libvorbis-dev pkg-config texinfo zlib1g-dev 

Then install the encoders. Had to install yasm as well, otherwise I got errors when compiling.

sudo apt-get install libfdk-aac-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install yasm

Then compile ffmpeg with needed flags

cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--bindir="$HOME/bin" \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libtheora \
--enable-libvorbis \
--enable-libmp3lame \
--enable-nonfree \
--enable-gpl
PATH="$HOME/bin:$PATH" make
make install
make distclean
hash -r
Neoterize answered 11/9, 2013 at 16:18 Comment(0)
I
8

Requires ffmpeg to be configured with --enable-libfdk_aac --enable-nonfree.

These instructions are referring to the ffmpeg configure, not fdk-aac configure. In addition to the FFmpeg and AAC Encoding guide, I assume you are also following the Compile FFmpeg on Ubuntu, Debian, or Mint guide. This guide already includes everything you need to gain support for libfdk_aac in ffmpeg because --enable-libfdk_aac and --enable-nonfree are already present in the ./configure line for ffmpeg.

All you need to do is successfully copy and paste each code box.

Indiscrete answered 11/9, 2013 at 18:4 Comment(7)
I'm trying to configure ffmpeg with --enable-nonfree and --enable-libfdk_aac like this: ./configure --enable-nonfree --enable-libfdk_aac but it gives me a warning saying that they're unrecognized options?Sharronsharyl
I followed this guide to install FFMPEG on a OS X jungels.net/articles/ffmpeg-howto.html I just realized that I grabbed the config.log from the LAME folder so I'm actually not sure where to find the one from FFMPEG?Sharronsharyl
@Luke That guide is terribly outdated. See Compile FFmpeg on OS X.Indiscrete
ok here's the actual config.log for FFMPEG I figured out where I installed it — pastebin.com/4D5C37X3Sharronsharyl
@Luke I see no obvious errors (but I don't know what I'm supposed to be looking for here), but it doesn't look like it came from the guide I linked to.Indiscrete
alright I installed FFMPEG following the guide you linked but I can't seem to find where it installedSharronsharyl
Thank you it solved my problem of building ffmpeg as static binary.Rosenberg
K
4

I wrote a guide on the whole process of installing FFmpeg from source. It also includes FDKAAC and other major codecs as well. Here is the specific part from the script:

git clone --depth 1 https://github.com/mstorsjo/fdk-aac &&
    pushd fdk-aac &&
    autoreconf -fiv &&
    ./configure --prefix="$USR_LOCAL_PREFIX" &&
    make -j $CPUS &&
    make install
popd

The whole guide along with the process https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source

Disclaimer: I am the author of this guide.

Knotting answered 27/9, 2023 at 14:22 Comment(0)
V
0

I found myself here trying to figure out how to compile ffmpeg with libfdk-aac on an old Raspberry Pi Model B+ V1.2 (Linux 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux).

While the instructions here did work (it compiled an ffmpeg binary successfully - although it took hours!), the binary failed to run (it crashes with “Illegal instruction”). Running in gdb showed more detail on the crash:

Program received signal SIGILL, Illegal instruction.
0xb6c884d0 in ?? () from /lib/arm-linux-gnueabihf/libmp3lame.so.0

I did finally find a solution: a pre-compiled static binary (ffmpeg-raspbian-armv6l.tar.gz) found here: https://github.com/homebridge/ffmpeg-for-homebridge/releases/tag/v0.1.0

If you (as root) copy that file to / and unpack it (tar xzf ffmpeg-raspbian-armv6l.tar.gz), it installs into /usr/local/bin/ffmpeg

This is the resulting output from running 'ffmpeg' after that:

ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
  configuration: --pkgconfigdir=/build/workspace/lib/pkgconfig --prefix=/build/workspace --pkg-config-flags=--static --extra-cflags=-I/build/workspace/include --extra-ldflags=-L/build/workspace/lib --extra-libs='-lpthread -lm' --enable-static --disable-debug --disable-shared --disable-ffplay --disable-doc --enable-openssl --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-runtime-cpudetect --enable-libfdk-aac --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-libspeex --enable-demuxer=rtsp --enable-omx-rpi --enable-mmal --enable-indev=alsa --enable-outdev=alsa
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

Hopefully this is useful to anyone else still persisting with the old v1 Raspberry Pi!

Valuation answered 26/3 at 21:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.