How To Use and Install FFmpeg Ubuntu 22.04

Updated: July 16, 2022

A set of tools for managing multimedia files is called FFmpeg, which is free and open-source. Some features are offered by FFmpeg, including decoding, transcoding, changing the resolution of videos, and more.

It is a multi-platform framework that runs effectively on Windows, Linux, and macOS. In this tutorial, I will help you install FFmpeg Ubuntu 22.04. Additionally, you will discover how to use the ffmpeg command-line tool to modify video resolution, specify codecs, and more.

Prerequisites to install FFmpeg Ubuntu

  • Operating System: In this tutorial, I will use Ubuntu 22.04. This tutorial also works on older Ubuntu versions.
  • Privileges: Check to see if sudo permissions are enabled on your Ubuntu.

Install FFmpeg Ubuntu 22.04

This tutorial will show you two ways to install it on Ubuntu. Each of them has different cons and pros. Choose the method that you think is easier for you and follow it.

Using Ubuntu APT

The fact that APT, or Advanced Package Tool, is pre-installed on every Ubuntu version makes me believe that it is the simplest way to install FFmpeg Ubuntu 22.04. It has FFmpeg packages, so you can install it on Ubuntu by executing the following straightforward commands with sudo permission:

sudo apt update
sudo apt install ffmpeg

You must execute this command to confirm the installation. If the FFmpeg Ubuntu versions are displayed in the terminal, your installation of FFmpeg Ubuntu was successful, and it is now ready for use. If not, you must review the commands you ran or choose the next step.

ffmpeg -version

The output should look like this:

Output when you install FFmpeg using APT

Using Snap

Installing FFmpeg by using Snap is also an easy method for you. By default, Snap isn’t installed on Ubuntu, but it’s a must-have application you need. It contains many packages, such as Pycharm, IntelliJ IDEA, Postman, and more.

Open your terminal by pressing Ctrl+Alt+T and enter the following command to install FFmpeg Ubuntu via Snap:

sudo snap install ffmpeg

Depending on the speed of your connection, the download can take some time. When finished, check the FFmpeg installation by executing this command in your terminal.

ffmpeg -version

The output should look like this:

Output when you use Snap to install FFmpeg

When these lines are printed on your terminal, it means that FFmpeg Ubuntu is installed on your Linux OS. You can now use it.

Using FFmpeg Ubuntu

As I indicated in the header, FFmpeg gives us access to a wide range of functions. We’ll look at some simple ffmpeg usage examples in this section.

Specifying codecs

With the -c flag option, you can choose the codecs to use. The codec can be the name of any decoder or encoder that is supported or it can be a unique value copy that just copies the input stream.

  • Using the libvorbis audio codec and libvpx video codec, convert an mp4 video file to webm:
ffmpeg -i input-media.webm -c:v libvpx -c:a libvorbis output-media.mp4

Change Video File Resolution

ffmpeg also allows us to change the video resolution. If you want to change the video resolution to 1920x1080 you will run the following command.

ffmpeg -i input-video.mp4 -filter:v scale=1920:1080 -c:a copy output-video.mp4

After resizing the video, you can now play it in VLC Ubuntu. It supports not only video but also audio and more.

Changing The Formats Of Video Files

You don’t need to specify the input and output formats when using ffmpeg to convert audio and video files. The output format is chosen from the output file extension that you specified, and the input file extension is automatically detected.

  • Converting video file from avi to mkv
ffmpeg -i input-video.avi output-video.mkv
  • Converting audio file from wav to mp3
ffmpeg input-audio.wav output-audio.mp3

Uninstall FFmpeg Ubuntu

If you don’t want to use this package anymore, you can consider uninstalling it on your Ubuntu. You need to execute the following commands to uninstall it.

  • If you installed FFmpeg by using APT:
sudo apt remove ffmpeg
  • If you used Snap to install FFmpeg:
sudo snap remove ffmpeg

Conclusion

You now know how to install FFmpeg Ubuntu 22.04 and uninstall it and use some simple samples. You can also visit its official documentation for more examples. If you are in need, you can comment below this tutorial, I will help you if I can.