How To

Install FFmpeg on Ubuntu 18.04: apt, Snap, and Usage Examples

FFmpeg is a free, open-source command-line tool for working with multimedia files. It can convert video and audio between formats, trim clips, resize video, extract audio tracks, and set sample rates. Under the hood it uses powerful shared libraries including libavcodeclibavformat, and libavutil.

It is also widely used as a backend for tools like HandBrake and media servers like Plex, and it powers many video processing pipelines on Linux servers.

This guide shows you how to install FFmpeg on Ubuntu 18.04 using two methods — the default Ubuntu repositories for a stable build, or the Snap package for the latest version. It also covers some practical conversion commands to get you started.

<strong>Prerequisite:</strong>&nbsp;You need sudo access.

Method 1: Install FFmpeg on Ubuntu Using apt

The simplest way to install FFmpeg is from the Ubuntu default repositories. This gives you FFmpeg 3.x, which is stable and works well for most common tasks.

Update your package list:

bashsudo apt update

Install FFmpeg:

bashsudo apt install ffmpeg

Verify the installation:

bashffmpeg -version

Output:

ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers

To see all supported encoders and decoders on your system:

bashffmpeg -encodersffmpeg -decoders

FFmpeg 3.x is now installed and ready to use.

Method 2: Install FFmpeg 4.x Using Snap

FFmpeg 4.x adds new filters, encoders, and decoders not available in version 3.x. The quickest way to get FFmpeg 4 on Ubuntu 18.04 is through the Snap package manager.

Install the FFmpeg Snap package:

bashsudo snap install ffmpeg

The download may take a few minutes depending on your connection speed.

Verify the installation:

bashffmpeg -version

Output:

ffmpeg version n4.1.4 Copyright (c) 2000-2019 the FFmpeg developers

FFmpeg 4.x is also available from Rob Savoury’s PPA if you prefer the apt method for this version. The Snap version is sandboxed, so for most desktop conversion tasks either method works equally well.

Convert Video and Audio Files

FFmpeg detects file formats automatically. You do not need to specify the input format. It reads the file and figures it out on its own. The output format is set by the file extension you provide.

Convert an MP4 video to WebM:

bashffmpeg -i input.mp4 output.webm

Convert an MP3 audio file to OGG:

bashffmpeg -i input.mp3 output.ogg

The -i flag marks the input file. The last argument is the output file name. You can also chain operations in a single command — for example, resize video during conversion by adding -vf scale=1280:720 to the command.

Specify Codecs for Conversion

For more control over the output quality and size, use the -c flag to set a specific codec. Use -c:v for video and -c:a for audio.

Convert an MP4 to WebM using the libvpx video codec and libvorbis audio codec:

bashffmpeg -i input.mp4 -c:v libvpx -c:a libvorbis output.webm

Convert an MP3 to OGG using the libopus codec for better compression at lower bitrates:

bashffmpeg -i input.mp3 -c:a libopus output.ogg

Use copy as the codec value to pass through the original stream without re-encoding. This is much faster and keeps the original quality unchanged.

FFmpeg is now installed and working on your Ubuntu 18.04 system. Use the apt version for quick setups and switch to the Snap version when you need newer codec support. Leave a comment below if you run into any conversion errors.

Cyber Defence

Recent Posts

Install Tomcat 9 on Ubuntu 18.04: Systemd Service Setup Guide

Apache Tomcat is an open-source Java application server that implements the Java Servlet, JavaServer Pages, and…

4 minutes ago

Change Timezone on Ubuntu 18.04: Command Line and GUI Methods

Setting the correct timezone on your Ubuntu machine is more important than it sounds. Your…

7 minutes ago

Install PrestaShop on Ubuntu 18.04 with Nginx and MySQL

PrestaShop is a free, open-source e-commerce platform built with PHP and MySQL. It comes with a…

22 minutes ago

Set Up SSH Keys on Ubuntu 18.04: Passwordless Login Guide

SSH keys give you a more secure and convenient way to connect to remote servers. Instead…

28 minutes ago

Set Up Nginx Server Blocks on Ubuntu 18.04: Host Multiple Sites

Nginx server blocks let you run more than one website on a single server. Each block…

23 hours ago

Install Tor Browser on Ubuntu 18.04: Anonymous Browsing Guide

Tor Browser is a modified version of Firefox that routes all your web traffic through the Tor…

23 hours ago