首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >元数据-提取器-缺失的标签列表?

元数据-提取器-缺失的标签列表?
EN

Stack Overflow用户
提问于 2018-11-22 00:19:22
回答 1查看 642关注 0票数 1

我使用元数据提取器从视频文件中检索元数据。我已经成功地检索了目录。现在我需要查询目录的具体信息-持续时间,高度等。

元数据提取器文档给出了如何查询特定标记值的示例:

代码语言:javascript
复制
// obtain the Exif directory
ExifSubIFDDirectory directory
    = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);

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

因此,我似乎需要获得相关标签的列表,如TAG_DATETIME_ORIGINAL,用于持续时间、高度等。

元数据提取器文档中的此页包含一个名为“各种标记值”的链接,但是它指向的页面只列出静态图像的标记,而不是视频文件的标记。

谷歌搜索Metadata-Extractor -- Complete List of All Tags似乎没有显示出所有标签的列表。

元数据提取器文档是否真的遗漏了一个标签列表,还是我以某种方式来处理这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-12-04 02:52:23

我在以下网站找到了一张标签列表:

n.htm

然而,这些常量似乎并不是实际代码所需要的。下面是工作的Java代码:

代码语言:javascript
复制
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);

我找到了常数(TAG_HEIGHT,TAG_WIDTH等)通过直接检查调试器中的元数据提取器对象。例如,我会键入:

代码语言:javascript
复制
 Mp4VideoDirectory.WIDTH

...and调试器(IntelliJ)将自动完成包含文本“宽度”的可用常量。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53422238

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档