簡體   English   中英

元數據提取器-缺少標簽列表?

[英]Metadata-Extractor — Missing List of Tags?

我正在使用元數據提取器從視頻文件中檢索元數據。 我已成功檢索目錄。 現在,我需要在目錄中查詢特定信息-持續時間,身高等。

元數據提取器文檔提供了以下示例,說明如何查詢特定標簽值:

// 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似乎未Metadata-Extractor -- Complete List of All Tags的列表。

元數據提取程序文檔是否確實缺少標簽列表,還是我以某種方式采用了錯誤的方式?

我在以下位置找到了標簽列表:

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

但是,這些常量似乎並不是實際代碼中所需要的。 這是有效的Java代碼:

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等)。 例如,我輸入:

 Mp4VideoDirectory.WIDTH

...,調試器(IntelliJ)將自動完成其中包含文本“ WIDTH”的可用常量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM