stass
31st August 2013 08:00 UTC
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)
stass
31st August 2013 17:04 UTC
Anders
But it NSIS has nothing to do with ... I wonder how this is implemented in NSIS ?
Anders
31st August 2013 18:33 UTC
Why do you think a installer would support such a thing out of the box? You can code it yourself with the File* instructions...
aerDNA
1st September 2013 05:34 UTC
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
Anders
1st September 2013 06:23 UTC
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...
aerDNA
1st September 2013 11:08 UTC
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).
stass
1st September 2013 17:21 UTC
aerDNA
Thank you so much!
ps helpful information : http://www.filesignatures.net/
aerDNA
1st September 2013 17:32 UTC
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.