0

我开发了一个自定义元数据提取器来提取音频和视频文件的详细元数据。提取器扩展了 AbstractMappingMetadataExtracter,它需要将提取的字段映射到自定义类型。提取器类名为 AudioMetadataExtractor,对应的属性文件包含映射。以下是该类的代码

public class AudioMetadataExtractor extends AbstractBaseMetadataExtractor {

public static ArrayList<String> SUPPORTED_MIMETYPES = addMimeTypes(new String[] { MimeTypes.MIMETYPE_MP3, MimeTypes.MIMETYPE_WMA });

public AudioMetadataExtractor() {
    this(SUPPORTED_MIMETYPES);
}

public AudioMetadataExtractor(ArrayList<String> supportedMimeTypes) {
    super(supportedMimeTypes);
}


@Override
protected Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable {

    Map<String, Serializable> rawProperties = newRawMap();

    File file = TempFileProvider.createTempFile("DCM", "MINFO");
    reader.getContent(file);

    MediaInfoJNA mediaInfoLib = new MediaInfoJNA();
    mediaInfoLib.Open(file.getAbsolutePath());

    String album = mediaInfoLib.Get(StreamKind.General, 0, "Album", MediaInfoJNA.InfoKind.Text, MediaInfoJNA.InfoKind.Name);
    System.out.println("Album1 " + album);
    String title = mediaInfoLib.Get(StreamKind.General, 0, "Title", MediaInfoJNA.InfoKind.Text, MediaInfoJNA.InfoKind.Name);
    System.out.println("Title " + title);
    String duration = mediaInfoLib.Get(StreamKind.General, 0, "Duration", MediaInfoJNA.InfoKind.Text, MediaInfoJNA.InfoKind.Name);
    System.out.println("Duration " + duration);

    putRawValue("album", album, rawProperties);

    mediaInfoLib.Close();

    return rawProperties;
}
}

提取器的配置如下

<bean id="metadata.extractor.AudioAsset" class="com.diipl.moviebeam.dcm.alfresco.metadata.AudioMetadataExtractor" parent="baseMetadataExtracter">
    <property name="inheritDefaultMapping">
        <value>true</value>
    </property>
</bean>

问题:上传新文件时,提取器被调用,我可以看到所有具有正确值的系统输出。但是,属性没有填充任何值。但是,如果我在文件上运行“提取通用元数据”操作,提取器会被调用,并且字段会获得正确的值。

4

0 回答 0