The file(1)
command (and associated libmagic
) can do this job on standard Unix systems; if Apple didn't include it into the phone OS, you can probably get it to run on the phone yourself. (On my x86-64 Linux system, the library is 109k.)
On my computer, it classified 146 easily-accessible videos into 18 different formats in under seven seconds. (120 gigabytes.) It got some wrong:
$ sort -u /tmp/out
data
ISO Media, MPEG v4 system, version 1
Matroska data
Microsoft ASF
MPEG transport stream data
RIFF (little-endian) data, AVI, 384 x 240, 25.00 fps, video: DivX 5, audio: MPEG-1 Layer 3 (mono, 44100 Hz)
RIFF (little-endian) data, AVI, 384 x 288, 25.00 fps, video: DivX 3 Low-Motion, audio: DivX (stereo, 44100 Hz)
RIFF (little-endian) data, AVI, 512 x 272, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
RIFF (little-endian) data, AVI, 512 x 288, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 44100 Hz)
RIFF (little-endian) data, AVI, 512 x 288, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
RIFF (little-endian) data, AVI, 512 x 328, 25.00 fps, video: DivX 5, audio: MPEG-1 Layer 3 (stereo, 32000 Hz)
RIFF (little-endian) data, AVI, 512 x 328, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 32000 Hz)
RIFF (little-endian) data, AVI, 572 x 304, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
RIFF (little-endian) data, AVI, 576 x 320, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
RIFF (little-endian) data, AVI, 608 x 336, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
RIFF (little-endian) data, AVI, 624 x 352, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
RIFF (little-endian) data, AVI, 640 x 352, 25.00 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz)
TeX font metric data (\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377
At those speeds, perhaps you can tolerate a little noise and fall back to a slower mechanism; or perhaps fill out the rules with formats it doesn't yet know.