TIKA Tutorial
TIKA Examples
TIKA Useful Resources
Selected Reading
- TIKA - GUI
- TIKA - Language Detection
- TIKA - Metadata Extraction
- TIKA - Content Extraction
- TIKA - Document Type Detection
- TIKA - File Formats
- TIKA - Referenced API
- TIKA - Environment
- TIKA - Architecture
- TIKA - Overview
- TIKA - Home
TIKA Examples
- TIKA - Extracting mp3 Files
- TIKA - Extracting mp4 Files
- TIKA - Extracting Image File
- TIKA - Extracting JAR File
- TIKA - Extracting .class File
- TIKA - Extracting XML Document
- TIKA - Extracting HTML Document
- TIKA - Extracting Text Document
- TIKA - Extracting MS-Office Files
- TIKA - Extracting ODF
- TIKA - Extracting PDF
TIKA Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
TIKA - Extracting mp3 Files
TIKA - Extracting mp3 Files
Given below is the program to extract content and metadata from mp3 files −
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.tika.exception.TikaException; import org.apache.tika.metadata.Metadata; import org.apache.tika.parser.ParseContext; import org.apache.tika.parser.mp3.LyricsHandler; import org.apache.tika.parser.mp3.Mp3Parser; import org.apache.tika.sax.BodyContentHandler; import org.xml.sax.SAXException; pubpc class Mp3Parse { pubpc static void main(final String[] args) throws Exception, IOException, SAXException, TikaException { //detecting the file type BodyContentHandler handler = new BodyContentHandler(); Metadata metadata = new Metadata(); FileInputStream inputstream = new FileInputStream(new File("example.mp3")); ParseContext pcontext = new ParseContext(); //Mp3 parser Mp3Parser Mp3Parser = new Mp3Parser(); Mp3Parser.parse(inputstream, handler, metadata, pcontext); LyricsHandler lyrics = new LyricsHandler(inputstream,handler); while(lyrics.hasLyrics()) { System.out.println(lyrics.toString()); } System.out.println("Contents of the document:" + handler.toString()); System.out.println("Metadata of the document:"); String[] metadataNames = metadata.names(); for(String name : metadataNames) { System.out.println(name + ": " + metadata.get(name)); } } }
Save the above code as JpegParse.java, and compile it from the command prompt by using the following commands −
javac Mp3Parse.java java Mp3Parse
Example.mp3 file has the following properties −

You will get the following output after executing the program. If the given file has any lyrics, our apppcation will capture and display that along with the output.
Output −
Contents of the document: Kanulanu Thaake Arijit Singh Manam (2014), track 01/06 2014 Soundtrack 30171.65 eng - DRGM Arijit Singh Manam (2014), track 01/06 2014 Soundtrack 30171.65 eng - DRGM Metadata of the document: xmpDM:releaseDate: 2014 xmpDM:duration: 30171.650390625 xmpDM:audioChannelType: Stereo dc:creator: Arijit Singh xmpDM:album: Manam (2014) Author: Arijit Singh xmpDM:artist: Arijit Singh channels: 2 xmpDM:audioSampleRate: 44100 xmpDM:logComment: eng - DRGM xmpDM:trackNumber: 01/06 version: MPEG 3 Layer III Version 1 creator: Arijit Singh xmpDM:composer: Music : Anoop Rubens | Lyrics : Vanamap xmpDM:audioCompressor: MP3 title: Kanulanu Thaake samplerate: 44100 meta:author: Arijit Singh xmpDM:genre: Soundtrack Content-Type: audio/mpeg xmpDM:albumArtist: Manam (2014) dc:title: Kanulanu ThaakeAdvertisements