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 shows the codecs and streams inside a video file

Tools
~/tips/tip-ffmpeg-ffprobe-show-streams

ffprobe -v error -show_format -show_streams video.mkv

Prints the container format and every stream of a media file, so you see codecs, resolution and duration.

Before converting a video, or when a TV refuses to play one, I want to know what is inside the file. ffprobe comes with FFmpeg and answers that.

ffprobe -v error -show_format -show_streams video.mkv
ffprobe -v error -show_streams -of json video.mkv

-show_format prints information about the container, in a section called FORMAT. -show_streams prints each stream in its own STREAM section, with the codec, the resolution or sample rate and more. -v error keeps the banner and the log lines out of the way, so only the data is printed.

The -of json option writes the same information as JSON, which you can then pass to jq for a single field.

ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,width,height -of csv=p=0 video.mkv

The result of that last command is one line such as h264,1920,1080.

The caveat is that ffprobe only reads the headers. It tells you what the file claims to contain, not whether the data is intact. For that, run a decode with ffmpeg -v error -i video.mkv -f null - and see if any errors are printed. Also keep in mind that ffprobe can be slow on files over a network share.

Further reading: ffprobe documentation

More Tools tips shuf -n 3 films.txt xmllint --format feed.xml pdftotext -layout invoice.pdf invoice.txt qrencode -t ANSIUTF8 'https://example.com/a/long/path?id=12345' where python All Tools tips (14) All topics

Link