Overview
When engineering video pipelines or troubleshooting audio-visual containers on Linux, ffprobe serves as the definitive utility for auditing stream properties, structural metadata, encoding parameters, and compression bitrates. This walkthrough explores hands-on workflows with ffprobe, guiding you through essential tooling installations, isolated stream inspections, and automated JSON metadata ingestion suited for production scripting.
1. Setting Up FFmpeg Packages and Generating Test Media
Begin by provisioning both the FFmpeg multimedia framework and the jq JSON processor on your Ubuntu workstation:

Create a dedicated scratch space to keep your experimental files neatly isolated, then switch into it:

Synthesize a benchmark 5-second 720p H.264 video synchronized with an AAC-encoded 1000Hz pure tone audio track via FFmpeg’s built-in test pattern generators:

Confirm that the output container (sample.mp4) exists on disk and verify its baseline footprint:

2. Baseline Probe Execution and Container-Level Diagnostics
Invoking ffprobe directly against any target media file reveals its fundamental architecture. Without supplemental switches, the command presents the compiled library versions followed by high-level container metrics, transport duration, multiplex bitrates, and a track-by-track stream manifest:

To declutter terminal logs, append -hide_banner. This flag suppresses the lengthy build configuration boilerplate, leaving only the operational stream definitions and file attributes:

Combine -v error to mute diagnostic warnings with -show_format to isolate global container metrics. The resulting [FORMAT]...[/FORMAT] payload exposes structural telemetry, including the transport protocol, total track count, container duration, absolute byte count, and aggregate transmission bitrate:

3. Dissecting Individual Video and Audio Streams
To audit every elementary stream encapsulated inside the container, pass -show_streams. Each media track emits a dedicated [STREAM]...[/STREAM] segment detailing low-level technical parameters such as codec implementations, frame geometry, temporal rates, pixel topologies, and audio sampling depths:

Targeting specific attributes prevents information overload. Use -select_streams v:0 to narrow down the inspection to the primary video track, paired with -show_entries and -of default=noprint_wrappers=1 to cleanly surface the codec identifier (codec_name), spatial boundaries (width, height), cadence (r_frame_rate), and bandwidth consumption (bit_rate) as raw key-value pairs:

Apply an identical strategy for audio tracks using -select_streams a:0. By explicitly querying codec_name, sample_rate, and channels, you can instantly confirm whether an incoming audio asset matches your target ingestion profile:

4. Exporting Structured JSON for Shell Automation
For downstream automation and API consumption, instruct ffprobe to serialize container and stream telemetry directly into JSON using -of json, piping the output into a persistent file:

Query the structured file using jq. Iterating through the streams[] array lets you project concise mappings pairing stream descriptors (codec_type) with their respective algorithms (codec_name):

When orchestrating shell scripts, administrative pipelines often require a single raw numeric value—such as playback runtime—without formatting tags or descriptive labels. By isolating the video track with -select_streams v:0, requesting stream=duration, and applying -of default=noprint_wrappers=1:nokey=1, ffprobe returns an unadorned numeric string ready for direct assignment to an environment variable:

Mastering these ffprobe filtering idioms equips you to inspect multimedia containers, build resilient automated validation pipelines, and extract precise encoding specifications directly from the Linux command line.