How does one reliably determine a file\'s type? File extension analysis is not acceptable. There must be a rubyesque tool similar to the UNIX file(1) comman
I found shelling out to be the most reliable. For compatibility on both Mac OS X and Ubuntu Linux I used:
file --mime -b myvideo.mp4 video/mp4; charset=binary
file --mime -b myvideo.mp4
Ubuntu also prints video codec information if it can which is pretty cool:
file -b myvideo.mp4 ISO Media, MPEG v4 system, version 2
file -b myvideo.mp4