Skip to content

Extracting Metadata

g$ edited this page Jul 5, 2021 · 3 revisions

By far the most-common task is extracting the metadata from an ISO Media File. As you can guess, ISO SAX is up to the challenge, and does so without bogging down in other parts of the container.

And by metadata, we mean in particular the QuickTime metadata format, widely used.

Here is the JUnit case for this task:

@Test
public void isoContainerHandler_Meta() throws Exception {
    final File fx = new File("redacted.m4a");
    assertTrue("exists failed", fx.exists());
    final IsoContainerHandler tx = new IsoContainerHandler(false, true, null);
    ISOParser.parse(fx, new NullHandler(), tx);
    final IsoMediaContainer imc = tx.render();
    assertNotNull("render failed", imc);
    assertNotNull("ftyp failed", imc.ftyp);
    assertNotNull("mvhd failed", imc.mvhd);
    assertNotNull("meta failed", imc.meta);
    assertNotNull("meta.hdlr failed", imc.meta.hdlr);
    assertTrue("meta.hdlr.type failed", "mdir".equals(imc.meta.hdlr.type));
    assertTrue("meta.size failed", imc.meta.map.size() > 0);
}

As you can see, not much involved! The only minor complication has to do with how the metadata is stored to begin with, because there may be multiple versions of the same value, that differ by language and/or format.

Note that the handler checks for the correct handler type before parsing the contents.

Clone this wiki locally