brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffprobe -select_streams with -show_entries prints just the values you need

CLI
~/tips/tip-ffprobe-select-streams-csv

ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 in.mp4

Prints selected properties of one stream, such as the video width and height, in plain machine-readable form.

The full ffprobe output is a wall of text, and scripts hate walls. Three options turn it into a single line that you can read in a shell variable.

ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 in.mp4

-select_streams v:0 limits the output to the first video stream. -show_entries stream=width,height keeps only those two fields. -of csv=p=0 prints them as comma-separated values without the section name in front. For a 640 by 360 clip the result is 640,360.

The same pattern works for the container. -show_entries format=duration prints the length in seconds. If you prefer labels over positions, use -of default=noprint_wrappers=1, which gives width=640 and height=360 on separate lines.

-v error hides the banner, so only the values reach your script.

A caveat: when a field is missing in the file, ffprobe leaves the column out or prints N/A, and a script that splits on commas then shifts. Check the output before you trust a position, and select the stream you mean, because a file with two video streams (for instance cover art) changes what v:0 is.

Further reading: ffprobe documentation

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso wget --spider https://example.com/file.zip rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' All CLI tips (46) All topics

Link