FFmpeg is a free and open source command line tool for transcoding multimedia files. It contains a set of shared audio and video libraries such as: libavcodec, libavformat, and libavutil. With this tool, you can convert between various video and audio formats, set sample rates and resize videos.
In this document will show you how to install a stable version and the latest version of FFmpeg. This instructions apply for any Ubuntu based distribution, including Linux Mint and Elementary OS.
In order to be able to add new repositories and install packages on your Ubuntu system, you must be logged in as a user with sudo
privileges.
In this section we will provide a step by step instructions about how to install FFmpeg version 4.x on Ubuntu.
The FFmpeg version 4.0 adds a number of new filters, encoders, and decoders. This version is available from the Jonathon F’s PPA.
The steps below describe how to install FFmpeg 4.x on Ubuntu 18.04:
- Start by adding the jonathonf/ffmpeg-4 PPA:
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
If you get an error message saying add-apt-repository command not found, install the software-properties-common package.
- Once the PPA is added to your system install the FFmpeg package by typing:
sudo apt install ffmpeg
- Verify the FFmpeg installation by running the ffmpeg -version command:
ffmpeg -version
- The output should look something like this:
ffmpeg version 4.0.3-1~18.04.york0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
FFmpeg 4 is now installed on your system and ready to be used.
In this section, we will look at some basic examples on how to use the ffmpeg utility.
When converting audio and video files with ffmpeg you do not have to specify the input and output formats. The input file format is auto detected and the output format is guessed from the file extension.
- Convert a video file from mp4 to webm:
ffmpeg -i input.mp4 output.webm
- Convert an audio file from mp3 to ogg:
ffmpeg -i input.mp3 output.ogg
When converting files you can specify the codecs you want to use with the -c option. The codec can be the name of any supported decoder/encoder or a special value copy which simply copies the input stream.
- Convert a video file from mp4 to webm using the libvpx video codec and libvorbis audio codec:
ffmpeg -i input.mp4 -c:v libvpx -c:a libvorbis output.webm
- Convert an audio file from mp3 to ogg encoded with the libopus codec.
ffmpeg -i input.mp3 -c:a libopus output.ogg
You have successfully installed FFmpeg on your Ubuntu 18.04. You can now visit the official FFmpeg Documentation page and learn how to use FFmpeg to convert and your video and audio files.
If you hit a problem or have feedback, leave a comment below.
The official Ubuntu repositories contain FFmpeg packages that can be installed with the apt package manager. This is the easiest way to install FFmpeg on Ubuntu, however the version included in the repositories may lag behind the latest version of FFmpeg.
At the time of writing this article, the current version of FFmpeg available in the Ubuntu 18.04 repositories is 3.4.4.
Perform the steps below to install FFmpeg 3.x on Ubuntu 18.04:
- Start by updating the packages list:
sudo apt update
- Next, install FFmpeg by typing the following command:
sudo apt install ffmpeg
To validate that the package is installed properly use the ffmpeg -version command which will print the FFmpeg version:
ffmpeg -version
The output should look something like this:
ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
To print all available FFmpeg’s encoders and decoders type:
ffmpeg -encoders
ffmpeg -decoders
That’s it. FFmpeg 3 is now installed on your system and you can start using it.