FFmpeg is open-source and cross-platform that handles a variety of multimedia files. It holds several audio and video libraries such as libavdevice, libavformat, libswscale, and many more. It is an easy stream analyzer for multimedia. Besides being a popular developer tool, it offers a powerful command-line interface for multimedia tasks. This free computer software was developed in 2000. Youtube, Trell, Mux, VLC Media Player, and many popular websites and multimedia platforms use FFmpeg.
This guide will help you to install FFmpeg on Ubuntu 22.04 and Ubuntu 20.04 and shows you how to perform video and audio file conversion using FFmpeg.
To install FFmpeg, your device must fulfill the following requirements:
FFmpeg resides in the repository of ubuntu. It can be installed using apt–manager. After every six months, a new version is released, whereas the repository contains the previous version concerning the latest version.
It is better to update and upgrade your package list before installing FFmpeg. Type the following code on the terminal to update your package list:
$ sudo apt-get update
Output:
Proceed with the following code to upgrade:
$ sudo apt-get dist-upgrade
Output:
Now install FFmpeg with the following command:
$ sudo apt-get install ffmpeg
Output:
Type the following command to verify the installation of FFmpeg. The version number will show that FFmpeg is installed.
$ ffmpeg - version
Output:
To check whether all encoders and decoders are installed with FFmpeg type the following commands
$ ffmpeg -encoders
Output:
$ ffmpeg -decoders
Output:
The above outputs demonstrate that FFmpeg is installed, and you can start working on it.
Here are some known libraries of ffmpeg listed with their usage, which you should know at the initial stage:
| Libraries | Usage |
|---|---|
| Contains decoders and encoders for audio/video. | |
| Contains input and output devices. | |
| Contains media filters. | |
| Contains functions for simplifying programming. | |
| Containing demuxers and muxers. |
Let’s try out some basic commands of FFmpeg to convert video files, extract audio files, convert any audio file into an Ogg file, convert a video file into an image, edit a video file, extract an audio and video file information, and many more simple tasks:
In the given examples “test” represents the input video file in avi format.
To know the complete detail of a video file, you use the command given below:
$ ffmpeg -i source_video.avi
Output:
You can easily create an image from a video file using the following code
$ ffmpeg -i source_video.avi image%d.jpg
Output:
Here %d represents the number of images created with names such as image1, image2, image3. JPG represents the file extension. You can create images with different file extensions such ``as PNG, JPEG, JPG, TIFF, GIF, and more.
FFmpeg allows one to convert a video file into a different format such as in mp4, WebM,avi. Try out the given code to convert a video file into mp4 format.
$ ffmpeg -i source_video.avi output.mp4
Output:
Ffmpeg allows you to trim the part of the video you want through this command.
$ ffmpeg -ss 00:21 -i source_video.avi -t 00:06 -vcodec copy -acodec copy newfile.mp4
Output:
In the code given above
Ffmpeg offers to resize a video file according to the desired size using -vf scale filter.
$ ffmpeg -i source_video.avi -vf scale=320:240 output.avi
Output:
In the given examples “sample” represents the input audio file in mp3 format.
You can easily convert an mp3 audio file into Ogg using the following code:
$ ffmpeg -i source_audio.mp3 new.ogg
Output:
To know the complete detail of an audio file, you can use the command given below:
$ ffmpeg -i source_audio.mp3
Output:
FFmpeg offers an amazing option to extract sound from a video file and save it in mp3 format.
$ ffmpeg -i source_video.avi -vn audio.ogg
Output:
Using this guide, you can easily install FFmpeg on Linux and learn how to convert media files using FFmpeg.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…