Skip to content

FFMPEG Compilation from Source

George Stoyanov edited this page Aug 23, 2017 · 3 revisions

FFMPEG Compilation Guide

Prerequisites

Installation of the required packages for the compilation and some additional libraries for FFMPEG:

sudo apt-get update
sudo apt-get install \
autoconf \
automake \
build-essential \
libopenjpeg5 \
fonts-dejavu-core \
fontconfig-config \
i965-va-driver \
git \
libtool \
pkg-config \
texinfo \
nasm \
yasm \
libass-dev \
mesa-vdpau-drivers \
checkinstall \
zlib1g-dev \
libxvidcore-dev \
libfontconfig1 \
cmake \
libsdl2-dev \
libopenjpeg-dev \
ladspa-sdk \
libsoxr-dev \
libschroedinger-dev \
libspeex-dev -y

Note: Desktop users can install the ffplay and x11grab dependencies: libsdl1.2-dev libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev.

And a full list of the packages which I am installing from source:

Video

  1. Kvazaar is an open-source HEVC encoder developed from scratch in C and licensed under LGPLv2.1
  2. Dirac is an open and royalty-free video compression format, specification and system developed by BBC Research & Development. Schrödinger and dirac-research (formerly just called "Dirac") are open and royalty-free software implementations (video codecs) of Dirac. Dirac format aims to provide high-quality video compression for Ultra HDTV and beyond, and as such competes with existing formats such as H.264 and VC-1.
  3. OpenJPEG is an open-source JPEG 2000 codec written in C language. It has been developed in order to promote the use of JPEG 2000, a still-image compression standard from the Joint Photographic Experts Group (JPEG). Since may 2015, it is officially recognized by ISO/IEC and ITU-T as a JPEG 2000 Reference Software.
  4. Theora is a free lossy video compression format. It is developed by the Xiph.Org Foundation and distributed without licensing fees alongside their other free and open media projects, including the Vorbis audio format and the Ogg container.
  5. libvpx is a free software video codec library from Google and the Alliance for Open Media (AOMedia). It serves as the reference software implementation for the video coding formats VP8 and VP9, and for AV1 a special fork named libaom that was stripped of backwards compatibility.
  6. x264 is a free software library developed by VideoLAN for encoding video streams into the H.264/MPEG-4 AVC format. It is released under the terms of the GNU General Public License.
  7. x265 is a library for encoding video into the High Efficiency Video Coding (HEVC/H.265) video compression format that was developed and standardized by the ISO/IEC MPEG and ITU-T VCEG. x265 is offered under either version 2 of the GNU General Public License (GPL) or a commercial license, similar to the x264 project. Judged by the objective quality metric VQM in 2015, x265 delivered video quality on par with the reference encoder of the royalty-free VP9 format that competes with HEVC. A codec comparison from 2015 found x265 to be a leading HEVC implementation measured by SSIM metric.
  8. OpenH264 is a free software library for real-time encoding and decoding video streams in the H.264/MPEG-4 AVC format. It is released under the terms of the Simplified BSD License.

Audio

  1. FDK-AAC is a standalone library of the Fraunhofer FDK AAC code. Fraunhofer FDK AAC is an open-source software library for encoding and decoding Advanced Audio Coding (AAC) format audio, developed by Fraunhofer IIS. It supports several Audio Object Types including MPEG-2 and MPEG-4 AAC LC, HE-AAC (AAC LC + SBR), HE-AACv2 (LC + SBR + PS) as well AAC-LD (low delay) and AAC-ELD (enhanced low delay) for real-time communication. The encoding library supports sample rates up to 96 kHz and up to eight channels (7.1 surround)
  2. MP3LAME is a high quality MPEG Audio Layer III (MP3) encoder licensed under the LGPL.
  3. Opus is a lossy audio coding format developed by the Xiph.Org Foundation and standardized by the Internet Engineering Task Force, designed to efficiently code speech and general audio in a single format, while remaining low-latency enough for real-time interactive communication and low-complexity enough for low-end ARM3 processors. Opus replaces both Vorbis and Speex for new applications, and several blind listening tests have ranked it higher-quality than any other standard audio format at any given bitrate until transparency is reached, including MP3, AAC, and HE-AAC.
  4. Vorbis is a free and open-source software project headed by the Xiph.Org Foundation. The project produces an audio coding format and software reference encoder/decoder (codec) for lossy audio compression. Vorbis is most commonly used in conjunction with the Ogg container format[7] and it is therefore often referred to as Ogg Vorbis.

Containers

  1. WebM is an open, royalty-free, media file format designed for the web. WebM defines the file container structure, video and audio formats. WebM files consist of video streams compressed with the VP8 or VP9 video codecs and audio streams compressed with the Vorbis or Opus audio codecs.
  2. Ogg is a free, open container format maintained by the Xiph.Org Foundation. The creators of the Ogg format state that it is unrestricted by software patents and is designed to provide for efficient streaming and manipulation of high quality digital multimedia. Its name is derived from "ogging", jargon from the computer game Netrek.

FFMPEG Compilation

I have created couple of scripts which when run will compile and install ffmpeg and couple of other video/audio encoders from source. The main script is called compilation.sh and it is calling all other required scripts. When run it is installing all required packages either from source or from the ubuntu repositories. It is also fixing the hostname error which is present when you create a new VM with Ubuntu 16.04. The full list of all the scripts could be found here.

The commands for compiling ffmpeg are:

git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure \
--enable-gpl \
--enable-ladspa \
--enable-libpulse \
--enable-libschroedinger \
--enable-libsoxr \
--enable-libspeex \
--enable-avfilter \
--enable-avresample \
--enable-postproc \
--enable-pthreads \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
--enable-libkvazaar \
--disable-ffplay \
--enable-libopenjpeg \
--enable-libwebp \
--enable-libxvid \
--enable-libvidstab \
--enable-libopenh264 
--enable-zlib
make
sudo make install
make distclean

Note: See ./configure --help for more options.

References:

FFMPEG Generic Compilation Guide
FFMPEG Ubuntu Compilation Guide
Kvazaar - Open Source HEVC Encoding Library GitHub Project
Kvazaar Official Webpage