Google Cloud Compute Engine

How to Install and Use FFmpeg on Ubuntu 18.04

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

How to Install and Use FFmpeg on Ubuntu 18.04. FFmpeg is a great tool to record, convert and stream audio and video.

This tutorial covers the steps required to install FFmpeg on Ubuntu 18.04. We will use the ffmpeg command line tool to convert audio, add text to video and many more.

Not using Ubuntu 18.04? Choose a different OS:

Ubuntu 18.04 LTS

Debian 9

This setup instructions works on Ubuntu 16.04 and any Ubuntu based distribution, including Linux Mint and Elementary OS. This tutorial is tested on Google Cloud for automatic image and video processing.

Prerequisites

A Ubuntu system with sudo privileges.

If you are using Google Cloud you need to have some additional requirements fulfilled.

Install FFmpeg 4.x on Ubuntu

FFmpeg 4 is available from the Jonathon F’s PPA.

01. Start by adding the jonathonf/ffmpeg-4 PPA

sudo add-apt-repository ppa:jonathonf/ffmpeg-4

02. Now you can install FFmpeg with the following command.

sudo apt install ffmpeg

03. Verify the installation.

ffmpeg -version

The output will be something similar to this.

Output
ffmpeg version 4.1-1~16.04.york1 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609

Now, FFmpeg is installed successfully and ready to be used.

FFmpeg Examples

In this part, we will look at some basic examples to use the ffmpeg utility.

Basic conversion

While converting the audio and the video files with ffmpeg you don’t need to specify the input and output formats. The input file format is detected automatically and the output format is selected from the file extension.

Convert a video file from webm to mp4

ffmpeg -i input.webm output.mp4

Convert an audio file from ogg to mp3

ffmpeg input.ogg output.mp3

Specifying codecs

You can specify the codecs you want to use with the -c flag 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 webm to mp4 using the libvpx video codec and libvorbis audio codec

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

Convert an audio file from ogg to mp3 encoded with the libopus codec.

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

Conclusion

Now you have learned how to install FFmpeg on your Ubuntu system.

Thanks for your time. If you face any problem or any feedback, just leave a comment below.

3 Comments

  1. I have a server on compute engine. I installed ffmpeg successfully on it. i can run ffmpeg commands in the terminal successfully. But when i try to execute using the php exec function on my live website it throws an error

    ffmpeg: symbol lookup error: /lib/x86_64-linux-gnu/libcairo.so.2: undefined symbol: FT_Get_Var_Design_Coordinates

  2. You missed an important step, whereby whenever you add a ppa repo you have to run `sudo apt update` so that the references in the operating system (as far as I know at the very least) get updated. The reason for that is, I tried doing everything I could to upgrade ffmpeg from v2 to v4, it never worked until I ran `update` after installing the new repo

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.