Inspecting Metadata and Stream Information with ffprobe

The FFmpeg tool suite includes ffmpeg (conversion), ffplay (playback), and ffprobe (analysis). ffprobe is a dedicated tool for retrieving technical information such as codec, resolution, frame rate, and bitrate from video and audio files.

Verified with: ffmpeg/ffprobe 6.1
Note: The ffprobe command does not start with ffmpeg, so all code blocks in this article use text blocks (excluded from CI testing).


1. Basic ffprobe Command

The simplest usage is just passing a filename.

ffprobe input.mp4

This single command outputs basic information about the file — container format, codecs, resolution, duration, and more — to standard error.


2. Key Options

-show_streams: Display stream information

ffprobe -show_streams input.mp4

Outputs detailed properties for each stream (video, audio, subtitles, etc.) in [STREAM] ... [/STREAM] blocks.

-show_format: Display container information

ffprobe -show_format input.mp4

Displays the container information for the entire file (format name, file size, duration, overall bitrate, etc.).

-print_format json (or -of json): Output in JSON format

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

3. JSON Output Example

Sample output from the above command (abbreviated):

{
  "streams": [
    {
      "index": 0,
      "codec_name": "h264",
      "codec_type": "video",
      "width": 1920,
      "height": 1080,
      "r_frame_rate": "30/1",
      "bit_rate": "4500000",
      "duration": "120.000000",
      "pix_fmt": "yuv420p"
    },
    {
      "index": 1,
      "codec_name": "aac",
      "codec_type": "audio",
      "sample_rate": "48000",
      "channels": 2,
      "bit_rate": "128000",
      "duration": "120.000000"
    }
  ],
  "format": {
    "filename": "input.mp4",
    "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
    "duration": "120.000000",
    "size": "57600000",
    "bit_rate": "3840000",
    "tags": {
      "encoder": "Lavf60.3.100"
    }
  }
}

4. Key Fields and How to Read Them

FieldLocationMeaning
codec_namestreamsCodec name (e.g., h264, aac, hevc)
codec_typestreamsStream type (video / audio / subtitle)
width / heightstreams (video)Resolution (pixels)
r_frame_ratestreams (video)Frame rate (fraction notation, e.g., 30/1 = 30fps)
bit_ratestreams / formatBitrate (bps)
durationstreams / formatDuration (seconds)
pix_fmtstreams (video)Pixel format (e.g., yuv420p)
sample_ratestreams (audio)Sample rate (Hz)
channelsstreams (audio)Number of audio channels

How to Read r_frame_rate

r_frame_rate is displayed as a fraction:

ValueMeaning
30/130fps
60000/1001~59.94fps (NTSC)
25/125fps (PAL)
24000/1001~23.976fps (cinematic)

5. Combining with jq

Combining with the jq command (JSON parser) lets you extract specific information.

Get only the resolution

ffprobe -v quiet -show_streams -print_format json input.mp4 | jq '.streams[] | select(.codec_type=="video") | {width, height}'

Get only the duration

ffprobe -v quiet -show_format -print_format json input.mp4 | jq '.format.duration'

Get a list of codec names

ffprobe -v quiet -show_streams -print_format json input.mp4 | jq '[.streams[].codec_name]'

jq can be installed on Linux/macOS with apt install jq / brew install jq. On Windows, winget install jqlang.jq is available.


6. Difference from ffmpeg -i

You can also check stream information with ffmpeg -i filename, but the purpose differs.

CommandPurposeOutputScript-friendly
ffprobeDedicated file analysisStandard output (JSON, etc.)Yes
ffmpeg -iInfo check for conversion commandsStandard errorDifficult to parse

For obtaining file information in scripts or automated processing, using ffprobe is recommended. Use ffmpeg -i for pre-conversion verification, and note that its output goes to the error stream.


Common Usage Summary

# Quick basic info check
ffprobe input.mp4

# Get all info in JSON format (for scripts)
ffprobe -v quiet -show_streams -show_format -print_format json input.mp4

# Check video streams only
ffprobe -v quiet -show_streams -select_streams v -print_format json input.mp4

# Check audio streams only
ffprobe -v quiet -show_streams -select_streams a -print_format json input.mp4


Tested with: ffmpeg 6.1.1 / Ubuntu 24.04 (GitHub Actions runner)
Primary sources: ffmpeg.org/ffprobe.html / ffmpeg.org/ffmpeg.html / trac.ffmpeg.org