Archive: How to determine the type of the file if the file has no extension ?


How to determine the type of the file if the file has no extension ?
As with NSIS, determine the type of file if the file has no extension ?
(these files are often formed when downloading is often found not in the correct extension for video and image files)


http://superuser.com/questions/27473...ontaining-data
http://www.optimasc.com/products/fileid/


Anders
But it NSIS has nothing to do with ... I wonder how this is implemented in NSIS ?


Why do you think a installer would support such a thing out of the box? You can code it yourself with the File* instructions...


Here's something I cooked. Supports basic media formats. I predict that in the years to come, it will be used by stass and two other guys. Couldn't sleep. :D


I would not trust that kind of detection, for example; mp3 files might start with a ID3 or LAME tag or no header at all and you would have to look for mp3 frames/sync. Both Wav and AVI files are in a RIFF container and you need to parse that first, not just use a fixed offset...


It's a simple approach and not 100% foolproof, I agree. But I tested against dozens of files and I think it's reliable enough for most practical purposes. I guess you didn't notice that in mp3 case several variations are checked for, including ID3 (LAME tag is never in the first 16B afaik, I tested Lame-encoded files w/wo ID3). In case of wav/avi, I initially considered checking for RIFF first but it would've been redundant as they in fact can be identified without exception by reading from a fixed offset (8; WAVEfmt/AVI LIST).


aerDNA
Thank you so much!

ps helpful information : http://www.filesignatures.net/


Small update: improved mp3, mp4, mkv and mov detection, added ogg and webm support, macro now returns the result in user var instead of stack.