Posted in Raspberry Pi

Compile FFMPEG for Raspberry Pi 3

Get FFMPEG source code:

$ git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
$ cd ffmpeg
$ mkdir dependencies
$ cd dependencies/
$ mkdir output

Compile libx264

$ git clone http://git.videolan.org/git/x264.git
$ cd x264/
$ ./configure --enable-static --prefix=/home/pi/ffmpeg/dependencies/output/
$ make -j4     (NOTE: this utilizes 4 threads/cores and is not applicable for Raspberry Pi Zero)
$ make install
$ cd ..

Compile ALSA

$ wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.1.1.tar.bz2
$ tar xjf alsa-lib-1.1.1.tar.bz2
$ cd alsa-lib-1.1.1/
$ ./configure --prefix=/home/pi/ffmpeg/dependencies/output
$ make -j4
$ make install
$ cd ..

Compile FDK-AAC

Installing build tools:

$ sudo apt-get install pkg-config autoconf automake libtool

Compile fdk-aac

$ git clone https://github.com/mstorsjo/fdk-aac.git
$ cd fdk-aac
$ ./autogen.sh
$ ./configure --enable-shared --enable-static
$ make -j4
$ sudo make install
$ sudo ldconfig
$ cd ..

Compile FFMPEG

$ cd ..
$ ./configure --prefix=/home/pi/ffmpeg/dependencies/output
--enable-gpl --enable-libx264 --enable-nonfree --enable-libfdk_aac
--enable-omx --enable-omx-rpi
--extra-cflags="-I/home/pi/ffmpeg/dependencies/output/include"
--extra-ldflags="-L/home/pi/ffmpeg/dependencies/output/lib"
--extra-libs="-lx264 -lpthread -lm -ldl"
$ make -j4
$ make install

--enable-omx --enable-omx-rpi : This enables ffmpeg runtime hardware encoding

Advertisements

One thought on “Compile FFMPEG for Raspberry Pi 3

  1. The above process work like a charm!
    If you happened to be getting “ERROR: OMX_Core.h not found” you just need to source missing headers. You can get them from the default repo by executing below command:

    sudo apt-get install libomxil-bellagio-dev

    At the end, you may also want to validate your compilation by running:

    ./ffmpeg -encoders | grep h264_omx

    If all went well, you should see something along the lines:

    V….. h264_omx OpenMAX IL H.264 video encoder (codec h264)

    Many Thanks for a solid guide which even consider in which directory user currently is!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s