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: Theffprobecommand does not start withffmpeg, so all code blocks in this article usetextblocks (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
-v quiet— Suppresses ffprobe’s own log output, outputting only pure JSON-print_format json(synonymous with-of json) — Sets output format to JSON- Combining
-show_streamsand-show_formatincludes all information in a single JSON
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
| Field | Location | Meaning |
|---|---|---|
codec_name | streams | Codec name (e.g., h264, aac, hevc) |
codec_type | streams | Stream type (video / audio / subtitle) |
width / height | streams (video) | Resolution (pixels) |
r_frame_rate | streams (video) | Frame rate (fraction notation, e.g., 30/1 = 30fps) |
bit_rate | streams / format | Bitrate (bps) |
duration | streams / format | Duration (seconds) |
pix_fmt | streams (video) | Pixel format (e.g., yuv420p) |
sample_rate | streams (audio) | Sample rate (Hz) |
channels | streams (audio) | Number of audio channels |
How to Read r_frame_rate
r_frame_rate is displayed as a fraction:
| Value | Meaning |
|---|---|
30/1 | 30fps |
60000/1001 | ~59.94fps (NTSC) |
25/1 | 25fps (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.
| Command | Purpose | Output | Script-friendly |
|---|---|---|---|
ffprobe | Dedicated file analysis | Standard output (JSON, etc.) | Yes |
ffmpeg -i | Info check for conversion commands | Standard error | Difficult 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
Related Articles
- ffmpeg / ffprobe / ffplay — Differences and When to Use Each
- What is FFmpeg — Basic Concepts and Getting Started
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