Skip to main content

Overview

ffprobe is a command-line tool for analyzing and inspecting multimedia streams. It can extract detailed information about media containers, codecs, streams, and metadata without performing any decoding or transcoding.
ffprobe is described as a “simple media prober based on the FFmpeg libraries” and was first released in 2007.

Basic Syntax

ffprobe [options] input_url

Common Options

input_url
string
required
Input file or URL to analyze
-v
string
Set logging levelValues: quiet, panic, fatal, error, warning, info, verbose, debug, traceCommon: -v quiet to suppress FFmpeg banner
-hide_banner
boolean
Hide FFmpeg banner (cleaner output)

Information Display Options

-show_format
boolean
Show container format informationDisplays container details like duration, bitrate, format name, and tags
-show_streams
boolean
Show stream informationDisplays details about each stream including codec, resolution, framerate, and bitrate
-show_programs
boolean
Show program informationDisplays information about programs in the container
-show_chapters
boolean
Show chapter informationLists chapters with their timestamps and metadata
-show_packets
boolean
Show packet informationDisplays detailed information about each packet (can be verbose)
-show_frames
boolean
Show frame informationDisplays information about each decoded frame
-show_stream_groups
boolean
Show stream group information
-show_data
boolean
Show packet/frame data payload
-show_error
boolean
Show probing error information

Output Format Options

ffprobe supports multiple output formats for easy parsing and integration:
-of
string
Set output format (alias: -print_format)Values:
  • default - Default format
  • compact - Compact output
  • csv - CSV format
  • flat - Flat format
  • ini - INI format
  • json - JSON format
  • xml - XML format

JSON Output

ffprobe -v quiet -print_format json -show_format -show_streams input.mp4
{
  "format": {
    "filename": "input.mp4",
    "nb_streams": 2,
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "duration": "120.000000",
    "size": "5242880",
    "bit_rate": "349525"
  },
  "streams": [
    {
      "index": 0,
      "codec_name": "h264",
      "codec_type": "video",
      "width": 1920,
      "height": 1080,
      "r_frame_rate": "30/1",
      "avg_frame_rate": "30/1"
    },
    {
      "index": 1,
      "codec_name": "aac",
      "codec_type": "audio",
      "sample_rate": "48000",
      "channels": 2,
      "channel_layout": "stereo"
    }
  ]
}

XML Output

ffprobe -v quiet -print_format xml -show_format -show_streams input.mp4

CSV Output

ffprobe -v quiet -print_format csv -show_streams input.mp4

Stream Selection

-select_streams
string
Select specific streams to analyzeExamples:
  • v:0 - First video stream
  • a:0 - First audio stream
  • v - All video streams
  • a - All audio streams

Frame/Packet Analysis

-read_intervals
string
Read only specified intervalsFormat: [START][%[END]]Example: -read_intervals "%+30" (first 30 seconds)
-count_frames
boolean
Count the number of frames per stream
-count_packets
boolean
Count the number of packets per stream
-show_entries
string
Show only specified entriesExample: -show_entries stream=width,height,codec_name

Real-World Examples

Basic Media Information

ffprobe -v quiet -hide_banner -show_format -show_streams input.mp4

JSON Output for Parsing

ffprobe -v quiet -print_format json -show_format -show_streams input.mp4

Get Video Duration

ffprobe -v quiet -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
This returns just the duration value in seconds, perfect for scripting.

Get Video Resolution

ffprobe -v quiet -select_streams v:0 -show_entries stream=width,height -of csv=p=0 input.mp4

Get Audio Information

ffprobe -v quiet -select_streams a:0 -show_entries stream=codec_name,sample_rate,channels -of json input.mp4

Get Video Bitrate

ffprobe -v quiet -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 input.mp4

Get Framerate

ffprobe -v quiet -select_streams v:0 -show_entries stream=r_frame_rate -of default=noprint_wrappers=1:nokey=1 input.mp4

Count Total Frames

ffprobe -v quiet -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mp4

Check for Specific Codec

ffprobe -v quiet -select_streams v:0 -show_entries stream=codec_name -of default=nw=1:nk=1 input.mp4

Analyze Packets (First 100)

ffprobe -v quiet -read_intervals "%+#100" -show_packets input.mp4

Get All Metadata

ffprobe -v quiet -show_entries format_tags -of json input.mp4

Pretty Print Stream Info

ffprobe -v quiet -show_streams -of flat input.mp4

Advanced Usage

Custom Entry Selection

ffprobe -v quiet -show_entries \
  stream=index,codec_name,codec_type,width,height,duration \
  -of json input.mp4

Multiple Formats

ffprobe -v quiet \
  -show_format \
  -show_streams \
  -show_chapters \
  -of json input.mp4

Stream Groups Analysis

ffprobe -v quiet -show_stream_groups -of json input.mp4

Detailed Frame Analysis

ffprobe -v quiet \
  -show_frames \
  -select_streams v:0 \
  -read_intervals "%+10" \
  -of json input.mp4

Output Format Customization

You can customize the output format with additional options:
noprint_wrappers
boolean
Don’t print wrapper elementsExample: -of default=noprint_wrappers=1
nokey
boolean
Don’t print key namesExample: -of default=nokey=1

Example: Clean Duration Output

ffprobe -v quiet \
  -show_entries format=duration \
  -of default=noprint_wrappers=1:nokey=1 \
  input.mp4
Output: 120.000000

Scripting Examples

Bash Script: Get Video Info

#!/bin/bash

FILE="$1"

# Get duration
DURATION=$(ffprobe -v quiet -show_entries format=duration \
  -of default=noprint_wrappers=1:nokey=1 "$FILE")

# Get resolution
RESOLUTION=$(ffprobe -v quiet -select_streams v:0 \
  -show_entries stream=width,height -of csv=p=0 "$FILE")

# Get codec
CODEC=$(ffprobe -v quiet -select_streams v:0 \
  -show_entries stream=codec_name -of default=nw=1:nk=1 "$FILE")

echo "File: $FILE"
echo "Duration: $DURATION seconds"
echo "Resolution: $RESOLUTION"
echo "Codec: $CODEC"

Python Script: Parse JSON Output

import json
import subprocess

def get_media_info(filename):
    cmd = [
        'ffprobe',
        '-v', 'quiet',
        '-print_format', 'json',
        '-show_format',
        '-show_streams',
        filename
    ]
    
    result = subprocess.run(cmd, capture_output=True, text=True)
    return json.loads(result.stdout)

info = get_media_info('input.mp4')
print(f"Duration: {info['format']['duration']}")
print(f"Video codec: {info['streams'][0]['codec_name']}")

Use Cases

Media Validation

Verify media files meet specific requirements (codec, resolution, bitrate)

Metadata Extraction

Extract tags, duration, and other metadata for cataloging

Quality Assurance

Analyze encoded files for quality control

Automation

Integrate into scripts for batch processing and validation

Source Code Reference

Key implementation details from the source code:
  • Program Birth Year: 2007 (fftools/ffprobe.c:93)
  • Section IDs: Comprehensive section structure for different output elements (fftools/ffprobe.c:164-231)
  • Output Formats: Support for JSON, XML, CSV, INI, and custom formats (fftools/ffprobe.c:256-326)
  • Stream Analysis: Detailed stream, packet, and frame analysis capabilities

Performance Tips

Fast Probing: Use -show_format -show_streams without frame/packet analysis for quick metadata extraction.
Using -show_packets or -show_frames can be very slow on large files as it requires reading and analyzing the entire file.

Common Options Summary

OptionPurposeExample
-show_formatContainer infoBasic file info
-show_streamsStream detailsCodec, resolution
-show_chaptersChapter listDVD/Blu-ray chapters
-of jsonJSON outputMachine parsing
-select_streams v:0First videoTarget specific stream
-count_framesFrame countTotal frames
-v quietSuppress logsClean output

See Also

Build docs developers (and LLMs) love