-2

I need to extract the audio duration value of the MP3, WAV, MIDI, OGG,FLAC, ACC audio types. For MP3 I was able to get the duration with Apache Tika with below code. But it does not give audio duration for WAV, MIDI, OGG,FLAC, ACC files with java. How to get the duration value with Apache Tika for other audio types. My metadata parser code is as below

Parser parser = new AutoDetectParser();
ContentHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
ParseContext context = new ParseContext();

parser.parse(content.getContentStream(), handler, metadata, context);

String duration = metadata.get("metadata_name_for_duration");
Manoj Lakshan
  • 107
  • 1
  • 6
  • 1
    Try fetching the Duation metadata entry instead of something made up? https://tika.apache.org/2.2.1/api/org/apache/tika/metadata/XMPDM.html#DURATION – Gagravarr Jan 10 '22 at 09:28
  • @Gagravarr I tried with "metadata.get("xmpDM:duration")". For mp3 this is giving value in seconds. But no value for other audio types. – Manoj Lakshan Jan 10 '22 at 10:36
  • 1
    Try a more recent version of Apache Tika, and ensure you have all the dependencies installed - all the Xiph formats should support it as well for starters if you've got everything installed – Gagravarr Jan 10 '22 at 10:56

1 Answers1

0

I was unable to find solution for audio metadata extraction with Apache Tika. So I moved to used https://exiftool.org/ tool with help of the https://github.com/mjeanroy/exiftool java integration. I was able to find duration metadata for MP3, WAV, OGG,FLAC from this tool. But still this tool does not supports MIDI and ACC files.

Hope this answer is helpful for any one having same requirement.

Manoj Lakshan
  • 107
  • 1
  • 6