FFmpeg: what it is, how it works and how to use it offline and online

FFmpeg is a powerful open source suite designed to manipulate, convert and stream multimedia files. It includes a wide range of programs and libraries that provide essential tools for manage video and audio in various formats. Basically FFmpeg works from command line but, thanks to its structure, it can be integrated into the applications that are developed. Find in Linux its natural operating environment but can also be used from Windows, even from the window WSL (Windows Subsystem for Linux)system component of Windows 10 and 11 that allows you to bring Linux to Windows.

With FFmpeg you can run format conversions, extract audio from multimedia content, cut, merge videos and apply filters and effects. The application can also be used to prepare it streaming real-time audio-video content on the Internet.

It is not for nothing that many open source applications and projects also integrate FFmpeg to exploit its powerful features multimedia features.

How to use FFmpeg from a Linux terminal window

If you need to perform basic operations on audio-video content, know that it is possible to carry them out from the Linux terminal window or from WSL. For example, try taking some royalty-free videos from Pixabay and putting FFmpeg to the test.

First of all, for install FFmpeg on Ubuntu and Debian-derived distributions, just type the following:

sudo apt install ffmpeg -y

So typing ffmpeg -version you have confirmation that FFmpeg is installed and you can check it version number.

Video conversion, audio extraction and GIF file generation with FFmpeg

By way of example only, simply issue the following command to request one conversion format (in this case from MP4 to AVI):

ffmpeg -i input.mp4 output.avi

In the place of input.mp4obviously the name of the video to be processed, stored in the folder you are in.

With the following command, however, it becomes simple extract the audio track from any video:

ffmpeg -i input.mp4 -vn -acodec copy output.mp3

Again, this command allows you to create a GIF starting from the specified video content:

ffmpeg -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos" -c:v gif output.gif

Create a video by specifying the bitrate

Bitrate is an important concept in the multimedia segment, in telecommunications and in general in information technology. It represents the amount of data transmitted or processed in a certain period of time and is expressed in bits per second (bps). The following command converts a video file from MP4 format to AVI format by specifying a bitrate video of 1,000 kbps In the example, 1000k is a relatively low bitrate and can result in video quality reduced compared to higher bitrates:

ffmpeg -i input.mp4 -b:v 1000k output.avi

How to merge two videos with FFmpeg

Per combine two videos with FFmpeg just type the following command, taking care to indicate the name of the file you want to obtain:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v] [0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4

To join two videos that they do not contain any audio trackssimply simplify the command as follows:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v] [1:v] concat=n=2:v=1:a=0 [v]" -map "[v]" output.mp4

FFmpeg merge video command

Extract a single frame from a video

In the following command, we ask FFmpeg to extract a single frame from a video in MP4 format and save the image thus acquired in the form of a PNG file. As you can see, it is sufficient to specify the exact time corresponding to the moment in which the image you wish to extract appears in the video being processed.

ffmpeg -i input.mp4 -ss 00:00:05 -vframes 1 output.png

Cut a portion of a video

And if you wanted to extract a part of a video, for example all the frame between 10 and 30 seconds? In this case, just use the following command, remembering to specify the start and end times of the cut as well as the name of the file you want to obtain:

ffmpeg -i input.mp4 -ss 00:00:10 -t 00:00:30 -c copy output.mp4

Switch from one codec to another

It goes without saying that, thanks to the multiple dedicated libraries that the application supports, with FFmpeg it is possible to transform a video obtaining another multimedia file based on a codec different than the original. In media files, the difference between containers and codecs is essential to understanding how audio and video data is stored and played.

Container is the file which can contain different types of multimedia data, such as video, audio, subtitles, metadata, and so on. It organizes and synchronizes audio and video data streams, manages metadata and can contain multiple data streams (audio tracks, subtitles,…). Some examples of containers are MP4, MKV, AVI, MOV, WebM.

A codec is an algorithm or technology used for compression e decompression of audio-video data. There are codecs for audio (for example MP3 and AAC) and video (H.264, H.265/HEVC, VP9,…).

Per switch between codecs audio-video to another, you can use the following command:

ffmpeg -i input.mp4 -c:v nuovo_codec_video -c:a nuovo_codec_audio output.mp4

In the place of nuovo_codec_video can be indicated for example libx264 per H.264 o libx265 per H.265/HEVC. The string nuovo_codec_audio it can instead be replaced, for example, with aac, mp3, opus and so on.

How to experience the potential of FFmpeg online

So far we have only scratched the surface. The potential of FFmpeg is practically infinite and it is possible to combine multiple commands to obtain professional audio-video processing with minimal effort, without even installing third-party applications.

ffmpeg.wasm is a version of FFmpeg compiled into WebAssembly (Wasm). WebAssembly is a web standard that allows high-performance binary code execution on regular browsers. Allows developers to execute complex applicationsin this case activate multimedia manipulations directly in the browser without requiring additional plugins or dedicated applications.

Try visiting the ffmpeg.app site: it is an “interface” that relies on the WASM project and which allows you to perform a vast array of operations with FFmpeg without even having installed the application on your device.

Command FFmpeg

Try typing something in the search box What do you want to do with FFmpeg today? You will discover an inexhaustible mine of practical suggestions for use FFmpeg. For example, selecting the tool that allows you to recode the video with the H.264 codecyou can click on the appropriate boxes to provide the application with the video to process and the preferences to apply.

Codificare video FFmpeg

ffmpeg.app it also helps to also discover the FFmpeg syntaxto be reused if you want to use the same command from the Linux terminal window, from WSL, in Windows or in macOS.

FFmpeg online: useful once you know the parameters of the application

Another particularly useful online service is FFmpeg online: in this case the Web application receives the video to be processed as input and then, a little further down, it is the user who is called to specify the parameters to pass to the open source utility. As seen in the image reproduced below, you can specify the options to use both in input and output.

FFmpeg online commands

If you require scenarios that require the processing or subsequent generation of multiple files, the field Get other file from file system allows you to specify additional preferences.

In short, the two services complement each other by helping to discover the secrets of FFmpeg and allowing the…


Please enter your comment!
Please enter your name here