Skip to content

OmarAssadi/matroska-tika

Repository files navigation

Matroska Tika

This project adds a Tika detector for MKV and WebM files, allowing you to determine the correct MIME type based on the file contents.

Usage

  1. Add Apache Tika as a dependency:
implementation 'org.apache.tika:tika-core'
  1. Add the Matroska Tika as a dependency. I intend on publishing this to the central repository soon.

  2. Either use the Matroska detector directly:

final MatroskaDetector detector=new MatroskaDetector();
final InputStream mkv=new BufferedInputStream(new FileInputStream("test.mkv"));
final MediaType type=detector.detect(mkv,new Metadata());

or use Tika's composite detector:

final TikaConfig tika=new TikaConfig();
final Detector detector=tika.getDetector();
final InputStream mkv=new BufferedInputStream(new FileInputStream("test.mkv"));
final MediaType type=detector.detect(mkv,new Metadata());