I have millions of files like `report.bin` which are maybe a Word file or maybe a PDF file.  

I can not trust the filename extension.  

Also, I must distinguish between PDF/A and PDF/X, and other distinct formats that are often saved with overlapping filename extensions.

Requirements:

* Free always, for any use. Ideally open source
* Identify as many file formats as possible, using only the file's data/metadata
* Works on Linux, Mac, and Windows
* Works offline
* Must be usable from a script or program, any library interface or command-line interface is fine
* Fast

[TrID](http://mark0.net/soft-trid-e.html) is not free for commercial use.