How to install and use FFmpeg on Ubuntu 18.04

s2 0

FFmpeg is a free, open source command line tool for transcoding multimedia files. It contains a number of shared audio and video libraries such as libavcodec, libavformat, and libavutil. With FFmpeg you can convert between different video and audio formats, set sample rates and resize videos.

This tutorial covers the steps required to install FFmpeg on Ubuntu 18.04. We’ll show you how to install the stable version of the distribution and the latest version of FFmpeg.

The same instructions apply to Ubuntu 16.04 and all Ubuntu-based distributions, including Linux Mint and Elementary OS.

requirements

You must be logged in as root or user with sudo privileges to complete the installation.

Installation of FFmpeg 3.x on Ubuntu

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 contained in the repositories may lag behind the latest version of FFmpeg.

At the time of this writing, the most current version of FFmpeg is available in the Ubuntu 18.04 repositories 3.4.4.

To install FFmpeg 3.x on Ubuntu 18.04, do the following:

  1. Start by updating the package list:

    sudo apt update
  2. Next, install FFmpeg by typing the following command:

    sudo apt install ffmpeg
  3. To verify that the package is installed correctly, use the ffmpeg -version Command that outputs 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 of FFmpeg’s available encoders and decoders, enter:

    ffmpeg -encodersffmpeg -decoders

That’s it. FFmpeg 3 is now installed on your system and you can use it.

Installation of FFmpeg 4.x on Ubuntu

FFmpeg version 4.x adds a number of new filters, encoders and decoders.

The easiest way to install FFmpeg 4.x on Ubuntu 18.04 is with the snappy
Packaging system.

Open your terminal by pressing Ctrl+Alt+T and install the FFmpeg snap package by typing:

sudo snap install ffmpeg

The download may take some time depending on the speed of your connection.

When you’re done, check the FFmpeg installation by running the ffmpeg -version Command:

ffmpeg -version

The output should look something like this:

ffmpeg version n4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

That’s it! FFmpeg has been installed on your system and is ready for use.

FFmpeg 4 is also with the Rob Savor’s PPA
.

FFmpeg examples

In this section, we’ll look at some basic examples of how to use the ffmpeg Utility.

Basic conversion

When converting audio and video files with ffmpeg, you do not need to specify the input and output formats. The input file format is detected automatically 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

Specify codecs

When converting files, you can specify the codecs that you will use with the -c Opportunity. The codec can be the name of any supported decoder / encoder or a special value copy that just copies the input stream.

  • Convert a video file from mp4 to webm with 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

diploma

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 your video and audio files.

If you run into any problem or have any feedback, please leave a comment below.