metadatametadata-extractor

Metadata-Extractor -- Missing List of Tags?


I'm using metadata-extractor to retrieve metadata from video files. I have it successfully retrieving the directories. Now I need to query the directories for specific info -- duration, height, etc.

The metadata-extractor docs give this example of how to query for a specific tag value:

// obtain the Exif directory
ExifSubIFDDirectory directory
    = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);

// query the tag's value
Date date
    = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);

So it appears I need to get a list of the relevant tags, such as TAG_DATETIME_ORIGINAL, for duration, height, etc.

This page in the metadata-extractor docs contains a link titled "the various tag values", but the page it goes to lists tags for still images only, not for video files.

Googling for Metadata-Extractor -- Complete List of All Tags does not seem to bring up a list of all tags.

Are the metadata-extractor docs really missing a list of tags, or am I approaching this the wrong way somehow?


Solution

  • I found a list of tags at:

    https://developer.tizen.org/dev-guide/2.3.1/org.tizen.guides/html/native/multimedia/metadata_extractor_n.htm

    However, those constants don't seem to be what's needed in actual code. Here's Java code that works:

    import com.drew.imaging.ImageMetadataReader;
    import com.drew.metadata.Directory;
    import com.drew.metadata.Metadata;
    import com.drew.metadata.Tag;
    import com.drew.metadata.file.FileTypeDirectory;
    import com.drew.metadata.mp4.Mp4Directory;
    import com.drew.metadata.mp4.media.Mp4SoundDirectory;
    import com.drew.metadata.mp4.media.Mp4VideoDirectory;
    
    [.....]
    
    Metadata theMetadata = null;
    try {
        InputStream stream = new URL(theVideoInfo.getLinkToVideo()).openStream();
        theMetadata = ImageMetadataReader.readMetadata(stream);
        }
    
    } catch (java.lang.Exception exception) {
        exception.printStackTrace();
    }
    
    Mp4SoundDirectory soundDirectory
            = theMetadata.getFirstDirectoryOfType(Mp4SoundDirectory.class);
    Mp4VideoDirectory videoDirectory
            = theMetadata.getFirstDirectoryOfType(Mp4VideoDirectory.class);
    Mp4Directory mp4Directory
            = theMetadata.getFirstDirectoryOfType(Mp4Directory.class);
    FileTypeDirectory fileTypeDirectory
            = theMetadata.getFirstDirectoryOfType(FileTypeDirectory.class);
    
    String numberOfAudioChannels
            = soundDirectory.getString(Mp4SoundDirectory.TAG_NUMBER_OF_CHANNELS);
    String duration = mp4Directory.getString(Mp4Directory.TAG_DURATION);
    String frameRate = videoDirectory.getString(Mp4VideoDirectory.TAG_FRAME_RATE);
    String height = videoDirectory.getString(Mp4VideoDirectory.TAG_HEIGHT);
    String width = videoDirectory.getString(Mp4VideoDirectory.TAG_WIDTH);
    String type = fileTypeDirectory.getString(FileTypeDirectory.TAG_DETECTED_FILE_MIME_TYPE);
    

    I found the constants (TAG_HEIGHT, TAG_WIDTH, etc.) by directly examining the metadata-extractor objects in the debugger. For example, I'd type:

     Mp4VideoDirectory.WIDTH
    

    ...and the debugger (IntelliJ) would auto-complete the available constants that had the text "WIDTH" in them.