FFMPEG (what is ffmpeg?) is a popular tool to encode, transcode and convert multimedia files. It supports an extensive number of formats including AVI, MPEG, MP4, WEBM and more. FFMPEG is open source and free software licensed under the GNU General Public License.

FFMPEG is available for Mac OSX, Windows, Linux and many other platforms.

This chapter covers installing FFMPEG on Linux systems:

Install FFMPEG on Linux

This method works for any Linux distribution: Ubuntu, CentOS, Debian, Amazon Linux, AWS Lambdas, etc.

Some package managers may include FFMPEG but the latest versions are not always available. In other cases, FFMPEG is not included in the core repositories (like CentOS, for example) and require using third-party repositories that again, might not be updated to the latest versions.

As a general rule, installing FFMPEG from a static build ensures that you can control the version, the location of the binary and the pace of updates

What a static build is?

A static build is a compiled version of a program which has been statically linked against libraries (learn more). For FFMPEG, it means that the original source code, including its external libraries, have been compiled into one final and stand-alone binary with no external dependencies.

John van Sickle's website always hosts the static builds of the latest stable version for different platforms like amd64, i686 or arm64.

If you don't know what platform architecture you have in your machine, use this command:

uname -m

Based on the returned value, you know:

Installation steps

Install FFMPEG on Ubuntu 18.04, 20.04 and 22.04

Installing FFMPEG in Ubuntu is really straight forward, as it's supported by the apt package manager. You need sudo privileges to run the installation.

Uninstall FFMPEG on Ubuntu 18.04, 20.04 and 22.04

If you need to uninstall FFMPEG from your Ubuntu machine, you can use a simple:

sudo apt-get remove ffmpeg

But if you want to completely remove FFMPEG, its dependencies and data, you must use:

sudo apt-get -y autoremove --purge ffmpeg

Install FFMPEG on CentOS

CentOS is a very popular Linux distribution that unfortuntely does not include ffmpeg in their core repositories.

If you want to install FFMPEG on CentOS, you have a few options:

Install FFMPEG using Yum

If you want to install FFMPEG using yum, you need to use a third-party repository like RPM Fusion repository.

Install FFMPEG using apt

apt is a command-line utility for installing, updating, removing, and otherwise managing deb packages on Ubuntu, Debian, and related Linux distributions. Most of the apt commands must be run as a user with sudo privileges.

You can find the detailed steps for installing FFMPEG with apt in the Ubuntu section of this page.

Install FFMPEG using snap

Snapcraft.io (snap) defines itself as "the app store for Linux", and it's a package manager backed by Canonical.

If you already have snap installed in your system and you want to use it for installing FFMPEG, you can do it with a simple command:

sudo snap install ffmpeg

And then double check the installation with:

ffmpeg -version

Install FFMPEG on a VPS

A virtual private server (or VPS) is a virtual machine sold as a service by an Internet hosting service (learn more) and it's a common hosting option for many Internet projects.

Usually VPS vendors provide root privileges to admin the server instance, so you can follow any of the methods explained in this tutorial. What you need to confirm is what version of the operating system your VPS uses and what hardware architecture the VPS runs or emulates.

Check your VPS OS version and distro

You can confirm what operating system and what version your VPS server is using with a simple command:

uname -a

The ouput will identify your operating system and version, for example:

Linux ip-xxx-xx-xx-xx 5.4.0-1057-aws #60~18.04.1-Ubuntu SMP Thu Sep 9 20:38:09 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Check architecture

The uname -a will usually output the architecture identifier, but if this is not the case, or you want to double check, use this command:

uname -m

This should output the architecture identifier that in most cases match with: i686, x86_64 or arm64.

What's next?

Once you know the distro, version and architecture, you can follow any of the tutorials on this page. If not sure, I suggest installing FFMPEG from a static build.

Install FFMPEG on a Linux shared hosting

Installing FFMPEG on a shared server can be a little tricky and in some cases, completely impossible. The reason for this is that FFMPEG consumes a lot of CPU resources almost blocking other tasks, making other programs or services to stop responding.

At the end, even if it's not a shared hosting and you have a dedicated server, it's a bad idea to use the same server to run FFMPEG and serve a website.

FFMPEG should have it's own dedicated hardware, or as an alternative, you can use a cloud video service.

Most of the hosting providers will prevent users to install FFMPEG on shared machines because of the performance reasons detailed above. Your first option should be contacting your hosting provider and ask if FFMPEG is supported in your plan or if they offer alternatives.

What to do if FFMPEG is not supported in my shared hosting?

You have mainly two options:

Install FFMPEG on Amazon Linux

Amazon Linux is a Linux operating system from Amazon Web Services (AWS). It provides a security-focused, stable, and high-performance execution environment to develop and run cloud applications, and you can select it as the pre-installed OS in your EC2 instances.

Amazon Linux is the OS that AWS Lambda instaces use to run lambda functions.

You should first check what OS and version your instance is using with:

uname -v

And then, what architecture the OS runs on:

uname -m

With this information, scroll up to installing FFMPEG on Linux section of this page and follow the instructions.

Install FFMPEG without root or sudo privileges

As a rule of thumb, you should be able to install ffmpeg without sudo privileges, but this can depend if you are using a shared hosting service that has explicitly blocked the installation of software or packages.

If you are on a shared-hosting service, read the section above about the possible solutions you have.

If you are not on a shared-hosting, but you do not have root access to the machine, you will probably be able to install ffmpeg for your account but you won't be able to make it available for other users, including calling it from Apache or PHP.

My first advice would be to try to install FFMPEG as a static build as described at the beginning of this tutorial.

If this option doesn't work, I would probably recommend checking my suggestions for the shared-hosting systems, as you are probably in a very similar situation.

Install FFMPEG on Ubuntu 14.04

Why am I specifically covering the installation of FFMPEG on Ubuntu 14.04?

The reason is that Canonical decided to stop including FFMPEG in the core repositories on Ubuntu 14.04. FFMPEG was replaced by avconv from the libav project project.

Canonical reversed that decision on Ubuntu 15.04.

So, users who, for whatever reason, still use Ubuntu 14.04 and need to use FFMPEG must find a workaround.

This workaround involves installing a static build or using a PPA (Personal Package Archive):


Published on March 5th, 2022

David Bosch
David Bosch David is an experienced engineer, now collaborating with JSON2Video.