How to Use ffprobe Command on Linux

The ffprobe command gathers media-related information. Linux administrators can easily retrieve multimedia information using the ffprobe command. With this command, users can display the verbose output of multimedia streams. Hence, it is a must-have tool in your toolkit.

With ffprobe, users can gather multimedia information, such as the bit rate, pixel format, codecs, width, height, and size of media files. Later, you can utilize the output from multimedia streams to perform statistical plotting and processing. 

In this article, we’ll cover a step-by-step guide on how to use the ffprobe command on Linux. We’ll also look at various ffprobe options and common examples that users can utilize for advanced processing. So, let’s get started!

Syntax

The syntax for the command looks something like this:

ffprobe [options] input_url

Install ffprobe Command on Linux

The ffprobe command is a part of the FFmpeg group. FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video files. The ffprobe is one of the libraries of the FFmpeg. Let’s look at how you can use the ffprobe command on Linux.

1. Update the System

Firstly, update the current repository and packages in your system. In this case, open the terminal using the shortcut key. The shortcut key for the terminal is “Ctrl + Alt + T”, then use the update command with the required repository. For example:

sudo apt update && sudo apt upgrade

The output should look something like this:

Update the system

2. Install the FFmpeg Package on Linux

Secondly, install the ffprobe package in your updated system. In this case, you will have to install the FFmpeg package first. Then you can install the ffprobe library. Execute the command given below: 

sudo apt install ffmpeg

Wait for the installation to complete. 

The output should look something like this:

Install ffmpeg command

3. Verify the FFmpeg Installation

Now that the installation is complete, you can verify it. 

For example: 

ffmpeg -version

Alternatively, you can also type in the ffmpeg command. For instance:

ffmpeg

4. Install the ffprobe Command on Linux

After verifying the installation of the FFmpeg package, the next step is to install the ffprobe library. For this step, use the install command. Specifically, type:

sudo apt install ffprobe

Finally, you have installed the ffprobe command on Linux. Now let’s look at its basic usage.

Use ffprobe Command on Linux

The ffprobe command consists of various multimedia specifiers and writers. Therefore, a brief description of each specifier and writer is discussed below:

  • Options:
    • Stream specifiers: used to apply a property to one or more streams. Most media have two streams: audio and video. You can choose which one you want to display and process using this specifier. 
    • Generic options: the options shared among all the ff* packages and libraries.
    • AVOptions: the options provided by the libavformat, libavdevice, and libavcodec libraries. 
  • Writers: defines the output form for the ffprobe command.
    • default: default format.
    • compact, csv: a format in which values are separated by a comma.
    • flat: consists of data stored in {key,value} pair.
    • ini: prints output in INI-based format.
    • json: prints output using JSON notation.
    • xml: prints output using XML based notations. 

1. Fetch Media File Properties

To use the ffprobe command to retrieve all multimedia properties. For example, type: 

ffprobe SampleVideo.mp4

Make sure to replace the SampleVideo.mp4 with the name of your media. 

The output should look something like this:

use ffprobe command on Linux

2. Filter the Output

As you can see, the output of this command consists of a lot of information. You can hide all of these headers with the help of -hide_banner flag. 

For instance, input: 

ffprobe -hide_banner SampleVideoeo.mp4

You should get a similar output:

Use ffprobe with hide banner option

The key information you can identify from the above screenshot is a video format, date and time of the media creation, video duration, bitrate, and the number of streams. 

3. Stream Specifiers in ffprobe Command on Linux

Use the stream specifier option to select a specific stream from your multimedia files. For the video stream, use the #0:0 option. For audio steam, use the option #0:1. Additionally, you can also use flag ‘v’ or ‘V’ to view the video information and flag  ‘a’ to view the audio-related information. 

For the subtitle information, use ‘s’ option in the command.

For instance, to inspect the audio stream, set the ‘a’ option to 0. Specifically, type: 

ffprobe -hide_banner -select_streams a:0 -show_entries SampleVideo.mp4

To view the video stream from your media file, set the ‘v’ option to 0. 

For example: 

ffprobe -hide_banner -select_streams v:0 -show_entries SampleVideo.mp4

4. Get Information for Each Stream

Apart from specifying the information for the type of stream, you can also access information related to the streams used in a certain multimedia file. For this type of media information, use the -show_streams option.

For this step, make sure to use -show_streams option. Specifically, type:

ffprobe -hide_banner -select_streams v:0 -show_streams SampleVideo.mp4

5. Get Information about the Video Containers

Similar to stream information, you can also get the details of the container format. For this step, you will use the -show_format flag. Specifically, type:

ffprobe -hide_banner -select_streams v:0 -show_format SampleVideo.mp4

Output:

use ffprobe command on Linux

6. Get Information about Individual Packets

In addition, you can also fetch the individual packet details in a video. For this, use the -show_packets option.

For instance: 

ffprobe -hide_banner -select_streams v:0 -show_packets SampleVideo.mp4

7. Get Information about Individual Frames

To extract frame-related information from a media file, use the -show_frames options with the ffprobe command. It will list down frame-related information such as its color channels, timestamps in the frame, height of each frame, and picture type used in the frames. 

For instance, type: 

ffprobe -hide_banner -v panic -select_streams v:0 -show_frames SampleVideo.mp4

You will get a similar output:

use ffprobe command on Linux

8. Output Formats in ffprob Command on Linux

Apart from all the format specifiers, ffprobe also allows users to export the output format for each media file. The output formats included in this library are CSV, JSON, INI, Flat, XML, and default formats. Hence, to change the output format, use the -print_format <format>

For different types of output formats, use the following examples:

#To Use CSV:
ffprobe -hide_banner -v panic -select_streams v:0 -print_format csv -show_format SampleVideo.mp4
#To use JSON:
ffprobe -hide_banner -v panic -select_streams v:0 -print_format json -show_format SampleVideo.mp4
#To use XML:
ffprobe -hide_banner -v panic -select_streams v:0 -print_format xml -show_format SampleVideo.mp4
# To use ini:
ffprobe -hide_banner -v panic -select_streams v:0 -print_format ini -show_format SampleVideo.mp4

The output for JSON format should look something like this:

use ffprobe command on Linux

And that’s a wrap! The ffprobe is a powerful library from the FFmpeg group. What we have covered in the article is just the top of the surface. To learn more about this command, visit their official website. In conclusion, you can extract plenty of information by combining it with different format specifiers. 

We hope you found this article to be helpful. If you have any handy examples on ffprobe, please let us know in the comments section, and we’ll try to answer them in the next articles. 

If this guide helped you, please share it.

Leave a Reply
Related Posts