← All one-liners·#076·media·self contained·beginner

One-Line Health Check for Any Video or Audio File

ffprobe (bundled with ffmpeg) dumps a media file's technical metadata as JSON — codecs, resolution, framerate, sample rate, channel count, duration, size — without transcoding a single frame. jq turns the verbose dump into a one-line summary, faster than opening the file in a player or scrolling ffmpeg's usual stderr banner.

Setup
  • → apt install ffmpeg # or: brew install ffmpeg — ffprobe ships in the same package
Cost per run
free
The one-liner
$ ffprobe -v error -print_format json -show_format -show_streams input.mp4 \
  | jq -r '
      {duration: (.format.duration|tonumber|round), size_kb: ((.format.size|tonumber)/1024|round)} as $fmt
      | (.streams[] | select(.codec_type=="video") | "video: \(.codec_name) \(.width)x\(.height) @ \(.r_frame_rate)fps"),
        (.streams[] | select(.codec_type=="audio") | "audio: \(.codec_name) \(.sample_rate)Hz \(.channels)ch"),
        "duration: \($fmt.duration)s, size: \($fmt.size_kb)KB"
    '
What each stage does
  1. [01] ffprobeffprobe -v error -print_format json -show_format -show_streams input.mp4
    Probes the container and every stream (video, audio, subtitle) without decoding or transcoding anything, and `-v error` silences ffmpeg's usual banner so stdout is clean JSON.
  2. [02] jq(.streams[] | select(.codec_type=="video") | "video: ..."), (.streams[] | select…
    Pulls one summary line per stream out of ffprobe's verbose per-stream JSON: the video stream's codec/resolution/framerate, the audio stream's codec/sample-rate/channel-count.
  3. [03] jq{duration, size_kb} as $fmt | "duration: \($fmt.duration)s, size: \($fmt.size_kb…
    Separately rounds the container-level duration and file size out of ffprobe's `.format` object into a final one-line summary.
Expected output (sample)
video: h264 1280x720 @ 30/1fps
audio: aac 44100Hz 1ch
duration: 5s, size: 106KB
Caveats & tips
  • Verified with ffmpeg/ffprobe 6.1.1 (Ubuntu) against a 5-second synthetic 1280x720 h264+aac clip generated locally with `ffmpeg -f lavfi -i testsrc=size=1280x720:rate=30 -f lavfi -i sine=frequency=1000 -t 5 -c:v libx264 -c:a aac out.mp4` — any real video or audio file works the same way; an audio-only file just prints no `video:` line.
  • `r_frame_rate` prints as a fraction (e.g. `30/1`, or `30000/1001` for NTSC-style rates) rather than a decimal — pipe through one more jq expression if you want it as a number.
  • A file with multiple audio or video tracks prints one line per stream; the filter doesn't collapse or pick a 'primary' one.