Get a Video's Duration and Resolution with mdls
Read length, pixel dimensions, and codecs of any video file from Spotlight metadata.
Run mdls -name kMDItemDurationSeconds -name kMDItemPixelWidth -name kMDItemPixelHeight video.mp4 to see a video's key facts.
01Command
Command
$ mdls -name kMDItemDurationSeconds -name kMDItemPixelWidth -name kMDItemPixelHeight -name kMDItemCodecs movie.mp402What it does
Spotlight already indexes technical details of every video on your Mac, and mdls reads that index without launching the file. This is faster than ffprobe and needs nothing installed — perfect for checking whether a clip fits a platform's upload limits. Run plain mdls video.mp4 first to see every attribute Spotlight has stored.
03Risk
!Warning: The metadata comes from Spotlight's index: freshly downloaded files may briefly report (null) until indexing catches up. Duration is reported in seconds, not minutes and seconds.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- mdls - display metadata for a fileEvidence: Documents mdls -name for reading Spotlight metadata attributes such as duration and pixel dimensions.
Last verified: 2026-09-18 · Category: Media