FFmpeg is a free, open-source multimedia framework that can decode and encode just about any file type. With its ability to transcode almost all media files created on different platforms, it’s no wonder why this program has become so popular among those looking for versatility in their video editing software!
In the following tutorial, you will learn how to install FFmpeg on Linux Mint 21 release series using the command line terminal and the FFmpeg PPA by Rob Savory to get the latest up-to-date version for your desktop.
Table of Contents
Update Linux Mint
First, update your system to avoid any conflicts.
sudo apt update && sudo apt upgrade
Install Required Packages
Before you continue, run the following command to install the following packages. Many of these will likely be installed; if unsure, run the command. These are prevalent packages.
sudo apt install dirmngr ca-certificates software-properties-common gnupg gnupg2 apt-transport-https -y
Import FFmpeg PPA
The best method for installing FFmpeg is to install the FFmpeg PPA by Rob Savoury, whose PPA repositories are well known for supporting multiple software spread across various versions of Ubuntu and its family distributions. The current version is FFmpeg 5, but the tutorial requires both to be imported.
The first task is to import the GPG key needed for all the repositories.
If you have issues importing the GPG key, please see the end section on GPG troubleshooting at the end of the article.
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/rob-savoury.gpg --keyserver keyserver.ubuntu.com --recv-keys E996735927E427A733BB653E374C7797FB006459
The FFmpeg 5 requires packages from the existing 4 FFmpeg PPA, import this first.
echo 'deb [signed-by=/usr/share/keyrings/rob-savoury.gpg] https://ppa.launchpadcontent.net/savoury1/ffmpeg4/ubuntu jammy main' | sudo tee -a /etc/apt/sources.list.d/ffmpeg-4-rob-savoury.list
Next, import FFmpeg 5 PPA.
echo 'deb [signed-by=/usr/share/keyrings/rob-savoury.gpg] https://ppa.launchpadcontent.net/savoury1/ffmpeg5/ubuntu jammy main' | sudo tee -a /etc/apt/sources.list.d/ffmpeg-5-rob-savoury.list
Once imported, run an APT update to reflect the new addition to your sources list.
sudo apt update
Next, quite a few upgrades are available for the dependencies required. Before proceeding any further, run a quick upgrade.
sudo apt upgrade
Install FFmpeg
With the PPA repository now added, run the following command to install FFmpeg.
sudo apt install ffmpeg -y
Next, verify the installation with the following terminal command.
ffmpeg -version
Example output:
If you want to see which FFmpeg’s decoders and encoders are available, type the following commands.
FFmpeg encoders:
ffmpeg -encoders
FFmpeg decoders:
ffmpeg -decoders
More information can be found using the following commands.
FFmpeg formats:
ffmpeg -formats
FFmpeg codecs:
ffmpeg -codecs
FFmpeg bitstream filters:
ffmpeg -bsfs
FFmpeg protocols:
ffmpeg -protocols
FFmpeg filters:
ffmpeg -filters
FFmpeg pixel formats
ffmpeg -pix_fmts
FFmpeg channel layouts:
ffmpeg -layouts
FFmpeg audio sample formats:
ffmpeg -sample_fmts
FFmpeg Basic Commands
Below are some basic commands for using FFmpeg. I would recommend visiting the official documentation to see a complete list of examples, as it is pretty extensive.
The primary command usage syntax for FFmpeg is below as an example.
ffmpeg [global_options] {[input_file_options] -i input_url} …{[output_file_options] output_url} …
Note that you will need to use these commands on each new file. There is no saving technique to date.
FFmpeg Conversion Example
To convert audio and video files with FFmpeg, you do not need to specify your command’s input and output formats. Instead, the input file format is auto-detected, and the output is given an output formulated from the file extension.
Convert a video file from mp4 to WebM.
ffmpeg -i existingfile.mp4 newfile.webm
Alternatively, it can also include more output files than just 1.
ffmpeg -i existingfile.wav newfile.mp3 newfile.ogg
Remember to check the list of supported formats using the following command:
ffmpeg -formats
FFmpeg Extract Audio from Video Example
If you want to extract the audio from a video file, this is done with the “-vn“ input.
ffmpeg -i video.mp4 -vn audio.mp3
Note that this will convert the audio to the current bit rate of the original video file.
If you want to specify a new rate, enter the following example command.
ffmpeg -i video.mp4 -vn -ab 128k audio.mp3
Some examples of the most common bit rates are 96k, 128k, 192k, 256k, and 320k.
How to Fix Broken GPG Import
Users that have installed Linux Mint for the first time or have not imported a GPG key before using the command line terminal will often have issues importing GPG keys from LaunchPAD PPAs due to the directories not being created. This is an easy fix. Use the following command that will, in turn, generate the directories.
sudo gpg --list-keys
Example output:
As above, the necessary directories have been created. This can be skipped, and use the following GPG import command below. If you have any issues with directories missing for this and any other PPA GPG key in the future, just run the above command.
Comments and Conclusion
FFmpeg is a fantastic multimedia framework. To learn more about what FFmpeg can do, visiting their documentation page will help you with your goals.