finding mime type of wma files using java

2.1k views Asked by At

I am using apache tika for detecting the mime type of audio and video files. For some reason tika reports the mime type of the wma file (Windows Media Audio format owned by Microsoft) as application/octet-stream. Do you know a better way to find mime type of file in java? Or can I use tika itself to query this information?

2

There are 2 answers

0
Favonius On

As per Microsoft support: http://support.microsoft.com/kb/284094, the mime type of WMA should be audio/x-ms-wma. As per: http://kb.iu.edu/data/agtj.html the mime-type application/octet-stream represents a binary file. I am not sure why TIKA is failing to recognize the proper mime type but it is the fallback/backup strategy to return application/octet-stream if the actual mime is not recognizable. The reason for failure could be many:

  1. Using an older version of library
  2. Or the library is new but the file type is newer than that
  3. Or some internal malfunction

Have a look at the below links for finding out mime-types in Java:

  1. Getting A File's Mime Type In Java
  2. http://www.rgagnon.com/javadetails/java-0487.html
1
Gagravarr On

Tika should be able to detect the files if you supply a filename for them, eg

Metadata m = new Metadata();
m.add(Metadata.RESOURCE_NAME_KEY, filename);
detector.detect(stream, m);

I've opened https://issues.apache.org/jira/browse/TIKA-629 to track the lack of mime magic detection for if you don't have the filename to hand.