How can I determine that a particular file (which may or may not have an ".mp3" file extension) is in fact an MP3 file? I wish to do this in C#.
According to http://www.garykessler.net/library/file_sigs.html an mp3 file will always start with ID3 (hex 49 44 33) However, presence of these bytes only mean that the file is tagged with ID3 information. If this signature is not found, it could be an untagged mp3 file. To determine this, check out the mp3 file structure and you'll see that an mp3 frame starts with the signature ff fb (hex).
So :
49 44 33
or
ff fb
it's safe to assume that it's an MP3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With