FFmpeg is a library of tools used for processing video and audio files. You can do a lot of things with it, such as encode videos or transcode audio to different formats, to name a few. In this guide, we'll show you how to install it on Ubuntu 20.04 Focal Fossa. There are two options for doing so, either from Ubuntu's software repository or compiling the latest version directly from source. We'll show you both methods below.In this tutorial you will learn:
- How to install FFmpeg from Ubuntu software repository
- How to install latest FFmpeg compiled from source
|Category||Requirements, Conventions or Software Version Used|
|System||Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa|
|Other||Privileged access to your Linux system as root or via the |
|Conventions|| # - requires given linux commands to be executed with root privileges either directly as a root user or by use of |
Install FFmpeg from Ubuntu repository
The fastest and easiest method for installing FFmpeg on Ubuntu is to use the
apt command to download it from Ubuntu's software repository. To do so, open a terminal and type the two following commands:
$ sudo apt update $ sudo apt install ffmpeg
When the process completes, FFmpeg should now be installed on your system. You can verify that it's installed and check the version number with this command:
$ ffmpeg -version
You can use the following commands to see all of the available encoders and decoders available through FFmpeg:
$ ffmpeg -encoders $ ffmpeg -decoders
Install latest FFmpeg from source
This next method of installing FFmpeg will give you the absolute latest version of it. If you need access to new features that haven't made it to the mainstream release yet, this is the method you'll want to use.
In order to compile FFmpeg, we're going to need a few packages already installed on our system. Install the necessary prerequisites with the following two commands in terminal:
$ sudo apt update $ sudo apt install libopus-dev libmp3lame-dev libfdk-aac-dev libvpx-dev libx264-dev yasm libass-dev libtheora-dev libvorbis-dev mercurial cmake build-essential
We will also need the
libx265-dev development library. However, it's best to compile this library from source as the version available in the Ubuntu repository may not be on par with the version that the latest FFmpeg requires.
Execute the following commands in terminal to download and compile the
libx265-dev package from source.
$ mkdir ~/ffmpeg; cd ~/ffmpeg $ hg clone https://bitbucket.org/multicoreware/x265 $ cd x265/build/linux $ PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source && PATH="$HOME/bin:$PATH" $ sudo make && sudo make install
You'll get a lot of output in your terminal, so keep an eye out for error messages. Once it finishes compiling, we can move on to installing FFmpeg.
Compile and install latest FFmpeg
Now that the prerequisites are satisfied, we can download the latest FFmpeg source code for installation. These commands will create a new directory (if it doesn't already exist) and then download the latest FFmpeg snapshot to said directory and extract the content from the tarball:
$ if [ -d ~/ffmpeg ]; then cd ~/ffmpeg; else mkdir ~/ffmpeg && cd ~/ffmpeg; fi $ wget -O- http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 | tar xj
Navigate to the newly extracted
$ cd ~/ffmpeg/ffmpeg
Next, copy and paste the following code into your terminal window and press enter on your keyboard. This will compile and install the FFmpeg code that we just downloaded. This process could take a while to finish, so be patient.
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" \ --extra-libs="-lpthread -lm" \ --bindir="$HOME/bin" \ --enable-gpl \ --enable-libass \ --enable-libfdk-aac \ --enable-libfreetype \ --enable-libmp3lame \ --enable-libopus \ --enable-libtheora \ --enable-libvorbis \ --enable-libvpx \ --enable-libx264 \ --enable-libx265 \ --enable-nonfree && \ PATH="$HOME/bin:$PATH" sudo make && sudo make install
Once the installation has completed, you can check to verify FFmpeg was installed successfully and view the version number:
$ ffmpeg -version
For additional information about updating or removing your FFmpeg installation, check out the official compilation guide.
FFmpeg is a vast and powerful collection of video and audio processing tools. Once you know the command syntax, you can use it to manipulate video and audio files in basically any way that you can imagine. See the official documentation at FFmpeg's website to see everything it can do.
In this article, we saw how to install FFmpeg using two different methods on Ubuntu 20.04 Focal Fossa. Whether you are looking for the quick and painless install from Ubuntu's repository or you need the latest version compiled from source, we've shown you how to get the appropriate version on your Ubuntu system.