How to install ffmpeg linux via command line

Install FFMPEG on you Linux to get a powerful open-source library dedicated to processing audio and video. You can use either of its APIs to process audio and video or use the tools it provides, such as ffmpeg, ffplay, ffprobe, to edit your audio and video files.

The basic directory structure of the FFMPEG library and its functions…

FFMPEG directory and its role

libavcodec: Provides a series of encoder implementations.
libavformat: Implements the stream protocol, container format and its own IO access.
libavutil: Includes the hasher, decoder, and various tool functions.
libavfilter: A variety of audio and video filters are available.
libabvdevice: Provides an interface to access the capture device and playback device.
libswresample: Implements mixing and resampling.
libswscale: Implements colour conversion and scaling.

In this tutorial, we will show the steps to install FFmpeg on  Linux operating systems such as Ubuntu 18.04/19.04/16.04… Debian 9/Linux Mint/Elementary OS, CentOS 7  and other similar streams Linux Distors.

Install ffmpeg on Ubuntu/Debian Linux

The below-given command has been performed on Ubuntu 19.04 but viable for other versions such as Ubuntu 18.04/16.04 including Debian, Linux Mint and Elementary OS. You can directly visit the official website of this to more about it.

Step 1: Go to Command Terminal

If you are using the Linux system Ubuntu or any other CLI’s interface then you can directly issue the ffmpeg installation commands given in the next steps. For Desktop use Ctrl+Alt+T keyboard shortcut or search for Terminal in Applications.

Step 2: Update the System

To make sure all the installed packages on your are up to date run the following command:

Command to install FFmpeg 3.4.x

Now, use this single command to download FFmpeg 3.4.x packages to install on the system.

sudo apt install ffmpeg

Check Version:

ffmpeg -version


ffmpeg -version
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100

Command to install FFmpeg 4.x

sudo apt update
sudo apt install software-properties-common

Now add a repository to get the installation packages of latest FFmpeg 4.x

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

Installing FFmpeg 4.x

sudo apt update
sudo apt install ffmpeg

Now, Check  you version

ffmpeg -- version

this time the output will be:

Installation using SNAP (optional) #2nd method

The easiest way to install the newest version of this tool is by using SNAPD command:

sudo apt install snapd
sudo snap install ffmpeg

Command to ffmpeg convert to mp4

Now after the installation, if you have some video file in MP4 format then you can easily use ffmpeg to convert into other formats using the terminal.

ffmpeg -i example.mp4 example.webm

Note: Replace the example.mp4 with the file name you want to convert and example.webm with the name you want to give to your output one.

Command to ffmpeg convert to mp3

In the same way, we can convert MP3 to other audio file formats such as Mp3 to .ogg

ffmpeg -i input.mp3 output.ogg

Install ffmpeg on CentOS 7 or RHEL (RedHat)

On the RPM-based systems using YUM packages manager such as CentOS 7 Linux Distros, we can use the following commands for the installation of  FFmpeg; to stream various audio or video content; converting, increasing or decreasing of sample rate, Resizing of video and more…

1: Open command terminal

On CentOS 7 open the command terminal available in the Applications of the System.

2: Install EPEL Repository in CentOS 7

sudo yum install epel-release

3: Import Nux Desktop repository GPG Key

The FFmpeg by default is not available in the CentOS 7 repository thus, we need to add the Nux one. First, get the GPG key to authenticate its package.

rpm --import

4: Add Nux Desktop repository

Use this command to add the NUX repo on CentOS.

For CentOS 7

yum -y install epel-release && rpm -Uvh

For CentOS 6

yum -y install epel-release && rpm -Uvh

5: Install FFMPEG on CentOS 7

Finally, after adding repository here is the command to install it on CentOS

sudo yum update
sudo yum install ffmpeg ffmpeg-devel

Check version

ffmpeg --version

Use Snap to install this tool on CentOS (# 2nd method)

If you want to install the latest version of FFmpeg on CentOS then use the SNAP, commands are:

sudo yum install epel-release
sudo yum install snapd
sudo systemctl enable --now snapd.socket


sudo snap install ffmpeg

The usage of this tool on CentOS will be the same as mentioned above…

Other Resources: