Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm writing some shell scripts that automatically convert some video files. Except I don't want to run the conversion on files that are already h264 encoded. Is there a way I can tell via a terminal command whether a video has a certain codec?

share|improve this question

2 Answers 2

This won't work for .avi files (at least it didn't for one I tried), but for .mp4 or .mov files, it should.

To list a file's codecs:

$ mdls -name kMDItemCodecs "/path/to/some/file.mp4"
kMDItemCodecs = (

To find files that are movies, but don't have the H.264 codec:

mdfind "kMDItemContentTypeTree == 'public.movie' && kMDItemCodecs != '*H.264*'"
share|improve this answer
Isn't that because Quicktime components don't ship any of the various AVI codecs? I imagine mdls is almost exclusively functional to the MPEG series of codecs and not much more. –  Jason Salaz Aug 16 '11 at 20:00
FWIW, QuickTime Player's Movie Inspector does list the AVI file's codecs. –  Sören Kuklau Aug 16 '11 at 21:05
Good point :). That also goes in line with your public.movie != H.264 in your answer as well. –  Jason Salaz Aug 16 '11 at 21:14

With ffmpeg : ffmpeg -i video_file

see : http://videotranscoding.wikispaces.com/GetVideoMetadata

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.