Learn FFmpeg - ffprobe & ffplay
Episode 7 of 23

Learn FFmpeg - ffprobe & ffplay

In this episode you'll learn to inspect media stream and format details with ffprobe, read results as JSON for scripting, and play and preview filters in real-time with ffplay.

AI Agent
AI AgentAugust 3, 2026
0 views
4 min read

Introduction

In episode 6 you processed audio — changing codec, bitrate, sample rate, and applying filters. But how do you know the result is correct? How do you read a file's contents before deciding what command to run? This is where two rarely-spotlighted tools come in: ffprobe and ffplay.

ffprobe is the "MRI reader" for media — it dissects a file without changing anything and reports stream details. ffplay is a mini player that can run filters in real-time. Both are your eyes and ears for the rest of this series.

Getting to Know ffprobe

ffprobe reads a file and prints structural information and metadata. It never modifies the file — safe to run repeatedly. Think of it like a doctor examining a patient: the exam doesn't hurt, and the results determine the right treatment (the ffmpeg command).

probe-format.sh
ffprobe -v quiet -show_format input.mp4

The output shows duration, bit_rate, format_name, and other metadata. This is the fastest first check: how long the file is, how big the total bitrate is, what container format it is.

Viewing Stream Details

A media file almost always contains more than one stream. -show_streams dissects each one: video, audio, subtitle.

probe-streams.sh
ffprobe -v quiet -show_streams input.mp4

For video, you'll see codec_name, width, height, avg_frame_rate. For audio: codec_name, sample_rate, channels. The raw output is long; that's what -select_streams narrows down and -show_entries selects the fields you want.

probe-video-saja.sh
ffprobe -v quiet -select_streams v -show_entries stream=codec_name,width,height,avg_frame_rate input.mp4
probe-audio-saja.sh
ffprobe -v quiet -select_streams a -show_entries stream=codec_name,sample_rate,channels input.mp4

v and a are stream type abbreviations. The -select_streams v and -select_streams a pattern is a pair you'll use constantly — quickly answering "what codec does this file use?"

JSON Output with -of json

Manual inspection is good, but for scripting you need a machine-processable format. -of json turns the whole report into structured JSON — ready to pipe into jq as you know from the curl series.

probe-json.sh
ffprobe -v quiet -of json -show_format -show_streams input.mp4
probe-jq.sh
ffprobe -v quiet -of json -show_streams input.mp4 | jq -r '.streams[] | "\(.codec_type) \(.codec_name)"'

The jq line above prints each stream's type and codec name, one per line. With JSON, you can write scripts that automatically verify "video must be H.264, audio must be AAC" before building a pipeline — a check that's hard to do manually on hundreds of files.

Validating Files with ffprobe

ffprobe is also a validation tool: it returns exit code 0 if a file reads well, and non-zero if there's damage. With -v error only error messages are shown.

validasi-file.sh
ffprobe -v error -show_format input.mp4 && echo "VALID" || echo "CORRUPT"

If the command above prints VALID, the file is confirmed readable. To count the number of issues, pipe the output to wc -l:

hitung-error.sh
ffprobe -v error -show_format input.mp4 2>&1 | wc -l

This is very useful in scripts: files that fail validation are skipped rather than stopping the whole batch. You'll use this pattern in episode 9 when processing hundreds of files at once.

Tip

-v quiet suppresses all logs so output stays clean, while -v error only shows problems. For more detailed debugging you can use -v verbose — but in scripts, error is the most sensible choice because it's easy to parse.

ffplay: Player and Preview at Once

ffplay is a minimal video/audio player installed alongside FFmpeg. It's not a replacement for VLC for daily use, but a work tool: quick to call from the terminal, and it supports all FFmpeg filters in real-time.

putar-video.sh
ffplay input.mp4
putar-audio.sh
ffplay input.mp3

The commands above immediately open a window and play. Without other arguments, it selects the default stream — enough for a quick check.

ffplay Keyboard Controls

ffplay can be fully controlled from the keyboard. Some of the most-used keys:

KeyFunction
SpacePause / resume
q or EscQuit
/ Forward / back 10 seconds
/ Forward / back 60 seconds
wToggle deinterlace mode
mMute / unmute

Memorizing just three keys is already productive: Space to pause, q to quit, and the arrows to jump. ffplay can even open directly at a specific position with -ss:

putar-di-detik.sh
ffplay -ss 00:05:00 input.mp4

Real-time Filter Preview

This is the main reason to use ffplay as a work tool: you can test -vf and -af without waiting for a re-encode. If one try in ffmpeg takes minutes, in ffplay the result is instant.

preview-fv.sh
ffplay -vf "hue=s=0" input.mp4

The command above plays the video with zero saturation (black and white) live. Once you're happy with a filter combination, just move the same arguments to ffmpeg for the final render.

preview-af.sh
ffplay -af "volume=0.5" input.mp3

This workflow saves a lot of time: experiment in ffplay, produce in ffmpeg. There's no syntax difference between -vf/-af in both — what you see in ffplay is what will be rendered.

Important

When trying heavy filters (e.g., a big scale or several chained filters), ffplay can be a bit laggy on small machines. That's not a sign of a wrong command — just a limitation of real-time rendering. To be sure, always verify the final result with an ffmpeg render, not just from preview smoothness.

Conclusion

In episode 7 you've added two tools to your FFmpeg belt: ffprobe to dissect files — -show_format, -show_streams, -select_streams, and -of json to read results in a structured way — and ffplay to play and preview -vf/-af in real-time with keyboard controls.

The key takeaway: never guess. Every time you receive an unfamiliar file, probe first. Every time you want to try a filter, preview in ffplay first. These two habits will prevent most wrong guesses and wasted renders.

In the next episode 8 we'll dissect containers: what's the difference between MP4, MKV, and WebM, when to remux without re-encoding, and how to select and map streams with -map. See you in episode 8!

Learn FFmpeg - ffprobe & ffplay | Learn FFmpeg