If i enter

$ file -i music.mp3

it returns music.mp3: application/octet-stream; charset=binary

If i wipe all tags and image in this file it recognises MIME type correctly.

music.mp3: audio/mpeg; charset=binary

Is there any workaround or a bugfix? Is it possible to get correct data without modifying mp3 file?

$ file --version
magic file from /etc/magic:/usr/share/misc/magic
  • Does wiping the tags and image in this file does it still play? Why do you need to worry about mime-types if it already plays ok? - Suggestion: Give us more details on how this file was created. Jan 31 '11 at 9:47
  • Yes. mp3-file without tags and album cover in it plays correctly. I need to regognise MIME-types because I use libmagic in my application to find mp3s. I don't know how files were created, but I should find a way to recognise any mp3 file correctly.
    – PocketSam
    Feb 2 '11 at 6:38

I was having the same problem with the same version of file on Ubuntu 10.04. I modified /etc/magic and was able to get the MIME-type of my MP3s to display as audio/mpeg. Here are the lines I added:

# MPEG Layer 3 sound files
0       beshort     &0xffe0     audio/mpeg
!:mime  audio/mpeg
#MP3 with ID3 tag
0       string      ID3     audio/mpeg
!:mime  audio/mpeg

Taken from http://www.opensource.apple.com/source/file/file-23/file/magic/magic.mime

I don't have much experience editing this "magic" directives, so I can't vouch for its effectiveness or security.


You can add your own rules to /etc/magic and /etc/magic.mime. See man 5 magic and the contents of /usr/share/misc/magic (or similar) for inspiration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.