FFmpeg is an open-source and free suite of different libraries and programs for managing files of different formats. It is the abbreviation of the Fast Forward Motion Picture Experts Group, a command-line tool, used to convert, record, and stream video as well as audio. It is also used to encode, decode, compress and transcode the files of different formats. FFmpeg is used in different operating systems like Mac, Windows, and all distributions of Linux. To use it in the latest version of Debian, which is a distribution of the Linux, Bullseye or also known as Debian 11, we have to install it.
This write-up will help to understand the installation procedure of FFmpeg in Debian 11 in detail.
How to install FFmpeg on Debian 11
To install FFmpeg on Debian 11, we will first update the repository as the repository of Debian contains all the packages. To update the repository, execute the command:
$ sudo apt update
Once all packages of the repository have been updated, use the install command for the installation of the FFmpeg:
$ sudo apt install ffmpeg -y
After the installation procedure is completed, we will confirm the installation by displaying the version of the installed FFmpeg.
$ ffmpeg -version
The output is displaying the 4.3.2.0 version of the FFmpeg, which also validates the installation of the FFmpeg. To display down the list of encoders, execute the command:
$ ffmpeg -encoders
After displaying the list of encoders, we can also display down the decoders using the command:
$ ffmpeg -decoders
The general syntax of using FFmpeg
Now as we discuss in the above section that the FFmpeg can be used for multi-purposes like for conversion of video formats, extracting audio from video, and extracting details of any file. Therefore, the general syntax for using the FFmpeg is defined as:
$ ffmpeg [global_options] {[input_file_options] -i input_url} ...{[output_file_options] output_url} ...
This command varies for different users depending upon the usage of this command. We will understand this syntax in the next sections while using FFmpeg for different purposes.
How to extract audio from an mp4 file to mp3
To extract audio from a video, we will consider and video which is saved in our machine by the name, MyVideo.mp4, we will use the command:
$ ffmpeg -i MyVideo.mp4 -vn MyAudio.mp3
The audio has been extracted from the file MyVideo.mp4 and is being saved as MyAudio.mp3. Before verifying the audio file, let us explain the above command. In the above command, we used the keyword ffmpeg which is used to tell the command line we are using the FFmpeg, then we used the flag -i which indicate the input file, then we typed the name of the input file which is “MyVideo.mp4”, then we used flag -vn which blocks the video streaming and save it as the MyAudio.mp3. Now to validate the mp3 file we will list down the contents by using the ls command:
$ ls
Now if we want to convert the audio of the file, to the same bit rate of its parent video file then execute the following command:
$ ffmpeg -i MyVideo.mp4 -vn -ab 128k NewAudio.mp3
To confirm it, list down using the command:
$ ls
Now if we want to extract the information of any mp3 file, we will run the following command:
$ ffmpeg -i MyAudio.mp3
To convert a file from one format to another, let us say we convert MyVideo.mp4 from mp4 format to and MyVideo.webm, to a WebM format using the command:
$ ffmpeg -i MyVideo.mp4 MyVideo.webm
To confirm the conversion we will display the contents of the directory:
$ ls
To explore more features and other information about the FFmpeg, run the command:
$ man ffmpeg
Similarly, to display all the formats supported by the FFmpeg, run:
$ ffmpeg -formats
If you want to remove the FFmpeg from Debian 11 along with all its files you can use the purge command as:
$ sudo apt purge ffmpeg -y
Conclusion
FFmpeg is one of the most popular and used command-line tools which is used for multi-purposes for video and audio files like for converting and compressing. In this write-up, we have discussed the installation procedure of the FFmpeg on Debian 11 and performed some tasks using the FFmpeg to understand how it works in Debian 11.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY