David Bosch - Mar 5th, 2022
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 should work for most of the Linux distributions, including Ubuntu, CentOS, Debian, etc. - Install FFMPEG on Ubuntu 18.04, 20.04 and 22.04
- Install FFMPEG on CentOS
- Install FFMPEG using yum
- Install FFMPEG using apt
- Install FFMPEG using snap
- Install FFMPEG on a VPS
- Install FFMPEG on a Linux shared hosting
- Install FFMPEG on Amazon Linux
- Install FFMPEG without root or sudo privileges
- Install FFMPEG on Ubuntu 14.04
- FAQs
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:
- i686: It's a 32-bit architecture based on Intel or AMD
- x86_64 or amd64: It's a 64-bit architecture based on Intel or AMD
- arm64 or aarch64: It's an 64-bit architecture based on ARM
Installation steps
-
STEP 1: Download the correct static build
Now you know what is your architecture, you can download the proper static build from John van Sickle's website:
i686:
wget -O ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-i686-static.tar.xz
x86_64 or amd64:
wget -O ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
arm64 or aarch64:
wget -O ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-arm64-static.tar.xz
This command will create a
ffmpeg.tar.xz
file in your working directory. -
STEP 2: Unzip and unpack the build
To unzip and unpack the downloaded file, use this command:
tar xvf ffmpeg.tar.xz
This will create a new directory with this naming convention:
ffmpeg-git-[YYYYMMDD]-[platform]-static
Where [YYYYMMDD] is the date of the latest stable version, and [platform] is your selected platform (i686, amd64, arm64), for example:
ffmpeg-git-20220302-amd64-static
Inside this new directory you have
ffmpeg
andffprobe
. -
STEP 3: Check installation
To confirm that the installation works, move to the recent created directory and run:
./ffmpeg -version
-
STEP 4: Make ffmpeg available everywhere
This step is optional, but recommended. If you want to use
ffmpeg
from any directory, you must move the binary into a directory included in the PATH environment variable.You can check what folders are in your PATH with this command:
echo $PATH
For example, you can move
ffmpeg
andffprobe
to/usr/bin
and make them globally available. To do this you will needsudo
privileges.sudo mv ffmpeg /usr/bin
sudo mv ffprobe /usr/bin
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.
-
STEP 1: Update the apt packages list
To make sure your
apt
is up to date with the latest packages, first update it:sudo apt update
-
STEP 2: Install the ffmpeg package
Now, use the regular
install
command:sudo apt install ffmpeg
-
STEP 3: Test the installation
You can check that installation was successful with this command:
ffmpeg -version
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:
-
Download and install a static build
You can find all steps for installing FFMPEG as a static build above in this page. This is my recommended option.
-
Use a third-party Yum repository
The issue with this option is that the third-party repositories are not always updated with the latest versions and requires additional configuration. See the instructions below if you want to use yum.
-
Compile the source files yourself
As an open-source software, you always have the chance to compile the source files what it's sometimes a little overengineered for most of users.
If you want to compile FFMPEG, you can find how here.
Install FFMPEG using Yum
If you want to install FFMPEG using yum
, you need to use a third-party repository like
RPM Fusion repository.
-
STEP 1: Enable EPEL software repository in your system
sudo yum install epel-release
-
STEP 2: Enable RPM Fusion repository
sudo yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
-
STEP 3: Install the ffmpeg package
sudo yum install ffmpeg ffmpeg-devel
-
STEP 4: Verify the installation
ffmpeg -version
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:
-
Upgrade to a virtual private server or a dedicated server
You can always upgrade your hosting and use dedicated servers, either virtual (VPS) or dedicated hardware.
However, depending on the workload FFMPEG has to take on, the costs of maintaining dedicated resources for video encoding can be very expensive.
If this is the case, you may want to rethink your technical approach to the project and replace FFMPEG with a cloud-based video editing service that will almost certainly be much cheaper or even free.
-
Use a cloud-base editing service
If server costs are not sustainable for your project or if you simply don't want to manage the complexity of FFMPEG, your best option is a cloud-based video editing service.
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):
-
STEP 1: Add the mc3man PPA
sudo add-apt-repository ppa:mc3man/trusty-media
-
STEP 2: Update the package list
Use these two commands:
sudo apt-get update
sudo apt-get dist-upgrade
-
STEP 3: Install the FFMPEG package
sudo apt-get install ffmpeg
-
STEP 4: Check the installation
ffmpeg -version
Self-evaluation
Published on March 5th, 2022