Redirect FFprobe stdout to JSON Keeping stderr
This guide explains how to export ffprobe metadata into
a JSON file by redirecting standard output (stdout) while
keeping diagnostic logs and standard error (stderr) visible
in your terminal console. You will learn the exact shell syntax for
stream redirection and the required ffprobe parameters to
produce clean JSON files on Linux, macOS, and Windows.
Understanding the Streams in FFprobe
By default, command-line shells manage output using separate data streams:
- Standard Output (
stdout/ File Descriptor1): The stream whereffprobeoutputs the requested structured data, such as JSON or XML. - Standard Error (
stderr/ File Descriptor2): The stream whereffprobedisplays application logs, banners, warnings, and error messages.
Because these streams are separated by default, directing standard output to a file does not capture or hide standard error unless you explicitly merge them.
The Command Syntax (Linux, macOS, and Windows CMD)
To capture the JSON output to a file while leaving error and log
messages in the terminal, redirect only file descriptor 1
using the > operator:
ffprobe -v error -show_format -show_streams -of json input.mp4 > output.jsonIf you prefer to be explicit with file descriptors, specify
1>:
ffprobe -show_format -show_streams -of json input.mp4 1> output.jsonBreakdown of Arguments:
-of json(or-print_format json): Instructsffprobeto format the requested metadata into valid JSON and write it directly tostdout.-show_format: Extracts container-level metadata (duration, bitrate, tags).-show_streams: Extracts individual stream metadata (codec details, resolution, audio channels).input.mp4: The target media file.> output.json: Redirects stream1(stdout) tooutput.json. Stream2(stderr) remains attached to the terminal window.
Controlling the Verbosity of stderr
If you want to maintain the stderr stream for monitoring
while preventing normal program banner clutter, use the -v
(verbosity) flag:
Show only critical errors:
ffprobe -v error -show_format -show_streams -of json input.mp4 > output.jsonShow warnings and errors:
ffprobe -v warning -show_format -show_streams -of json input.mp4 > output.jsonShow full diagnostic logs without the build configuration banner:
ffprobe -hide_banner -v info -show_format -show_streams -of json input.mp4 > output.json
In all cases, any warning or error produced by the decoder will print
directly to your screen, and only valid JSON will be written to
output.json.
PowerShell Syntax (Windows)
PowerShell handles native command redirection slightly differently. In PowerShell 5.1 and newer, use the explicit stream indicator:
ffprobe.exe -v error -show_format -show_streams -of json input.mp4 1> output.jsonIf you experience character encoding issues with PowerShell's redirection operators, use the raw byte pipeline instead:
ffprobe.exe -v error -show_format -show_streams -of json input.mp4 | Out-File -FilePath output.json -Encoding utf8Because Out-File only receives objects from the success
stream (stdout), errors and warnings sent to
stderr will continue to render directly in the PowerShell
console.